text stringlengths 525 23.5k | conversation_id int64 129 108k | embedding list | cluster int64 6 6 |
|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down.
There is a cursor pointing at some symbol of the string. Suppose that cursor is at position i (1 ≤ i ≤ n, the string uses 1-based indexing) now. Left and right arrow keys are used to move cursor around the string. The string is cyclic, that means that when Nam presses left arrow key, the cursor will move to position i - 1 if i > 1 or to the end of the string (i. e. position n) otherwise. The same holds when he presses the right arrow key (if i = n, the cursor appears at the beginning of the string).
When Nam presses up arrow key, the letter which the text cursor is pointing to will change to the next letter in English alphabet (assuming that alphabet is also cyclic, i. e. after 'z' follows 'a'). The same holds when he presses the down arrow key.
Initially, the text cursor is at position p.
Because Nam has a lot homework to do, he wants to complete this as fast as possible. Can you help him by calculating the minimum number of arrow keys presses to make the string to be a palindrome?
Input
The first line contains two space-separated integers n (1 ≤ n ≤ 105) and p (1 ≤ p ≤ n), the length of Nam's string and the initial position of the text cursor.
The next line contains n lowercase characters of Nam's string.
Output
Print the minimum number of presses needed to change string into a palindrome.
Examples
Input
8 3
aeabcaez
Output
6
Note
A string is a palindrome if it reads the same forward or reversed.
In the sample test, initial Nam's string is: <image> (cursor position is shown bold).
In optimal solution, Nam may do 6 following steps:
<image>
The result, <image>, is now a palindrome.
Tags: brute force, greedy, implementation
Correct Solution:
```
n , p = map(int,input().split())
string = input()
def palindrome_transformer(string,n,p):#1 base indexing is p
if n % 2 == 0:
s_1 = string[0:int(n/2)]
s_2 = string[int(n/2):len(string)]
s_1_reversed = ""
for numbers in range(int(len(string)/2)-1,-1,-1):
s_1_reversed += s_1[numbers]
score = 0
different_elements = [] #0 means no and 1 means yes
for i in range(len(s_1)):
if abs(ord(s_1_reversed[i]) - ord(s_2[i])) > 12:
score += 26 - abs(ord(s_1_reversed[i]) - ord(s_2[i]))
different_elements.append(1)
else:
if abs(ord(s_1_reversed[i]) - ord(s_2[i])) == 0:
different_elements.append(0)
else:
different_elements.append(1)
score += abs(ord(s_1_reversed[i]) - ord(s_2[i]))
if p <= int(len(string)/2):
different_elements.reverse()
start = 1
for elements in different_elements:
if elements ==1:
break
else:
start +=1
different_elements.reverse()
end = int(len(string)/2)
for elements in different_elements:
if elements ==1:
break
else:
end -=1
if start == int(len(string)/2) +1 and end ==0 :
return 0
score += max(p,end) - min(start,p) + min(max(end - p,0),max(p-start,0))
else:
p -= int(len(string)/2)
start = 1
for elements in different_elements:
if elements == 1:
break
else:
start += 1
different_elements.reverse()
end = int(len(string) / 2)
for elements in different_elements:
if elements == 1:
break
else:
end -= 1
if start == int(len(string) / 2) + 1 and end == 0:
return 0
score += max(p, end) - min(start, p) + min(max(end - p, 0), max(p - start, 0))
return score
if n % 2 == 1 :
string_new = ""
for i in range(len(string)):
if i == int(len(string) /2 ):
continue
else:
string_new += string[i]
if p > int(n/2):
p-=1
return palindrome_transformer(string_new,n-1,p)
elif p == int(n/2):
return palindrome_transformer(string_new,n-1,p)
else:
return palindrome_transformer(string_new, n - 1, p)
print(palindrome_transformer(string,n,p))
```
| 70,201 | [
0.283447265625,
-0.09881591796875,
-0.0283660888671875,
0.2078857421875,
-0.399169921875,
-0.343505859375,
0.10400390625,
0.00563812255859375,
-0.03302001953125,
0.88623046875,
0.69873046875,
-0.1405029296875,
0.136962890625,
-0.6494140625,
-0.491455078125,
-0.03961181640625,
-0.465576171875,
-0.888671875,
-0.350830078125,
-0.036773681640625,
0.20263671875,
0.134521484375,
-1.390625,
-0.37060546875,
-0.0141754150390625,
1.126953125,
0.72021484375,
0.07708740234375,
0.99072265625,
1.28515625,
-0.267822265625,
-0.29248046875,
0.552734375,
-0.96337890625,
-0.329833984375,
-0.59716796875,
0.32470703125,
-0.470458984375,
-0.1927490234375,
-0.65771484375,
0.240234375,
-0.5947265625,
0.5146484375,
-0.509765625,
-1.0654296875,
-0.2239990234375,
-0.4990234375,
-0.4658203125,
0.09478759765625,
-0.476806640625,
0.2646484375,
-0.39453125,
0.326416015625,
-0.271728515625,
-0.1856689453125,
-0.17529296875,
0.09051513671875,
-0.115966796875,
-0.666015625,
0.1922607421875,
0.03143310546875,
0.10662841796875,
-0.1480712890625,
-0.701171875,
-0.369384765625,
0.231689453125,
-0.37109375,
-0.137939453125,
0.1988525390625,
-1.201171875,
-0.55859375,
0.01070404052734375,
-0.370361328125,
-0.4541015625,
-0.2113037109375,
0.2587890625,
0.1505126953125,
-0.00629425048828125,
-0.62646484375,
1.1103515625,
-0.044952392578125,
0.921875,
0.1895751953125,
0.1531982421875,
-0.4111328125,
-0.1854248046875,
-0.043243408203125,
0.1873779296875,
-0.197021484375,
-0.32177734375,
0.133544921875,
0.396240234375,
-0.57470703125,
0.044677734375,
0.2445068359375,
0.9765625,
0.073974609375,
0.156005859375,
0.58740234375,
0.1451416015625,
0.3623046875,
0.90380859375,
-0.321044921875,
0.78759765625,
-0.2391357421875,
-0.131103515625,
-0.0772705078125,
0.0919189453125,
-0.075927734375,
-0.6767578125,
-0.255615234375,
-0.462890625,
0.5185546875,
0.2763671875,
-0.365478515625,
1.0185546875,
-0.18212890625,
0.401611328125,
-0.3154296875,
0.344482421875,
0.320556640625,
0.2122802734375,
0.52197265625,
-0.406005859375,
0.283203125,
-0.1470947265625,
-0.5224609375,
1.017578125,
-0.810546875,
-0.295654296875,
0.494384765625,
0.2109375,
-0.1802978515625,
0.13232421875,
-0.2030029296875,
0.72607421875,
-0.07952880859375,
0.41796875,
0.69970703125,
-0.70703125,
0.62939453125,
-0.2454833984375,
-0.039703369140625,
1.5732421875,
0.305419921875,
0.260986328125,
0.55615234375,
0.41357421875,
-0.751953125,
0.375732421875,
-0.9521484375,
0.953125,
0.291748046875,
0.4072265625,
-0.0811767578125,
-0.06353759765625,
-0.1668701171875,
0.78564453125,
-0.1558837890625,
0.529296875,
-0.301513671875,
0.27490234375,
-0.2880859375,
0.8623046875,
-0.2451171875,
0.89013671875,
-0.646484375,
-0.71630859375,
0.01904296875,
-0.77734375,
-0.1171875,
-0.050689697265625,
-0.4208984375,
0.99462890625,
0.58349609375,
1.1435546875,
0.98388671875,
-0.11700439453125,
0.200927734375,
0.242431640625,
-0.496337890625,
0.52783203125,
0.53076171875,
0.64697265625,
0.2261962890625,
0.33740234375,
-0.076904296875,
-0.383056640625,
-0.5390625,
-0.256591796875,
-0.007648468017578125,
0.50146484375,
-0.168212890625,
0.27734375,
0.281005859375,
0.06304931640625,
-0.865234375,
-0.253662109375,
-0.036407470703125,
-1.23828125,
-0.280517578125,
0.395263671875,
-0.064697265625,
0.6103515625,
-0.4580078125,
-0.37646484375,
0.392578125,
1.1494140625,
-0.33251953125,
0.1224365234375,
0.4091796875,
0.226806640625,
-0.33642578125,
0.158447265625,
-0.0751953125,
-0.2276611328125,
-0.61572265625,
0.76953125,
-0.1767578125,
0.08782958984375,
0.039154052734375,
0.96435546875,
0.26513671875,
0.489013671875,
-0.3544921875,
-0.038848876953125,
0.6123046875,
0.8154296875,
-0.01505279541015625,
0.309326171875,
0.250244140625,
0.6337890625,
0.34912109375,
0.708984375,
0.471435546875,
0.0714111328125,
0.2288818359375,
0.9580078125,
0.1572265625,
-0.156494140625,
-0.150390625,
0.467529296875,
0.41259765625,
0.41015625,
0.198974609375,
0.5107421875,
0.1302490234375,
-0.075927734375,
-0.63037109375,
0.481689453125,
-0.29248046875,
1.1591796875,
0.319091796875,
0.291748046875,
-0.11761474609375,
-0.12249755859375,
0.410888671875,
0.6875,
-1.001953125,
-0.87255859375,
0.179931640625,
-0.137451171875,
0.052947998046875,
-0.057525634765625,
0.205078125,
0.591796875,
0.455322265625,
0.53076171875,
-0.1376953125,
-0.388671875,
-0.90185546875,
-1.0107421875,
-0.55859375,
-0.09869384765625,
-0.74267578125,
-0.114501953125,
0.398193359375,
-0.94189453125,
0.424560546875,
-0.46484375,
-0.198486328125,
-0.24853515625,
-0.81787109375,
0.6953125,
-0.128662109375,
0.6064453125,
-0.70556640625,
0.273193359375,
-0.18798828125,
1.0146484375,
-0.62890625,
-0.254638671875,
-0.0999755859375,
-0.3525390625,
-0.0227203369140625,
-0.22021484375,
0.607421875,
-0.1331787109375,
-0.68212890625,
-0.9345703125,
-0.316162109375,
-0.1925048828125,
-0.44482421875,
0.214111328125,
-0.369384765625,
0.64111328125,
0.3349609375,
-0.6142578125,
0.83251953125,
0.90576171875,
-0.857421875,
0.248779296875,
0.12335205078125,
0.07745361328125,
-0.66162109375,
1.7158203125,
0.52685546875,
0.4296875,
-0.49658203125,
-0.45947265625,
-0.492431640625,
0.28466796875,
0.10540771484375,
-0.44287109375,
-0.2685546875,
0.68994140625,
0.357177734375,
-1.068359375,
0.64404296875,
-1.0615234375,
-0.814453125,
-0.36474609375,
-0.027191162109375,
0.6904296875,
0.6806640625,
0.155517578125,
0.145263671875,
-0.267578125,
-0.59912109375,
0.56689453125,
0.51806640625,
-0.270263671875,
-0.2476806640625,
0.615234375,
-0.214599609375,
-0.075927734375,
0.615234375,
-0.370849609375,
-0.15673828125,
-0.2030029296875,
0.26025390625,
0.48095703125,
0.058135986328125,
0.5009765625,
0.640625,
0.457763671875,
-1.064453125,
-0.3095703125,
-0.0631103515625,
0.61962890625,
-0.0189361572265625,
0.64013671875,
0.264404296875,
-0.45166015625,
-0.51171875,
-1.30078125,
0.62646484375,
0.039215087890625,
0.78955078125,
-0.533203125,
0.94140625,
0.228515625,
-0.350341796875,
0.39111328125,
-0.984375,
-0.1741943359375,
1.2607421875,
-0.20751953125,
0.7900390625,
-0.6337890625,
0.2210693359375,
-0.263916015625,
0.01235198974609375,
0.841796875,
0.3125,
0.54345703125,
-0.1253662109375,
-0.5947265625,
-0.12005615234375,
-0.13427734375,
-0.07672119140625,
-0.67333984375,
0.1632080078125,
-0.677734375,
-0.451416015625,
-1.080078125,
0.49169921875,
0.84521484375,
0.5771484375,
0.00971221923828125,
0.2259521484375,
0.1763916015625,
0.783203125,
0.349609375,
-0.2548828125,
0.2125244140625,
-0.61376953125,
0.87890625,
0.09674072265625,
-0.282958984375,
-1.0107421875,
-0.185791015625,
-0.287109375,
0.1824951171875,
0.1400146484375,
-0.1641845703125,
-0.97900390625,
-0.11871337890625,
-0.10528564453125,
0.7802734375,
-0.61962890625,
-0.57568359375,
-0.52880859375,
0.560546875,
0.48193359375,
-0.7802734375,
0.2135009765625,
-0.8251953125,
0.495361328125,
0.319091796875,
0.205078125,
-0.5517578125,
-0.411376953125,
-0.60498046875,
-0.72509765625,
0.468505859375,
0.65380859375,
0.1790771484375,
0.24560546875,
-1.154296875,
0.6103515625,
0.04010009765625,
-0.335693359375,
-0.1707763671875,
-0.1739501953125,
0.2481689453125,
-0.30322265625,
0.1966552734375,
-0.5810546875,
-0.3046875,
0.132568359375,
-1.134765625,
0.822265625,
-0.364013671875,
0.3876953125,
-0.1224365234375,
-0.258544921875,
0.2127685546875,
0.4921875,
-0.36083984375,
0.05584716796875,
-0.25634765625,
0.64599609375,
-0.89697265625,
-0.802734375,
0.50830078125,
-0.311767578125,
-0.2213134765625,
1.03125,
0.01380157470703125,
-0.552734375,
0.66162109375,
-0.09356689453125,
-0.30712890625,
0.435302734375,
-0.316162109375,
0.55029296875,
-0.30615234375,
-0.09344482421875,
-0.10845947265625,
-0.45947265625,
1.0380859375,
-0.0162506103515625,
-0.953125,
-0.089599609375,
-1.1357421875,
-0.331787109375,
-0.223876953125,
-0.10101318359375,
0.359619140625,
0.1383056640625,
-0.133056640625,
0.22021484375,
-0.45068359375,
-0.11083984375,
-0.30029296875,
-0.662109375,
-0.03216552734375,
0.090087890625,
0.27783203125,
0.52685546875,
-0.0021343231201171875,
-0.5302734375,
-0.04931640625,
-0.2099609375,
0.0256195068359375,
-0.473876953125,
-0.07196044921875,
-0.408935546875,
-0.304931640625,
-0.298828125,
0.364501953125,
0.184326171875,
0.463623046875,
0.88623046875,
0.291015625,
0.359619140625,
0.444580078125,
-0.393798828125,
1.0341796875,
0.2032470703125,
-1.25,
-0.375732421875,
0.458251953125,
-0.1192626953125,
1.015625,
-0.06536865234375,
-0.6640625,
-0.43994140625,
-0.89453125,
0.165283203125,
-0.7236328125,
-0.3505859375,
-0.86083984375,
-0.7314453125,
-0.21044921875,
0.311279296875,
-0.472900390625,
-0.68994140625,
0.443115234375,
-0.96630859375,
0.360595703125,
-0.478271484375,
0.0031414031982421875,
-0.470703125,
-0.40673828125,
-0.361572265625,
1.0712890625,
0.228271484375,
0.61865234375,
0.2396240234375,
-0.2352294921875,
0.441162109375,
0.0697021484375,
-0.98486328125,
0.09796142578125,
-0.1708984375,
0.7373046875,
-0.037353515625,
-0.2939453125,
-0.5068359375,
0.578125,
-0.8447265625,
0.3115234375,
0.050628662109375,
-0.41650390625,
-0.050445556640625,
-0.11712646484375,
0.943359375,
-0.609375,
-0.0501708984375,
-0.497314453125,
0.861328125,
0.75537109375,
-0.3076171875,
-0.260498046875,
-0.7900390625,
-0.425048828125,
-1.17578125,
0.52490234375,
-0.304931640625,
0.5068359375,
-0.56982421875,
-0.349365234375,
1.1533203125,
-0.69091796875,
0.6796875,
1.029296875,
0.1971435546875,
0.440185546875,
-0.53564453125,
0.56640625,
0.7109375,
-0.26171875,
-0.0625,
-0.00969696044921875,
-0.64453125,
0.176025390625,
-0.040985107421875,
-1.2607421875,
-0.81005859375,
0.5126953125,
1.375,
-0.034423828125,
0.5810546875,
0.36962890625,
-1.177734375,
-0.65283203125,
0.63671875,
-0.12060546875,
0.3994140625,
0.7080078125,
0.2017822265625,
-0.364990234375,
0.2119140625,
-0.2142333984375,
-0.2384033203125,
-0.198974609375,
0.9150390625,
-0.6962890625,
-0.4970703125,
0.9345703125,
0.86279296875,
-1.234375,
-1.0341796875,
-0.4248046875,
-0.2181396484375,
-0.273681640625,
-0.552734375,
0.026641845703125,
0.046142578125,
-0.3984375,
-0.24609375,
0.09417724609375,
-0.390380859375,
0.2900390625,
0.064208984375,
0.154541015625,
-0.7060546875,
0.59033203125,
0.60595703125,
-0.2418212890625,
-0.25146484375,
-1.28125,
-0.2052001953125,
-0.0197296142578125,
0.333984375,
0.7080078125,
-0.55419921875,
0.428955078125,
0.364990234375,
0.034912109375,
0.5546875,
-0.388671875,
-0.1954345703125,
0.43212890625,
-0.4716796875,
-0.4306640625,
-0.140380859375,
0.1729736328125,
-0.57568359375,
0.41015625,
-0.47314453125,
-0.1524658203125,
0.0626220703125,
0.273193359375,
-0.5322265625,
-0.6845703125,
-0.4267578125,
-1.42578125,
-0.861328125,
-0.41259765625,
-1.1064453125,
-0.2393798828125,
0.2015380859375,
-0.142822265625,
-0.64892578125,
0.052093505859375,
0.55419921875,
-0.7216796875,
0.78662109375,
-0.371337890625,
0.334228515625,
-0.93408203125,
0.010772705078125,
-0.6630859375,
0.07763671875,
-0.62255859375,
-0.2607421875,
-0.52587890625,
0.1466064453125,
-0.1119384765625,
0.25146484375,
-0.4931640625,
0.2266845703125,
-0.2384033203125,
-0.398193359375,
0.302490234375,
-0.04705810546875,
0.11956787109375,
0.83251953125,
0.85791015625,
0.018402099609375,
0.30029296875,
0.26806640625,
-0.42626953125,
-0.8369140625,
0.251220703125,
0.358154296875,
-0.421875,
-0.08880615234375,
-0.1990966796875,
0.3095703125,
-1.205078125,
0.15234375,
-0.241455078125,
0.34716796875,
-0.0677490234375,
-0.2095947265625,
0.373046875,
1.1474609375,
-0.00039768218994140625,
0.365966796875,
-0.12188720703125,
0.0143585205078125,
0.344482421875,
-0.08685302734375,
0.27734375,
0.76953125,
-0.0596923828125,
-0.3037109375,
-0.31640625,
0.521484375,
0.2222900390625,
0.30029296875,
-0.471923828125,
-0.53662109375,
-0.716796875,
0.1776123046875,
-0.1561279296875,
0.697265625,
0.2464599609375,
-0.91259765625,
0.07916259765625,
-0.01611328125,
-0.67041015625,
0.155029296875,
-0.9482421875,
-1.2734375,
-0.03460693359375,
-0.1309814453125,
-0.2120361328125,
-0.31201171875,
-0.389892578125,
-0.57177734375,
0.051666259765625,
0.708984375,
-0.63134765625,
0.65966796875,
-0.032928466796875,
0.7265625,
0.271240234375,
0.1688232421875,
0.038330078125,
0.51513671875,
-0.72705078125,
-0.6083984375,
-0.346435546875,
0.9775390625,
0.411376953125,
0.0027828216552734375,
-0.59765625,
0.1170654296875,
0.0322265625,
0.271484375,
-0.59619140625,
0.16796875,
-0.300048828125,
0.7607421875,
-1.03125,
-0.337158203125,
-0.1865234375,
0.76416015625,
-0.0298919677734375,
-0.286376953125,
-0.2022705078125,
0.95263671875,
0.720703125,
0.1055908203125,
0.69189453125,
0.36669921875,
0.56396484375,
-0.380126953125,
-0.1822509765625,
-0.09686279296875,
0.95849609375,
0.587890625,
0.5341796875,
-0.043548583984375,
0.46240234375,
0.736328125,
-0.39697265625,
-0.406005859375,
0.4619140625,
0.049652099609375,
0.00843048095703125,
0.1798095703125,
-0.389404296875,
-0.28173828125,
0.144775390625,
-0.358642578125,
0.58984375,
-0.324462890625,
0.272216796875,
-0.277587890625,
-0.87939453125,
0.84423828125,
-0.404296875,
-0.11865234375,
-0.13134765625,
-0.466552734375,
0.5068359375,
0.54052734375,
-0.06427001953125,
0.2186279296875,
0.80078125,
0.9677734375,
0.314208984375,
0.63623046875,
0.6611328125,
0.308837890625,
-0.88916015625,
0.00693511962890625,
0.257080078125,
0.120361328125,
-0.49365234375,
0.019012451171875,
-0.80224609375,
0.76611328125,
-0.08953857421875,
-0.330810546875,
0.4306640625,
-0.2626953125,
0.1546630859375,
-0.52099609375,
0.9443359375,
-0.257080078125,
0.11016845703125,
0.548828125,
-0.0496826171875,
-0.787109375,
1.2099609375,
-0.33154296875,
0.27392578125,
-0.041961669921875,
1.517578125,
0.2340087890625,
1.568359375,
0.767578125,
-0.38330078125,
0.08251953125,
0.08551025390625,
-0.15185546875,
-0.52685546875,
-0.09088134765625,
-0.0047607421875,
-0.1593017578125,
-0.6005859375,
-0.56982421875,
-0.19775390625,
0.6015625,
0.01363372802734375,
-0.90234375,
0.0184173583984375,
0.055694580078125,
-0.919921875,
0.480224609375,
0.059173583984375,
0.156005859375,
0.268310546875,
0.114501953125,
-0.1546630859375,
-0.47314453125,
0.146240234375,
-0.2215576171875,
0.17138671875,
-0.7939453125,
-0.64306640625,
-0.85791015625,
-0.66455078125,
-0.62353515625,
-0.13330078125,
-0.26123046875,
-1.0634765625,
0.6630859375,
0.56787109375,
0.548828125,
0.41015625,
-0.3935546875,
0.109375,
0.68603515625,
1.1865234375,
0.08099365234375,
0.63623046875,
0.52783203125,
-0.0562744140625,
0.264404296875,
-0.669921875,
0.167236328125,
-0.52734375,
0.2476806640625,
-0.50634765625,
0.36083984375,
-0.78369140625,
-1.298828125,
-0.07293701171875,
0.397705078125,
0.64599609375,
-0.6640625,
-1.0625,
-0.09222412109375,
-0.89599609375,
-0.0750732421875,
-0.3681640625,
0.85107421875,
-0.420654296875,
-0.0484619140625,
-0.04925537109375,
-1.1103515625,
4.37890625,
1.1533203125,
0.6474609375,
0.434326171875,
0.13818359375,
1.15234375,
0.40771484375,
-0.64013671875,
-0.6640625,
-0.1524658203125,
0.60107421875,
-0.34375,
-0.08258056640625,
0.89599609375,
0.174072265625,
0.430419921875,
-0.7236328125,
-0.177490234375,
-0.061492919921875,
-1.1484375,
-0.765625,
0.2191162109375,
-0.2373046875,
0.328125,
0.0020503997802734375,
0.33154296875,
0.642578125,
-0.68701171875,
-0.70703125,
-0.3759765625,
-0.1341552734375,
-0.69921875,
1.0283203125,
0.3837890625,
-0.39501953125,
0.626953125,
-0.28271484375,
-0.63623046875,
-0.030975341796875,
0.25048828125,
0.0684814453125,
0.1661376953125,
0.1553955078125,
-0.56884765625,
-0.2489013671875,
0.57275390625,
-0.40478515625,
0.2119140625,
0.2841796875,
-0.76611328125,
0.8447265625,
-0.01279449462890625,
0.30810546875,
-0.1678466796875,
-0.96484375,
0.2626953125,
0.391357421875,
-0.028533935546875,
-0.52685546875,
0.6923828125,
0.1302490234375,
0.3115234375,
0.2037353515625,
0.438720703125,
-0.92919921875,
0.89892578125,
-0.32275390625,
0.154541015625,
-0.61181640625,
0.287353515625,
-0.10723876953125,
-0.361083984375,
-0.287841796875,
-0.249267578125,
0.6455078125,
0.286376953125,
0.1563720703125,
0.2626953125,
0.4423828125,
-0.77099609375,
0.3701171875,
0.28125,
-0.310302734375,
-0.29638671875,
0.68701171875,
0.8291015625,
-0.4892578125,
-0.331298828125,
-0.529296875,
0.51025390625,
0.432373046875,
0.71435546875,
-0.06494140625,
-0.99365234375,
-0.2469482421875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down.
There is a cursor pointing at some symbol of the string. Suppose that cursor is at position i (1 ≤ i ≤ n, the string uses 1-based indexing) now. Left and right arrow keys are used to move cursor around the string. The string is cyclic, that means that when Nam presses left arrow key, the cursor will move to position i - 1 if i > 1 or to the end of the string (i. e. position n) otherwise. The same holds when he presses the right arrow key (if i = n, the cursor appears at the beginning of the string).
When Nam presses up arrow key, the letter which the text cursor is pointing to will change to the next letter in English alphabet (assuming that alphabet is also cyclic, i. e. after 'z' follows 'a'). The same holds when he presses the down arrow key.
Initially, the text cursor is at position p.
Because Nam has a lot homework to do, he wants to complete this as fast as possible. Can you help him by calculating the minimum number of arrow keys presses to make the string to be a palindrome?
Input
The first line contains two space-separated integers n (1 ≤ n ≤ 105) and p (1 ≤ p ≤ n), the length of Nam's string and the initial position of the text cursor.
The next line contains n lowercase characters of Nam's string.
Output
Print the minimum number of presses needed to change string into a palindrome.
Examples
Input
8 3
aeabcaez
Output
6
Note
A string is a palindrome if it reads the same forward or reversed.
In the sample test, initial Nam's string is: <image> (cursor position is shown bold).
In optimal solution, Nam may do 6 following steps:
<image>
The result, <image>, is now a palindrome.
Tags: brute force, greedy, implementation
Correct Solution:
```
n, p = map(int, input().split())
s = list(map(ord, input()))
if p > n//2:
p = n - p
else:
p -= 1
l = n // 2
r = -1
ans = 0
for i in range(n//2):
d = abs(s[i]-s[n-i-1])
d = min(d, 26 - d)
if d:
l = min(l, i)
r = max(r, i)
ans += d
print(ans + r - l + min(abs(r-p), abs(l-p)) if ans else 0)
```
| 70,202 | [
0.283447265625,
-0.09881591796875,
-0.0283660888671875,
0.2078857421875,
-0.399169921875,
-0.343505859375,
0.10400390625,
0.00563812255859375,
-0.03302001953125,
0.88623046875,
0.69873046875,
-0.1405029296875,
0.136962890625,
-0.6494140625,
-0.491455078125,
-0.03961181640625,
-0.465576171875,
-0.888671875,
-0.350830078125,
-0.036773681640625,
0.20263671875,
0.134521484375,
-1.390625,
-0.37060546875,
-0.0141754150390625,
1.126953125,
0.72021484375,
0.07708740234375,
0.99072265625,
1.28515625,
-0.267822265625,
-0.29248046875,
0.552734375,
-0.96337890625,
-0.329833984375,
-0.59716796875,
0.32470703125,
-0.470458984375,
-0.1927490234375,
-0.65771484375,
0.240234375,
-0.5947265625,
0.5146484375,
-0.509765625,
-1.0654296875,
-0.2239990234375,
-0.4990234375,
-0.4658203125,
0.09478759765625,
-0.476806640625,
0.2646484375,
-0.39453125,
0.326416015625,
-0.271728515625,
-0.1856689453125,
-0.17529296875,
0.09051513671875,
-0.115966796875,
-0.666015625,
0.1922607421875,
0.03143310546875,
0.10662841796875,
-0.1480712890625,
-0.701171875,
-0.369384765625,
0.231689453125,
-0.37109375,
-0.137939453125,
0.1988525390625,
-1.201171875,
-0.55859375,
0.01070404052734375,
-0.370361328125,
-0.4541015625,
-0.2113037109375,
0.2587890625,
0.1505126953125,
-0.00629425048828125,
-0.62646484375,
1.1103515625,
-0.044952392578125,
0.921875,
0.1895751953125,
0.1531982421875,
-0.4111328125,
-0.1854248046875,
-0.043243408203125,
0.1873779296875,
-0.197021484375,
-0.32177734375,
0.133544921875,
0.396240234375,
-0.57470703125,
0.044677734375,
0.2445068359375,
0.9765625,
0.073974609375,
0.156005859375,
0.58740234375,
0.1451416015625,
0.3623046875,
0.90380859375,
-0.321044921875,
0.78759765625,
-0.2391357421875,
-0.131103515625,
-0.0772705078125,
0.0919189453125,
-0.075927734375,
-0.6767578125,
-0.255615234375,
-0.462890625,
0.5185546875,
0.2763671875,
-0.365478515625,
1.0185546875,
-0.18212890625,
0.401611328125,
-0.3154296875,
0.344482421875,
0.320556640625,
0.2122802734375,
0.52197265625,
-0.406005859375,
0.283203125,
-0.1470947265625,
-0.5224609375,
1.017578125,
-0.810546875,
-0.295654296875,
0.494384765625,
0.2109375,
-0.1802978515625,
0.13232421875,
-0.2030029296875,
0.72607421875,
-0.07952880859375,
0.41796875,
0.69970703125,
-0.70703125,
0.62939453125,
-0.2454833984375,
-0.039703369140625,
1.5732421875,
0.305419921875,
0.260986328125,
0.55615234375,
0.41357421875,
-0.751953125,
0.375732421875,
-0.9521484375,
0.953125,
0.291748046875,
0.4072265625,
-0.0811767578125,
-0.06353759765625,
-0.1668701171875,
0.78564453125,
-0.1558837890625,
0.529296875,
-0.301513671875,
0.27490234375,
-0.2880859375,
0.8623046875,
-0.2451171875,
0.89013671875,
-0.646484375,
-0.71630859375,
0.01904296875,
-0.77734375,
-0.1171875,
-0.050689697265625,
-0.4208984375,
0.99462890625,
0.58349609375,
1.1435546875,
0.98388671875,
-0.11700439453125,
0.200927734375,
0.242431640625,
-0.496337890625,
0.52783203125,
0.53076171875,
0.64697265625,
0.2261962890625,
0.33740234375,
-0.076904296875,
-0.383056640625,
-0.5390625,
-0.256591796875,
-0.007648468017578125,
0.50146484375,
-0.168212890625,
0.27734375,
0.281005859375,
0.06304931640625,
-0.865234375,
-0.253662109375,
-0.036407470703125,
-1.23828125,
-0.280517578125,
0.395263671875,
-0.064697265625,
0.6103515625,
-0.4580078125,
-0.37646484375,
0.392578125,
1.1494140625,
-0.33251953125,
0.1224365234375,
0.4091796875,
0.226806640625,
-0.33642578125,
0.158447265625,
-0.0751953125,
-0.2276611328125,
-0.61572265625,
0.76953125,
-0.1767578125,
0.08782958984375,
0.039154052734375,
0.96435546875,
0.26513671875,
0.489013671875,
-0.3544921875,
-0.038848876953125,
0.6123046875,
0.8154296875,
-0.01505279541015625,
0.309326171875,
0.250244140625,
0.6337890625,
0.34912109375,
0.708984375,
0.471435546875,
0.0714111328125,
0.2288818359375,
0.9580078125,
0.1572265625,
-0.156494140625,
-0.150390625,
0.467529296875,
0.41259765625,
0.41015625,
0.198974609375,
0.5107421875,
0.1302490234375,
-0.075927734375,
-0.63037109375,
0.481689453125,
-0.29248046875,
1.1591796875,
0.319091796875,
0.291748046875,
-0.11761474609375,
-0.12249755859375,
0.410888671875,
0.6875,
-1.001953125,
-0.87255859375,
0.179931640625,
-0.137451171875,
0.052947998046875,
-0.057525634765625,
0.205078125,
0.591796875,
0.455322265625,
0.53076171875,
-0.1376953125,
-0.388671875,
-0.90185546875,
-1.0107421875,
-0.55859375,
-0.09869384765625,
-0.74267578125,
-0.114501953125,
0.398193359375,
-0.94189453125,
0.424560546875,
-0.46484375,
-0.198486328125,
-0.24853515625,
-0.81787109375,
0.6953125,
-0.128662109375,
0.6064453125,
-0.70556640625,
0.273193359375,
-0.18798828125,
1.0146484375,
-0.62890625,
-0.254638671875,
-0.0999755859375,
-0.3525390625,
-0.0227203369140625,
-0.22021484375,
0.607421875,
-0.1331787109375,
-0.68212890625,
-0.9345703125,
-0.316162109375,
-0.1925048828125,
-0.44482421875,
0.214111328125,
-0.369384765625,
0.64111328125,
0.3349609375,
-0.6142578125,
0.83251953125,
0.90576171875,
-0.857421875,
0.248779296875,
0.12335205078125,
0.07745361328125,
-0.66162109375,
1.7158203125,
0.52685546875,
0.4296875,
-0.49658203125,
-0.45947265625,
-0.492431640625,
0.28466796875,
0.10540771484375,
-0.44287109375,
-0.2685546875,
0.68994140625,
0.357177734375,
-1.068359375,
0.64404296875,
-1.0615234375,
-0.814453125,
-0.36474609375,
-0.027191162109375,
0.6904296875,
0.6806640625,
0.155517578125,
0.145263671875,
-0.267578125,
-0.59912109375,
0.56689453125,
0.51806640625,
-0.270263671875,
-0.2476806640625,
0.615234375,
-0.214599609375,
-0.075927734375,
0.615234375,
-0.370849609375,
-0.15673828125,
-0.2030029296875,
0.26025390625,
0.48095703125,
0.058135986328125,
0.5009765625,
0.640625,
0.457763671875,
-1.064453125,
-0.3095703125,
-0.0631103515625,
0.61962890625,
-0.0189361572265625,
0.64013671875,
0.264404296875,
-0.45166015625,
-0.51171875,
-1.30078125,
0.62646484375,
0.039215087890625,
0.78955078125,
-0.533203125,
0.94140625,
0.228515625,
-0.350341796875,
0.39111328125,
-0.984375,
-0.1741943359375,
1.2607421875,
-0.20751953125,
0.7900390625,
-0.6337890625,
0.2210693359375,
-0.263916015625,
0.01235198974609375,
0.841796875,
0.3125,
0.54345703125,
-0.1253662109375,
-0.5947265625,
-0.12005615234375,
-0.13427734375,
-0.07672119140625,
-0.67333984375,
0.1632080078125,
-0.677734375,
-0.451416015625,
-1.080078125,
0.49169921875,
0.84521484375,
0.5771484375,
0.00971221923828125,
0.2259521484375,
0.1763916015625,
0.783203125,
0.349609375,
-0.2548828125,
0.2125244140625,
-0.61376953125,
0.87890625,
0.09674072265625,
-0.282958984375,
-1.0107421875,
-0.185791015625,
-0.287109375,
0.1824951171875,
0.1400146484375,
-0.1641845703125,
-0.97900390625,
-0.11871337890625,
-0.10528564453125,
0.7802734375,
-0.61962890625,
-0.57568359375,
-0.52880859375,
0.560546875,
0.48193359375,
-0.7802734375,
0.2135009765625,
-0.8251953125,
0.495361328125,
0.319091796875,
0.205078125,
-0.5517578125,
-0.411376953125,
-0.60498046875,
-0.72509765625,
0.468505859375,
0.65380859375,
0.1790771484375,
0.24560546875,
-1.154296875,
0.6103515625,
0.04010009765625,
-0.335693359375,
-0.1707763671875,
-0.1739501953125,
0.2481689453125,
-0.30322265625,
0.1966552734375,
-0.5810546875,
-0.3046875,
0.132568359375,
-1.134765625,
0.822265625,
-0.364013671875,
0.3876953125,
-0.1224365234375,
-0.258544921875,
0.2127685546875,
0.4921875,
-0.36083984375,
0.05584716796875,
-0.25634765625,
0.64599609375,
-0.89697265625,
-0.802734375,
0.50830078125,
-0.311767578125,
-0.2213134765625,
1.03125,
0.01380157470703125,
-0.552734375,
0.66162109375,
-0.09356689453125,
-0.30712890625,
0.435302734375,
-0.316162109375,
0.55029296875,
-0.30615234375,
-0.09344482421875,
-0.10845947265625,
-0.45947265625,
1.0380859375,
-0.0162506103515625,
-0.953125,
-0.089599609375,
-1.1357421875,
-0.331787109375,
-0.223876953125,
-0.10101318359375,
0.359619140625,
0.1383056640625,
-0.133056640625,
0.22021484375,
-0.45068359375,
-0.11083984375,
-0.30029296875,
-0.662109375,
-0.03216552734375,
0.090087890625,
0.27783203125,
0.52685546875,
-0.0021343231201171875,
-0.5302734375,
-0.04931640625,
-0.2099609375,
0.0256195068359375,
-0.473876953125,
-0.07196044921875,
-0.408935546875,
-0.304931640625,
-0.298828125,
0.364501953125,
0.184326171875,
0.463623046875,
0.88623046875,
0.291015625,
0.359619140625,
0.444580078125,
-0.393798828125,
1.0341796875,
0.2032470703125,
-1.25,
-0.375732421875,
0.458251953125,
-0.1192626953125,
1.015625,
-0.06536865234375,
-0.6640625,
-0.43994140625,
-0.89453125,
0.165283203125,
-0.7236328125,
-0.3505859375,
-0.86083984375,
-0.7314453125,
-0.21044921875,
0.311279296875,
-0.472900390625,
-0.68994140625,
0.443115234375,
-0.96630859375,
0.360595703125,
-0.478271484375,
0.0031414031982421875,
-0.470703125,
-0.40673828125,
-0.361572265625,
1.0712890625,
0.228271484375,
0.61865234375,
0.2396240234375,
-0.2352294921875,
0.441162109375,
0.0697021484375,
-0.98486328125,
0.09796142578125,
-0.1708984375,
0.7373046875,
-0.037353515625,
-0.2939453125,
-0.5068359375,
0.578125,
-0.8447265625,
0.3115234375,
0.050628662109375,
-0.41650390625,
-0.050445556640625,
-0.11712646484375,
0.943359375,
-0.609375,
-0.0501708984375,
-0.497314453125,
0.861328125,
0.75537109375,
-0.3076171875,
-0.260498046875,
-0.7900390625,
-0.425048828125,
-1.17578125,
0.52490234375,
-0.304931640625,
0.5068359375,
-0.56982421875,
-0.349365234375,
1.1533203125,
-0.69091796875,
0.6796875,
1.029296875,
0.1971435546875,
0.440185546875,
-0.53564453125,
0.56640625,
0.7109375,
-0.26171875,
-0.0625,
-0.00969696044921875,
-0.64453125,
0.176025390625,
-0.040985107421875,
-1.2607421875,
-0.81005859375,
0.5126953125,
1.375,
-0.034423828125,
0.5810546875,
0.36962890625,
-1.177734375,
-0.65283203125,
0.63671875,
-0.12060546875,
0.3994140625,
0.7080078125,
0.2017822265625,
-0.364990234375,
0.2119140625,
-0.2142333984375,
-0.2384033203125,
-0.198974609375,
0.9150390625,
-0.6962890625,
-0.4970703125,
0.9345703125,
0.86279296875,
-1.234375,
-1.0341796875,
-0.4248046875,
-0.2181396484375,
-0.273681640625,
-0.552734375,
0.026641845703125,
0.046142578125,
-0.3984375,
-0.24609375,
0.09417724609375,
-0.390380859375,
0.2900390625,
0.064208984375,
0.154541015625,
-0.7060546875,
0.59033203125,
0.60595703125,
-0.2418212890625,
-0.25146484375,
-1.28125,
-0.2052001953125,
-0.0197296142578125,
0.333984375,
0.7080078125,
-0.55419921875,
0.428955078125,
0.364990234375,
0.034912109375,
0.5546875,
-0.388671875,
-0.1954345703125,
0.43212890625,
-0.4716796875,
-0.4306640625,
-0.140380859375,
0.1729736328125,
-0.57568359375,
0.41015625,
-0.47314453125,
-0.1524658203125,
0.0626220703125,
0.273193359375,
-0.5322265625,
-0.6845703125,
-0.4267578125,
-1.42578125,
-0.861328125,
-0.41259765625,
-1.1064453125,
-0.2393798828125,
0.2015380859375,
-0.142822265625,
-0.64892578125,
0.052093505859375,
0.55419921875,
-0.7216796875,
0.78662109375,
-0.371337890625,
0.334228515625,
-0.93408203125,
0.010772705078125,
-0.6630859375,
0.07763671875,
-0.62255859375,
-0.2607421875,
-0.52587890625,
0.1466064453125,
-0.1119384765625,
0.25146484375,
-0.4931640625,
0.2266845703125,
-0.2384033203125,
-0.398193359375,
0.302490234375,
-0.04705810546875,
0.11956787109375,
0.83251953125,
0.85791015625,
0.018402099609375,
0.30029296875,
0.26806640625,
-0.42626953125,
-0.8369140625,
0.251220703125,
0.358154296875,
-0.421875,
-0.08880615234375,
-0.1990966796875,
0.3095703125,
-1.205078125,
0.15234375,
-0.241455078125,
0.34716796875,
-0.0677490234375,
-0.2095947265625,
0.373046875,
1.1474609375,
-0.00039768218994140625,
0.365966796875,
-0.12188720703125,
0.0143585205078125,
0.344482421875,
-0.08685302734375,
0.27734375,
0.76953125,
-0.0596923828125,
-0.3037109375,
-0.31640625,
0.521484375,
0.2222900390625,
0.30029296875,
-0.471923828125,
-0.53662109375,
-0.716796875,
0.1776123046875,
-0.1561279296875,
0.697265625,
0.2464599609375,
-0.91259765625,
0.07916259765625,
-0.01611328125,
-0.67041015625,
0.155029296875,
-0.9482421875,
-1.2734375,
-0.03460693359375,
-0.1309814453125,
-0.2120361328125,
-0.31201171875,
-0.389892578125,
-0.57177734375,
0.051666259765625,
0.708984375,
-0.63134765625,
0.65966796875,
-0.032928466796875,
0.7265625,
0.271240234375,
0.1688232421875,
0.038330078125,
0.51513671875,
-0.72705078125,
-0.6083984375,
-0.346435546875,
0.9775390625,
0.411376953125,
0.0027828216552734375,
-0.59765625,
0.1170654296875,
0.0322265625,
0.271484375,
-0.59619140625,
0.16796875,
-0.300048828125,
0.7607421875,
-1.03125,
-0.337158203125,
-0.1865234375,
0.76416015625,
-0.0298919677734375,
-0.286376953125,
-0.2022705078125,
0.95263671875,
0.720703125,
0.1055908203125,
0.69189453125,
0.36669921875,
0.56396484375,
-0.380126953125,
-0.1822509765625,
-0.09686279296875,
0.95849609375,
0.587890625,
0.5341796875,
-0.043548583984375,
0.46240234375,
0.736328125,
-0.39697265625,
-0.406005859375,
0.4619140625,
0.049652099609375,
0.00843048095703125,
0.1798095703125,
-0.389404296875,
-0.28173828125,
0.144775390625,
-0.358642578125,
0.58984375,
-0.324462890625,
0.272216796875,
-0.277587890625,
-0.87939453125,
0.84423828125,
-0.404296875,
-0.11865234375,
-0.13134765625,
-0.466552734375,
0.5068359375,
0.54052734375,
-0.06427001953125,
0.2186279296875,
0.80078125,
0.9677734375,
0.314208984375,
0.63623046875,
0.6611328125,
0.308837890625,
-0.88916015625,
0.00693511962890625,
0.257080078125,
0.120361328125,
-0.49365234375,
0.019012451171875,
-0.80224609375,
0.76611328125,
-0.08953857421875,
-0.330810546875,
0.4306640625,
-0.2626953125,
0.1546630859375,
-0.52099609375,
0.9443359375,
-0.257080078125,
0.11016845703125,
0.548828125,
-0.0496826171875,
-0.787109375,
1.2099609375,
-0.33154296875,
0.27392578125,
-0.041961669921875,
1.517578125,
0.2340087890625,
1.568359375,
0.767578125,
-0.38330078125,
0.08251953125,
0.08551025390625,
-0.15185546875,
-0.52685546875,
-0.09088134765625,
-0.0047607421875,
-0.1593017578125,
-0.6005859375,
-0.56982421875,
-0.19775390625,
0.6015625,
0.01363372802734375,
-0.90234375,
0.0184173583984375,
0.055694580078125,
-0.919921875,
0.480224609375,
0.059173583984375,
0.156005859375,
0.268310546875,
0.114501953125,
-0.1546630859375,
-0.47314453125,
0.146240234375,
-0.2215576171875,
0.17138671875,
-0.7939453125,
-0.64306640625,
-0.85791015625,
-0.66455078125,
-0.62353515625,
-0.13330078125,
-0.26123046875,
-1.0634765625,
0.6630859375,
0.56787109375,
0.548828125,
0.41015625,
-0.3935546875,
0.109375,
0.68603515625,
1.1865234375,
0.08099365234375,
0.63623046875,
0.52783203125,
-0.0562744140625,
0.264404296875,
-0.669921875,
0.167236328125,
-0.52734375,
0.2476806640625,
-0.50634765625,
0.36083984375,
-0.78369140625,
-1.298828125,
-0.07293701171875,
0.397705078125,
0.64599609375,
-0.6640625,
-1.0625,
-0.09222412109375,
-0.89599609375,
-0.0750732421875,
-0.3681640625,
0.85107421875,
-0.420654296875,
-0.0484619140625,
-0.04925537109375,
-1.1103515625,
4.37890625,
1.1533203125,
0.6474609375,
0.434326171875,
0.13818359375,
1.15234375,
0.40771484375,
-0.64013671875,
-0.6640625,
-0.1524658203125,
0.60107421875,
-0.34375,
-0.08258056640625,
0.89599609375,
0.174072265625,
0.430419921875,
-0.7236328125,
-0.177490234375,
-0.061492919921875,
-1.1484375,
-0.765625,
0.2191162109375,
-0.2373046875,
0.328125,
0.0020503997802734375,
0.33154296875,
0.642578125,
-0.68701171875,
-0.70703125,
-0.3759765625,
-0.1341552734375,
-0.69921875,
1.0283203125,
0.3837890625,
-0.39501953125,
0.626953125,
-0.28271484375,
-0.63623046875,
-0.030975341796875,
0.25048828125,
0.0684814453125,
0.1661376953125,
0.1553955078125,
-0.56884765625,
-0.2489013671875,
0.57275390625,
-0.40478515625,
0.2119140625,
0.2841796875,
-0.76611328125,
0.8447265625,
-0.01279449462890625,
0.30810546875,
-0.1678466796875,
-0.96484375,
0.2626953125,
0.391357421875,
-0.028533935546875,
-0.52685546875,
0.6923828125,
0.1302490234375,
0.3115234375,
0.2037353515625,
0.438720703125,
-0.92919921875,
0.89892578125,
-0.32275390625,
0.154541015625,
-0.61181640625,
0.287353515625,
-0.10723876953125,
-0.361083984375,
-0.287841796875,
-0.249267578125,
0.6455078125,
0.286376953125,
0.1563720703125,
0.2626953125,
0.4423828125,
-0.77099609375,
0.3701171875,
0.28125,
-0.310302734375,
-0.29638671875,
0.68701171875,
0.8291015625,
-0.4892578125,
-0.331298828125,
-0.529296875,
0.51025390625,
0.432373046875,
0.71435546875,
-0.06494140625,
-0.99365234375,
-0.2469482421875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color ci. The goal of the game is to destroy all the gemstones in the line as quickly as possible.
In one second, Genos is able to choose exactly one continuous substring of colored gemstones that is a palindrome and remove it from the line. After the substring is removed, the remaining gemstones shift to form a solid line again. What is the minimum number of seconds needed to destroy the entire line?
Let us remind, that the string (or substring) is called palindrome, if it reads same backwards or forward. In our case this means the color of the first gemstone is equal to the color of the last one, the color of the second gemstone is equal to the color of the next to last and so on.
Input
The first line of input contains a single integer n (1 ≤ n ≤ 500) — the number of gemstones.
The second line contains n space-separated integers, the i-th of which is ci (1 ≤ ci ≤ n) — the color of the i-th gemstone in a line.
Output
Print a single integer — the minimum number of seconds needed to destroy the entire line.
Examples
Input
3
1 2 1
Output
1
Input
3
1 2 3
Output
3
Input
7
1 4 4 2 3 2 1
Output
2
Note
In the first sample, Genos can destroy the entire line in one second.
In the second sample, Genos can only destroy one gemstone at a time, so destroying three gemstones takes three seconds.
In the third sample, to achieve the optimal time of two seconds, destroy palindrome 4 4 first and then destroy palindrome 1 2 3 2 1.
Tags: dp
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush
def RL(): return map(int, sys.stdin.readline().rstrip().split())
def RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))
def N(): return int(input())
def comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0
def perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0
def mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
# ------------------------------
def main():
n = N()
arr = RLL()
dp = [[n]*n for _ in range(n)]
for i in range(n): dp[i][i] = 1
for le in range(2, n+1):
for l in range(n):
r = l+le-1
if r>=n: break
if le==2:
if arr[l]==arr[r]: dp[l][r] = 1
else: dp[l][r] = 2
else:
for m in range(l, r):
dp[l][r] = min(dp[l][r], dp[l][m]+dp[m+1][r])
if arr[l]==arr[r]:
dp[l][r] = min(dp[l+1][r-1], dp[l][r])
print(dp[0][-1])
if __name__ == "__main__":
main()
```
| 70,260 | [
-0.056793212890625,
0.050872802734375,
0.2412109375,
0.15673828125,
-0.7763671875,
-0.7568359375,
-0.173095703125,
-0.1007080078125,
0.4267578125,
1.0498046875,
0.2900390625,
-0.10833740234375,
0.225830078125,
-0.60205078125,
-0.367919921875,
0.11328125,
-0.443359375,
-0.80517578125,
-0.038665771484375,
-0.253173828125,
0.02789306640625,
-0.1661376953125,
-0.9404296875,
-0.2066650390625,
-0.1715087890625,
0.90380859375,
0.017852783203125,
0.27294921875,
0.80126953125,
1.2998046875,
-0.45458984375,
-0.43212890625,
0.759765625,
-1.361328125,
-0.0413818359375,
-0.040557861328125,
0.57763671875,
-0.1949462890625,
-0.5,
-0.393310546875,
0.39404296875,
-0.261474609375,
1.0458984375,
-0.462646484375,
-0.841796875,
-0.01230621337890625,
-0.151123046875,
-0.5498046875,
-0.61279296875,
-0.265869140625,
0.10845947265625,
-0.07305908203125,
0.492431640625,
-0.02825927734375,
0.292236328125,
-0.2568359375,
0.1922607421875,
0.1654052734375,
-0.454833984375,
0.247802734375,
0.4560546875,
0.0340576171875,
-0.051177978515625,
-0.71826171875,
0.275146484375,
0.71875,
-0.213623046875,
-0.146240234375,
-0.2359619140625,
-1.068359375,
0.058380126953125,
0.2200927734375,
0.1829833984375,
-0.64013671875,
-0.51025390625,
0.2320556640625,
0.37890625,
0.1834716796875,
-0.477783203125,
0.86181640625,
-0.1346435546875,
0.71044921875,
0.0806884765625,
0.11871337890625,
-0.440185546875,
-0.56982421875,
0.054534912109375,
0.25048828125,
-0.0787353515625,
-0.05889892578125,
-0.4580078125,
0.64794921875,
-0.8115234375,
0.1439208984375,
0.42822265625,
0.8779296875,
-0.369140625,
0.37451171875,
0.350341796875,
0.214599609375,
0.78515625,
0.8623046875,
-0.564453125,
1.1220703125,
-0.68505859375,
-0.273681640625,
0.3857421875,
-0.08856201171875,
-0.055633544921875,
-0.54931640625,
-0.1038818359375,
-0.373046875,
0.278076171875,
0.498046875,
0.081787109375,
0.8935546875,
-0.062347412109375,
0.3125,
-0.59326171875,
0.164794921875,
0.435791015625,
0.035491943359375,
0.4677734375,
-0.260498046875,
0.459228515625,
-0.35791015625,
-0.359375,
0.97412109375,
-0.82763671875,
-0.19921875,
0.48193359375,
-0.2027587890625,
0.2578125,
0.4140625,
-0.01332855224609375,
0.376220703125,
-0.274169921875,
0.56298828125,
0.9306640625,
-0.48486328125,
0.79931640625,
0.060211181640625,
-0.262939453125,
1.6689453125,
0.0885009765625,
-0.0207672119140625,
0.67919921875,
0.46044921875,
-0.88720703125,
0.47998046875,
-0.8115234375,
0.2105712890625,
-0.06634521484375,
0.428466796875,
-0.11871337890625,
0.412841796875,
-0.392333984375,
0.46630859375,
0.057952880859375,
0.080322265625,
-0.1876220703125,
0.29345703125,
-0.007152557373046875,
0.87890625,
-0.71826171875,
0.98291015625,
-0.392333984375,
-0.869140625,
-0.0982666015625,
-0.335693359375,
0.361572265625,
-0.30322265625,
0.081787109375,
0.73291015625,
0.5556640625,
0.845703125,
0.7451171875,
-0.00530242919921875,
0.314208984375,
0.451416015625,
-0.038818359375,
0.27490234375,
0.7021484375,
0.78955078125,
-0.1075439453125,
0.355224609375,
0.1064453125,
-0.341796875,
-0.499755859375,
-0.34228515625,
0.11444091796875,
0.402099609375,
-0.307861328125,
0.1708984375,
0.1944580078125,
0.25244140625,
-0.72900390625,
-0.298828125,
-0.296630859375,
-1.4443359375,
-0.0290374755859375,
0.6015625,
-0.427734375,
0.373779296875,
-0.369140625,
-0.0992431640625,
0.64404296875,
1.3056640625,
-0.1534423828125,
0.2230224609375,
0.5361328125,
0.31396484375,
-0.320556640625,
0.276611328125,
-0.36474609375,
-0.0494384765625,
-0.34716796875,
0.72021484375,
0.1702880859375,
-0.2208251953125,
0.279052734375,
0.59326171875,
0.1180419921875,
0.364990234375,
-0.496337890625,
-0.1903076171875,
0.0797119140625,
0.8740234375,
0.2001953125,
0.427001953125,
0.0877685546875,
0.9267578125,
0.346923828125,
0.658203125,
0.391845703125,
0.040130615234375,
0.56689453125,
0.64306640625,
-0.3310546875,
0.156494140625,
-0.3076171875,
0.52099609375,
0.587890625,
0.370361328125,
0.2186279296875,
0.74853515625,
-0.0928955078125,
-0.3046875,
-0.56103515625,
0.5927734375,
-0.380859375,
0.93310546875,
0.32373046875,
0.1925048828125,
-0.416015625,
-0.1724853515625,
0.72607421875,
0.9140625,
-0.65771484375,
-0.36083984375,
0.0970458984375,
-0.017486572265625,
0.1060791015625,
-0.345947265625,
0.376220703125,
0.51611328125,
0.19140625,
0.397705078125,
-0.2386474609375,
-0.206787109375,
-0.62158203125,
-0.70263671875,
-0.70654296875,
-0.48779296875,
-0.427001953125,
-0.310791015625,
0.338623046875,
-0.96533203125,
0.1729736328125,
-0.45751953125,
-0.1861572265625,
-0.1614990234375,
-0.61181640625,
0.495849609375,
-0.005523681640625,
0.5517578125,
-0.83837890625,
0.4404296875,
0.01137542724609375,
1.091796875,
-0.71337890625,
0.0178680419921875,
-0.16552734375,
-0.53515625,
0.2159423828125,
-0.31640625,
0.52294921875,
-0.01522064208984375,
-0.42529296875,
-0.55322265625,
-0.40771484375,
-0.058807373046875,
-0.580078125,
-0.11676025390625,
-0.412353515625,
1.0087890625,
0.427978515625,
-0.611328125,
0.95849609375,
0.5263671875,
-0.56591796875,
0.5205078125,
0.113525390625,
0.1927490234375,
-0.74169921875,
1.142578125,
0.186767578125,
0.6962890625,
-0.6357421875,
-0.39111328125,
-0.2484130859375,
0.06890869140625,
-0.07818603515625,
-0.44140625,
-0.49609375,
0.6650390625,
0.051025390625,
-0.97216796875,
0.70361328125,
-1.0693359375,
-0.2607421875,
-0.252197265625,
-0.282470703125,
0.6142578125,
1.046875,
0.2161865234375,
-0.51220703125,
-0.07916259765625,
-0.49560546875,
0.291259765625,
0.52587890625,
-0.44384765625,
-0.25,
0.603515625,
0.11419677734375,
0.229736328125,
0.6650390625,
-0.4345703125,
-0.14111328125,
-0.0237884521484375,
0.11376953125,
0.66552734375,
0.52685546875,
0.303466796875,
0.38623046875,
0.80859375,
-0.94580078125,
0.0252685546875,
-0.0212554931640625,
0.5166015625,
0.3955078125,
0.42578125,
0.28173828125,
-0.609375,
-0.5791015625,
-1.2099609375,
0.200439453125,
0.11676025390625,
0.5576171875,
-0.4970703125,
0.90673828125,
-0.0374755859375,
-0.55322265625,
0.58837890625,
-0.5634765625,
0.0775146484375,
1.2275390625,
-0.185546875,
0.7734375,
-0.497802734375,
0.546875,
-0.2349853515625,
-0.01200103759765625,
0.166748046875,
0.430419921875,
0.59130859375,
-0.338134765625,
-0.400390625,
-0.4228515625,
-0.62841796875,
0.1109619140625,
-0.63232421875,
0.08428955078125,
-0.68359375,
-0.55517578125,
-0.7509765625,
0.73388671875,
0.60302734375,
0.79150390625,
0.05487060546875,
0.11322021484375,
-0.466796875,
0.469970703125,
0.29931640625,
-0.35302734375,
0.119873046875,
-0.7509765625,
0.73828125,
0.1285400390625,
-0.09051513671875,
-0.3154296875,
-0.332275390625,
-0.403564453125,
-0.0740966796875,
0.572265625,
-0.28515625,
-1.1083984375,
0.27685546875,
-0.05499267578125,
0.88916015625,
-0.64013671875,
-0.12286376953125,
-0.57666015625,
0.69287109375,
0.298828125,
-0.93896484375,
-0.1112060546875,
-0.689453125,
0.337646484375,
0.80810546875,
-0.10107421875,
-0.353271484375,
-0.2415771484375,
-0.654296875,
-0.72705078125,
0.336669921875,
0.89111328125,
0.03759765625,
0.055633544921875,
-0.80322265625,
0.364501953125,
0.454345703125,
-0.34033203125,
0.1817626953125,
-0.03851318359375,
0.2012939453125,
-0.289794921875,
0.411865234375,
-0.2724609375,
-0.341552734375,
-0.0147705078125,
-1.1591796875,
0.765625,
-0.163818359375,
0.09844970703125,
-0.323486328125,
-0.3017578125,
-0.176025390625,
0.5556640625,
-0.189453125,
0.03741455078125,
-0.235107421875,
0.331298828125,
-0.59619140625,
-1.142578125,
0.5048828125,
-0.11663818359375,
-0.60546875,
0.8955078125,
0.0123291015625,
-0.28271484375,
0.2529296875,
0.5322265625,
-0.62939453125,
0.61376953125,
-0.33056640625,
0.361328125,
-0.12152099609375,
-0.146240234375,
-0.189453125,
-0.62109375,
0.71875,
0.10101318359375,
-0.8671875,
-0.0218353271484375,
-1.033203125,
-0.51171875,
-0.12310791015625,
-0.484375,
0.14208984375,
0.0306396484375,
-0.302001953125,
0.274658203125,
-0.433349609375,
-0.57275390625,
-0.6201171875,
-0.8349609375,
-0.353515625,
0.7236328125,
0.176513671875,
0.221923828125,
0.1474609375,
-0.611328125,
0.254638671875,
-0.30322265625,
-0.00848388671875,
-0.200927734375,
-0.050567626953125,
-0.2998046875,
-0.08148193359375,
-0.373291015625,
0.4306640625,
0.4775390625,
0.492431640625,
0.974609375,
0.2269287109375,
0.3505859375,
0.282470703125,
-0.71533203125,
0.859375,
0.43408203125,
-1.20703125,
-0.2054443359375,
0.90380859375,
-0.036346435546875,
0.7392578125,
-0.14697265625,
-0.84619140625,
-0.95068359375,
-0.88037109375,
0.25927734375,
-0.64794921875,
0.032989501953125,
-0.78369140625,
-0.671875,
-0.39892578125,
0.453857421875,
0.0017242431640625,
-0.50927734375,
0.129150390625,
-1.1142578125,
0.286865234375,
-0.99951171875,
0.117431640625,
-0.73974609375,
-0.5634765625,
-0.2232666015625,
1.0107421875,
-0.052734375,
0.26953125,
0.623046875,
0.0753173828125,
-0.1451416015625,
-0.298828125,
-0.5146484375,
-0.1265869140625,
-0.421875,
0.3818359375,
-0.03826904296875,
-0.422607421875,
-0.55078125,
0.517578125,
-0.966796875,
0.2437744140625,
-0.1949462890625,
-0.393798828125,
-0.29052734375,
-0.48583984375,
0.81591796875,
-0.379638671875,
-0.0802001953125,
-0.380615234375,
0.246337890625,
0.86962890625,
-0.0335693359375,
-0.228759765625,
-0.322265625,
-0.58447265625,
-1.1650390625,
0.4453125,
-0.6591796875,
-0.1474609375,
-0.62255859375,
0.0743408203125,
0.80126953125,
-0.312255859375,
0.70361328125,
1.1533203125,
0.30078125,
0.560546875,
-0.677734375,
0.72998046875,
0.509765625,
-0.389404296875,
0.31591796875,
-0.041168212890625,
-0.74462890625,
-0.09478759765625,
-0.2529296875,
-1.2392578125,
-0.84814453125,
-0.1754150390625,
1.2021484375,
-0.615234375,
0.7265625,
-0.0875244140625,
-1.267578125,
-0.88623046875,
1.091796875,
0.04248046875,
0.304443359375,
0.6884765625,
-0.486328125,
-0.028106689453125,
0.00843048095703125,
0.18505859375,
-0.241455078125,
-0.6904296875,
1.2734375,
-0.294677734375,
-0.466552734375,
0.95654296875,
0.73583984375,
-1.4755859375,
-1.1259765625,
-0.11407470703125,
0.058624267578125,
0.0140533447265625,
-0.72021484375,
-0.15869140625,
0.35205078125,
-0.748046875,
0.043365478515625,
0.587890625,
0.07293701171875,
0.2476806640625,
0.1220703125,
0.35693359375,
-0.61865234375,
0.02679443359375,
0.5576171875,
-0.3115234375,
-0.470947265625,
-1.1298828125,
-0.484130859375,
-0.1939697265625,
0.01276397705078125,
0.68994140625,
-0.13330078125,
0.250244140625,
0.337158203125,
0.0880126953125,
0.57275390625,
-0.37744140625,
-0.416748046875,
0.5009765625,
-0.40771484375,
-0.75634765625,
-0.39404296875,
0.2236328125,
0.010955810546875,
0.30029296875,
-0.69677734375,
0.07855224609375,
-0.0020427703857421875,
0.2156982421875,
-0.40478515625,
-0.82275390625,
-0.40576171875,
-1.212890625,
-0.482177734375,
-0.6220703125,
-0.80517578125,
-0.3125,
0.0106964111328125,
-0.131591796875,
-0.56201171875,
0.0012722015380859375,
0.28955078125,
-0.505859375,
0.480712890625,
-0.84912109375,
0.35546875,
-0.77978515625,
-0.145751953125,
-0.6826171875,
-0.0443115234375,
-0.68505859375,
-0.137451171875,
-0.791015625,
0.302734375,
-0.220703125,
0.65771484375,
-0.287109375,
0.2054443359375,
-0.505859375,
-0.2347412109375,
-0.25048828125,
0.1966552734375,
0.2203369140625,
0.74169921875,
0.806640625,
-0.1732177734375,
0.22900390625,
-0.1590576171875,
0.1380615234375,
-0.272705078125,
0.3720703125,
0.0863037109375,
-0.260498046875,
-0.458251953125,
-0.44482421875,
-0.00945281982421875,
-1.197265625,
0.10943603515625,
-0.66552734375,
0.3916015625,
0.11712646484375,
0.01219940185546875,
0.1920166015625,
1.0029296875,
-0.2471923828125,
0.205322265625,
-0.10052490234375,
0.39990234375,
0.2091064453125,
-0.31494140625,
0.28759765625,
0.98583984375,
-0.10821533203125,
-0.576171875,
-0.0283050537109375,
-0.01401519775390625,
0.014007568359375,
0.316650390625,
-0.55859375,
-0.158935546875,
-0.86083984375,
-0.81787109375,
-0.31884765625,
0.223876953125,
0.82568359375,
-0.302001953125,
0.15380859375,
-0.241455078125,
-0.5478515625,
-0.1851806640625,
-1.2177734375,
-0.86767578125,
-0.1236572265625,
-0.1651611328125,
-0.002666473388671875,
-0.37890625,
-0.6396484375,
0.115478515625,
0.00836944580078125,
0.388671875,
-0.294189453125,
0.440185546875,
-0.191162109375,
0.3994140625,
-0.030975341796875,
-0.01092529296875,
0.16162109375,
0.2296142578125,
-0.97412109375,
-0.4287109375,
-0.2509765625,
0.9833984375,
0.238037109375,
-0.2607421875,
-0.662109375,
-0.059173583984375,
-0.06298828125,
0.375,
-0.80126953125,
0.051971435546875,
-0.055999755859375,
0.52001953125,
-0.41357421875,
0.05145263671875,
-0.0034465789794921875,
0.11474609375,
0.11236572265625,
-0.294921875,
-0.505859375,
1.03125,
0.50341796875,
0.330810546875,
1.02734375,
0.033355712890625,
0.2366943359375,
-0.58056640625,
-0.2459716796875,
-0.09759521484375,
0.703125,
0.465576171875,
0.5986328125,
-0.203857421875,
0.211669921875,
0.849609375,
-0.2200927734375,
0.06915283203125,
0.0440673828125,
0.1300048828125,
-0.1700439453125,
-0.11944580078125,
-0.208251953125,
-0.11651611328125,
0.2271728515625,
-0.478759765625,
0.4111328125,
-0.300048828125,
0.176025390625,
-0.050933837890625,
-0.3125,
0.56884765625,
-0.350341796875,
-0.09405517578125,
-0.0274810791015625,
-0.69921875,
0.0908203125,
0.54541015625,
0.0714111328125,
0.032989501953125,
0.81494140625,
0.72119140625,
0.50537109375,
0.716796875,
0.480712890625,
0.68408203125,
-0.69091796875,
0.1693115234375,
0.1331787109375,
0.045928955078125,
-0.630859375,
-0.72705078125,
-1.1044921875,
0.417724609375,
-0.173583984375,
-0.346923828125,
0.241943359375,
-0.484375,
0.2401123046875,
-0.454833984375,
0.5146484375,
-0.1993408203125,
0.2078857421875,
0.450439453125,
0.148193359375,
-0.5810546875,
0.63525390625,
-0.2353515625,
-0.059539794921875,
0.175537109375,
1.2421875,
0.233642578125,
1.3056640625,
0.328369140625,
-0.318115234375,
0.056304931640625,
0.197509765625,
-0.6455078125,
-0.423095703125,
-0.0635986328125,
-0.275634765625,
-0.258056640625,
-0.5771484375,
-0.431884765625,
-0.291748046875,
0.9169921875,
-0.043792724609375,
-0.83642578125,
-0.0200347900390625,
0.0268707275390625,
-0.76318359375,
0.53369140625,
0.08258056640625,
0.2186279296875,
0.375,
-0.1893310546875,
-0.059295654296875,
-0.6796875,
0.4951171875,
-0.7578125,
0.338623046875,
-0.421142578125,
-0.1854248046875,
-0.480712890625,
-0.76123046875,
-0.6962890625,
-0.2215576171875,
-0.383544921875,
-0.83349609375,
0.47607421875,
0.75390625,
0.126708984375,
0.2481689453125,
-0.321533203125,
-0.0234222412109375,
0.94091796875,
1.5048828125,
0.141357421875,
0.888671875,
0.0860595703125,
-0.282470703125,
0.1453857421875,
-0.02301025390625,
0.7978515625,
0.00708770751953125,
-0.125,
-0.08477783203125,
0.265380859375,
-1.0234375,
-1.107421875,
0.09033203125,
0.52685546875,
0.322998046875,
-0.48828125,
-1.0263671875,
-0.0032558441162109375,
-1.005859375,
0.013275146484375,
-0.666015625,
0.99755859375,
-0.270263671875,
0.086669921875,
-0.1563720703125,
-1.02734375,
4.46875,
1.115234375,
1.2197265625,
0.62890625,
-0.123291015625,
1.0595703125,
0.5634765625,
-0.564453125,
-0.29248046875,
-0.45849609375,
0.54736328125,
-0.5205078125,
0.0928955078125,
0.8720703125,
0.5341796875,
0.80615234375,
-0.59228515625,
0.08929443359375,
0.182861328125,
-0.7158203125,
-0.32958984375,
0.308837890625,
-0.03369140625,
0.2032470703125,
-0.1463623046875,
0.33349609375,
0.7412109375,
-0.62255859375,
-0.2122802734375,
-0.314208984375,
0.08416748046875,
-0.36572265625,
0.8125,
0.107666015625,
-0.05517578125,
0.53662109375,
0.06414794921875,
-0.314697265625,
-0.038421630859375,
0.26513671875,
-0.338623046875,
0.228271484375,
0.1787109375,
-0.82275390625,
-0.4189453125,
0.29150390625,
-0.685546875,
0.420654296875,
0.278564453125,
-0.94091796875,
0.916015625,
0.231689453125,
0.1822509765625,
-0.5,
-0.82080078125,
-0.005702972412109375,
0.241455078125,
-0.0250396728515625,
-0.008575439453125,
0.52099609375,
0.630859375,
0.68212890625,
0.06256103515625,
0.351806640625,
-0.87109375,
0.935546875,
-0.334716796875,
0.471923828125,
-0.70947265625,
-0.141357421875,
-0.107421875,
-0.11712646484375,
-0.015167236328125,
-0.638671875,
1.01953125,
0.341796875,
-0.27392578125,
0.9423828125,
0.334228515625,
-0.3388671875,
0.3427734375,
-0.7529296875,
-0.2103271484375,
-0.217529296875,
0.63818359375,
1.2978515625,
-0.59228515625,
-0.402587890625,
-0.0345458984375,
0.763671875,
0.447265625,
0.84716796875,
0.047698974609375,
-0.859375,
-0.050811767578125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in any order, any operation may be applied any number of times. The i-th operation is described by a string ai of length two and a string bi of length one. No two of q possible operations have the same string ai.
When Limak has a string s he can perform the i-th operation on s if the first two letters of s match a two-letter string ai. Performing the i-th operation removes first two letters of s and inserts there a string bi. See the notes section for further clarification.
You may note that performing an operation decreases the length of a string s exactly by 1. Also, for some sets of operations there may be a string that cannot be compressed any further, because the first two letters don't match any ai.
Limak wants to start with a string of length n and perform n - 1 operations to finally get a one-letter string "a". In how many ways can he choose the starting string to be able to get "a"? Remember that Limak can use only letters he knows.
Input
The first line contains two integers n and q (2 ≤ n ≤ 6, 1 ≤ q ≤ 36) — the length of the initial string and the number of available operations.
The next q lines describe the possible operations. The i-th of them contains two strings ai and bi (|ai| = 2, |bi| = 1). It's guaranteed that ai ≠ aj for i ≠ j and that all ai and bi consist of only first six lowercase English letters.
Output
Print the number of strings of length n that Limak will be able to transform to string "a" by applying only operations given in the input.
Examples
Input
3 5
ab a
cc c
ca a
ee c
ff d
Output
4
Input
2 8
af e
dc d
cc f
bc b
da b
eb a
bb b
ff c
Output
1
Input
6 2
bb a
ba a
Output
0
Note
In the first sample, we count initial strings of length 3 from which Limak can get a required string "a". There are 4 such strings: "abb", "cab", "cca", "eea". The first one Limak can compress using operation 1 two times (changing "ab" to a single "a"). The first operation would change "abb" to "ab" and the second operation would change "ab" to "a".
Other three strings may be compressed as follows:
* "cab" <image> "ab" <image> "a"
* "cca" <image> "ca" <image> "a"
* "eea" <image> "ca" <image> "a"
In the second sample, the only correct initial string is "eb" because it can be immediately compressed to "a".
Tags: brute force, dfs and similar, dp, strings
Correct Solution:
```
from itertools import product
#n = int(input().strip())
n, q = map(int, input().strip().split())
dic = {}
for i in range(q):
a, b = input().strip().split()
dic[a] = b
count = 0
for i in product('abcdef', repeat = n):
s = ''.join(i)
for j in range(n-1):
if s[:1] == 'g':
break
s = dic.get(s[:2], 'g') + s[2:]
if s == 'a':
count += 1
print(count)
```
| 70,292 | [
0.405517578125,
-0.0950927734375,
0.2056884765625,
-0.07342529296875,
-0.63916015625,
-0.362548828125,
-0.0787353515625,
0.19384765625,
0.1724853515625,
0.93212890625,
0.90771484375,
-0.11602783203125,
-0.102783203125,
-0.99609375,
-0.484375,
0.2491455078125,
-0.325927734375,
-0.5732421875,
-0.269775390625,
-0.199951171875,
0.1385498046875,
-0.468994140625,
-1.3232421875,
-0.23779296875,
-0.62939453125,
0.61376953125,
0.60888671875,
0.16357421875,
1.0791015625,
1.0810546875,
-0.231689453125,
-0.48291015625,
0.59619140625,
-1.234375,
-0.1663818359375,
-0.286865234375,
0.7158203125,
-0.66650390625,
-0.34033203125,
-0.59033203125,
0.298583984375,
-0.72509765625,
0.373779296875,
-0.666015625,
-1.1650390625,
-0.047088623046875,
-0.357421875,
-0.56640625,
-0.083740234375,
-0.83447265625,
0.2509765625,
-0.34375,
0.90625,
-0.300537109375,
0.09759521484375,
-0.165283203125,
0.50927734375,
-0.04119873046875,
-0.53857421875,
0.446533203125,
0.06591796875,
0.2802734375,
0.26611328125,
-0.56640625,
-0.2479248046875,
-0.1365966796875,
-0.141845703125,
-0.24609375,
-0.0950927734375,
-0.61572265625,
-0.587890625,
0.12188720703125,
-0.60107421875,
-0.669921875,
-0.2003173828125,
-0.0167388916015625,
0.173828125,
-0.08294677734375,
-0.61865234375,
1.060546875,
0.07183837890625,
1.025390625,
0.73193359375,
0.29443359375,
-0.189697265625,
-0.59423828125,
0.0794677734375,
0.27978515625,
0.0545654296875,
0.163330078125,
-0.265380859375,
0.75439453125,
-1.08203125,
-0.04815673828125,
0.48828125,
0.57861328125,
-0.07940673828125,
0.1142578125,
0.198974609375,
-0.1605224609375,
1.0556640625,
0.426513671875,
-0.1029052734375,
1.1943359375,
-0.5009765625,
0.2861328125,
-0.021881103515625,
0.007091522216796875,
-0.3134765625,
-0.06146240234375,
-0.13525390625,
-0.19091796875,
1.0751953125,
0.1865234375,
-0.2369384765625,
0.76513671875,
0.1746826171875,
0.56298828125,
-0.6376953125,
0.2322998046875,
0.35791015625,
0.41748046875,
0.8408203125,
-0.32861328125,
-0.12432861328125,
-0.1685791015625,
-0.135498046875,
0.654296875,
-0.84326171875,
-0.19677734375,
0.13525390625,
-0.189453125,
-0.161865234375,
0.30908203125,
-0.347412109375,
0.66845703125,
-0.2154541015625,
0.5927734375,
1.107421875,
-0.5634765625,
0.826171875,
-0.0151214599609375,
-0.00812530517578125,
1.49609375,
0.1683349609375,
0.270263671875,
0.7529296875,
0.09686279296875,
-0.74658203125,
0.488525390625,
-0.97607421875,
0.36083984375,
0.348388671875,
0.1275634765625,
-0.377685546875,
0.249267578125,
-0.1817626953125,
0.311279296875,
-0.001735687255859375,
-0.07421875,
-0.20703125,
0.33935546875,
-0.6201171875,
1.0546875,
-0.0732421875,
0.87060546875,
-0.42236328125,
-0.314697265625,
0.0888671875,
-0.071533203125,
0.09637451171875,
-0.2978515625,
-0.322021484375,
0.8203125,
0.374755859375,
1.064453125,
0.94873046875,
-0.0073699951171875,
0.387451171875,
0.390625,
-0.262451171875,
0.486083984375,
0.39794921875,
0.7490234375,
0.228271484375,
0.40380859375,
0.031036376953125,
-0.08441162109375,
-0.1845703125,
-0.28125,
-0.06060791015625,
0.72802734375,
-0.4296875,
-0.148681640625,
0.04595947265625,
0.18603515625,
-0.97314453125,
0.455322265625,
0.0535888671875,
-0.9833984375,
-0.265380859375,
0.74951171875,
-0.453857421875,
0.62841796875,
-0.55419921875,
-0.69970703125,
0.62060546875,
1.1943359375,
0.1446533203125,
0.0263824462890625,
0.79638671875,
0.541015625,
-0.420654296875,
0.334716796875,
-0.232421875,
-0.5244140625,
-0.560546875,
0.73193359375,
0.0509033203125,
-0.09967041015625,
0.168701171875,
0.26025390625,
0.306396484375,
0.70068359375,
-0.37255859375,
-0.028106689453125,
0.80078125,
1.0947265625,
-0.054412841796875,
0.44580078125,
0.156005859375,
0.96484375,
0.505859375,
0.9404296875,
0.638671875,
0.308837890625,
0.64453125,
0.93505859375,
0.015350341796875,
0.0011730194091796875,
0.051300048828125,
0.6611328125,
0.436279296875,
0.67333984375,
0.12286376953125,
0.2100830078125,
-0.2705078125,
0.05712890625,
-0.5966796875,
-0.004596710205078125,
-0.2763671875,
0.77685546875,
0.10687255859375,
0.74755859375,
-0.30859375,
-0.413330078125,
0.3251953125,
0.6484375,
-0.958984375,
-0.44384765625,
-0.376220703125,
-0.135498046875,
0.350341796875,
-0.046966552734375,
0.259521484375,
0.052337646484375,
0.320068359375,
0.1103515625,
-0.2489013671875,
-0.69384765625,
-1.095703125,
-0.98779296875,
-0.7548828125,
-0.51806640625,
-0.62451171875,
0.126953125,
0.179443359375,
-1.1728515625,
0.53564453125,
-0.54638671875,
-0.2427978515625,
-0.020721435546875,
-0.85107421875,
0.5537109375,
-0.227294921875,
0.470947265625,
-0.452392578125,
0.368408203125,
0.299560546875,
1.306640625,
-0.162353515625,
0.1776123046875,
-0.0751953125,
-0.63623046875,
0.27880859375,
-0.272216796875,
0.57861328125,
-0.1357421875,
-0.734375,
-0.587890625,
-0.340087890625,
-0.08221435546875,
-0.56884765625,
0.373779296875,
-0.412841796875,
0.5791015625,
0.36669921875,
-1.0576171875,
0.685546875,
1.1533203125,
-0.5458984375,
0.6748046875,
-0.362548828125,
0.0278472900390625,
-0.79345703125,
1.18359375,
0.255859375,
0.414794921875,
-0.321044921875,
-0.8623046875,
-0.3818359375,
-0.18798828125,
0.06793212890625,
-0.302734375,
-0.0772705078125,
0.63232421875,
-0.381103515625,
-0.7587890625,
0.6376953125,
-1.013671875,
-0.322265625,
-0.7998046875,
-0.63134765625,
0.78955078125,
0.68896484375,
0.1461181640625,
0.0021762847900390625,
-0.144287109375,
-0.143798828125,
0.9814453125,
0.2269287109375,
-0.630859375,
0.07647705078125,
0.5078125,
0.031463623046875,
0.0125885009765625,
0.54443359375,
-0.55517578125,
-0.3798828125,
0.06890869140625,
-0.03436279296875,
0.71337890625,
0.2376708984375,
0.57666015625,
0.57958984375,
0.6220703125,
-1.0087890625,
-0.1505126953125,
-0.43505859375,
0.413818359375,
0.425537109375,
0.23193359375,
0.416015625,
-0.464111328125,
-0.5234375,
-0.90234375,
0.40966796875,
0.1962890625,
0.428955078125,
-0.6708984375,
0.9072265625,
0.05267333984375,
-0.39404296875,
0.380859375,
-0.501953125,
-0.1041259765625,
0.8896484375,
-0.395751953125,
0.724609375,
-0.6806640625,
0.63916015625,
-0.1055908203125,
-0.1796875,
0.84228515625,
0.286376953125,
0.452880859375,
-0.544921875,
-0.304443359375,
-0.505859375,
-0.28466796875,
0.2548828125,
-0.5478515625,
0.10748291015625,
-0.72509765625,
-0.29638671875,
-0.91357421875,
0.54296875,
0.36474609375,
0.7578125,
-0.067626953125,
0.494140625,
0.06512451171875,
0.71484375,
0.69091796875,
-0.2352294921875,
-0.05438232421875,
-0.456787109375,
0.87646484375,
0.243896484375,
-0.281982421875,
-0.54248046875,
-0.1630859375,
-0.458984375,
0.39599609375,
-0.0374755859375,
-0.08685302734375,
-0.9150390625,
0.42333984375,
0.1990966796875,
0.7001953125,
-0.463134765625,
-0.52490234375,
-0.359619140625,
0.361328125,
0.59619140625,
-1.2021484375,
0.00028061866760253906,
-0.677734375,
0.87451171875,
0.43994140625,
-0.2332763671875,
-0.4267578125,
-0.62109375,
-0.6171875,
-0.453857421875,
-0.0782470703125,
0.71142578125,
0.314208984375,
0.412353515625,
-0.99267578125,
0.32666015625,
0.301513671875,
-0.2119140625,
0.04052734375,
-0.16796875,
0.22021484375,
-0.1436767578125,
0.74951171875,
-0.339599609375,
-0.71728515625,
0.021636962890625,
-1.302734375,
0.2880859375,
-0.68359375,
0.339599609375,
0.046966552734375,
-0.478759765625,
-0.302001953125,
0.329833984375,
-0.430419921875,
-0.0377197265625,
0.06964111328125,
0.68408203125,
-1.0576171875,
-0.998046875,
0.5517578125,
-0.2393798828125,
-0.493408203125,
1.19140625,
0.0958251953125,
-0.544921875,
0.02545166015625,
0.240966796875,
-0.37939453125,
0.54833984375,
-1.0693359375,
0.63818359375,
-0.447265625,
-0.34423828125,
-0.449951171875,
-0.56201171875,
0.412109375,
-0.0860595703125,
-0.52880859375,
-0.496826171875,
-1.326171875,
-0.159423828125,
-0.036376953125,
-0.5517578125,
0.44921875,
-0.054656982421875,
0.167724609375,
-0.057586669921875,
-0.47998046875,
-0.177734375,
-0.607421875,
-0.47314453125,
-0.39111328125,
0.53759765625,
0.53857421875,
0.7998046875,
-0.043365478515625,
-0.333740234375,
0.028564453125,
-0.0970458984375,
0.09515380859375,
-0.1522216796875,
-0.2105712890625,
0.0237579345703125,
-0.12164306640625,
-0.135009765625,
0.314208984375,
-0.181640625,
0.09552001953125,
0.485595703125,
0.054412841796875,
0.66015625,
0.228759765625,
-0.72802734375,
1.31640625,
0.189453125,
-1.0390625,
-0.216796875,
0.90478515625,
-0.127197265625,
0.3427734375,
0.31591796875,
-1.015625,
-0.86279296875,
-0.74072265625,
0.489501953125,
-0.72314453125,
-0.396728515625,
-1.2158203125,
-0.377685546875,
-0.54931640625,
0.708984375,
-0.032806396484375,
-0.42138671875,
0.42236328125,
-1.046875,
0.3681640625,
-0.60205078125,
-0.67626953125,
-0.56787109375,
-0.68310546875,
-0.091064453125,
1.146484375,
0.077880859375,
0.2498779296875,
0.2607421875,
-0.265869140625,
0.58984375,
0.24169921875,
-0.94775390625,
-0.32470703125,
-0.1446533203125,
0.429443359375,
-0.09375,
0.0261383056640625,
-0.394287109375,
0.4072265625,
-0.77099609375,
0.333740234375,
-0.264404296875,
-0.34619140625,
-0.35400390625,
-0.41064453125,
1.1650390625,
-0.61572265625,
0.062286376953125,
-0.2294921875,
0.6962890625,
0.92919921875,
-0.02581787109375,
-0.42333984375,
-0.88623046875,
-1.052734375,
-0.9443359375,
0.63232421875,
-0.402587890625,
0.0018777847290039062,
-0.471435546875,
0.031982421875,
0.8291015625,
-0.164306640625,
0.5830078125,
0.869140625,
0.10345458984375,
-0.0958251953125,
-0.61474609375,
0.7099609375,
0.41552734375,
-0.4951171875,
-0.302001953125,
0.372314453125,
-0.603515625,
0.311767578125,
-0.422607421875,
-1.2119140625,
-0.80029296875,
0.337158203125,
1.3984375,
-0.243408203125,
0.900390625,
-0.059844970703125,
-0.88916015625,
-0.43017578125,
0.66357421875,
0.12139892578125,
0.327392578125,
0.78125,
-0.1126708984375,
-0.329833984375,
0.10894775390625,
-0.373046875,
-0.109130859375,
-0.62548828125,
1.23046875,
-0.6357421875,
-0.625,
0.453125,
0.99365234375,
-0.90869140625,
-1.302734375,
-0.2376708984375,
-0.3125,
-0.434326171875,
-0.86767578125,
-0.129638671875,
0.266357421875,
-0.2474365234375,
0.10369873046875,
0.31787109375,
-0.065185546875,
0.55712890625,
0.1260986328125,
0.5234375,
-0.1416015625,
0.4521484375,
0.69580078125,
-0.51171875,
-0.642578125,
-1.03125,
-0.048614501953125,
-0.361328125,
0.2294921875,
0.59814453125,
-0.2142333984375,
0.50537109375,
0.5419921875,
-0.15966796875,
0.77099609375,
-0.38818359375,
-0.462158203125,
0.2237548828125,
-1.134765625,
-0.451904296875,
0.026519775390625,
0.54345703125,
-0.47265625,
0.292236328125,
-0.79833984375,
-0.537109375,
0.343505859375,
0.54052734375,
-0.36767578125,
-1.0625,
-0.12274169921875,
-1.2109375,
-0.62841796875,
-0.58642578125,
-0.75439453125,
-0.1837158203125,
-0.1953125,
0.01244354248046875,
-0.7890625,
-0.08221435546875,
0.283203125,
-0.505859375,
0.8330078125,
-0.556640625,
0.54638671875,
-0.669921875,
-0.11895751953125,
-0.64501953125,
0.14404296875,
-0.54150390625,
-0.1407470703125,
-0.320068359375,
0.328125,
-0.17724609375,
0.56591796875,
-0.3173828125,
0.309326171875,
-0.2088623046875,
-0.40478515625,
-0.100341796875,
0.1590576171875,
-0.2288818359375,
0.673828125,
0.5224609375,
-0.2587890625,
0.333740234375,
-0.11639404296875,
-0.1492919921875,
-0.252685546875,
0.90380859375,
0.16015625,
-0.040679931640625,
-0.1749267578125,
-0.2362060546875,
0.371826171875,
-0.96826171875,
0.30810546875,
-0.141357421875,
0.533203125,
0.0002970695495605469,
-0.237548828125,
0.3564453125,
1.0888671875,
-0.119140625,
0.006641387939453125,
0.2333984375,
0.145263671875,
0.1314697265625,
0.1522216796875,
-0.0233612060546875,
0.484375,
-0.1982421875,
-0.343017578125,
-0.1400146484375,
0.3291015625,
0.06268310546875,
0.409912109375,
-0.1524658203125,
-0.76513671875,
-0.65673828125,
-0.288330078125,
-0.047698974609375,
0.51708984375,
0.5400390625,
-0.60009765625,
0.0209503173828125,
0.0628662109375,
-0.7783203125,
0.0950927734375,
-1.0166015625,
-1.0859375,
0.00504302978515625,
0.07574462890625,
-0.73974609375,
-0.10162353515625,
-0.48046875,
-0.200439453125,
0.01421356201171875,
0.2183837890625,
-0.89013671875,
0.3251953125,
0.0029048919677734375,
0.58203125,
-0.2322998046875,
-0.0160064697265625,
-0.017822265625,
0.353759765625,
-0.6044921875,
-0.2303466796875,
-0.348876953125,
0.5888671875,
0.27880859375,
-0.2353515625,
-0.22998046875,
0.1783447265625,
0.2152099609375,
0.207275390625,
-0.55908203125,
0.250732421875,
-0.0775146484375,
0.88818359375,
-0.77587890625,
-0.204345703125,
-0.396240234375,
0.272705078125,
0.10394287109375,
-0.53759765625,
-0.8154296875,
1.2626953125,
0.76513671875,
-0.1380615234375,
0.303466796875,
0.163330078125,
0.43994140625,
-0.304931640625,
0.11297607421875,
-0.48095703125,
0.8603515625,
0.443359375,
0.59326171875,
-0.1422119140625,
0.285400390625,
0.51806640625,
-0.06134033203125,
-0.57470703125,
0.380126953125,
0.286865234375,
0.045806884765625,
0.071533203125,
-0.27880859375,
-0.41943359375,
-0.04400634765625,
-0.8857421875,
0.2841796875,
-0.185302734375,
-0.0736083984375,
-0.51318359375,
-0.48974609375,
0.85791015625,
-0.53076171875,
-0.00977325439453125,
0.298828125,
-0.264404296875,
0.33740234375,
0.517578125,
0.140380859375,
0.1728515625,
0.955078125,
0.72998046875,
0.63623046875,
0.59130859375,
0.2509765625,
0.365234375,
-0.759765625,
0.1826171875,
0.3251953125,
0.01152801513671875,
0.056640625,
-0.1036376953125,
-0.876953125,
0.5654296875,
-0.331787109375,
-0.3291015625,
0.359130859375,
-0.61181640625,
-0.1983642578125,
-0.421142578125,
0.86279296875,
-0.673828125,
0.55517578125,
0.6484375,
-0.289306640625,
-0.5888671875,
1.1982421875,
-0.401123046875,
0.1790771484375,
0.165771484375,
1.1767578125,
0.362060546875,
1.4345703125,
0.484619140625,
-0.090576171875,
0.114501953125,
0.460693359375,
-0.2337646484375,
-0.71533203125,
-0.47265625,
-0.375,
0.200439453125,
-0.86962890625,
-0.469970703125,
-0.373046875,
1.0224609375,
0.08148193359375,
-0.7685546875,
-0.19873046875,
0.0633544921875,
-0.77587890625,
0.19970703125,
0.311767578125,
0.459716796875,
0.07763671875,
-0.204345703125,
-0.037445068359375,
-0.48876953125,
0.1180419921875,
-0.29150390625,
0.3603515625,
-0.60205078125,
-0.5361328125,
-0.30029296875,
-1.0400390625,
-0.669921875,
0.1705322265625,
-0.1593017578125,
-0.830078125,
0.6201171875,
0.75390625,
0.1885986328125,
0.310791015625,
-0.48095703125,
0.386962890625,
0.95166015625,
1.28515625,
-0.09161376953125,
0.78955078125,
0.415283203125,
-0.300048828125,
0.1549072265625,
-0.431640625,
0.57666015625,
0.06610107421875,
0.52783203125,
-0.33984375,
0.6826171875,
-0.6015625,
-1.1650390625,
0.11773681640625,
0.44384765625,
0.67578125,
-0.91259765625,
-1.2861328125,
-0.1861572265625,
-1.017578125,
-0.151611328125,
-0.44775390625,
0.83935546875,
-0.29443359375,
0.1649169921875,
0.05267333984375,
-1.0712890625,
4.3359375,
1.294921875,
1.021484375,
0.35107421875,
0.51708984375,
1.3828125,
0.37841796875,
-0.5771484375,
-0.54736328125,
-0.48583984375,
0.490234375,
-0.281494140625,
0.06439208984375,
0.8671875,
0.2191162109375,
0.62744140625,
-0.5048828125,
0.049957275390625,
-0.301513671875,
-0.83740234375,
-0.8251953125,
0.279541015625,
-0.00595855712890625,
0.2347412109375,
-0.2802734375,
0.19091796875,
0.62255859375,
-0.78271484375,
-0.315673828125,
-0.86572265625,
0.00533294677734375,
-0.580078125,
0.9365234375,
0.0963134765625,
0.19091796875,
0.595703125,
-0.036529541015625,
-0.42041015625,
-0.194091796875,
-0.11126708984375,
-0.1619873046875,
0.3232421875,
0.82666015625,
-0.58251953125,
-0.2149658203125,
0.59326171875,
-0.80810546875,
0.55615234375,
0.4140625,
-1.220703125,
1.0224609375,
-0.259765625,
0.6162109375,
-0.6376953125,
-0.77197265625,
0.0019245147705078125,
-0.06512451171875,
-0.059295654296875,
-0.2191162109375,
0.3798828125,
0.1728515625,
0.294921875,
0.12225341796875,
0.436767578125,
-0.86083984375,
0.52001953125,
-0.08843994140625,
0.364990234375,
-0.67236328125,
-0.11126708984375,
-0.342041015625,
-0.2418212890625,
-0.5,
-0.24169921875,
0.7529296875,
0.2376708984375,
-0.0904541015625,
0.5361328125,
0.64453125,
-0.5068359375,
0.2359619140625,
-0.35791015625,
-0.2493896484375,
-0.466064453125,
0.7509765625,
1.134765625,
-0.4853515625,
-0.10955810546875,
-0.1319580078125,
0.486328125,
0.60791015625,
0.533203125,
-0.1982421875,
-0.270751953125,
-0.32763671875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in any order, any operation may be applied any number of times. The i-th operation is described by a string ai of length two and a string bi of length one. No two of q possible operations have the same string ai.
When Limak has a string s he can perform the i-th operation on s if the first two letters of s match a two-letter string ai. Performing the i-th operation removes first two letters of s and inserts there a string bi. See the notes section for further clarification.
You may note that performing an operation decreases the length of a string s exactly by 1. Also, for some sets of operations there may be a string that cannot be compressed any further, because the first two letters don't match any ai.
Limak wants to start with a string of length n and perform n - 1 operations to finally get a one-letter string "a". In how many ways can he choose the starting string to be able to get "a"? Remember that Limak can use only letters he knows.
Input
The first line contains two integers n and q (2 ≤ n ≤ 6, 1 ≤ q ≤ 36) — the length of the initial string and the number of available operations.
The next q lines describe the possible operations. The i-th of them contains two strings ai and bi (|ai| = 2, |bi| = 1). It's guaranteed that ai ≠ aj for i ≠ j and that all ai and bi consist of only first six lowercase English letters.
Output
Print the number of strings of length n that Limak will be able to transform to string "a" by applying only operations given in the input.
Examples
Input
3 5
ab a
cc c
ca a
ee c
ff d
Output
4
Input
2 8
af e
dc d
cc f
bc b
da b
eb a
bb b
ff c
Output
1
Input
6 2
bb a
ba a
Output
0
Note
In the first sample, we count initial strings of length 3 from which Limak can get a required string "a". There are 4 such strings: "abb", "cab", "cca", "eea". The first one Limak can compress using operation 1 two times (changing "ab" to a single "a"). The first operation would change "abb" to "ab" and the second operation would change "ab" to "a".
Other three strings may be compressed as follows:
* "cab" <image> "ab" <image> "a"
* "cca" <image> "ca" <image> "a"
* "eea" <image> "ca" <image> "a"
In the second sample, the only correct initial string is "eb" because it can be immediately compressed to "a".
Tags: brute force, dfs and similar, dp, strings
Correct Solution:
```
n, q = map(int, input().split())
fr = dict()
for i in range(q):
a, b = input().split()
if b in fr:
fr[b].append(a)
else:
fr[b] = [a]
def dfs(c, cnt):
global n
if cnt == n:
return 1
if cnt > n:
return 0
global fr
if c not in fr:
return 0
ans = 0
for i in fr[c]:
ans += dfs(i[0], cnt+1)
return ans
print(dfs('a', 1))
```
| 70,293 | [
0.405517578125,
-0.0950927734375,
0.2056884765625,
-0.07342529296875,
-0.63916015625,
-0.362548828125,
-0.0787353515625,
0.19384765625,
0.1724853515625,
0.93212890625,
0.90771484375,
-0.11602783203125,
-0.102783203125,
-0.99609375,
-0.484375,
0.2491455078125,
-0.325927734375,
-0.5732421875,
-0.269775390625,
-0.199951171875,
0.1385498046875,
-0.468994140625,
-1.3232421875,
-0.23779296875,
-0.62939453125,
0.61376953125,
0.60888671875,
0.16357421875,
1.0791015625,
1.0810546875,
-0.231689453125,
-0.48291015625,
0.59619140625,
-1.234375,
-0.1663818359375,
-0.286865234375,
0.7158203125,
-0.66650390625,
-0.34033203125,
-0.59033203125,
0.298583984375,
-0.72509765625,
0.373779296875,
-0.666015625,
-1.1650390625,
-0.047088623046875,
-0.357421875,
-0.56640625,
-0.083740234375,
-0.83447265625,
0.2509765625,
-0.34375,
0.90625,
-0.300537109375,
0.09759521484375,
-0.165283203125,
0.50927734375,
-0.04119873046875,
-0.53857421875,
0.446533203125,
0.06591796875,
0.2802734375,
0.26611328125,
-0.56640625,
-0.2479248046875,
-0.1365966796875,
-0.141845703125,
-0.24609375,
-0.0950927734375,
-0.61572265625,
-0.587890625,
0.12188720703125,
-0.60107421875,
-0.669921875,
-0.2003173828125,
-0.0167388916015625,
0.173828125,
-0.08294677734375,
-0.61865234375,
1.060546875,
0.07183837890625,
1.025390625,
0.73193359375,
0.29443359375,
-0.189697265625,
-0.59423828125,
0.0794677734375,
0.27978515625,
0.0545654296875,
0.163330078125,
-0.265380859375,
0.75439453125,
-1.08203125,
-0.04815673828125,
0.48828125,
0.57861328125,
-0.07940673828125,
0.1142578125,
0.198974609375,
-0.1605224609375,
1.0556640625,
0.426513671875,
-0.1029052734375,
1.1943359375,
-0.5009765625,
0.2861328125,
-0.021881103515625,
0.007091522216796875,
-0.3134765625,
-0.06146240234375,
-0.13525390625,
-0.19091796875,
1.0751953125,
0.1865234375,
-0.2369384765625,
0.76513671875,
0.1746826171875,
0.56298828125,
-0.6376953125,
0.2322998046875,
0.35791015625,
0.41748046875,
0.8408203125,
-0.32861328125,
-0.12432861328125,
-0.1685791015625,
-0.135498046875,
0.654296875,
-0.84326171875,
-0.19677734375,
0.13525390625,
-0.189453125,
-0.161865234375,
0.30908203125,
-0.347412109375,
0.66845703125,
-0.2154541015625,
0.5927734375,
1.107421875,
-0.5634765625,
0.826171875,
-0.0151214599609375,
-0.00812530517578125,
1.49609375,
0.1683349609375,
0.270263671875,
0.7529296875,
0.09686279296875,
-0.74658203125,
0.488525390625,
-0.97607421875,
0.36083984375,
0.348388671875,
0.1275634765625,
-0.377685546875,
0.249267578125,
-0.1817626953125,
0.311279296875,
-0.001735687255859375,
-0.07421875,
-0.20703125,
0.33935546875,
-0.6201171875,
1.0546875,
-0.0732421875,
0.87060546875,
-0.42236328125,
-0.314697265625,
0.0888671875,
-0.071533203125,
0.09637451171875,
-0.2978515625,
-0.322021484375,
0.8203125,
0.374755859375,
1.064453125,
0.94873046875,
-0.0073699951171875,
0.387451171875,
0.390625,
-0.262451171875,
0.486083984375,
0.39794921875,
0.7490234375,
0.228271484375,
0.40380859375,
0.031036376953125,
-0.08441162109375,
-0.1845703125,
-0.28125,
-0.06060791015625,
0.72802734375,
-0.4296875,
-0.148681640625,
0.04595947265625,
0.18603515625,
-0.97314453125,
0.455322265625,
0.0535888671875,
-0.9833984375,
-0.265380859375,
0.74951171875,
-0.453857421875,
0.62841796875,
-0.55419921875,
-0.69970703125,
0.62060546875,
1.1943359375,
0.1446533203125,
0.0263824462890625,
0.79638671875,
0.541015625,
-0.420654296875,
0.334716796875,
-0.232421875,
-0.5244140625,
-0.560546875,
0.73193359375,
0.0509033203125,
-0.09967041015625,
0.168701171875,
0.26025390625,
0.306396484375,
0.70068359375,
-0.37255859375,
-0.028106689453125,
0.80078125,
1.0947265625,
-0.054412841796875,
0.44580078125,
0.156005859375,
0.96484375,
0.505859375,
0.9404296875,
0.638671875,
0.308837890625,
0.64453125,
0.93505859375,
0.015350341796875,
0.0011730194091796875,
0.051300048828125,
0.6611328125,
0.436279296875,
0.67333984375,
0.12286376953125,
0.2100830078125,
-0.2705078125,
0.05712890625,
-0.5966796875,
-0.004596710205078125,
-0.2763671875,
0.77685546875,
0.10687255859375,
0.74755859375,
-0.30859375,
-0.413330078125,
0.3251953125,
0.6484375,
-0.958984375,
-0.44384765625,
-0.376220703125,
-0.135498046875,
0.350341796875,
-0.046966552734375,
0.259521484375,
0.052337646484375,
0.320068359375,
0.1103515625,
-0.2489013671875,
-0.69384765625,
-1.095703125,
-0.98779296875,
-0.7548828125,
-0.51806640625,
-0.62451171875,
0.126953125,
0.179443359375,
-1.1728515625,
0.53564453125,
-0.54638671875,
-0.2427978515625,
-0.020721435546875,
-0.85107421875,
0.5537109375,
-0.227294921875,
0.470947265625,
-0.452392578125,
0.368408203125,
0.299560546875,
1.306640625,
-0.162353515625,
0.1776123046875,
-0.0751953125,
-0.63623046875,
0.27880859375,
-0.272216796875,
0.57861328125,
-0.1357421875,
-0.734375,
-0.587890625,
-0.340087890625,
-0.08221435546875,
-0.56884765625,
0.373779296875,
-0.412841796875,
0.5791015625,
0.36669921875,
-1.0576171875,
0.685546875,
1.1533203125,
-0.5458984375,
0.6748046875,
-0.362548828125,
0.0278472900390625,
-0.79345703125,
1.18359375,
0.255859375,
0.414794921875,
-0.321044921875,
-0.8623046875,
-0.3818359375,
-0.18798828125,
0.06793212890625,
-0.302734375,
-0.0772705078125,
0.63232421875,
-0.381103515625,
-0.7587890625,
0.6376953125,
-1.013671875,
-0.322265625,
-0.7998046875,
-0.63134765625,
0.78955078125,
0.68896484375,
0.1461181640625,
0.0021762847900390625,
-0.144287109375,
-0.143798828125,
0.9814453125,
0.2269287109375,
-0.630859375,
0.07647705078125,
0.5078125,
0.031463623046875,
0.0125885009765625,
0.54443359375,
-0.55517578125,
-0.3798828125,
0.06890869140625,
-0.03436279296875,
0.71337890625,
0.2376708984375,
0.57666015625,
0.57958984375,
0.6220703125,
-1.0087890625,
-0.1505126953125,
-0.43505859375,
0.413818359375,
0.425537109375,
0.23193359375,
0.416015625,
-0.464111328125,
-0.5234375,
-0.90234375,
0.40966796875,
0.1962890625,
0.428955078125,
-0.6708984375,
0.9072265625,
0.05267333984375,
-0.39404296875,
0.380859375,
-0.501953125,
-0.1041259765625,
0.8896484375,
-0.395751953125,
0.724609375,
-0.6806640625,
0.63916015625,
-0.1055908203125,
-0.1796875,
0.84228515625,
0.286376953125,
0.452880859375,
-0.544921875,
-0.304443359375,
-0.505859375,
-0.28466796875,
0.2548828125,
-0.5478515625,
0.10748291015625,
-0.72509765625,
-0.29638671875,
-0.91357421875,
0.54296875,
0.36474609375,
0.7578125,
-0.067626953125,
0.494140625,
0.06512451171875,
0.71484375,
0.69091796875,
-0.2352294921875,
-0.05438232421875,
-0.456787109375,
0.87646484375,
0.243896484375,
-0.281982421875,
-0.54248046875,
-0.1630859375,
-0.458984375,
0.39599609375,
-0.0374755859375,
-0.08685302734375,
-0.9150390625,
0.42333984375,
0.1990966796875,
0.7001953125,
-0.463134765625,
-0.52490234375,
-0.359619140625,
0.361328125,
0.59619140625,
-1.2021484375,
0.00028061866760253906,
-0.677734375,
0.87451171875,
0.43994140625,
-0.2332763671875,
-0.4267578125,
-0.62109375,
-0.6171875,
-0.453857421875,
-0.0782470703125,
0.71142578125,
0.314208984375,
0.412353515625,
-0.99267578125,
0.32666015625,
0.301513671875,
-0.2119140625,
0.04052734375,
-0.16796875,
0.22021484375,
-0.1436767578125,
0.74951171875,
-0.339599609375,
-0.71728515625,
0.021636962890625,
-1.302734375,
0.2880859375,
-0.68359375,
0.339599609375,
0.046966552734375,
-0.478759765625,
-0.302001953125,
0.329833984375,
-0.430419921875,
-0.0377197265625,
0.06964111328125,
0.68408203125,
-1.0576171875,
-0.998046875,
0.5517578125,
-0.2393798828125,
-0.493408203125,
1.19140625,
0.0958251953125,
-0.544921875,
0.02545166015625,
0.240966796875,
-0.37939453125,
0.54833984375,
-1.0693359375,
0.63818359375,
-0.447265625,
-0.34423828125,
-0.449951171875,
-0.56201171875,
0.412109375,
-0.0860595703125,
-0.52880859375,
-0.496826171875,
-1.326171875,
-0.159423828125,
-0.036376953125,
-0.5517578125,
0.44921875,
-0.054656982421875,
0.167724609375,
-0.057586669921875,
-0.47998046875,
-0.177734375,
-0.607421875,
-0.47314453125,
-0.39111328125,
0.53759765625,
0.53857421875,
0.7998046875,
-0.043365478515625,
-0.333740234375,
0.028564453125,
-0.0970458984375,
0.09515380859375,
-0.1522216796875,
-0.2105712890625,
0.0237579345703125,
-0.12164306640625,
-0.135009765625,
0.314208984375,
-0.181640625,
0.09552001953125,
0.485595703125,
0.054412841796875,
0.66015625,
0.228759765625,
-0.72802734375,
1.31640625,
0.189453125,
-1.0390625,
-0.216796875,
0.90478515625,
-0.127197265625,
0.3427734375,
0.31591796875,
-1.015625,
-0.86279296875,
-0.74072265625,
0.489501953125,
-0.72314453125,
-0.396728515625,
-1.2158203125,
-0.377685546875,
-0.54931640625,
0.708984375,
-0.032806396484375,
-0.42138671875,
0.42236328125,
-1.046875,
0.3681640625,
-0.60205078125,
-0.67626953125,
-0.56787109375,
-0.68310546875,
-0.091064453125,
1.146484375,
0.077880859375,
0.2498779296875,
0.2607421875,
-0.265869140625,
0.58984375,
0.24169921875,
-0.94775390625,
-0.32470703125,
-0.1446533203125,
0.429443359375,
-0.09375,
0.0261383056640625,
-0.394287109375,
0.4072265625,
-0.77099609375,
0.333740234375,
-0.264404296875,
-0.34619140625,
-0.35400390625,
-0.41064453125,
1.1650390625,
-0.61572265625,
0.062286376953125,
-0.2294921875,
0.6962890625,
0.92919921875,
-0.02581787109375,
-0.42333984375,
-0.88623046875,
-1.052734375,
-0.9443359375,
0.63232421875,
-0.402587890625,
0.0018777847290039062,
-0.471435546875,
0.031982421875,
0.8291015625,
-0.164306640625,
0.5830078125,
0.869140625,
0.10345458984375,
-0.0958251953125,
-0.61474609375,
0.7099609375,
0.41552734375,
-0.4951171875,
-0.302001953125,
0.372314453125,
-0.603515625,
0.311767578125,
-0.422607421875,
-1.2119140625,
-0.80029296875,
0.337158203125,
1.3984375,
-0.243408203125,
0.900390625,
-0.059844970703125,
-0.88916015625,
-0.43017578125,
0.66357421875,
0.12139892578125,
0.327392578125,
0.78125,
-0.1126708984375,
-0.329833984375,
0.10894775390625,
-0.373046875,
-0.109130859375,
-0.62548828125,
1.23046875,
-0.6357421875,
-0.625,
0.453125,
0.99365234375,
-0.90869140625,
-1.302734375,
-0.2376708984375,
-0.3125,
-0.434326171875,
-0.86767578125,
-0.129638671875,
0.266357421875,
-0.2474365234375,
0.10369873046875,
0.31787109375,
-0.065185546875,
0.55712890625,
0.1260986328125,
0.5234375,
-0.1416015625,
0.4521484375,
0.69580078125,
-0.51171875,
-0.642578125,
-1.03125,
-0.048614501953125,
-0.361328125,
0.2294921875,
0.59814453125,
-0.2142333984375,
0.50537109375,
0.5419921875,
-0.15966796875,
0.77099609375,
-0.38818359375,
-0.462158203125,
0.2237548828125,
-1.134765625,
-0.451904296875,
0.026519775390625,
0.54345703125,
-0.47265625,
0.292236328125,
-0.79833984375,
-0.537109375,
0.343505859375,
0.54052734375,
-0.36767578125,
-1.0625,
-0.12274169921875,
-1.2109375,
-0.62841796875,
-0.58642578125,
-0.75439453125,
-0.1837158203125,
-0.1953125,
0.01244354248046875,
-0.7890625,
-0.08221435546875,
0.283203125,
-0.505859375,
0.8330078125,
-0.556640625,
0.54638671875,
-0.669921875,
-0.11895751953125,
-0.64501953125,
0.14404296875,
-0.54150390625,
-0.1407470703125,
-0.320068359375,
0.328125,
-0.17724609375,
0.56591796875,
-0.3173828125,
0.309326171875,
-0.2088623046875,
-0.40478515625,
-0.100341796875,
0.1590576171875,
-0.2288818359375,
0.673828125,
0.5224609375,
-0.2587890625,
0.333740234375,
-0.11639404296875,
-0.1492919921875,
-0.252685546875,
0.90380859375,
0.16015625,
-0.040679931640625,
-0.1749267578125,
-0.2362060546875,
0.371826171875,
-0.96826171875,
0.30810546875,
-0.141357421875,
0.533203125,
0.0002970695495605469,
-0.237548828125,
0.3564453125,
1.0888671875,
-0.119140625,
0.006641387939453125,
0.2333984375,
0.145263671875,
0.1314697265625,
0.1522216796875,
-0.0233612060546875,
0.484375,
-0.1982421875,
-0.343017578125,
-0.1400146484375,
0.3291015625,
0.06268310546875,
0.409912109375,
-0.1524658203125,
-0.76513671875,
-0.65673828125,
-0.288330078125,
-0.047698974609375,
0.51708984375,
0.5400390625,
-0.60009765625,
0.0209503173828125,
0.0628662109375,
-0.7783203125,
0.0950927734375,
-1.0166015625,
-1.0859375,
0.00504302978515625,
0.07574462890625,
-0.73974609375,
-0.10162353515625,
-0.48046875,
-0.200439453125,
0.01421356201171875,
0.2183837890625,
-0.89013671875,
0.3251953125,
0.0029048919677734375,
0.58203125,
-0.2322998046875,
-0.0160064697265625,
-0.017822265625,
0.353759765625,
-0.6044921875,
-0.2303466796875,
-0.348876953125,
0.5888671875,
0.27880859375,
-0.2353515625,
-0.22998046875,
0.1783447265625,
0.2152099609375,
0.207275390625,
-0.55908203125,
0.250732421875,
-0.0775146484375,
0.88818359375,
-0.77587890625,
-0.204345703125,
-0.396240234375,
0.272705078125,
0.10394287109375,
-0.53759765625,
-0.8154296875,
1.2626953125,
0.76513671875,
-0.1380615234375,
0.303466796875,
0.163330078125,
0.43994140625,
-0.304931640625,
0.11297607421875,
-0.48095703125,
0.8603515625,
0.443359375,
0.59326171875,
-0.1422119140625,
0.285400390625,
0.51806640625,
-0.06134033203125,
-0.57470703125,
0.380126953125,
0.286865234375,
0.045806884765625,
0.071533203125,
-0.27880859375,
-0.41943359375,
-0.04400634765625,
-0.8857421875,
0.2841796875,
-0.185302734375,
-0.0736083984375,
-0.51318359375,
-0.48974609375,
0.85791015625,
-0.53076171875,
-0.00977325439453125,
0.298828125,
-0.264404296875,
0.33740234375,
0.517578125,
0.140380859375,
0.1728515625,
0.955078125,
0.72998046875,
0.63623046875,
0.59130859375,
0.2509765625,
0.365234375,
-0.759765625,
0.1826171875,
0.3251953125,
0.01152801513671875,
0.056640625,
-0.1036376953125,
-0.876953125,
0.5654296875,
-0.331787109375,
-0.3291015625,
0.359130859375,
-0.61181640625,
-0.1983642578125,
-0.421142578125,
0.86279296875,
-0.673828125,
0.55517578125,
0.6484375,
-0.289306640625,
-0.5888671875,
1.1982421875,
-0.401123046875,
0.1790771484375,
0.165771484375,
1.1767578125,
0.362060546875,
1.4345703125,
0.484619140625,
-0.090576171875,
0.114501953125,
0.460693359375,
-0.2337646484375,
-0.71533203125,
-0.47265625,
-0.375,
0.200439453125,
-0.86962890625,
-0.469970703125,
-0.373046875,
1.0224609375,
0.08148193359375,
-0.7685546875,
-0.19873046875,
0.0633544921875,
-0.77587890625,
0.19970703125,
0.311767578125,
0.459716796875,
0.07763671875,
-0.204345703125,
-0.037445068359375,
-0.48876953125,
0.1180419921875,
-0.29150390625,
0.3603515625,
-0.60205078125,
-0.5361328125,
-0.30029296875,
-1.0400390625,
-0.669921875,
0.1705322265625,
-0.1593017578125,
-0.830078125,
0.6201171875,
0.75390625,
0.1885986328125,
0.310791015625,
-0.48095703125,
0.386962890625,
0.95166015625,
1.28515625,
-0.09161376953125,
0.78955078125,
0.415283203125,
-0.300048828125,
0.1549072265625,
-0.431640625,
0.57666015625,
0.06610107421875,
0.52783203125,
-0.33984375,
0.6826171875,
-0.6015625,
-1.1650390625,
0.11773681640625,
0.44384765625,
0.67578125,
-0.91259765625,
-1.2861328125,
-0.1861572265625,
-1.017578125,
-0.151611328125,
-0.44775390625,
0.83935546875,
-0.29443359375,
0.1649169921875,
0.05267333984375,
-1.0712890625,
4.3359375,
1.294921875,
1.021484375,
0.35107421875,
0.51708984375,
1.3828125,
0.37841796875,
-0.5771484375,
-0.54736328125,
-0.48583984375,
0.490234375,
-0.281494140625,
0.06439208984375,
0.8671875,
0.2191162109375,
0.62744140625,
-0.5048828125,
0.049957275390625,
-0.301513671875,
-0.83740234375,
-0.8251953125,
0.279541015625,
-0.00595855712890625,
0.2347412109375,
-0.2802734375,
0.19091796875,
0.62255859375,
-0.78271484375,
-0.315673828125,
-0.86572265625,
0.00533294677734375,
-0.580078125,
0.9365234375,
0.0963134765625,
0.19091796875,
0.595703125,
-0.036529541015625,
-0.42041015625,
-0.194091796875,
-0.11126708984375,
-0.1619873046875,
0.3232421875,
0.82666015625,
-0.58251953125,
-0.2149658203125,
0.59326171875,
-0.80810546875,
0.55615234375,
0.4140625,
-1.220703125,
1.0224609375,
-0.259765625,
0.6162109375,
-0.6376953125,
-0.77197265625,
0.0019245147705078125,
-0.06512451171875,
-0.059295654296875,
-0.2191162109375,
0.3798828125,
0.1728515625,
0.294921875,
0.12225341796875,
0.436767578125,
-0.86083984375,
0.52001953125,
-0.08843994140625,
0.364990234375,
-0.67236328125,
-0.11126708984375,
-0.342041015625,
-0.2418212890625,
-0.5,
-0.24169921875,
0.7529296875,
0.2376708984375,
-0.0904541015625,
0.5361328125,
0.64453125,
-0.5068359375,
0.2359619140625,
-0.35791015625,
-0.2493896484375,
-0.466064453125,
0.7509765625,
1.134765625,
-0.4853515625,
-0.10955810546875,
-0.1319580078125,
0.486328125,
0.60791015625,
0.533203125,
-0.1982421875,
-0.270751953125,
-0.32763671875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in any order, any operation may be applied any number of times. The i-th operation is described by a string ai of length two and a string bi of length one. No two of q possible operations have the same string ai.
When Limak has a string s he can perform the i-th operation on s if the first two letters of s match a two-letter string ai. Performing the i-th operation removes first two letters of s and inserts there a string bi. See the notes section for further clarification.
You may note that performing an operation decreases the length of a string s exactly by 1. Also, for some sets of operations there may be a string that cannot be compressed any further, because the first two letters don't match any ai.
Limak wants to start with a string of length n and perform n - 1 operations to finally get a one-letter string "a". In how many ways can he choose the starting string to be able to get "a"? Remember that Limak can use only letters he knows.
Input
The first line contains two integers n and q (2 ≤ n ≤ 6, 1 ≤ q ≤ 36) — the length of the initial string and the number of available operations.
The next q lines describe the possible operations. The i-th of them contains two strings ai and bi (|ai| = 2, |bi| = 1). It's guaranteed that ai ≠ aj for i ≠ j and that all ai and bi consist of only first six lowercase English letters.
Output
Print the number of strings of length n that Limak will be able to transform to string "a" by applying only operations given in the input.
Examples
Input
3 5
ab a
cc c
ca a
ee c
ff d
Output
4
Input
2 8
af e
dc d
cc f
bc b
da b
eb a
bb b
ff c
Output
1
Input
6 2
bb a
ba a
Output
0
Note
In the first sample, we count initial strings of length 3 from which Limak can get a required string "a". There are 4 such strings: "abb", "cab", "cca", "eea". The first one Limak can compress using operation 1 two times (changing "ab" to a single "a"). The first operation would change "abb" to "ab" and the second operation would change "ab" to "a".
Other three strings may be compressed as follows:
* "cab" <image> "ab" <image> "a"
* "cca" <image> "ca" <image> "a"
* "eea" <image> "ca" <image> "a"
In the second sample, the only correct initial string is "eb" because it can be immediately compressed to "a".
Tags: brute force, dfs and similar, dp, strings
Correct Solution:
```
n, m = map(int, input().split())
d = {}
for i in range(m):
t, o = input().split()
if o in d:
d[o].append(t)
else:
d[o] = [t]
q = [('a', 0)]
cnt = 0
while q and q[0][1] < n :
st = q[0]
q.pop(0)
if st[1] == n - 1:
cnt += 1
if st[0][0] in d:
for j in d[st[0][0]]:
q.append((j + st[0][1:], st[1] + 1))
print(cnt)
```
| 70,294 | [
0.405517578125,
-0.0950927734375,
0.2056884765625,
-0.07342529296875,
-0.63916015625,
-0.362548828125,
-0.0787353515625,
0.19384765625,
0.1724853515625,
0.93212890625,
0.90771484375,
-0.11602783203125,
-0.102783203125,
-0.99609375,
-0.484375,
0.2491455078125,
-0.325927734375,
-0.5732421875,
-0.269775390625,
-0.199951171875,
0.1385498046875,
-0.468994140625,
-1.3232421875,
-0.23779296875,
-0.62939453125,
0.61376953125,
0.60888671875,
0.16357421875,
1.0791015625,
1.0810546875,
-0.231689453125,
-0.48291015625,
0.59619140625,
-1.234375,
-0.1663818359375,
-0.286865234375,
0.7158203125,
-0.66650390625,
-0.34033203125,
-0.59033203125,
0.298583984375,
-0.72509765625,
0.373779296875,
-0.666015625,
-1.1650390625,
-0.047088623046875,
-0.357421875,
-0.56640625,
-0.083740234375,
-0.83447265625,
0.2509765625,
-0.34375,
0.90625,
-0.300537109375,
0.09759521484375,
-0.165283203125,
0.50927734375,
-0.04119873046875,
-0.53857421875,
0.446533203125,
0.06591796875,
0.2802734375,
0.26611328125,
-0.56640625,
-0.2479248046875,
-0.1365966796875,
-0.141845703125,
-0.24609375,
-0.0950927734375,
-0.61572265625,
-0.587890625,
0.12188720703125,
-0.60107421875,
-0.669921875,
-0.2003173828125,
-0.0167388916015625,
0.173828125,
-0.08294677734375,
-0.61865234375,
1.060546875,
0.07183837890625,
1.025390625,
0.73193359375,
0.29443359375,
-0.189697265625,
-0.59423828125,
0.0794677734375,
0.27978515625,
0.0545654296875,
0.163330078125,
-0.265380859375,
0.75439453125,
-1.08203125,
-0.04815673828125,
0.48828125,
0.57861328125,
-0.07940673828125,
0.1142578125,
0.198974609375,
-0.1605224609375,
1.0556640625,
0.426513671875,
-0.1029052734375,
1.1943359375,
-0.5009765625,
0.2861328125,
-0.021881103515625,
0.007091522216796875,
-0.3134765625,
-0.06146240234375,
-0.13525390625,
-0.19091796875,
1.0751953125,
0.1865234375,
-0.2369384765625,
0.76513671875,
0.1746826171875,
0.56298828125,
-0.6376953125,
0.2322998046875,
0.35791015625,
0.41748046875,
0.8408203125,
-0.32861328125,
-0.12432861328125,
-0.1685791015625,
-0.135498046875,
0.654296875,
-0.84326171875,
-0.19677734375,
0.13525390625,
-0.189453125,
-0.161865234375,
0.30908203125,
-0.347412109375,
0.66845703125,
-0.2154541015625,
0.5927734375,
1.107421875,
-0.5634765625,
0.826171875,
-0.0151214599609375,
-0.00812530517578125,
1.49609375,
0.1683349609375,
0.270263671875,
0.7529296875,
0.09686279296875,
-0.74658203125,
0.488525390625,
-0.97607421875,
0.36083984375,
0.348388671875,
0.1275634765625,
-0.377685546875,
0.249267578125,
-0.1817626953125,
0.311279296875,
-0.001735687255859375,
-0.07421875,
-0.20703125,
0.33935546875,
-0.6201171875,
1.0546875,
-0.0732421875,
0.87060546875,
-0.42236328125,
-0.314697265625,
0.0888671875,
-0.071533203125,
0.09637451171875,
-0.2978515625,
-0.322021484375,
0.8203125,
0.374755859375,
1.064453125,
0.94873046875,
-0.0073699951171875,
0.387451171875,
0.390625,
-0.262451171875,
0.486083984375,
0.39794921875,
0.7490234375,
0.228271484375,
0.40380859375,
0.031036376953125,
-0.08441162109375,
-0.1845703125,
-0.28125,
-0.06060791015625,
0.72802734375,
-0.4296875,
-0.148681640625,
0.04595947265625,
0.18603515625,
-0.97314453125,
0.455322265625,
0.0535888671875,
-0.9833984375,
-0.265380859375,
0.74951171875,
-0.453857421875,
0.62841796875,
-0.55419921875,
-0.69970703125,
0.62060546875,
1.1943359375,
0.1446533203125,
0.0263824462890625,
0.79638671875,
0.541015625,
-0.420654296875,
0.334716796875,
-0.232421875,
-0.5244140625,
-0.560546875,
0.73193359375,
0.0509033203125,
-0.09967041015625,
0.168701171875,
0.26025390625,
0.306396484375,
0.70068359375,
-0.37255859375,
-0.028106689453125,
0.80078125,
1.0947265625,
-0.054412841796875,
0.44580078125,
0.156005859375,
0.96484375,
0.505859375,
0.9404296875,
0.638671875,
0.308837890625,
0.64453125,
0.93505859375,
0.015350341796875,
0.0011730194091796875,
0.051300048828125,
0.6611328125,
0.436279296875,
0.67333984375,
0.12286376953125,
0.2100830078125,
-0.2705078125,
0.05712890625,
-0.5966796875,
-0.004596710205078125,
-0.2763671875,
0.77685546875,
0.10687255859375,
0.74755859375,
-0.30859375,
-0.413330078125,
0.3251953125,
0.6484375,
-0.958984375,
-0.44384765625,
-0.376220703125,
-0.135498046875,
0.350341796875,
-0.046966552734375,
0.259521484375,
0.052337646484375,
0.320068359375,
0.1103515625,
-0.2489013671875,
-0.69384765625,
-1.095703125,
-0.98779296875,
-0.7548828125,
-0.51806640625,
-0.62451171875,
0.126953125,
0.179443359375,
-1.1728515625,
0.53564453125,
-0.54638671875,
-0.2427978515625,
-0.020721435546875,
-0.85107421875,
0.5537109375,
-0.227294921875,
0.470947265625,
-0.452392578125,
0.368408203125,
0.299560546875,
1.306640625,
-0.162353515625,
0.1776123046875,
-0.0751953125,
-0.63623046875,
0.27880859375,
-0.272216796875,
0.57861328125,
-0.1357421875,
-0.734375,
-0.587890625,
-0.340087890625,
-0.08221435546875,
-0.56884765625,
0.373779296875,
-0.412841796875,
0.5791015625,
0.36669921875,
-1.0576171875,
0.685546875,
1.1533203125,
-0.5458984375,
0.6748046875,
-0.362548828125,
0.0278472900390625,
-0.79345703125,
1.18359375,
0.255859375,
0.414794921875,
-0.321044921875,
-0.8623046875,
-0.3818359375,
-0.18798828125,
0.06793212890625,
-0.302734375,
-0.0772705078125,
0.63232421875,
-0.381103515625,
-0.7587890625,
0.6376953125,
-1.013671875,
-0.322265625,
-0.7998046875,
-0.63134765625,
0.78955078125,
0.68896484375,
0.1461181640625,
0.0021762847900390625,
-0.144287109375,
-0.143798828125,
0.9814453125,
0.2269287109375,
-0.630859375,
0.07647705078125,
0.5078125,
0.031463623046875,
0.0125885009765625,
0.54443359375,
-0.55517578125,
-0.3798828125,
0.06890869140625,
-0.03436279296875,
0.71337890625,
0.2376708984375,
0.57666015625,
0.57958984375,
0.6220703125,
-1.0087890625,
-0.1505126953125,
-0.43505859375,
0.413818359375,
0.425537109375,
0.23193359375,
0.416015625,
-0.464111328125,
-0.5234375,
-0.90234375,
0.40966796875,
0.1962890625,
0.428955078125,
-0.6708984375,
0.9072265625,
0.05267333984375,
-0.39404296875,
0.380859375,
-0.501953125,
-0.1041259765625,
0.8896484375,
-0.395751953125,
0.724609375,
-0.6806640625,
0.63916015625,
-0.1055908203125,
-0.1796875,
0.84228515625,
0.286376953125,
0.452880859375,
-0.544921875,
-0.304443359375,
-0.505859375,
-0.28466796875,
0.2548828125,
-0.5478515625,
0.10748291015625,
-0.72509765625,
-0.29638671875,
-0.91357421875,
0.54296875,
0.36474609375,
0.7578125,
-0.067626953125,
0.494140625,
0.06512451171875,
0.71484375,
0.69091796875,
-0.2352294921875,
-0.05438232421875,
-0.456787109375,
0.87646484375,
0.243896484375,
-0.281982421875,
-0.54248046875,
-0.1630859375,
-0.458984375,
0.39599609375,
-0.0374755859375,
-0.08685302734375,
-0.9150390625,
0.42333984375,
0.1990966796875,
0.7001953125,
-0.463134765625,
-0.52490234375,
-0.359619140625,
0.361328125,
0.59619140625,
-1.2021484375,
0.00028061866760253906,
-0.677734375,
0.87451171875,
0.43994140625,
-0.2332763671875,
-0.4267578125,
-0.62109375,
-0.6171875,
-0.453857421875,
-0.0782470703125,
0.71142578125,
0.314208984375,
0.412353515625,
-0.99267578125,
0.32666015625,
0.301513671875,
-0.2119140625,
0.04052734375,
-0.16796875,
0.22021484375,
-0.1436767578125,
0.74951171875,
-0.339599609375,
-0.71728515625,
0.021636962890625,
-1.302734375,
0.2880859375,
-0.68359375,
0.339599609375,
0.046966552734375,
-0.478759765625,
-0.302001953125,
0.329833984375,
-0.430419921875,
-0.0377197265625,
0.06964111328125,
0.68408203125,
-1.0576171875,
-0.998046875,
0.5517578125,
-0.2393798828125,
-0.493408203125,
1.19140625,
0.0958251953125,
-0.544921875,
0.02545166015625,
0.240966796875,
-0.37939453125,
0.54833984375,
-1.0693359375,
0.63818359375,
-0.447265625,
-0.34423828125,
-0.449951171875,
-0.56201171875,
0.412109375,
-0.0860595703125,
-0.52880859375,
-0.496826171875,
-1.326171875,
-0.159423828125,
-0.036376953125,
-0.5517578125,
0.44921875,
-0.054656982421875,
0.167724609375,
-0.057586669921875,
-0.47998046875,
-0.177734375,
-0.607421875,
-0.47314453125,
-0.39111328125,
0.53759765625,
0.53857421875,
0.7998046875,
-0.043365478515625,
-0.333740234375,
0.028564453125,
-0.0970458984375,
0.09515380859375,
-0.1522216796875,
-0.2105712890625,
0.0237579345703125,
-0.12164306640625,
-0.135009765625,
0.314208984375,
-0.181640625,
0.09552001953125,
0.485595703125,
0.054412841796875,
0.66015625,
0.228759765625,
-0.72802734375,
1.31640625,
0.189453125,
-1.0390625,
-0.216796875,
0.90478515625,
-0.127197265625,
0.3427734375,
0.31591796875,
-1.015625,
-0.86279296875,
-0.74072265625,
0.489501953125,
-0.72314453125,
-0.396728515625,
-1.2158203125,
-0.377685546875,
-0.54931640625,
0.708984375,
-0.032806396484375,
-0.42138671875,
0.42236328125,
-1.046875,
0.3681640625,
-0.60205078125,
-0.67626953125,
-0.56787109375,
-0.68310546875,
-0.091064453125,
1.146484375,
0.077880859375,
0.2498779296875,
0.2607421875,
-0.265869140625,
0.58984375,
0.24169921875,
-0.94775390625,
-0.32470703125,
-0.1446533203125,
0.429443359375,
-0.09375,
0.0261383056640625,
-0.394287109375,
0.4072265625,
-0.77099609375,
0.333740234375,
-0.264404296875,
-0.34619140625,
-0.35400390625,
-0.41064453125,
1.1650390625,
-0.61572265625,
0.062286376953125,
-0.2294921875,
0.6962890625,
0.92919921875,
-0.02581787109375,
-0.42333984375,
-0.88623046875,
-1.052734375,
-0.9443359375,
0.63232421875,
-0.402587890625,
0.0018777847290039062,
-0.471435546875,
0.031982421875,
0.8291015625,
-0.164306640625,
0.5830078125,
0.869140625,
0.10345458984375,
-0.0958251953125,
-0.61474609375,
0.7099609375,
0.41552734375,
-0.4951171875,
-0.302001953125,
0.372314453125,
-0.603515625,
0.311767578125,
-0.422607421875,
-1.2119140625,
-0.80029296875,
0.337158203125,
1.3984375,
-0.243408203125,
0.900390625,
-0.059844970703125,
-0.88916015625,
-0.43017578125,
0.66357421875,
0.12139892578125,
0.327392578125,
0.78125,
-0.1126708984375,
-0.329833984375,
0.10894775390625,
-0.373046875,
-0.109130859375,
-0.62548828125,
1.23046875,
-0.6357421875,
-0.625,
0.453125,
0.99365234375,
-0.90869140625,
-1.302734375,
-0.2376708984375,
-0.3125,
-0.434326171875,
-0.86767578125,
-0.129638671875,
0.266357421875,
-0.2474365234375,
0.10369873046875,
0.31787109375,
-0.065185546875,
0.55712890625,
0.1260986328125,
0.5234375,
-0.1416015625,
0.4521484375,
0.69580078125,
-0.51171875,
-0.642578125,
-1.03125,
-0.048614501953125,
-0.361328125,
0.2294921875,
0.59814453125,
-0.2142333984375,
0.50537109375,
0.5419921875,
-0.15966796875,
0.77099609375,
-0.38818359375,
-0.462158203125,
0.2237548828125,
-1.134765625,
-0.451904296875,
0.026519775390625,
0.54345703125,
-0.47265625,
0.292236328125,
-0.79833984375,
-0.537109375,
0.343505859375,
0.54052734375,
-0.36767578125,
-1.0625,
-0.12274169921875,
-1.2109375,
-0.62841796875,
-0.58642578125,
-0.75439453125,
-0.1837158203125,
-0.1953125,
0.01244354248046875,
-0.7890625,
-0.08221435546875,
0.283203125,
-0.505859375,
0.8330078125,
-0.556640625,
0.54638671875,
-0.669921875,
-0.11895751953125,
-0.64501953125,
0.14404296875,
-0.54150390625,
-0.1407470703125,
-0.320068359375,
0.328125,
-0.17724609375,
0.56591796875,
-0.3173828125,
0.309326171875,
-0.2088623046875,
-0.40478515625,
-0.100341796875,
0.1590576171875,
-0.2288818359375,
0.673828125,
0.5224609375,
-0.2587890625,
0.333740234375,
-0.11639404296875,
-0.1492919921875,
-0.252685546875,
0.90380859375,
0.16015625,
-0.040679931640625,
-0.1749267578125,
-0.2362060546875,
0.371826171875,
-0.96826171875,
0.30810546875,
-0.141357421875,
0.533203125,
0.0002970695495605469,
-0.237548828125,
0.3564453125,
1.0888671875,
-0.119140625,
0.006641387939453125,
0.2333984375,
0.145263671875,
0.1314697265625,
0.1522216796875,
-0.0233612060546875,
0.484375,
-0.1982421875,
-0.343017578125,
-0.1400146484375,
0.3291015625,
0.06268310546875,
0.409912109375,
-0.1524658203125,
-0.76513671875,
-0.65673828125,
-0.288330078125,
-0.047698974609375,
0.51708984375,
0.5400390625,
-0.60009765625,
0.0209503173828125,
0.0628662109375,
-0.7783203125,
0.0950927734375,
-1.0166015625,
-1.0859375,
0.00504302978515625,
0.07574462890625,
-0.73974609375,
-0.10162353515625,
-0.48046875,
-0.200439453125,
0.01421356201171875,
0.2183837890625,
-0.89013671875,
0.3251953125,
0.0029048919677734375,
0.58203125,
-0.2322998046875,
-0.0160064697265625,
-0.017822265625,
0.353759765625,
-0.6044921875,
-0.2303466796875,
-0.348876953125,
0.5888671875,
0.27880859375,
-0.2353515625,
-0.22998046875,
0.1783447265625,
0.2152099609375,
0.207275390625,
-0.55908203125,
0.250732421875,
-0.0775146484375,
0.88818359375,
-0.77587890625,
-0.204345703125,
-0.396240234375,
0.272705078125,
0.10394287109375,
-0.53759765625,
-0.8154296875,
1.2626953125,
0.76513671875,
-0.1380615234375,
0.303466796875,
0.163330078125,
0.43994140625,
-0.304931640625,
0.11297607421875,
-0.48095703125,
0.8603515625,
0.443359375,
0.59326171875,
-0.1422119140625,
0.285400390625,
0.51806640625,
-0.06134033203125,
-0.57470703125,
0.380126953125,
0.286865234375,
0.045806884765625,
0.071533203125,
-0.27880859375,
-0.41943359375,
-0.04400634765625,
-0.8857421875,
0.2841796875,
-0.185302734375,
-0.0736083984375,
-0.51318359375,
-0.48974609375,
0.85791015625,
-0.53076171875,
-0.00977325439453125,
0.298828125,
-0.264404296875,
0.33740234375,
0.517578125,
0.140380859375,
0.1728515625,
0.955078125,
0.72998046875,
0.63623046875,
0.59130859375,
0.2509765625,
0.365234375,
-0.759765625,
0.1826171875,
0.3251953125,
0.01152801513671875,
0.056640625,
-0.1036376953125,
-0.876953125,
0.5654296875,
-0.331787109375,
-0.3291015625,
0.359130859375,
-0.61181640625,
-0.1983642578125,
-0.421142578125,
0.86279296875,
-0.673828125,
0.55517578125,
0.6484375,
-0.289306640625,
-0.5888671875,
1.1982421875,
-0.401123046875,
0.1790771484375,
0.165771484375,
1.1767578125,
0.362060546875,
1.4345703125,
0.484619140625,
-0.090576171875,
0.114501953125,
0.460693359375,
-0.2337646484375,
-0.71533203125,
-0.47265625,
-0.375,
0.200439453125,
-0.86962890625,
-0.469970703125,
-0.373046875,
1.0224609375,
0.08148193359375,
-0.7685546875,
-0.19873046875,
0.0633544921875,
-0.77587890625,
0.19970703125,
0.311767578125,
0.459716796875,
0.07763671875,
-0.204345703125,
-0.037445068359375,
-0.48876953125,
0.1180419921875,
-0.29150390625,
0.3603515625,
-0.60205078125,
-0.5361328125,
-0.30029296875,
-1.0400390625,
-0.669921875,
0.1705322265625,
-0.1593017578125,
-0.830078125,
0.6201171875,
0.75390625,
0.1885986328125,
0.310791015625,
-0.48095703125,
0.386962890625,
0.95166015625,
1.28515625,
-0.09161376953125,
0.78955078125,
0.415283203125,
-0.300048828125,
0.1549072265625,
-0.431640625,
0.57666015625,
0.06610107421875,
0.52783203125,
-0.33984375,
0.6826171875,
-0.6015625,
-1.1650390625,
0.11773681640625,
0.44384765625,
0.67578125,
-0.91259765625,
-1.2861328125,
-0.1861572265625,
-1.017578125,
-0.151611328125,
-0.44775390625,
0.83935546875,
-0.29443359375,
0.1649169921875,
0.05267333984375,
-1.0712890625,
4.3359375,
1.294921875,
1.021484375,
0.35107421875,
0.51708984375,
1.3828125,
0.37841796875,
-0.5771484375,
-0.54736328125,
-0.48583984375,
0.490234375,
-0.281494140625,
0.06439208984375,
0.8671875,
0.2191162109375,
0.62744140625,
-0.5048828125,
0.049957275390625,
-0.301513671875,
-0.83740234375,
-0.8251953125,
0.279541015625,
-0.00595855712890625,
0.2347412109375,
-0.2802734375,
0.19091796875,
0.62255859375,
-0.78271484375,
-0.315673828125,
-0.86572265625,
0.00533294677734375,
-0.580078125,
0.9365234375,
0.0963134765625,
0.19091796875,
0.595703125,
-0.036529541015625,
-0.42041015625,
-0.194091796875,
-0.11126708984375,
-0.1619873046875,
0.3232421875,
0.82666015625,
-0.58251953125,
-0.2149658203125,
0.59326171875,
-0.80810546875,
0.55615234375,
0.4140625,
-1.220703125,
1.0224609375,
-0.259765625,
0.6162109375,
-0.6376953125,
-0.77197265625,
0.0019245147705078125,
-0.06512451171875,
-0.059295654296875,
-0.2191162109375,
0.3798828125,
0.1728515625,
0.294921875,
0.12225341796875,
0.436767578125,
-0.86083984375,
0.52001953125,
-0.08843994140625,
0.364990234375,
-0.67236328125,
-0.11126708984375,
-0.342041015625,
-0.2418212890625,
-0.5,
-0.24169921875,
0.7529296875,
0.2376708984375,
-0.0904541015625,
0.5361328125,
0.64453125,
-0.5068359375,
0.2359619140625,
-0.35791015625,
-0.2493896484375,
-0.466064453125,
0.7509765625,
1.134765625,
-0.4853515625,
-0.10955810546875,
-0.1319580078125,
0.486328125,
0.60791015625,
0.533203125,
-0.1982421875,
-0.270751953125,
-0.32763671875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in any order, any operation may be applied any number of times. The i-th operation is described by a string ai of length two and a string bi of length one. No two of q possible operations have the same string ai.
When Limak has a string s he can perform the i-th operation on s if the first two letters of s match a two-letter string ai. Performing the i-th operation removes first two letters of s and inserts there a string bi. See the notes section for further clarification.
You may note that performing an operation decreases the length of a string s exactly by 1. Also, for some sets of operations there may be a string that cannot be compressed any further, because the first two letters don't match any ai.
Limak wants to start with a string of length n and perform n - 1 operations to finally get a one-letter string "a". In how many ways can he choose the starting string to be able to get "a"? Remember that Limak can use only letters he knows.
Input
The first line contains two integers n and q (2 ≤ n ≤ 6, 1 ≤ q ≤ 36) — the length of the initial string and the number of available operations.
The next q lines describe the possible operations. The i-th of them contains two strings ai and bi (|ai| = 2, |bi| = 1). It's guaranteed that ai ≠ aj for i ≠ j and that all ai and bi consist of only first six lowercase English letters.
Output
Print the number of strings of length n that Limak will be able to transform to string "a" by applying only operations given in the input.
Examples
Input
3 5
ab a
cc c
ca a
ee c
ff d
Output
4
Input
2 8
af e
dc d
cc f
bc b
da b
eb a
bb b
ff c
Output
1
Input
6 2
bb a
ba a
Output
0
Note
In the first sample, we count initial strings of length 3 from which Limak can get a required string "a". There are 4 such strings: "abb", "cab", "cca", "eea". The first one Limak can compress using operation 1 two times (changing "ab" to a single "a"). The first operation would change "abb" to "ab" and the second operation would change "ab" to "a".
Other three strings may be compressed as follows:
* "cab" <image> "ab" <image> "a"
* "cca" <image> "ca" <image> "a"
* "eea" <image> "ca" <image> "a"
In the second sample, the only correct initial string is "eb" because it can be immediately compressed to "a".
Tags: brute force, dfs and similar, dp, strings
Correct Solution:
```
n,q=map(int,input().split())
d={i:""for i in "abcdef"}
for i in range(q):
a,b=input().split()
d[b]+=a[0]
cur=d['a']
for i in range(n-2):
nwcur=""
for j in cur:nwcur+=d[j]
cur=nwcur
print(len(cur))
```
| 70,295 | [
0.405517578125,
-0.0950927734375,
0.2056884765625,
-0.07342529296875,
-0.63916015625,
-0.362548828125,
-0.0787353515625,
0.19384765625,
0.1724853515625,
0.93212890625,
0.90771484375,
-0.11602783203125,
-0.102783203125,
-0.99609375,
-0.484375,
0.2491455078125,
-0.325927734375,
-0.5732421875,
-0.269775390625,
-0.199951171875,
0.1385498046875,
-0.468994140625,
-1.3232421875,
-0.23779296875,
-0.62939453125,
0.61376953125,
0.60888671875,
0.16357421875,
1.0791015625,
1.0810546875,
-0.231689453125,
-0.48291015625,
0.59619140625,
-1.234375,
-0.1663818359375,
-0.286865234375,
0.7158203125,
-0.66650390625,
-0.34033203125,
-0.59033203125,
0.298583984375,
-0.72509765625,
0.373779296875,
-0.666015625,
-1.1650390625,
-0.047088623046875,
-0.357421875,
-0.56640625,
-0.083740234375,
-0.83447265625,
0.2509765625,
-0.34375,
0.90625,
-0.300537109375,
0.09759521484375,
-0.165283203125,
0.50927734375,
-0.04119873046875,
-0.53857421875,
0.446533203125,
0.06591796875,
0.2802734375,
0.26611328125,
-0.56640625,
-0.2479248046875,
-0.1365966796875,
-0.141845703125,
-0.24609375,
-0.0950927734375,
-0.61572265625,
-0.587890625,
0.12188720703125,
-0.60107421875,
-0.669921875,
-0.2003173828125,
-0.0167388916015625,
0.173828125,
-0.08294677734375,
-0.61865234375,
1.060546875,
0.07183837890625,
1.025390625,
0.73193359375,
0.29443359375,
-0.189697265625,
-0.59423828125,
0.0794677734375,
0.27978515625,
0.0545654296875,
0.163330078125,
-0.265380859375,
0.75439453125,
-1.08203125,
-0.04815673828125,
0.48828125,
0.57861328125,
-0.07940673828125,
0.1142578125,
0.198974609375,
-0.1605224609375,
1.0556640625,
0.426513671875,
-0.1029052734375,
1.1943359375,
-0.5009765625,
0.2861328125,
-0.021881103515625,
0.007091522216796875,
-0.3134765625,
-0.06146240234375,
-0.13525390625,
-0.19091796875,
1.0751953125,
0.1865234375,
-0.2369384765625,
0.76513671875,
0.1746826171875,
0.56298828125,
-0.6376953125,
0.2322998046875,
0.35791015625,
0.41748046875,
0.8408203125,
-0.32861328125,
-0.12432861328125,
-0.1685791015625,
-0.135498046875,
0.654296875,
-0.84326171875,
-0.19677734375,
0.13525390625,
-0.189453125,
-0.161865234375,
0.30908203125,
-0.347412109375,
0.66845703125,
-0.2154541015625,
0.5927734375,
1.107421875,
-0.5634765625,
0.826171875,
-0.0151214599609375,
-0.00812530517578125,
1.49609375,
0.1683349609375,
0.270263671875,
0.7529296875,
0.09686279296875,
-0.74658203125,
0.488525390625,
-0.97607421875,
0.36083984375,
0.348388671875,
0.1275634765625,
-0.377685546875,
0.249267578125,
-0.1817626953125,
0.311279296875,
-0.001735687255859375,
-0.07421875,
-0.20703125,
0.33935546875,
-0.6201171875,
1.0546875,
-0.0732421875,
0.87060546875,
-0.42236328125,
-0.314697265625,
0.0888671875,
-0.071533203125,
0.09637451171875,
-0.2978515625,
-0.322021484375,
0.8203125,
0.374755859375,
1.064453125,
0.94873046875,
-0.0073699951171875,
0.387451171875,
0.390625,
-0.262451171875,
0.486083984375,
0.39794921875,
0.7490234375,
0.228271484375,
0.40380859375,
0.031036376953125,
-0.08441162109375,
-0.1845703125,
-0.28125,
-0.06060791015625,
0.72802734375,
-0.4296875,
-0.148681640625,
0.04595947265625,
0.18603515625,
-0.97314453125,
0.455322265625,
0.0535888671875,
-0.9833984375,
-0.265380859375,
0.74951171875,
-0.453857421875,
0.62841796875,
-0.55419921875,
-0.69970703125,
0.62060546875,
1.1943359375,
0.1446533203125,
0.0263824462890625,
0.79638671875,
0.541015625,
-0.420654296875,
0.334716796875,
-0.232421875,
-0.5244140625,
-0.560546875,
0.73193359375,
0.0509033203125,
-0.09967041015625,
0.168701171875,
0.26025390625,
0.306396484375,
0.70068359375,
-0.37255859375,
-0.028106689453125,
0.80078125,
1.0947265625,
-0.054412841796875,
0.44580078125,
0.156005859375,
0.96484375,
0.505859375,
0.9404296875,
0.638671875,
0.308837890625,
0.64453125,
0.93505859375,
0.015350341796875,
0.0011730194091796875,
0.051300048828125,
0.6611328125,
0.436279296875,
0.67333984375,
0.12286376953125,
0.2100830078125,
-0.2705078125,
0.05712890625,
-0.5966796875,
-0.004596710205078125,
-0.2763671875,
0.77685546875,
0.10687255859375,
0.74755859375,
-0.30859375,
-0.413330078125,
0.3251953125,
0.6484375,
-0.958984375,
-0.44384765625,
-0.376220703125,
-0.135498046875,
0.350341796875,
-0.046966552734375,
0.259521484375,
0.052337646484375,
0.320068359375,
0.1103515625,
-0.2489013671875,
-0.69384765625,
-1.095703125,
-0.98779296875,
-0.7548828125,
-0.51806640625,
-0.62451171875,
0.126953125,
0.179443359375,
-1.1728515625,
0.53564453125,
-0.54638671875,
-0.2427978515625,
-0.020721435546875,
-0.85107421875,
0.5537109375,
-0.227294921875,
0.470947265625,
-0.452392578125,
0.368408203125,
0.299560546875,
1.306640625,
-0.162353515625,
0.1776123046875,
-0.0751953125,
-0.63623046875,
0.27880859375,
-0.272216796875,
0.57861328125,
-0.1357421875,
-0.734375,
-0.587890625,
-0.340087890625,
-0.08221435546875,
-0.56884765625,
0.373779296875,
-0.412841796875,
0.5791015625,
0.36669921875,
-1.0576171875,
0.685546875,
1.1533203125,
-0.5458984375,
0.6748046875,
-0.362548828125,
0.0278472900390625,
-0.79345703125,
1.18359375,
0.255859375,
0.414794921875,
-0.321044921875,
-0.8623046875,
-0.3818359375,
-0.18798828125,
0.06793212890625,
-0.302734375,
-0.0772705078125,
0.63232421875,
-0.381103515625,
-0.7587890625,
0.6376953125,
-1.013671875,
-0.322265625,
-0.7998046875,
-0.63134765625,
0.78955078125,
0.68896484375,
0.1461181640625,
0.0021762847900390625,
-0.144287109375,
-0.143798828125,
0.9814453125,
0.2269287109375,
-0.630859375,
0.07647705078125,
0.5078125,
0.031463623046875,
0.0125885009765625,
0.54443359375,
-0.55517578125,
-0.3798828125,
0.06890869140625,
-0.03436279296875,
0.71337890625,
0.2376708984375,
0.57666015625,
0.57958984375,
0.6220703125,
-1.0087890625,
-0.1505126953125,
-0.43505859375,
0.413818359375,
0.425537109375,
0.23193359375,
0.416015625,
-0.464111328125,
-0.5234375,
-0.90234375,
0.40966796875,
0.1962890625,
0.428955078125,
-0.6708984375,
0.9072265625,
0.05267333984375,
-0.39404296875,
0.380859375,
-0.501953125,
-0.1041259765625,
0.8896484375,
-0.395751953125,
0.724609375,
-0.6806640625,
0.63916015625,
-0.1055908203125,
-0.1796875,
0.84228515625,
0.286376953125,
0.452880859375,
-0.544921875,
-0.304443359375,
-0.505859375,
-0.28466796875,
0.2548828125,
-0.5478515625,
0.10748291015625,
-0.72509765625,
-0.29638671875,
-0.91357421875,
0.54296875,
0.36474609375,
0.7578125,
-0.067626953125,
0.494140625,
0.06512451171875,
0.71484375,
0.69091796875,
-0.2352294921875,
-0.05438232421875,
-0.456787109375,
0.87646484375,
0.243896484375,
-0.281982421875,
-0.54248046875,
-0.1630859375,
-0.458984375,
0.39599609375,
-0.0374755859375,
-0.08685302734375,
-0.9150390625,
0.42333984375,
0.1990966796875,
0.7001953125,
-0.463134765625,
-0.52490234375,
-0.359619140625,
0.361328125,
0.59619140625,
-1.2021484375,
0.00028061866760253906,
-0.677734375,
0.87451171875,
0.43994140625,
-0.2332763671875,
-0.4267578125,
-0.62109375,
-0.6171875,
-0.453857421875,
-0.0782470703125,
0.71142578125,
0.314208984375,
0.412353515625,
-0.99267578125,
0.32666015625,
0.301513671875,
-0.2119140625,
0.04052734375,
-0.16796875,
0.22021484375,
-0.1436767578125,
0.74951171875,
-0.339599609375,
-0.71728515625,
0.021636962890625,
-1.302734375,
0.2880859375,
-0.68359375,
0.339599609375,
0.046966552734375,
-0.478759765625,
-0.302001953125,
0.329833984375,
-0.430419921875,
-0.0377197265625,
0.06964111328125,
0.68408203125,
-1.0576171875,
-0.998046875,
0.5517578125,
-0.2393798828125,
-0.493408203125,
1.19140625,
0.0958251953125,
-0.544921875,
0.02545166015625,
0.240966796875,
-0.37939453125,
0.54833984375,
-1.0693359375,
0.63818359375,
-0.447265625,
-0.34423828125,
-0.449951171875,
-0.56201171875,
0.412109375,
-0.0860595703125,
-0.52880859375,
-0.496826171875,
-1.326171875,
-0.159423828125,
-0.036376953125,
-0.5517578125,
0.44921875,
-0.054656982421875,
0.167724609375,
-0.057586669921875,
-0.47998046875,
-0.177734375,
-0.607421875,
-0.47314453125,
-0.39111328125,
0.53759765625,
0.53857421875,
0.7998046875,
-0.043365478515625,
-0.333740234375,
0.028564453125,
-0.0970458984375,
0.09515380859375,
-0.1522216796875,
-0.2105712890625,
0.0237579345703125,
-0.12164306640625,
-0.135009765625,
0.314208984375,
-0.181640625,
0.09552001953125,
0.485595703125,
0.054412841796875,
0.66015625,
0.228759765625,
-0.72802734375,
1.31640625,
0.189453125,
-1.0390625,
-0.216796875,
0.90478515625,
-0.127197265625,
0.3427734375,
0.31591796875,
-1.015625,
-0.86279296875,
-0.74072265625,
0.489501953125,
-0.72314453125,
-0.396728515625,
-1.2158203125,
-0.377685546875,
-0.54931640625,
0.708984375,
-0.032806396484375,
-0.42138671875,
0.42236328125,
-1.046875,
0.3681640625,
-0.60205078125,
-0.67626953125,
-0.56787109375,
-0.68310546875,
-0.091064453125,
1.146484375,
0.077880859375,
0.2498779296875,
0.2607421875,
-0.265869140625,
0.58984375,
0.24169921875,
-0.94775390625,
-0.32470703125,
-0.1446533203125,
0.429443359375,
-0.09375,
0.0261383056640625,
-0.394287109375,
0.4072265625,
-0.77099609375,
0.333740234375,
-0.264404296875,
-0.34619140625,
-0.35400390625,
-0.41064453125,
1.1650390625,
-0.61572265625,
0.062286376953125,
-0.2294921875,
0.6962890625,
0.92919921875,
-0.02581787109375,
-0.42333984375,
-0.88623046875,
-1.052734375,
-0.9443359375,
0.63232421875,
-0.402587890625,
0.0018777847290039062,
-0.471435546875,
0.031982421875,
0.8291015625,
-0.164306640625,
0.5830078125,
0.869140625,
0.10345458984375,
-0.0958251953125,
-0.61474609375,
0.7099609375,
0.41552734375,
-0.4951171875,
-0.302001953125,
0.372314453125,
-0.603515625,
0.311767578125,
-0.422607421875,
-1.2119140625,
-0.80029296875,
0.337158203125,
1.3984375,
-0.243408203125,
0.900390625,
-0.059844970703125,
-0.88916015625,
-0.43017578125,
0.66357421875,
0.12139892578125,
0.327392578125,
0.78125,
-0.1126708984375,
-0.329833984375,
0.10894775390625,
-0.373046875,
-0.109130859375,
-0.62548828125,
1.23046875,
-0.6357421875,
-0.625,
0.453125,
0.99365234375,
-0.90869140625,
-1.302734375,
-0.2376708984375,
-0.3125,
-0.434326171875,
-0.86767578125,
-0.129638671875,
0.266357421875,
-0.2474365234375,
0.10369873046875,
0.31787109375,
-0.065185546875,
0.55712890625,
0.1260986328125,
0.5234375,
-0.1416015625,
0.4521484375,
0.69580078125,
-0.51171875,
-0.642578125,
-1.03125,
-0.048614501953125,
-0.361328125,
0.2294921875,
0.59814453125,
-0.2142333984375,
0.50537109375,
0.5419921875,
-0.15966796875,
0.77099609375,
-0.38818359375,
-0.462158203125,
0.2237548828125,
-1.134765625,
-0.451904296875,
0.026519775390625,
0.54345703125,
-0.47265625,
0.292236328125,
-0.79833984375,
-0.537109375,
0.343505859375,
0.54052734375,
-0.36767578125,
-1.0625,
-0.12274169921875,
-1.2109375,
-0.62841796875,
-0.58642578125,
-0.75439453125,
-0.1837158203125,
-0.1953125,
0.01244354248046875,
-0.7890625,
-0.08221435546875,
0.283203125,
-0.505859375,
0.8330078125,
-0.556640625,
0.54638671875,
-0.669921875,
-0.11895751953125,
-0.64501953125,
0.14404296875,
-0.54150390625,
-0.1407470703125,
-0.320068359375,
0.328125,
-0.17724609375,
0.56591796875,
-0.3173828125,
0.309326171875,
-0.2088623046875,
-0.40478515625,
-0.100341796875,
0.1590576171875,
-0.2288818359375,
0.673828125,
0.5224609375,
-0.2587890625,
0.333740234375,
-0.11639404296875,
-0.1492919921875,
-0.252685546875,
0.90380859375,
0.16015625,
-0.040679931640625,
-0.1749267578125,
-0.2362060546875,
0.371826171875,
-0.96826171875,
0.30810546875,
-0.141357421875,
0.533203125,
0.0002970695495605469,
-0.237548828125,
0.3564453125,
1.0888671875,
-0.119140625,
0.006641387939453125,
0.2333984375,
0.145263671875,
0.1314697265625,
0.1522216796875,
-0.0233612060546875,
0.484375,
-0.1982421875,
-0.343017578125,
-0.1400146484375,
0.3291015625,
0.06268310546875,
0.409912109375,
-0.1524658203125,
-0.76513671875,
-0.65673828125,
-0.288330078125,
-0.047698974609375,
0.51708984375,
0.5400390625,
-0.60009765625,
0.0209503173828125,
0.0628662109375,
-0.7783203125,
0.0950927734375,
-1.0166015625,
-1.0859375,
0.00504302978515625,
0.07574462890625,
-0.73974609375,
-0.10162353515625,
-0.48046875,
-0.200439453125,
0.01421356201171875,
0.2183837890625,
-0.89013671875,
0.3251953125,
0.0029048919677734375,
0.58203125,
-0.2322998046875,
-0.0160064697265625,
-0.017822265625,
0.353759765625,
-0.6044921875,
-0.2303466796875,
-0.348876953125,
0.5888671875,
0.27880859375,
-0.2353515625,
-0.22998046875,
0.1783447265625,
0.2152099609375,
0.207275390625,
-0.55908203125,
0.250732421875,
-0.0775146484375,
0.88818359375,
-0.77587890625,
-0.204345703125,
-0.396240234375,
0.272705078125,
0.10394287109375,
-0.53759765625,
-0.8154296875,
1.2626953125,
0.76513671875,
-0.1380615234375,
0.303466796875,
0.163330078125,
0.43994140625,
-0.304931640625,
0.11297607421875,
-0.48095703125,
0.8603515625,
0.443359375,
0.59326171875,
-0.1422119140625,
0.285400390625,
0.51806640625,
-0.06134033203125,
-0.57470703125,
0.380126953125,
0.286865234375,
0.045806884765625,
0.071533203125,
-0.27880859375,
-0.41943359375,
-0.04400634765625,
-0.8857421875,
0.2841796875,
-0.185302734375,
-0.0736083984375,
-0.51318359375,
-0.48974609375,
0.85791015625,
-0.53076171875,
-0.00977325439453125,
0.298828125,
-0.264404296875,
0.33740234375,
0.517578125,
0.140380859375,
0.1728515625,
0.955078125,
0.72998046875,
0.63623046875,
0.59130859375,
0.2509765625,
0.365234375,
-0.759765625,
0.1826171875,
0.3251953125,
0.01152801513671875,
0.056640625,
-0.1036376953125,
-0.876953125,
0.5654296875,
-0.331787109375,
-0.3291015625,
0.359130859375,
-0.61181640625,
-0.1983642578125,
-0.421142578125,
0.86279296875,
-0.673828125,
0.55517578125,
0.6484375,
-0.289306640625,
-0.5888671875,
1.1982421875,
-0.401123046875,
0.1790771484375,
0.165771484375,
1.1767578125,
0.362060546875,
1.4345703125,
0.484619140625,
-0.090576171875,
0.114501953125,
0.460693359375,
-0.2337646484375,
-0.71533203125,
-0.47265625,
-0.375,
0.200439453125,
-0.86962890625,
-0.469970703125,
-0.373046875,
1.0224609375,
0.08148193359375,
-0.7685546875,
-0.19873046875,
0.0633544921875,
-0.77587890625,
0.19970703125,
0.311767578125,
0.459716796875,
0.07763671875,
-0.204345703125,
-0.037445068359375,
-0.48876953125,
0.1180419921875,
-0.29150390625,
0.3603515625,
-0.60205078125,
-0.5361328125,
-0.30029296875,
-1.0400390625,
-0.669921875,
0.1705322265625,
-0.1593017578125,
-0.830078125,
0.6201171875,
0.75390625,
0.1885986328125,
0.310791015625,
-0.48095703125,
0.386962890625,
0.95166015625,
1.28515625,
-0.09161376953125,
0.78955078125,
0.415283203125,
-0.300048828125,
0.1549072265625,
-0.431640625,
0.57666015625,
0.06610107421875,
0.52783203125,
-0.33984375,
0.6826171875,
-0.6015625,
-1.1650390625,
0.11773681640625,
0.44384765625,
0.67578125,
-0.91259765625,
-1.2861328125,
-0.1861572265625,
-1.017578125,
-0.151611328125,
-0.44775390625,
0.83935546875,
-0.29443359375,
0.1649169921875,
0.05267333984375,
-1.0712890625,
4.3359375,
1.294921875,
1.021484375,
0.35107421875,
0.51708984375,
1.3828125,
0.37841796875,
-0.5771484375,
-0.54736328125,
-0.48583984375,
0.490234375,
-0.281494140625,
0.06439208984375,
0.8671875,
0.2191162109375,
0.62744140625,
-0.5048828125,
0.049957275390625,
-0.301513671875,
-0.83740234375,
-0.8251953125,
0.279541015625,
-0.00595855712890625,
0.2347412109375,
-0.2802734375,
0.19091796875,
0.62255859375,
-0.78271484375,
-0.315673828125,
-0.86572265625,
0.00533294677734375,
-0.580078125,
0.9365234375,
0.0963134765625,
0.19091796875,
0.595703125,
-0.036529541015625,
-0.42041015625,
-0.194091796875,
-0.11126708984375,
-0.1619873046875,
0.3232421875,
0.82666015625,
-0.58251953125,
-0.2149658203125,
0.59326171875,
-0.80810546875,
0.55615234375,
0.4140625,
-1.220703125,
1.0224609375,
-0.259765625,
0.6162109375,
-0.6376953125,
-0.77197265625,
0.0019245147705078125,
-0.06512451171875,
-0.059295654296875,
-0.2191162109375,
0.3798828125,
0.1728515625,
0.294921875,
0.12225341796875,
0.436767578125,
-0.86083984375,
0.52001953125,
-0.08843994140625,
0.364990234375,
-0.67236328125,
-0.11126708984375,
-0.342041015625,
-0.2418212890625,
-0.5,
-0.24169921875,
0.7529296875,
0.2376708984375,
-0.0904541015625,
0.5361328125,
0.64453125,
-0.5068359375,
0.2359619140625,
-0.35791015625,
-0.2493896484375,
-0.466064453125,
0.7509765625,
1.134765625,
-0.4853515625,
-0.10955810546875,
-0.1319580078125,
0.486328125,
0.60791015625,
0.533203125,
-0.1982421875,
-0.270751953125,
-0.32763671875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in any order, any operation may be applied any number of times. The i-th operation is described by a string ai of length two and a string bi of length one. No two of q possible operations have the same string ai.
When Limak has a string s he can perform the i-th operation on s if the first two letters of s match a two-letter string ai. Performing the i-th operation removes first two letters of s and inserts there a string bi. See the notes section for further clarification.
You may note that performing an operation decreases the length of a string s exactly by 1. Also, for some sets of operations there may be a string that cannot be compressed any further, because the first two letters don't match any ai.
Limak wants to start with a string of length n and perform n - 1 operations to finally get a one-letter string "a". In how many ways can he choose the starting string to be able to get "a"? Remember that Limak can use only letters he knows.
Input
The first line contains two integers n and q (2 ≤ n ≤ 6, 1 ≤ q ≤ 36) — the length of the initial string and the number of available operations.
The next q lines describe the possible operations. The i-th of them contains two strings ai and bi (|ai| = 2, |bi| = 1). It's guaranteed that ai ≠ aj for i ≠ j and that all ai and bi consist of only first six lowercase English letters.
Output
Print the number of strings of length n that Limak will be able to transform to string "a" by applying only operations given in the input.
Examples
Input
3 5
ab a
cc c
ca a
ee c
ff d
Output
4
Input
2 8
af e
dc d
cc f
bc b
da b
eb a
bb b
ff c
Output
1
Input
6 2
bb a
ba a
Output
0
Note
In the first sample, we count initial strings of length 3 from which Limak can get a required string "a". There are 4 such strings: "abb", "cab", "cca", "eea". The first one Limak can compress using operation 1 two times (changing "ab" to a single "a"). The first operation would change "abb" to "ab" and the second operation would change "ab" to "a".
Other three strings may be compressed as follows:
* "cab" <image> "ab" <image> "a"
* "cca" <image> "ca" <image> "a"
* "eea" <image> "ca" <image> "a"
In the second sample, the only correct initial string is "eb" because it can be immediately compressed to "a".
Tags: brute force, dfs and similar, dp, strings
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
from itertools import combinations_with_replacement,permutations
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
s = 'abcdef'
letters = list(s)
n,m = list(map(int,input().split()))
mp = {}
for i in range(m):
x,red = list(map(str,input().split()))
mp[x] = red
combo = list(combinations_with_replacement(letters,n))
perm = []
for i in combo:
perm+=list(permutations(list(i)))
all_words = []
for i in perm:
x = ''.join(str(x) for x in i)
all_words.append(x)
unique = set()
for i in all_words:
flag = 0
cur = i[0]
for j in range(1,len(i)):
two = cur+i[j]
if two in mp:
cur = mp[two]
else:
flag = 1
break
if flag==0 and cur=='a':
unique.add(i)
print(len(unique))
```
| 70,296 | [
0.405517578125,
-0.0950927734375,
0.2056884765625,
-0.07342529296875,
-0.63916015625,
-0.362548828125,
-0.0787353515625,
0.19384765625,
0.1724853515625,
0.93212890625,
0.90771484375,
-0.11602783203125,
-0.102783203125,
-0.99609375,
-0.484375,
0.2491455078125,
-0.325927734375,
-0.5732421875,
-0.269775390625,
-0.199951171875,
0.1385498046875,
-0.468994140625,
-1.3232421875,
-0.23779296875,
-0.62939453125,
0.61376953125,
0.60888671875,
0.16357421875,
1.0791015625,
1.0810546875,
-0.231689453125,
-0.48291015625,
0.59619140625,
-1.234375,
-0.1663818359375,
-0.286865234375,
0.7158203125,
-0.66650390625,
-0.34033203125,
-0.59033203125,
0.298583984375,
-0.72509765625,
0.373779296875,
-0.666015625,
-1.1650390625,
-0.047088623046875,
-0.357421875,
-0.56640625,
-0.083740234375,
-0.83447265625,
0.2509765625,
-0.34375,
0.90625,
-0.300537109375,
0.09759521484375,
-0.165283203125,
0.50927734375,
-0.04119873046875,
-0.53857421875,
0.446533203125,
0.06591796875,
0.2802734375,
0.26611328125,
-0.56640625,
-0.2479248046875,
-0.1365966796875,
-0.141845703125,
-0.24609375,
-0.0950927734375,
-0.61572265625,
-0.587890625,
0.12188720703125,
-0.60107421875,
-0.669921875,
-0.2003173828125,
-0.0167388916015625,
0.173828125,
-0.08294677734375,
-0.61865234375,
1.060546875,
0.07183837890625,
1.025390625,
0.73193359375,
0.29443359375,
-0.189697265625,
-0.59423828125,
0.0794677734375,
0.27978515625,
0.0545654296875,
0.163330078125,
-0.265380859375,
0.75439453125,
-1.08203125,
-0.04815673828125,
0.48828125,
0.57861328125,
-0.07940673828125,
0.1142578125,
0.198974609375,
-0.1605224609375,
1.0556640625,
0.426513671875,
-0.1029052734375,
1.1943359375,
-0.5009765625,
0.2861328125,
-0.021881103515625,
0.007091522216796875,
-0.3134765625,
-0.06146240234375,
-0.13525390625,
-0.19091796875,
1.0751953125,
0.1865234375,
-0.2369384765625,
0.76513671875,
0.1746826171875,
0.56298828125,
-0.6376953125,
0.2322998046875,
0.35791015625,
0.41748046875,
0.8408203125,
-0.32861328125,
-0.12432861328125,
-0.1685791015625,
-0.135498046875,
0.654296875,
-0.84326171875,
-0.19677734375,
0.13525390625,
-0.189453125,
-0.161865234375,
0.30908203125,
-0.347412109375,
0.66845703125,
-0.2154541015625,
0.5927734375,
1.107421875,
-0.5634765625,
0.826171875,
-0.0151214599609375,
-0.00812530517578125,
1.49609375,
0.1683349609375,
0.270263671875,
0.7529296875,
0.09686279296875,
-0.74658203125,
0.488525390625,
-0.97607421875,
0.36083984375,
0.348388671875,
0.1275634765625,
-0.377685546875,
0.249267578125,
-0.1817626953125,
0.311279296875,
-0.001735687255859375,
-0.07421875,
-0.20703125,
0.33935546875,
-0.6201171875,
1.0546875,
-0.0732421875,
0.87060546875,
-0.42236328125,
-0.314697265625,
0.0888671875,
-0.071533203125,
0.09637451171875,
-0.2978515625,
-0.322021484375,
0.8203125,
0.374755859375,
1.064453125,
0.94873046875,
-0.0073699951171875,
0.387451171875,
0.390625,
-0.262451171875,
0.486083984375,
0.39794921875,
0.7490234375,
0.228271484375,
0.40380859375,
0.031036376953125,
-0.08441162109375,
-0.1845703125,
-0.28125,
-0.06060791015625,
0.72802734375,
-0.4296875,
-0.148681640625,
0.04595947265625,
0.18603515625,
-0.97314453125,
0.455322265625,
0.0535888671875,
-0.9833984375,
-0.265380859375,
0.74951171875,
-0.453857421875,
0.62841796875,
-0.55419921875,
-0.69970703125,
0.62060546875,
1.1943359375,
0.1446533203125,
0.0263824462890625,
0.79638671875,
0.541015625,
-0.420654296875,
0.334716796875,
-0.232421875,
-0.5244140625,
-0.560546875,
0.73193359375,
0.0509033203125,
-0.09967041015625,
0.168701171875,
0.26025390625,
0.306396484375,
0.70068359375,
-0.37255859375,
-0.028106689453125,
0.80078125,
1.0947265625,
-0.054412841796875,
0.44580078125,
0.156005859375,
0.96484375,
0.505859375,
0.9404296875,
0.638671875,
0.308837890625,
0.64453125,
0.93505859375,
0.015350341796875,
0.0011730194091796875,
0.051300048828125,
0.6611328125,
0.436279296875,
0.67333984375,
0.12286376953125,
0.2100830078125,
-0.2705078125,
0.05712890625,
-0.5966796875,
-0.004596710205078125,
-0.2763671875,
0.77685546875,
0.10687255859375,
0.74755859375,
-0.30859375,
-0.413330078125,
0.3251953125,
0.6484375,
-0.958984375,
-0.44384765625,
-0.376220703125,
-0.135498046875,
0.350341796875,
-0.046966552734375,
0.259521484375,
0.052337646484375,
0.320068359375,
0.1103515625,
-0.2489013671875,
-0.69384765625,
-1.095703125,
-0.98779296875,
-0.7548828125,
-0.51806640625,
-0.62451171875,
0.126953125,
0.179443359375,
-1.1728515625,
0.53564453125,
-0.54638671875,
-0.2427978515625,
-0.020721435546875,
-0.85107421875,
0.5537109375,
-0.227294921875,
0.470947265625,
-0.452392578125,
0.368408203125,
0.299560546875,
1.306640625,
-0.162353515625,
0.1776123046875,
-0.0751953125,
-0.63623046875,
0.27880859375,
-0.272216796875,
0.57861328125,
-0.1357421875,
-0.734375,
-0.587890625,
-0.340087890625,
-0.08221435546875,
-0.56884765625,
0.373779296875,
-0.412841796875,
0.5791015625,
0.36669921875,
-1.0576171875,
0.685546875,
1.1533203125,
-0.5458984375,
0.6748046875,
-0.362548828125,
0.0278472900390625,
-0.79345703125,
1.18359375,
0.255859375,
0.414794921875,
-0.321044921875,
-0.8623046875,
-0.3818359375,
-0.18798828125,
0.06793212890625,
-0.302734375,
-0.0772705078125,
0.63232421875,
-0.381103515625,
-0.7587890625,
0.6376953125,
-1.013671875,
-0.322265625,
-0.7998046875,
-0.63134765625,
0.78955078125,
0.68896484375,
0.1461181640625,
0.0021762847900390625,
-0.144287109375,
-0.143798828125,
0.9814453125,
0.2269287109375,
-0.630859375,
0.07647705078125,
0.5078125,
0.031463623046875,
0.0125885009765625,
0.54443359375,
-0.55517578125,
-0.3798828125,
0.06890869140625,
-0.03436279296875,
0.71337890625,
0.2376708984375,
0.57666015625,
0.57958984375,
0.6220703125,
-1.0087890625,
-0.1505126953125,
-0.43505859375,
0.413818359375,
0.425537109375,
0.23193359375,
0.416015625,
-0.464111328125,
-0.5234375,
-0.90234375,
0.40966796875,
0.1962890625,
0.428955078125,
-0.6708984375,
0.9072265625,
0.05267333984375,
-0.39404296875,
0.380859375,
-0.501953125,
-0.1041259765625,
0.8896484375,
-0.395751953125,
0.724609375,
-0.6806640625,
0.63916015625,
-0.1055908203125,
-0.1796875,
0.84228515625,
0.286376953125,
0.452880859375,
-0.544921875,
-0.304443359375,
-0.505859375,
-0.28466796875,
0.2548828125,
-0.5478515625,
0.10748291015625,
-0.72509765625,
-0.29638671875,
-0.91357421875,
0.54296875,
0.36474609375,
0.7578125,
-0.067626953125,
0.494140625,
0.06512451171875,
0.71484375,
0.69091796875,
-0.2352294921875,
-0.05438232421875,
-0.456787109375,
0.87646484375,
0.243896484375,
-0.281982421875,
-0.54248046875,
-0.1630859375,
-0.458984375,
0.39599609375,
-0.0374755859375,
-0.08685302734375,
-0.9150390625,
0.42333984375,
0.1990966796875,
0.7001953125,
-0.463134765625,
-0.52490234375,
-0.359619140625,
0.361328125,
0.59619140625,
-1.2021484375,
0.00028061866760253906,
-0.677734375,
0.87451171875,
0.43994140625,
-0.2332763671875,
-0.4267578125,
-0.62109375,
-0.6171875,
-0.453857421875,
-0.0782470703125,
0.71142578125,
0.314208984375,
0.412353515625,
-0.99267578125,
0.32666015625,
0.301513671875,
-0.2119140625,
0.04052734375,
-0.16796875,
0.22021484375,
-0.1436767578125,
0.74951171875,
-0.339599609375,
-0.71728515625,
0.021636962890625,
-1.302734375,
0.2880859375,
-0.68359375,
0.339599609375,
0.046966552734375,
-0.478759765625,
-0.302001953125,
0.329833984375,
-0.430419921875,
-0.0377197265625,
0.06964111328125,
0.68408203125,
-1.0576171875,
-0.998046875,
0.5517578125,
-0.2393798828125,
-0.493408203125,
1.19140625,
0.0958251953125,
-0.544921875,
0.02545166015625,
0.240966796875,
-0.37939453125,
0.54833984375,
-1.0693359375,
0.63818359375,
-0.447265625,
-0.34423828125,
-0.449951171875,
-0.56201171875,
0.412109375,
-0.0860595703125,
-0.52880859375,
-0.496826171875,
-1.326171875,
-0.159423828125,
-0.036376953125,
-0.5517578125,
0.44921875,
-0.054656982421875,
0.167724609375,
-0.057586669921875,
-0.47998046875,
-0.177734375,
-0.607421875,
-0.47314453125,
-0.39111328125,
0.53759765625,
0.53857421875,
0.7998046875,
-0.043365478515625,
-0.333740234375,
0.028564453125,
-0.0970458984375,
0.09515380859375,
-0.1522216796875,
-0.2105712890625,
0.0237579345703125,
-0.12164306640625,
-0.135009765625,
0.314208984375,
-0.181640625,
0.09552001953125,
0.485595703125,
0.054412841796875,
0.66015625,
0.228759765625,
-0.72802734375,
1.31640625,
0.189453125,
-1.0390625,
-0.216796875,
0.90478515625,
-0.127197265625,
0.3427734375,
0.31591796875,
-1.015625,
-0.86279296875,
-0.74072265625,
0.489501953125,
-0.72314453125,
-0.396728515625,
-1.2158203125,
-0.377685546875,
-0.54931640625,
0.708984375,
-0.032806396484375,
-0.42138671875,
0.42236328125,
-1.046875,
0.3681640625,
-0.60205078125,
-0.67626953125,
-0.56787109375,
-0.68310546875,
-0.091064453125,
1.146484375,
0.077880859375,
0.2498779296875,
0.2607421875,
-0.265869140625,
0.58984375,
0.24169921875,
-0.94775390625,
-0.32470703125,
-0.1446533203125,
0.429443359375,
-0.09375,
0.0261383056640625,
-0.394287109375,
0.4072265625,
-0.77099609375,
0.333740234375,
-0.264404296875,
-0.34619140625,
-0.35400390625,
-0.41064453125,
1.1650390625,
-0.61572265625,
0.062286376953125,
-0.2294921875,
0.6962890625,
0.92919921875,
-0.02581787109375,
-0.42333984375,
-0.88623046875,
-1.052734375,
-0.9443359375,
0.63232421875,
-0.402587890625,
0.0018777847290039062,
-0.471435546875,
0.031982421875,
0.8291015625,
-0.164306640625,
0.5830078125,
0.869140625,
0.10345458984375,
-0.0958251953125,
-0.61474609375,
0.7099609375,
0.41552734375,
-0.4951171875,
-0.302001953125,
0.372314453125,
-0.603515625,
0.311767578125,
-0.422607421875,
-1.2119140625,
-0.80029296875,
0.337158203125,
1.3984375,
-0.243408203125,
0.900390625,
-0.059844970703125,
-0.88916015625,
-0.43017578125,
0.66357421875,
0.12139892578125,
0.327392578125,
0.78125,
-0.1126708984375,
-0.329833984375,
0.10894775390625,
-0.373046875,
-0.109130859375,
-0.62548828125,
1.23046875,
-0.6357421875,
-0.625,
0.453125,
0.99365234375,
-0.90869140625,
-1.302734375,
-0.2376708984375,
-0.3125,
-0.434326171875,
-0.86767578125,
-0.129638671875,
0.266357421875,
-0.2474365234375,
0.10369873046875,
0.31787109375,
-0.065185546875,
0.55712890625,
0.1260986328125,
0.5234375,
-0.1416015625,
0.4521484375,
0.69580078125,
-0.51171875,
-0.642578125,
-1.03125,
-0.048614501953125,
-0.361328125,
0.2294921875,
0.59814453125,
-0.2142333984375,
0.50537109375,
0.5419921875,
-0.15966796875,
0.77099609375,
-0.38818359375,
-0.462158203125,
0.2237548828125,
-1.134765625,
-0.451904296875,
0.026519775390625,
0.54345703125,
-0.47265625,
0.292236328125,
-0.79833984375,
-0.537109375,
0.343505859375,
0.54052734375,
-0.36767578125,
-1.0625,
-0.12274169921875,
-1.2109375,
-0.62841796875,
-0.58642578125,
-0.75439453125,
-0.1837158203125,
-0.1953125,
0.01244354248046875,
-0.7890625,
-0.08221435546875,
0.283203125,
-0.505859375,
0.8330078125,
-0.556640625,
0.54638671875,
-0.669921875,
-0.11895751953125,
-0.64501953125,
0.14404296875,
-0.54150390625,
-0.1407470703125,
-0.320068359375,
0.328125,
-0.17724609375,
0.56591796875,
-0.3173828125,
0.309326171875,
-0.2088623046875,
-0.40478515625,
-0.100341796875,
0.1590576171875,
-0.2288818359375,
0.673828125,
0.5224609375,
-0.2587890625,
0.333740234375,
-0.11639404296875,
-0.1492919921875,
-0.252685546875,
0.90380859375,
0.16015625,
-0.040679931640625,
-0.1749267578125,
-0.2362060546875,
0.371826171875,
-0.96826171875,
0.30810546875,
-0.141357421875,
0.533203125,
0.0002970695495605469,
-0.237548828125,
0.3564453125,
1.0888671875,
-0.119140625,
0.006641387939453125,
0.2333984375,
0.145263671875,
0.1314697265625,
0.1522216796875,
-0.0233612060546875,
0.484375,
-0.1982421875,
-0.343017578125,
-0.1400146484375,
0.3291015625,
0.06268310546875,
0.409912109375,
-0.1524658203125,
-0.76513671875,
-0.65673828125,
-0.288330078125,
-0.047698974609375,
0.51708984375,
0.5400390625,
-0.60009765625,
0.0209503173828125,
0.0628662109375,
-0.7783203125,
0.0950927734375,
-1.0166015625,
-1.0859375,
0.00504302978515625,
0.07574462890625,
-0.73974609375,
-0.10162353515625,
-0.48046875,
-0.200439453125,
0.01421356201171875,
0.2183837890625,
-0.89013671875,
0.3251953125,
0.0029048919677734375,
0.58203125,
-0.2322998046875,
-0.0160064697265625,
-0.017822265625,
0.353759765625,
-0.6044921875,
-0.2303466796875,
-0.348876953125,
0.5888671875,
0.27880859375,
-0.2353515625,
-0.22998046875,
0.1783447265625,
0.2152099609375,
0.207275390625,
-0.55908203125,
0.250732421875,
-0.0775146484375,
0.88818359375,
-0.77587890625,
-0.204345703125,
-0.396240234375,
0.272705078125,
0.10394287109375,
-0.53759765625,
-0.8154296875,
1.2626953125,
0.76513671875,
-0.1380615234375,
0.303466796875,
0.163330078125,
0.43994140625,
-0.304931640625,
0.11297607421875,
-0.48095703125,
0.8603515625,
0.443359375,
0.59326171875,
-0.1422119140625,
0.285400390625,
0.51806640625,
-0.06134033203125,
-0.57470703125,
0.380126953125,
0.286865234375,
0.045806884765625,
0.071533203125,
-0.27880859375,
-0.41943359375,
-0.04400634765625,
-0.8857421875,
0.2841796875,
-0.185302734375,
-0.0736083984375,
-0.51318359375,
-0.48974609375,
0.85791015625,
-0.53076171875,
-0.00977325439453125,
0.298828125,
-0.264404296875,
0.33740234375,
0.517578125,
0.140380859375,
0.1728515625,
0.955078125,
0.72998046875,
0.63623046875,
0.59130859375,
0.2509765625,
0.365234375,
-0.759765625,
0.1826171875,
0.3251953125,
0.01152801513671875,
0.056640625,
-0.1036376953125,
-0.876953125,
0.5654296875,
-0.331787109375,
-0.3291015625,
0.359130859375,
-0.61181640625,
-0.1983642578125,
-0.421142578125,
0.86279296875,
-0.673828125,
0.55517578125,
0.6484375,
-0.289306640625,
-0.5888671875,
1.1982421875,
-0.401123046875,
0.1790771484375,
0.165771484375,
1.1767578125,
0.362060546875,
1.4345703125,
0.484619140625,
-0.090576171875,
0.114501953125,
0.460693359375,
-0.2337646484375,
-0.71533203125,
-0.47265625,
-0.375,
0.200439453125,
-0.86962890625,
-0.469970703125,
-0.373046875,
1.0224609375,
0.08148193359375,
-0.7685546875,
-0.19873046875,
0.0633544921875,
-0.77587890625,
0.19970703125,
0.311767578125,
0.459716796875,
0.07763671875,
-0.204345703125,
-0.037445068359375,
-0.48876953125,
0.1180419921875,
-0.29150390625,
0.3603515625,
-0.60205078125,
-0.5361328125,
-0.30029296875,
-1.0400390625,
-0.669921875,
0.1705322265625,
-0.1593017578125,
-0.830078125,
0.6201171875,
0.75390625,
0.1885986328125,
0.310791015625,
-0.48095703125,
0.386962890625,
0.95166015625,
1.28515625,
-0.09161376953125,
0.78955078125,
0.415283203125,
-0.300048828125,
0.1549072265625,
-0.431640625,
0.57666015625,
0.06610107421875,
0.52783203125,
-0.33984375,
0.6826171875,
-0.6015625,
-1.1650390625,
0.11773681640625,
0.44384765625,
0.67578125,
-0.91259765625,
-1.2861328125,
-0.1861572265625,
-1.017578125,
-0.151611328125,
-0.44775390625,
0.83935546875,
-0.29443359375,
0.1649169921875,
0.05267333984375,
-1.0712890625,
4.3359375,
1.294921875,
1.021484375,
0.35107421875,
0.51708984375,
1.3828125,
0.37841796875,
-0.5771484375,
-0.54736328125,
-0.48583984375,
0.490234375,
-0.281494140625,
0.06439208984375,
0.8671875,
0.2191162109375,
0.62744140625,
-0.5048828125,
0.049957275390625,
-0.301513671875,
-0.83740234375,
-0.8251953125,
0.279541015625,
-0.00595855712890625,
0.2347412109375,
-0.2802734375,
0.19091796875,
0.62255859375,
-0.78271484375,
-0.315673828125,
-0.86572265625,
0.00533294677734375,
-0.580078125,
0.9365234375,
0.0963134765625,
0.19091796875,
0.595703125,
-0.036529541015625,
-0.42041015625,
-0.194091796875,
-0.11126708984375,
-0.1619873046875,
0.3232421875,
0.82666015625,
-0.58251953125,
-0.2149658203125,
0.59326171875,
-0.80810546875,
0.55615234375,
0.4140625,
-1.220703125,
1.0224609375,
-0.259765625,
0.6162109375,
-0.6376953125,
-0.77197265625,
0.0019245147705078125,
-0.06512451171875,
-0.059295654296875,
-0.2191162109375,
0.3798828125,
0.1728515625,
0.294921875,
0.12225341796875,
0.436767578125,
-0.86083984375,
0.52001953125,
-0.08843994140625,
0.364990234375,
-0.67236328125,
-0.11126708984375,
-0.342041015625,
-0.2418212890625,
-0.5,
-0.24169921875,
0.7529296875,
0.2376708984375,
-0.0904541015625,
0.5361328125,
0.64453125,
-0.5068359375,
0.2359619140625,
-0.35791015625,
-0.2493896484375,
-0.466064453125,
0.7509765625,
1.134765625,
-0.4853515625,
-0.10955810546875,
-0.1319580078125,
0.486328125,
0.60791015625,
0.533203125,
-0.1982421875,
-0.270751953125,
-0.32763671875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in any order, any operation may be applied any number of times. The i-th operation is described by a string ai of length two and a string bi of length one. No two of q possible operations have the same string ai.
When Limak has a string s he can perform the i-th operation on s if the first two letters of s match a two-letter string ai. Performing the i-th operation removes first two letters of s and inserts there a string bi. See the notes section for further clarification.
You may note that performing an operation decreases the length of a string s exactly by 1. Also, for some sets of operations there may be a string that cannot be compressed any further, because the first two letters don't match any ai.
Limak wants to start with a string of length n and perform n - 1 operations to finally get a one-letter string "a". In how many ways can he choose the starting string to be able to get "a"? Remember that Limak can use only letters he knows.
Input
The first line contains two integers n and q (2 ≤ n ≤ 6, 1 ≤ q ≤ 36) — the length of the initial string and the number of available operations.
The next q lines describe the possible operations. The i-th of them contains two strings ai and bi (|ai| = 2, |bi| = 1). It's guaranteed that ai ≠ aj for i ≠ j and that all ai and bi consist of only first six lowercase English letters.
Output
Print the number of strings of length n that Limak will be able to transform to string "a" by applying only operations given in the input.
Examples
Input
3 5
ab a
cc c
ca a
ee c
ff d
Output
4
Input
2 8
af e
dc d
cc f
bc b
da b
eb a
bb b
ff c
Output
1
Input
6 2
bb a
ba a
Output
0
Note
In the first sample, we count initial strings of length 3 from which Limak can get a required string "a". There are 4 such strings: "abb", "cab", "cca", "eea". The first one Limak can compress using operation 1 two times (changing "ab" to a single "a"). The first operation would change "abb" to "ab" and the second operation would change "ab" to "a".
Other three strings may be compressed as follows:
* "cab" <image> "ab" <image> "a"
* "cca" <image> "ca" <image> "a"
* "eea" <image> "ca" <image> "a"
In the second sample, the only correct initial string is "eb" because it can be immediately compressed to "a".
Tags: brute force, dfs and similar, dp, strings
Correct Solution:
```
n,k = map(int,input().split())
l = {}
cnt = 0
for i in range(k):
a,b = input().split()
l[a] = b;
if n==2:
print(list(l.values()).count('a'))
exit(0)
def allcombs(s,prefix,l):
global cnt
if l==0:
if (check(prefix)):
cnt+=1
return
for i in s:
allcombs(s,prefix+i,l-1)
def check(s):
while len(s)>1:
yes = False
if s[:2] in l:
s = l[s[:2]] + s[2:]
yes = True
if not yes:
return False
if s=='a':
return True
else:
return False
allcombs(['a','b','c','d','e','f'],"",n)
print(cnt)
```
| 70,297 | [
0.405517578125,
-0.0950927734375,
0.2056884765625,
-0.07342529296875,
-0.63916015625,
-0.362548828125,
-0.0787353515625,
0.19384765625,
0.1724853515625,
0.93212890625,
0.90771484375,
-0.11602783203125,
-0.102783203125,
-0.99609375,
-0.484375,
0.2491455078125,
-0.325927734375,
-0.5732421875,
-0.269775390625,
-0.199951171875,
0.1385498046875,
-0.468994140625,
-1.3232421875,
-0.23779296875,
-0.62939453125,
0.61376953125,
0.60888671875,
0.16357421875,
1.0791015625,
1.0810546875,
-0.231689453125,
-0.48291015625,
0.59619140625,
-1.234375,
-0.1663818359375,
-0.286865234375,
0.7158203125,
-0.66650390625,
-0.34033203125,
-0.59033203125,
0.298583984375,
-0.72509765625,
0.373779296875,
-0.666015625,
-1.1650390625,
-0.047088623046875,
-0.357421875,
-0.56640625,
-0.083740234375,
-0.83447265625,
0.2509765625,
-0.34375,
0.90625,
-0.300537109375,
0.09759521484375,
-0.165283203125,
0.50927734375,
-0.04119873046875,
-0.53857421875,
0.446533203125,
0.06591796875,
0.2802734375,
0.26611328125,
-0.56640625,
-0.2479248046875,
-0.1365966796875,
-0.141845703125,
-0.24609375,
-0.0950927734375,
-0.61572265625,
-0.587890625,
0.12188720703125,
-0.60107421875,
-0.669921875,
-0.2003173828125,
-0.0167388916015625,
0.173828125,
-0.08294677734375,
-0.61865234375,
1.060546875,
0.07183837890625,
1.025390625,
0.73193359375,
0.29443359375,
-0.189697265625,
-0.59423828125,
0.0794677734375,
0.27978515625,
0.0545654296875,
0.163330078125,
-0.265380859375,
0.75439453125,
-1.08203125,
-0.04815673828125,
0.48828125,
0.57861328125,
-0.07940673828125,
0.1142578125,
0.198974609375,
-0.1605224609375,
1.0556640625,
0.426513671875,
-0.1029052734375,
1.1943359375,
-0.5009765625,
0.2861328125,
-0.021881103515625,
0.007091522216796875,
-0.3134765625,
-0.06146240234375,
-0.13525390625,
-0.19091796875,
1.0751953125,
0.1865234375,
-0.2369384765625,
0.76513671875,
0.1746826171875,
0.56298828125,
-0.6376953125,
0.2322998046875,
0.35791015625,
0.41748046875,
0.8408203125,
-0.32861328125,
-0.12432861328125,
-0.1685791015625,
-0.135498046875,
0.654296875,
-0.84326171875,
-0.19677734375,
0.13525390625,
-0.189453125,
-0.161865234375,
0.30908203125,
-0.347412109375,
0.66845703125,
-0.2154541015625,
0.5927734375,
1.107421875,
-0.5634765625,
0.826171875,
-0.0151214599609375,
-0.00812530517578125,
1.49609375,
0.1683349609375,
0.270263671875,
0.7529296875,
0.09686279296875,
-0.74658203125,
0.488525390625,
-0.97607421875,
0.36083984375,
0.348388671875,
0.1275634765625,
-0.377685546875,
0.249267578125,
-0.1817626953125,
0.311279296875,
-0.001735687255859375,
-0.07421875,
-0.20703125,
0.33935546875,
-0.6201171875,
1.0546875,
-0.0732421875,
0.87060546875,
-0.42236328125,
-0.314697265625,
0.0888671875,
-0.071533203125,
0.09637451171875,
-0.2978515625,
-0.322021484375,
0.8203125,
0.374755859375,
1.064453125,
0.94873046875,
-0.0073699951171875,
0.387451171875,
0.390625,
-0.262451171875,
0.486083984375,
0.39794921875,
0.7490234375,
0.228271484375,
0.40380859375,
0.031036376953125,
-0.08441162109375,
-0.1845703125,
-0.28125,
-0.06060791015625,
0.72802734375,
-0.4296875,
-0.148681640625,
0.04595947265625,
0.18603515625,
-0.97314453125,
0.455322265625,
0.0535888671875,
-0.9833984375,
-0.265380859375,
0.74951171875,
-0.453857421875,
0.62841796875,
-0.55419921875,
-0.69970703125,
0.62060546875,
1.1943359375,
0.1446533203125,
0.0263824462890625,
0.79638671875,
0.541015625,
-0.420654296875,
0.334716796875,
-0.232421875,
-0.5244140625,
-0.560546875,
0.73193359375,
0.0509033203125,
-0.09967041015625,
0.168701171875,
0.26025390625,
0.306396484375,
0.70068359375,
-0.37255859375,
-0.028106689453125,
0.80078125,
1.0947265625,
-0.054412841796875,
0.44580078125,
0.156005859375,
0.96484375,
0.505859375,
0.9404296875,
0.638671875,
0.308837890625,
0.64453125,
0.93505859375,
0.015350341796875,
0.0011730194091796875,
0.051300048828125,
0.6611328125,
0.436279296875,
0.67333984375,
0.12286376953125,
0.2100830078125,
-0.2705078125,
0.05712890625,
-0.5966796875,
-0.004596710205078125,
-0.2763671875,
0.77685546875,
0.10687255859375,
0.74755859375,
-0.30859375,
-0.413330078125,
0.3251953125,
0.6484375,
-0.958984375,
-0.44384765625,
-0.376220703125,
-0.135498046875,
0.350341796875,
-0.046966552734375,
0.259521484375,
0.052337646484375,
0.320068359375,
0.1103515625,
-0.2489013671875,
-0.69384765625,
-1.095703125,
-0.98779296875,
-0.7548828125,
-0.51806640625,
-0.62451171875,
0.126953125,
0.179443359375,
-1.1728515625,
0.53564453125,
-0.54638671875,
-0.2427978515625,
-0.020721435546875,
-0.85107421875,
0.5537109375,
-0.227294921875,
0.470947265625,
-0.452392578125,
0.368408203125,
0.299560546875,
1.306640625,
-0.162353515625,
0.1776123046875,
-0.0751953125,
-0.63623046875,
0.27880859375,
-0.272216796875,
0.57861328125,
-0.1357421875,
-0.734375,
-0.587890625,
-0.340087890625,
-0.08221435546875,
-0.56884765625,
0.373779296875,
-0.412841796875,
0.5791015625,
0.36669921875,
-1.0576171875,
0.685546875,
1.1533203125,
-0.5458984375,
0.6748046875,
-0.362548828125,
0.0278472900390625,
-0.79345703125,
1.18359375,
0.255859375,
0.414794921875,
-0.321044921875,
-0.8623046875,
-0.3818359375,
-0.18798828125,
0.06793212890625,
-0.302734375,
-0.0772705078125,
0.63232421875,
-0.381103515625,
-0.7587890625,
0.6376953125,
-1.013671875,
-0.322265625,
-0.7998046875,
-0.63134765625,
0.78955078125,
0.68896484375,
0.1461181640625,
0.0021762847900390625,
-0.144287109375,
-0.143798828125,
0.9814453125,
0.2269287109375,
-0.630859375,
0.07647705078125,
0.5078125,
0.031463623046875,
0.0125885009765625,
0.54443359375,
-0.55517578125,
-0.3798828125,
0.06890869140625,
-0.03436279296875,
0.71337890625,
0.2376708984375,
0.57666015625,
0.57958984375,
0.6220703125,
-1.0087890625,
-0.1505126953125,
-0.43505859375,
0.413818359375,
0.425537109375,
0.23193359375,
0.416015625,
-0.464111328125,
-0.5234375,
-0.90234375,
0.40966796875,
0.1962890625,
0.428955078125,
-0.6708984375,
0.9072265625,
0.05267333984375,
-0.39404296875,
0.380859375,
-0.501953125,
-0.1041259765625,
0.8896484375,
-0.395751953125,
0.724609375,
-0.6806640625,
0.63916015625,
-0.1055908203125,
-0.1796875,
0.84228515625,
0.286376953125,
0.452880859375,
-0.544921875,
-0.304443359375,
-0.505859375,
-0.28466796875,
0.2548828125,
-0.5478515625,
0.10748291015625,
-0.72509765625,
-0.29638671875,
-0.91357421875,
0.54296875,
0.36474609375,
0.7578125,
-0.067626953125,
0.494140625,
0.06512451171875,
0.71484375,
0.69091796875,
-0.2352294921875,
-0.05438232421875,
-0.456787109375,
0.87646484375,
0.243896484375,
-0.281982421875,
-0.54248046875,
-0.1630859375,
-0.458984375,
0.39599609375,
-0.0374755859375,
-0.08685302734375,
-0.9150390625,
0.42333984375,
0.1990966796875,
0.7001953125,
-0.463134765625,
-0.52490234375,
-0.359619140625,
0.361328125,
0.59619140625,
-1.2021484375,
0.00028061866760253906,
-0.677734375,
0.87451171875,
0.43994140625,
-0.2332763671875,
-0.4267578125,
-0.62109375,
-0.6171875,
-0.453857421875,
-0.0782470703125,
0.71142578125,
0.314208984375,
0.412353515625,
-0.99267578125,
0.32666015625,
0.301513671875,
-0.2119140625,
0.04052734375,
-0.16796875,
0.22021484375,
-0.1436767578125,
0.74951171875,
-0.339599609375,
-0.71728515625,
0.021636962890625,
-1.302734375,
0.2880859375,
-0.68359375,
0.339599609375,
0.046966552734375,
-0.478759765625,
-0.302001953125,
0.329833984375,
-0.430419921875,
-0.0377197265625,
0.06964111328125,
0.68408203125,
-1.0576171875,
-0.998046875,
0.5517578125,
-0.2393798828125,
-0.493408203125,
1.19140625,
0.0958251953125,
-0.544921875,
0.02545166015625,
0.240966796875,
-0.37939453125,
0.54833984375,
-1.0693359375,
0.63818359375,
-0.447265625,
-0.34423828125,
-0.449951171875,
-0.56201171875,
0.412109375,
-0.0860595703125,
-0.52880859375,
-0.496826171875,
-1.326171875,
-0.159423828125,
-0.036376953125,
-0.5517578125,
0.44921875,
-0.054656982421875,
0.167724609375,
-0.057586669921875,
-0.47998046875,
-0.177734375,
-0.607421875,
-0.47314453125,
-0.39111328125,
0.53759765625,
0.53857421875,
0.7998046875,
-0.043365478515625,
-0.333740234375,
0.028564453125,
-0.0970458984375,
0.09515380859375,
-0.1522216796875,
-0.2105712890625,
0.0237579345703125,
-0.12164306640625,
-0.135009765625,
0.314208984375,
-0.181640625,
0.09552001953125,
0.485595703125,
0.054412841796875,
0.66015625,
0.228759765625,
-0.72802734375,
1.31640625,
0.189453125,
-1.0390625,
-0.216796875,
0.90478515625,
-0.127197265625,
0.3427734375,
0.31591796875,
-1.015625,
-0.86279296875,
-0.74072265625,
0.489501953125,
-0.72314453125,
-0.396728515625,
-1.2158203125,
-0.377685546875,
-0.54931640625,
0.708984375,
-0.032806396484375,
-0.42138671875,
0.42236328125,
-1.046875,
0.3681640625,
-0.60205078125,
-0.67626953125,
-0.56787109375,
-0.68310546875,
-0.091064453125,
1.146484375,
0.077880859375,
0.2498779296875,
0.2607421875,
-0.265869140625,
0.58984375,
0.24169921875,
-0.94775390625,
-0.32470703125,
-0.1446533203125,
0.429443359375,
-0.09375,
0.0261383056640625,
-0.394287109375,
0.4072265625,
-0.77099609375,
0.333740234375,
-0.264404296875,
-0.34619140625,
-0.35400390625,
-0.41064453125,
1.1650390625,
-0.61572265625,
0.062286376953125,
-0.2294921875,
0.6962890625,
0.92919921875,
-0.02581787109375,
-0.42333984375,
-0.88623046875,
-1.052734375,
-0.9443359375,
0.63232421875,
-0.402587890625,
0.0018777847290039062,
-0.471435546875,
0.031982421875,
0.8291015625,
-0.164306640625,
0.5830078125,
0.869140625,
0.10345458984375,
-0.0958251953125,
-0.61474609375,
0.7099609375,
0.41552734375,
-0.4951171875,
-0.302001953125,
0.372314453125,
-0.603515625,
0.311767578125,
-0.422607421875,
-1.2119140625,
-0.80029296875,
0.337158203125,
1.3984375,
-0.243408203125,
0.900390625,
-0.059844970703125,
-0.88916015625,
-0.43017578125,
0.66357421875,
0.12139892578125,
0.327392578125,
0.78125,
-0.1126708984375,
-0.329833984375,
0.10894775390625,
-0.373046875,
-0.109130859375,
-0.62548828125,
1.23046875,
-0.6357421875,
-0.625,
0.453125,
0.99365234375,
-0.90869140625,
-1.302734375,
-0.2376708984375,
-0.3125,
-0.434326171875,
-0.86767578125,
-0.129638671875,
0.266357421875,
-0.2474365234375,
0.10369873046875,
0.31787109375,
-0.065185546875,
0.55712890625,
0.1260986328125,
0.5234375,
-0.1416015625,
0.4521484375,
0.69580078125,
-0.51171875,
-0.642578125,
-1.03125,
-0.048614501953125,
-0.361328125,
0.2294921875,
0.59814453125,
-0.2142333984375,
0.50537109375,
0.5419921875,
-0.15966796875,
0.77099609375,
-0.38818359375,
-0.462158203125,
0.2237548828125,
-1.134765625,
-0.451904296875,
0.026519775390625,
0.54345703125,
-0.47265625,
0.292236328125,
-0.79833984375,
-0.537109375,
0.343505859375,
0.54052734375,
-0.36767578125,
-1.0625,
-0.12274169921875,
-1.2109375,
-0.62841796875,
-0.58642578125,
-0.75439453125,
-0.1837158203125,
-0.1953125,
0.01244354248046875,
-0.7890625,
-0.08221435546875,
0.283203125,
-0.505859375,
0.8330078125,
-0.556640625,
0.54638671875,
-0.669921875,
-0.11895751953125,
-0.64501953125,
0.14404296875,
-0.54150390625,
-0.1407470703125,
-0.320068359375,
0.328125,
-0.17724609375,
0.56591796875,
-0.3173828125,
0.309326171875,
-0.2088623046875,
-0.40478515625,
-0.100341796875,
0.1590576171875,
-0.2288818359375,
0.673828125,
0.5224609375,
-0.2587890625,
0.333740234375,
-0.11639404296875,
-0.1492919921875,
-0.252685546875,
0.90380859375,
0.16015625,
-0.040679931640625,
-0.1749267578125,
-0.2362060546875,
0.371826171875,
-0.96826171875,
0.30810546875,
-0.141357421875,
0.533203125,
0.0002970695495605469,
-0.237548828125,
0.3564453125,
1.0888671875,
-0.119140625,
0.006641387939453125,
0.2333984375,
0.145263671875,
0.1314697265625,
0.1522216796875,
-0.0233612060546875,
0.484375,
-0.1982421875,
-0.343017578125,
-0.1400146484375,
0.3291015625,
0.06268310546875,
0.409912109375,
-0.1524658203125,
-0.76513671875,
-0.65673828125,
-0.288330078125,
-0.047698974609375,
0.51708984375,
0.5400390625,
-0.60009765625,
0.0209503173828125,
0.0628662109375,
-0.7783203125,
0.0950927734375,
-1.0166015625,
-1.0859375,
0.00504302978515625,
0.07574462890625,
-0.73974609375,
-0.10162353515625,
-0.48046875,
-0.200439453125,
0.01421356201171875,
0.2183837890625,
-0.89013671875,
0.3251953125,
0.0029048919677734375,
0.58203125,
-0.2322998046875,
-0.0160064697265625,
-0.017822265625,
0.353759765625,
-0.6044921875,
-0.2303466796875,
-0.348876953125,
0.5888671875,
0.27880859375,
-0.2353515625,
-0.22998046875,
0.1783447265625,
0.2152099609375,
0.207275390625,
-0.55908203125,
0.250732421875,
-0.0775146484375,
0.88818359375,
-0.77587890625,
-0.204345703125,
-0.396240234375,
0.272705078125,
0.10394287109375,
-0.53759765625,
-0.8154296875,
1.2626953125,
0.76513671875,
-0.1380615234375,
0.303466796875,
0.163330078125,
0.43994140625,
-0.304931640625,
0.11297607421875,
-0.48095703125,
0.8603515625,
0.443359375,
0.59326171875,
-0.1422119140625,
0.285400390625,
0.51806640625,
-0.06134033203125,
-0.57470703125,
0.380126953125,
0.286865234375,
0.045806884765625,
0.071533203125,
-0.27880859375,
-0.41943359375,
-0.04400634765625,
-0.8857421875,
0.2841796875,
-0.185302734375,
-0.0736083984375,
-0.51318359375,
-0.48974609375,
0.85791015625,
-0.53076171875,
-0.00977325439453125,
0.298828125,
-0.264404296875,
0.33740234375,
0.517578125,
0.140380859375,
0.1728515625,
0.955078125,
0.72998046875,
0.63623046875,
0.59130859375,
0.2509765625,
0.365234375,
-0.759765625,
0.1826171875,
0.3251953125,
0.01152801513671875,
0.056640625,
-0.1036376953125,
-0.876953125,
0.5654296875,
-0.331787109375,
-0.3291015625,
0.359130859375,
-0.61181640625,
-0.1983642578125,
-0.421142578125,
0.86279296875,
-0.673828125,
0.55517578125,
0.6484375,
-0.289306640625,
-0.5888671875,
1.1982421875,
-0.401123046875,
0.1790771484375,
0.165771484375,
1.1767578125,
0.362060546875,
1.4345703125,
0.484619140625,
-0.090576171875,
0.114501953125,
0.460693359375,
-0.2337646484375,
-0.71533203125,
-0.47265625,
-0.375,
0.200439453125,
-0.86962890625,
-0.469970703125,
-0.373046875,
1.0224609375,
0.08148193359375,
-0.7685546875,
-0.19873046875,
0.0633544921875,
-0.77587890625,
0.19970703125,
0.311767578125,
0.459716796875,
0.07763671875,
-0.204345703125,
-0.037445068359375,
-0.48876953125,
0.1180419921875,
-0.29150390625,
0.3603515625,
-0.60205078125,
-0.5361328125,
-0.30029296875,
-1.0400390625,
-0.669921875,
0.1705322265625,
-0.1593017578125,
-0.830078125,
0.6201171875,
0.75390625,
0.1885986328125,
0.310791015625,
-0.48095703125,
0.386962890625,
0.95166015625,
1.28515625,
-0.09161376953125,
0.78955078125,
0.415283203125,
-0.300048828125,
0.1549072265625,
-0.431640625,
0.57666015625,
0.06610107421875,
0.52783203125,
-0.33984375,
0.6826171875,
-0.6015625,
-1.1650390625,
0.11773681640625,
0.44384765625,
0.67578125,
-0.91259765625,
-1.2861328125,
-0.1861572265625,
-1.017578125,
-0.151611328125,
-0.44775390625,
0.83935546875,
-0.29443359375,
0.1649169921875,
0.05267333984375,
-1.0712890625,
4.3359375,
1.294921875,
1.021484375,
0.35107421875,
0.51708984375,
1.3828125,
0.37841796875,
-0.5771484375,
-0.54736328125,
-0.48583984375,
0.490234375,
-0.281494140625,
0.06439208984375,
0.8671875,
0.2191162109375,
0.62744140625,
-0.5048828125,
0.049957275390625,
-0.301513671875,
-0.83740234375,
-0.8251953125,
0.279541015625,
-0.00595855712890625,
0.2347412109375,
-0.2802734375,
0.19091796875,
0.62255859375,
-0.78271484375,
-0.315673828125,
-0.86572265625,
0.00533294677734375,
-0.580078125,
0.9365234375,
0.0963134765625,
0.19091796875,
0.595703125,
-0.036529541015625,
-0.42041015625,
-0.194091796875,
-0.11126708984375,
-0.1619873046875,
0.3232421875,
0.82666015625,
-0.58251953125,
-0.2149658203125,
0.59326171875,
-0.80810546875,
0.55615234375,
0.4140625,
-1.220703125,
1.0224609375,
-0.259765625,
0.6162109375,
-0.6376953125,
-0.77197265625,
0.0019245147705078125,
-0.06512451171875,
-0.059295654296875,
-0.2191162109375,
0.3798828125,
0.1728515625,
0.294921875,
0.12225341796875,
0.436767578125,
-0.86083984375,
0.52001953125,
-0.08843994140625,
0.364990234375,
-0.67236328125,
-0.11126708984375,
-0.342041015625,
-0.2418212890625,
-0.5,
-0.24169921875,
0.7529296875,
0.2376708984375,
-0.0904541015625,
0.5361328125,
0.64453125,
-0.5068359375,
0.2359619140625,
-0.35791015625,
-0.2493896484375,
-0.466064453125,
0.7509765625,
1.134765625,
-0.4853515625,
-0.10955810546875,
-0.1319580078125,
0.486328125,
0.60791015625,
0.533203125,
-0.1982421875,
-0.270751953125,
-0.32763671875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in any order, any operation may be applied any number of times. The i-th operation is described by a string ai of length two and a string bi of length one. No two of q possible operations have the same string ai.
When Limak has a string s he can perform the i-th operation on s if the first two letters of s match a two-letter string ai. Performing the i-th operation removes first two letters of s and inserts there a string bi. See the notes section for further clarification.
You may note that performing an operation decreases the length of a string s exactly by 1. Also, for some sets of operations there may be a string that cannot be compressed any further, because the first two letters don't match any ai.
Limak wants to start with a string of length n and perform n - 1 operations to finally get a one-letter string "a". In how many ways can he choose the starting string to be able to get "a"? Remember that Limak can use only letters he knows.
Input
The first line contains two integers n and q (2 ≤ n ≤ 6, 1 ≤ q ≤ 36) — the length of the initial string and the number of available operations.
The next q lines describe the possible operations. The i-th of them contains two strings ai and bi (|ai| = 2, |bi| = 1). It's guaranteed that ai ≠ aj for i ≠ j and that all ai and bi consist of only first six lowercase English letters.
Output
Print the number of strings of length n that Limak will be able to transform to string "a" by applying only operations given in the input.
Examples
Input
3 5
ab a
cc c
ca a
ee c
ff d
Output
4
Input
2 8
af e
dc d
cc f
bc b
da b
eb a
bb b
ff c
Output
1
Input
6 2
bb a
ba a
Output
0
Note
In the first sample, we count initial strings of length 3 from which Limak can get a required string "a". There are 4 such strings: "abb", "cab", "cca", "eea". The first one Limak can compress using operation 1 two times (changing "ab" to a single "a"). The first operation would change "abb" to "ab" and the second operation would change "ab" to "a".
Other three strings may be compressed as follows:
* "cab" <image> "ab" <image> "a"
* "cca" <image> "ca" <image> "a"
* "eea" <image> "ca" <image> "a"
In the second sample, the only correct initial string is "eb" because it can be immediately compressed to "a".
Tags: brute force, dfs and similar, dp, strings
Correct Solution:
```
n,q=map(int,input().split())
d={}
ch=set()
ans=set()
for i in range(q):
a,b=input().split()
d.setdefault(b,set()).add(a)
ch={"a"}
while ch!=set():
b=ch.pop()
if len(b)==n: ans.add(b); continue
for a in d.setdefault(b[0],set()):
ch.add(''.join((a,b[1:])))
print(len(ans))
```
| 70,298 | [
0.405517578125,
-0.0950927734375,
0.2056884765625,
-0.07342529296875,
-0.63916015625,
-0.362548828125,
-0.0787353515625,
0.19384765625,
0.1724853515625,
0.93212890625,
0.90771484375,
-0.11602783203125,
-0.102783203125,
-0.99609375,
-0.484375,
0.2491455078125,
-0.325927734375,
-0.5732421875,
-0.269775390625,
-0.199951171875,
0.1385498046875,
-0.468994140625,
-1.3232421875,
-0.23779296875,
-0.62939453125,
0.61376953125,
0.60888671875,
0.16357421875,
1.0791015625,
1.0810546875,
-0.231689453125,
-0.48291015625,
0.59619140625,
-1.234375,
-0.1663818359375,
-0.286865234375,
0.7158203125,
-0.66650390625,
-0.34033203125,
-0.59033203125,
0.298583984375,
-0.72509765625,
0.373779296875,
-0.666015625,
-1.1650390625,
-0.047088623046875,
-0.357421875,
-0.56640625,
-0.083740234375,
-0.83447265625,
0.2509765625,
-0.34375,
0.90625,
-0.300537109375,
0.09759521484375,
-0.165283203125,
0.50927734375,
-0.04119873046875,
-0.53857421875,
0.446533203125,
0.06591796875,
0.2802734375,
0.26611328125,
-0.56640625,
-0.2479248046875,
-0.1365966796875,
-0.141845703125,
-0.24609375,
-0.0950927734375,
-0.61572265625,
-0.587890625,
0.12188720703125,
-0.60107421875,
-0.669921875,
-0.2003173828125,
-0.0167388916015625,
0.173828125,
-0.08294677734375,
-0.61865234375,
1.060546875,
0.07183837890625,
1.025390625,
0.73193359375,
0.29443359375,
-0.189697265625,
-0.59423828125,
0.0794677734375,
0.27978515625,
0.0545654296875,
0.163330078125,
-0.265380859375,
0.75439453125,
-1.08203125,
-0.04815673828125,
0.48828125,
0.57861328125,
-0.07940673828125,
0.1142578125,
0.198974609375,
-0.1605224609375,
1.0556640625,
0.426513671875,
-0.1029052734375,
1.1943359375,
-0.5009765625,
0.2861328125,
-0.021881103515625,
0.007091522216796875,
-0.3134765625,
-0.06146240234375,
-0.13525390625,
-0.19091796875,
1.0751953125,
0.1865234375,
-0.2369384765625,
0.76513671875,
0.1746826171875,
0.56298828125,
-0.6376953125,
0.2322998046875,
0.35791015625,
0.41748046875,
0.8408203125,
-0.32861328125,
-0.12432861328125,
-0.1685791015625,
-0.135498046875,
0.654296875,
-0.84326171875,
-0.19677734375,
0.13525390625,
-0.189453125,
-0.161865234375,
0.30908203125,
-0.347412109375,
0.66845703125,
-0.2154541015625,
0.5927734375,
1.107421875,
-0.5634765625,
0.826171875,
-0.0151214599609375,
-0.00812530517578125,
1.49609375,
0.1683349609375,
0.270263671875,
0.7529296875,
0.09686279296875,
-0.74658203125,
0.488525390625,
-0.97607421875,
0.36083984375,
0.348388671875,
0.1275634765625,
-0.377685546875,
0.249267578125,
-0.1817626953125,
0.311279296875,
-0.001735687255859375,
-0.07421875,
-0.20703125,
0.33935546875,
-0.6201171875,
1.0546875,
-0.0732421875,
0.87060546875,
-0.42236328125,
-0.314697265625,
0.0888671875,
-0.071533203125,
0.09637451171875,
-0.2978515625,
-0.322021484375,
0.8203125,
0.374755859375,
1.064453125,
0.94873046875,
-0.0073699951171875,
0.387451171875,
0.390625,
-0.262451171875,
0.486083984375,
0.39794921875,
0.7490234375,
0.228271484375,
0.40380859375,
0.031036376953125,
-0.08441162109375,
-0.1845703125,
-0.28125,
-0.06060791015625,
0.72802734375,
-0.4296875,
-0.148681640625,
0.04595947265625,
0.18603515625,
-0.97314453125,
0.455322265625,
0.0535888671875,
-0.9833984375,
-0.265380859375,
0.74951171875,
-0.453857421875,
0.62841796875,
-0.55419921875,
-0.69970703125,
0.62060546875,
1.1943359375,
0.1446533203125,
0.0263824462890625,
0.79638671875,
0.541015625,
-0.420654296875,
0.334716796875,
-0.232421875,
-0.5244140625,
-0.560546875,
0.73193359375,
0.0509033203125,
-0.09967041015625,
0.168701171875,
0.26025390625,
0.306396484375,
0.70068359375,
-0.37255859375,
-0.028106689453125,
0.80078125,
1.0947265625,
-0.054412841796875,
0.44580078125,
0.156005859375,
0.96484375,
0.505859375,
0.9404296875,
0.638671875,
0.308837890625,
0.64453125,
0.93505859375,
0.015350341796875,
0.0011730194091796875,
0.051300048828125,
0.6611328125,
0.436279296875,
0.67333984375,
0.12286376953125,
0.2100830078125,
-0.2705078125,
0.05712890625,
-0.5966796875,
-0.004596710205078125,
-0.2763671875,
0.77685546875,
0.10687255859375,
0.74755859375,
-0.30859375,
-0.413330078125,
0.3251953125,
0.6484375,
-0.958984375,
-0.44384765625,
-0.376220703125,
-0.135498046875,
0.350341796875,
-0.046966552734375,
0.259521484375,
0.052337646484375,
0.320068359375,
0.1103515625,
-0.2489013671875,
-0.69384765625,
-1.095703125,
-0.98779296875,
-0.7548828125,
-0.51806640625,
-0.62451171875,
0.126953125,
0.179443359375,
-1.1728515625,
0.53564453125,
-0.54638671875,
-0.2427978515625,
-0.020721435546875,
-0.85107421875,
0.5537109375,
-0.227294921875,
0.470947265625,
-0.452392578125,
0.368408203125,
0.299560546875,
1.306640625,
-0.162353515625,
0.1776123046875,
-0.0751953125,
-0.63623046875,
0.27880859375,
-0.272216796875,
0.57861328125,
-0.1357421875,
-0.734375,
-0.587890625,
-0.340087890625,
-0.08221435546875,
-0.56884765625,
0.373779296875,
-0.412841796875,
0.5791015625,
0.36669921875,
-1.0576171875,
0.685546875,
1.1533203125,
-0.5458984375,
0.6748046875,
-0.362548828125,
0.0278472900390625,
-0.79345703125,
1.18359375,
0.255859375,
0.414794921875,
-0.321044921875,
-0.8623046875,
-0.3818359375,
-0.18798828125,
0.06793212890625,
-0.302734375,
-0.0772705078125,
0.63232421875,
-0.381103515625,
-0.7587890625,
0.6376953125,
-1.013671875,
-0.322265625,
-0.7998046875,
-0.63134765625,
0.78955078125,
0.68896484375,
0.1461181640625,
0.0021762847900390625,
-0.144287109375,
-0.143798828125,
0.9814453125,
0.2269287109375,
-0.630859375,
0.07647705078125,
0.5078125,
0.031463623046875,
0.0125885009765625,
0.54443359375,
-0.55517578125,
-0.3798828125,
0.06890869140625,
-0.03436279296875,
0.71337890625,
0.2376708984375,
0.57666015625,
0.57958984375,
0.6220703125,
-1.0087890625,
-0.1505126953125,
-0.43505859375,
0.413818359375,
0.425537109375,
0.23193359375,
0.416015625,
-0.464111328125,
-0.5234375,
-0.90234375,
0.40966796875,
0.1962890625,
0.428955078125,
-0.6708984375,
0.9072265625,
0.05267333984375,
-0.39404296875,
0.380859375,
-0.501953125,
-0.1041259765625,
0.8896484375,
-0.395751953125,
0.724609375,
-0.6806640625,
0.63916015625,
-0.1055908203125,
-0.1796875,
0.84228515625,
0.286376953125,
0.452880859375,
-0.544921875,
-0.304443359375,
-0.505859375,
-0.28466796875,
0.2548828125,
-0.5478515625,
0.10748291015625,
-0.72509765625,
-0.29638671875,
-0.91357421875,
0.54296875,
0.36474609375,
0.7578125,
-0.067626953125,
0.494140625,
0.06512451171875,
0.71484375,
0.69091796875,
-0.2352294921875,
-0.05438232421875,
-0.456787109375,
0.87646484375,
0.243896484375,
-0.281982421875,
-0.54248046875,
-0.1630859375,
-0.458984375,
0.39599609375,
-0.0374755859375,
-0.08685302734375,
-0.9150390625,
0.42333984375,
0.1990966796875,
0.7001953125,
-0.463134765625,
-0.52490234375,
-0.359619140625,
0.361328125,
0.59619140625,
-1.2021484375,
0.00028061866760253906,
-0.677734375,
0.87451171875,
0.43994140625,
-0.2332763671875,
-0.4267578125,
-0.62109375,
-0.6171875,
-0.453857421875,
-0.0782470703125,
0.71142578125,
0.314208984375,
0.412353515625,
-0.99267578125,
0.32666015625,
0.301513671875,
-0.2119140625,
0.04052734375,
-0.16796875,
0.22021484375,
-0.1436767578125,
0.74951171875,
-0.339599609375,
-0.71728515625,
0.021636962890625,
-1.302734375,
0.2880859375,
-0.68359375,
0.339599609375,
0.046966552734375,
-0.478759765625,
-0.302001953125,
0.329833984375,
-0.430419921875,
-0.0377197265625,
0.06964111328125,
0.68408203125,
-1.0576171875,
-0.998046875,
0.5517578125,
-0.2393798828125,
-0.493408203125,
1.19140625,
0.0958251953125,
-0.544921875,
0.02545166015625,
0.240966796875,
-0.37939453125,
0.54833984375,
-1.0693359375,
0.63818359375,
-0.447265625,
-0.34423828125,
-0.449951171875,
-0.56201171875,
0.412109375,
-0.0860595703125,
-0.52880859375,
-0.496826171875,
-1.326171875,
-0.159423828125,
-0.036376953125,
-0.5517578125,
0.44921875,
-0.054656982421875,
0.167724609375,
-0.057586669921875,
-0.47998046875,
-0.177734375,
-0.607421875,
-0.47314453125,
-0.39111328125,
0.53759765625,
0.53857421875,
0.7998046875,
-0.043365478515625,
-0.333740234375,
0.028564453125,
-0.0970458984375,
0.09515380859375,
-0.1522216796875,
-0.2105712890625,
0.0237579345703125,
-0.12164306640625,
-0.135009765625,
0.314208984375,
-0.181640625,
0.09552001953125,
0.485595703125,
0.054412841796875,
0.66015625,
0.228759765625,
-0.72802734375,
1.31640625,
0.189453125,
-1.0390625,
-0.216796875,
0.90478515625,
-0.127197265625,
0.3427734375,
0.31591796875,
-1.015625,
-0.86279296875,
-0.74072265625,
0.489501953125,
-0.72314453125,
-0.396728515625,
-1.2158203125,
-0.377685546875,
-0.54931640625,
0.708984375,
-0.032806396484375,
-0.42138671875,
0.42236328125,
-1.046875,
0.3681640625,
-0.60205078125,
-0.67626953125,
-0.56787109375,
-0.68310546875,
-0.091064453125,
1.146484375,
0.077880859375,
0.2498779296875,
0.2607421875,
-0.265869140625,
0.58984375,
0.24169921875,
-0.94775390625,
-0.32470703125,
-0.1446533203125,
0.429443359375,
-0.09375,
0.0261383056640625,
-0.394287109375,
0.4072265625,
-0.77099609375,
0.333740234375,
-0.264404296875,
-0.34619140625,
-0.35400390625,
-0.41064453125,
1.1650390625,
-0.61572265625,
0.062286376953125,
-0.2294921875,
0.6962890625,
0.92919921875,
-0.02581787109375,
-0.42333984375,
-0.88623046875,
-1.052734375,
-0.9443359375,
0.63232421875,
-0.402587890625,
0.0018777847290039062,
-0.471435546875,
0.031982421875,
0.8291015625,
-0.164306640625,
0.5830078125,
0.869140625,
0.10345458984375,
-0.0958251953125,
-0.61474609375,
0.7099609375,
0.41552734375,
-0.4951171875,
-0.302001953125,
0.372314453125,
-0.603515625,
0.311767578125,
-0.422607421875,
-1.2119140625,
-0.80029296875,
0.337158203125,
1.3984375,
-0.243408203125,
0.900390625,
-0.059844970703125,
-0.88916015625,
-0.43017578125,
0.66357421875,
0.12139892578125,
0.327392578125,
0.78125,
-0.1126708984375,
-0.329833984375,
0.10894775390625,
-0.373046875,
-0.109130859375,
-0.62548828125,
1.23046875,
-0.6357421875,
-0.625,
0.453125,
0.99365234375,
-0.90869140625,
-1.302734375,
-0.2376708984375,
-0.3125,
-0.434326171875,
-0.86767578125,
-0.129638671875,
0.266357421875,
-0.2474365234375,
0.10369873046875,
0.31787109375,
-0.065185546875,
0.55712890625,
0.1260986328125,
0.5234375,
-0.1416015625,
0.4521484375,
0.69580078125,
-0.51171875,
-0.642578125,
-1.03125,
-0.048614501953125,
-0.361328125,
0.2294921875,
0.59814453125,
-0.2142333984375,
0.50537109375,
0.5419921875,
-0.15966796875,
0.77099609375,
-0.38818359375,
-0.462158203125,
0.2237548828125,
-1.134765625,
-0.451904296875,
0.026519775390625,
0.54345703125,
-0.47265625,
0.292236328125,
-0.79833984375,
-0.537109375,
0.343505859375,
0.54052734375,
-0.36767578125,
-1.0625,
-0.12274169921875,
-1.2109375,
-0.62841796875,
-0.58642578125,
-0.75439453125,
-0.1837158203125,
-0.1953125,
0.01244354248046875,
-0.7890625,
-0.08221435546875,
0.283203125,
-0.505859375,
0.8330078125,
-0.556640625,
0.54638671875,
-0.669921875,
-0.11895751953125,
-0.64501953125,
0.14404296875,
-0.54150390625,
-0.1407470703125,
-0.320068359375,
0.328125,
-0.17724609375,
0.56591796875,
-0.3173828125,
0.309326171875,
-0.2088623046875,
-0.40478515625,
-0.100341796875,
0.1590576171875,
-0.2288818359375,
0.673828125,
0.5224609375,
-0.2587890625,
0.333740234375,
-0.11639404296875,
-0.1492919921875,
-0.252685546875,
0.90380859375,
0.16015625,
-0.040679931640625,
-0.1749267578125,
-0.2362060546875,
0.371826171875,
-0.96826171875,
0.30810546875,
-0.141357421875,
0.533203125,
0.0002970695495605469,
-0.237548828125,
0.3564453125,
1.0888671875,
-0.119140625,
0.006641387939453125,
0.2333984375,
0.145263671875,
0.1314697265625,
0.1522216796875,
-0.0233612060546875,
0.484375,
-0.1982421875,
-0.343017578125,
-0.1400146484375,
0.3291015625,
0.06268310546875,
0.409912109375,
-0.1524658203125,
-0.76513671875,
-0.65673828125,
-0.288330078125,
-0.047698974609375,
0.51708984375,
0.5400390625,
-0.60009765625,
0.0209503173828125,
0.0628662109375,
-0.7783203125,
0.0950927734375,
-1.0166015625,
-1.0859375,
0.00504302978515625,
0.07574462890625,
-0.73974609375,
-0.10162353515625,
-0.48046875,
-0.200439453125,
0.01421356201171875,
0.2183837890625,
-0.89013671875,
0.3251953125,
0.0029048919677734375,
0.58203125,
-0.2322998046875,
-0.0160064697265625,
-0.017822265625,
0.353759765625,
-0.6044921875,
-0.2303466796875,
-0.348876953125,
0.5888671875,
0.27880859375,
-0.2353515625,
-0.22998046875,
0.1783447265625,
0.2152099609375,
0.207275390625,
-0.55908203125,
0.250732421875,
-0.0775146484375,
0.88818359375,
-0.77587890625,
-0.204345703125,
-0.396240234375,
0.272705078125,
0.10394287109375,
-0.53759765625,
-0.8154296875,
1.2626953125,
0.76513671875,
-0.1380615234375,
0.303466796875,
0.163330078125,
0.43994140625,
-0.304931640625,
0.11297607421875,
-0.48095703125,
0.8603515625,
0.443359375,
0.59326171875,
-0.1422119140625,
0.285400390625,
0.51806640625,
-0.06134033203125,
-0.57470703125,
0.380126953125,
0.286865234375,
0.045806884765625,
0.071533203125,
-0.27880859375,
-0.41943359375,
-0.04400634765625,
-0.8857421875,
0.2841796875,
-0.185302734375,
-0.0736083984375,
-0.51318359375,
-0.48974609375,
0.85791015625,
-0.53076171875,
-0.00977325439453125,
0.298828125,
-0.264404296875,
0.33740234375,
0.517578125,
0.140380859375,
0.1728515625,
0.955078125,
0.72998046875,
0.63623046875,
0.59130859375,
0.2509765625,
0.365234375,
-0.759765625,
0.1826171875,
0.3251953125,
0.01152801513671875,
0.056640625,
-0.1036376953125,
-0.876953125,
0.5654296875,
-0.331787109375,
-0.3291015625,
0.359130859375,
-0.61181640625,
-0.1983642578125,
-0.421142578125,
0.86279296875,
-0.673828125,
0.55517578125,
0.6484375,
-0.289306640625,
-0.5888671875,
1.1982421875,
-0.401123046875,
0.1790771484375,
0.165771484375,
1.1767578125,
0.362060546875,
1.4345703125,
0.484619140625,
-0.090576171875,
0.114501953125,
0.460693359375,
-0.2337646484375,
-0.71533203125,
-0.47265625,
-0.375,
0.200439453125,
-0.86962890625,
-0.469970703125,
-0.373046875,
1.0224609375,
0.08148193359375,
-0.7685546875,
-0.19873046875,
0.0633544921875,
-0.77587890625,
0.19970703125,
0.311767578125,
0.459716796875,
0.07763671875,
-0.204345703125,
-0.037445068359375,
-0.48876953125,
0.1180419921875,
-0.29150390625,
0.3603515625,
-0.60205078125,
-0.5361328125,
-0.30029296875,
-1.0400390625,
-0.669921875,
0.1705322265625,
-0.1593017578125,
-0.830078125,
0.6201171875,
0.75390625,
0.1885986328125,
0.310791015625,
-0.48095703125,
0.386962890625,
0.95166015625,
1.28515625,
-0.09161376953125,
0.78955078125,
0.415283203125,
-0.300048828125,
0.1549072265625,
-0.431640625,
0.57666015625,
0.06610107421875,
0.52783203125,
-0.33984375,
0.6826171875,
-0.6015625,
-1.1650390625,
0.11773681640625,
0.44384765625,
0.67578125,
-0.91259765625,
-1.2861328125,
-0.1861572265625,
-1.017578125,
-0.151611328125,
-0.44775390625,
0.83935546875,
-0.29443359375,
0.1649169921875,
0.05267333984375,
-1.0712890625,
4.3359375,
1.294921875,
1.021484375,
0.35107421875,
0.51708984375,
1.3828125,
0.37841796875,
-0.5771484375,
-0.54736328125,
-0.48583984375,
0.490234375,
-0.281494140625,
0.06439208984375,
0.8671875,
0.2191162109375,
0.62744140625,
-0.5048828125,
0.049957275390625,
-0.301513671875,
-0.83740234375,
-0.8251953125,
0.279541015625,
-0.00595855712890625,
0.2347412109375,
-0.2802734375,
0.19091796875,
0.62255859375,
-0.78271484375,
-0.315673828125,
-0.86572265625,
0.00533294677734375,
-0.580078125,
0.9365234375,
0.0963134765625,
0.19091796875,
0.595703125,
-0.036529541015625,
-0.42041015625,
-0.194091796875,
-0.11126708984375,
-0.1619873046875,
0.3232421875,
0.82666015625,
-0.58251953125,
-0.2149658203125,
0.59326171875,
-0.80810546875,
0.55615234375,
0.4140625,
-1.220703125,
1.0224609375,
-0.259765625,
0.6162109375,
-0.6376953125,
-0.77197265625,
0.0019245147705078125,
-0.06512451171875,
-0.059295654296875,
-0.2191162109375,
0.3798828125,
0.1728515625,
0.294921875,
0.12225341796875,
0.436767578125,
-0.86083984375,
0.52001953125,
-0.08843994140625,
0.364990234375,
-0.67236328125,
-0.11126708984375,
-0.342041015625,
-0.2418212890625,
-0.5,
-0.24169921875,
0.7529296875,
0.2376708984375,
-0.0904541015625,
0.5361328125,
0.64453125,
-0.5068359375,
0.2359619140625,
-0.35791015625,
-0.2493896484375,
-0.466064453125,
0.7509765625,
1.134765625,
-0.4853515625,
-0.10955810546875,
-0.1319580078125,
0.486328125,
0.60791015625,
0.533203125,
-0.1982421875,
-0.270751953125,
-0.32763671875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in any order, any operation may be applied any number of times. The i-th operation is described by a string ai of length two and a string bi of length one. No two of q possible operations have the same string ai.
When Limak has a string s he can perform the i-th operation on s if the first two letters of s match a two-letter string ai. Performing the i-th operation removes first two letters of s and inserts there a string bi. See the notes section for further clarification.
You may note that performing an operation decreases the length of a string s exactly by 1. Also, for some sets of operations there may be a string that cannot be compressed any further, because the first two letters don't match any ai.
Limak wants to start with a string of length n and perform n - 1 operations to finally get a one-letter string "a". In how many ways can he choose the starting string to be able to get "a"? Remember that Limak can use only letters he knows.
Input
The first line contains two integers n and q (2 ≤ n ≤ 6, 1 ≤ q ≤ 36) — the length of the initial string and the number of available operations.
The next q lines describe the possible operations. The i-th of them contains two strings ai and bi (|ai| = 2, |bi| = 1). It's guaranteed that ai ≠ aj for i ≠ j and that all ai and bi consist of only first six lowercase English letters.
Output
Print the number of strings of length n that Limak will be able to transform to string "a" by applying only operations given in the input.
Examples
Input
3 5
ab a
cc c
ca a
ee c
ff d
Output
4
Input
2 8
af e
dc d
cc f
bc b
da b
eb a
bb b
ff c
Output
1
Input
6 2
bb a
ba a
Output
0
Note
In the first sample, we count initial strings of length 3 from which Limak can get a required string "a". There are 4 such strings: "abb", "cab", "cca", "eea". The first one Limak can compress using operation 1 two times (changing "ab" to a single "a"). The first operation would change "abb" to "ab" and the second operation would change "ab" to "a".
Other three strings may be compressed as follows:
* "cab" <image> "ab" <image> "a"
* "cca" <image> "ca" <image> "a"
* "eea" <image> "ca" <image> "a"
In the second sample, the only correct initial string is "eb" because it can be immediately compressed to "a".
Tags: brute force, dfs and similar, dp, strings
Correct Solution:
```
n, m = map(int, input().split())
mp = dict()
for _ in range(m):
a, b = input().split()
mp[a] = b;
from itertools import product
count = 0
for t in product('abcdef', repeat=n) :
s = ''.join(t)
for _ in range(n - 1):
s = mp.get(s[:2], 'g') + s[2:];
if (s=='a'):
count += 1
print(count)
```
| 70,299 | [
0.405517578125,
-0.0950927734375,
0.2056884765625,
-0.07342529296875,
-0.63916015625,
-0.362548828125,
-0.0787353515625,
0.19384765625,
0.1724853515625,
0.93212890625,
0.90771484375,
-0.11602783203125,
-0.102783203125,
-0.99609375,
-0.484375,
0.2491455078125,
-0.325927734375,
-0.5732421875,
-0.269775390625,
-0.199951171875,
0.1385498046875,
-0.468994140625,
-1.3232421875,
-0.23779296875,
-0.62939453125,
0.61376953125,
0.60888671875,
0.16357421875,
1.0791015625,
1.0810546875,
-0.231689453125,
-0.48291015625,
0.59619140625,
-1.234375,
-0.1663818359375,
-0.286865234375,
0.7158203125,
-0.66650390625,
-0.34033203125,
-0.59033203125,
0.298583984375,
-0.72509765625,
0.373779296875,
-0.666015625,
-1.1650390625,
-0.047088623046875,
-0.357421875,
-0.56640625,
-0.083740234375,
-0.83447265625,
0.2509765625,
-0.34375,
0.90625,
-0.300537109375,
0.09759521484375,
-0.165283203125,
0.50927734375,
-0.04119873046875,
-0.53857421875,
0.446533203125,
0.06591796875,
0.2802734375,
0.26611328125,
-0.56640625,
-0.2479248046875,
-0.1365966796875,
-0.141845703125,
-0.24609375,
-0.0950927734375,
-0.61572265625,
-0.587890625,
0.12188720703125,
-0.60107421875,
-0.669921875,
-0.2003173828125,
-0.0167388916015625,
0.173828125,
-0.08294677734375,
-0.61865234375,
1.060546875,
0.07183837890625,
1.025390625,
0.73193359375,
0.29443359375,
-0.189697265625,
-0.59423828125,
0.0794677734375,
0.27978515625,
0.0545654296875,
0.163330078125,
-0.265380859375,
0.75439453125,
-1.08203125,
-0.04815673828125,
0.48828125,
0.57861328125,
-0.07940673828125,
0.1142578125,
0.198974609375,
-0.1605224609375,
1.0556640625,
0.426513671875,
-0.1029052734375,
1.1943359375,
-0.5009765625,
0.2861328125,
-0.021881103515625,
0.007091522216796875,
-0.3134765625,
-0.06146240234375,
-0.13525390625,
-0.19091796875,
1.0751953125,
0.1865234375,
-0.2369384765625,
0.76513671875,
0.1746826171875,
0.56298828125,
-0.6376953125,
0.2322998046875,
0.35791015625,
0.41748046875,
0.8408203125,
-0.32861328125,
-0.12432861328125,
-0.1685791015625,
-0.135498046875,
0.654296875,
-0.84326171875,
-0.19677734375,
0.13525390625,
-0.189453125,
-0.161865234375,
0.30908203125,
-0.347412109375,
0.66845703125,
-0.2154541015625,
0.5927734375,
1.107421875,
-0.5634765625,
0.826171875,
-0.0151214599609375,
-0.00812530517578125,
1.49609375,
0.1683349609375,
0.270263671875,
0.7529296875,
0.09686279296875,
-0.74658203125,
0.488525390625,
-0.97607421875,
0.36083984375,
0.348388671875,
0.1275634765625,
-0.377685546875,
0.249267578125,
-0.1817626953125,
0.311279296875,
-0.001735687255859375,
-0.07421875,
-0.20703125,
0.33935546875,
-0.6201171875,
1.0546875,
-0.0732421875,
0.87060546875,
-0.42236328125,
-0.314697265625,
0.0888671875,
-0.071533203125,
0.09637451171875,
-0.2978515625,
-0.322021484375,
0.8203125,
0.374755859375,
1.064453125,
0.94873046875,
-0.0073699951171875,
0.387451171875,
0.390625,
-0.262451171875,
0.486083984375,
0.39794921875,
0.7490234375,
0.228271484375,
0.40380859375,
0.031036376953125,
-0.08441162109375,
-0.1845703125,
-0.28125,
-0.06060791015625,
0.72802734375,
-0.4296875,
-0.148681640625,
0.04595947265625,
0.18603515625,
-0.97314453125,
0.455322265625,
0.0535888671875,
-0.9833984375,
-0.265380859375,
0.74951171875,
-0.453857421875,
0.62841796875,
-0.55419921875,
-0.69970703125,
0.62060546875,
1.1943359375,
0.1446533203125,
0.0263824462890625,
0.79638671875,
0.541015625,
-0.420654296875,
0.334716796875,
-0.232421875,
-0.5244140625,
-0.560546875,
0.73193359375,
0.0509033203125,
-0.09967041015625,
0.168701171875,
0.26025390625,
0.306396484375,
0.70068359375,
-0.37255859375,
-0.028106689453125,
0.80078125,
1.0947265625,
-0.054412841796875,
0.44580078125,
0.156005859375,
0.96484375,
0.505859375,
0.9404296875,
0.638671875,
0.308837890625,
0.64453125,
0.93505859375,
0.015350341796875,
0.0011730194091796875,
0.051300048828125,
0.6611328125,
0.436279296875,
0.67333984375,
0.12286376953125,
0.2100830078125,
-0.2705078125,
0.05712890625,
-0.5966796875,
-0.004596710205078125,
-0.2763671875,
0.77685546875,
0.10687255859375,
0.74755859375,
-0.30859375,
-0.413330078125,
0.3251953125,
0.6484375,
-0.958984375,
-0.44384765625,
-0.376220703125,
-0.135498046875,
0.350341796875,
-0.046966552734375,
0.259521484375,
0.052337646484375,
0.320068359375,
0.1103515625,
-0.2489013671875,
-0.69384765625,
-1.095703125,
-0.98779296875,
-0.7548828125,
-0.51806640625,
-0.62451171875,
0.126953125,
0.179443359375,
-1.1728515625,
0.53564453125,
-0.54638671875,
-0.2427978515625,
-0.020721435546875,
-0.85107421875,
0.5537109375,
-0.227294921875,
0.470947265625,
-0.452392578125,
0.368408203125,
0.299560546875,
1.306640625,
-0.162353515625,
0.1776123046875,
-0.0751953125,
-0.63623046875,
0.27880859375,
-0.272216796875,
0.57861328125,
-0.1357421875,
-0.734375,
-0.587890625,
-0.340087890625,
-0.08221435546875,
-0.56884765625,
0.373779296875,
-0.412841796875,
0.5791015625,
0.36669921875,
-1.0576171875,
0.685546875,
1.1533203125,
-0.5458984375,
0.6748046875,
-0.362548828125,
0.0278472900390625,
-0.79345703125,
1.18359375,
0.255859375,
0.414794921875,
-0.321044921875,
-0.8623046875,
-0.3818359375,
-0.18798828125,
0.06793212890625,
-0.302734375,
-0.0772705078125,
0.63232421875,
-0.381103515625,
-0.7587890625,
0.6376953125,
-1.013671875,
-0.322265625,
-0.7998046875,
-0.63134765625,
0.78955078125,
0.68896484375,
0.1461181640625,
0.0021762847900390625,
-0.144287109375,
-0.143798828125,
0.9814453125,
0.2269287109375,
-0.630859375,
0.07647705078125,
0.5078125,
0.031463623046875,
0.0125885009765625,
0.54443359375,
-0.55517578125,
-0.3798828125,
0.06890869140625,
-0.03436279296875,
0.71337890625,
0.2376708984375,
0.57666015625,
0.57958984375,
0.6220703125,
-1.0087890625,
-0.1505126953125,
-0.43505859375,
0.413818359375,
0.425537109375,
0.23193359375,
0.416015625,
-0.464111328125,
-0.5234375,
-0.90234375,
0.40966796875,
0.1962890625,
0.428955078125,
-0.6708984375,
0.9072265625,
0.05267333984375,
-0.39404296875,
0.380859375,
-0.501953125,
-0.1041259765625,
0.8896484375,
-0.395751953125,
0.724609375,
-0.6806640625,
0.63916015625,
-0.1055908203125,
-0.1796875,
0.84228515625,
0.286376953125,
0.452880859375,
-0.544921875,
-0.304443359375,
-0.505859375,
-0.28466796875,
0.2548828125,
-0.5478515625,
0.10748291015625,
-0.72509765625,
-0.29638671875,
-0.91357421875,
0.54296875,
0.36474609375,
0.7578125,
-0.067626953125,
0.494140625,
0.06512451171875,
0.71484375,
0.69091796875,
-0.2352294921875,
-0.05438232421875,
-0.456787109375,
0.87646484375,
0.243896484375,
-0.281982421875,
-0.54248046875,
-0.1630859375,
-0.458984375,
0.39599609375,
-0.0374755859375,
-0.08685302734375,
-0.9150390625,
0.42333984375,
0.1990966796875,
0.7001953125,
-0.463134765625,
-0.52490234375,
-0.359619140625,
0.361328125,
0.59619140625,
-1.2021484375,
0.00028061866760253906,
-0.677734375,
0.87451171875,
0.43994140625,
-0.2332763671875,
-0.4267578125,
-0.62109375,
-0.6171875,
-0.453857421875,
-0.0782470703125,
0.71142578125,
0.314208984375,
0.412353515625,
-0.99267578125,
0.32666015625,
0.301513671875,
-0.2119140625,
0.04052734375,
-0.16796875,
0.22021484375,
-0.1436767578125,
0.74951171875,
-0.339599609375,
-0.71728515625,
0.021636962890625,
-1.302734375,
0.2880859375,
-0.68359375,
0.339599609375,
0.046966552734375,
-0.478759765625,
-0.302001953125,
0.329833984375,
-0.430419921875,
-0.0377197265625,
0.06964111328125,
0.68408203125,
-1.0576171875,
-0.998046875,
0.5517578125,
-0.2393798828125,
-0.493408203125,
1.19140625,
0.0958251953125,
-0.544921875,
0.02545166015625,
0.240966796875,
-0.37939453125,
0.54833984375,
-1.0693359375,
0.63818359375,
-0.447265625,
-0.34423828125,
-0.449951171875,
-0.56201171875,
0.412109375,
-0.0860595703125,
-0.52880859375,
-0.496826171875,
-1.326171875,
-0.159423828125,
-0.036376953125,
-0.5517578125,
0.44921875,
-0.054656982421875,
0.167724609375,
-0.057586669921875,
-0.47998046875,
-0.177734375,
-0.607421875,
-0.47314453125,
-0.39111328125,
0.53759765625,
0.53857421875,
0.7998046875,
-0.043365478515625,
-0.333740234375,
0.028564453125,
-0.0970458984375,
0.09515380859375,
-0.1522216796875,
-0.2105712890625,
0.0237579345703125,
-0.12164306640625,
-0.135009765625,
0.314208984375,
-0.181640625,
0.09552001953125,
0.485595703125,
0.054412841796875,
0.66015625,
0.228759765625,
-0.72802734375,
1.31640625,
0.189453125,
-1.0390625,
-0.216796875,
0.90478515625,
-0.127197265625,
0.3427734375,
0.31591796875,
-1.015625,
-0.86279296875,
-0.74072265625,
0.489501953125,
-0.72314453125,
-0.396728515625,
-1.2158203125,
-0.377685546875,
-0.54931640625,
0.708984375,
-0.032806396484375,
-0.42138671875,
0.42236328125,
-1.046875,
0.3681640625,
-0.60205078125,
-0.67626953125,
-0.56787109375,
-0.68310546875,
-0.091064453125,
1.146484375,
0.077880859375,
0.2498779296875,
0.2607421875,
-0.265869140625,
0.58984375,
0.24169921875,
-0.94775390625,
-0.32470703125,
-0.1446533203125,
0.429443359375,
-0.09375,
0.0261383056640625,
-0.394287109375,
0.4072265625,
-0.77099609375,
0.333740234375,
-0.264404296875,
-0.34619140625,
-0.35400390625,
-0.41064453125,
1.1650390625,
-0.61572265625,
0.062286376953125,
-0.2294921875,
0.6962890625,
0.92919921875,
-0.02581787109375,
-0.42333984375,
-0.88623046875,
-1.052734375,
-0.9443359375,
0.63232421875,
-0.402587890625,
0.0018777847290039062,
-0.471435546875,
0.031982421875,
0.8291015625,
-0.164306640625,
0.5830078125,
0.869140625,
0.10345458984375,
-0.0958251953125,
-0.61474609375,
0.7099609375,
0.41552734375,
-0.4951171875,
-0.302001953125,
0.372314453125,
-0.603515625,
0.311767578125,
-0.422607421875,
-1.2119140625,
-0.80029296875,
0.337158203125,
1.3984375,
-0.243408203125,
0.900390625,
-0.059844970703125,
-0.88916015625,
-0.43017578125,
0.66357421875,
0.12139892578125,
0.327392578125,
0.78125,
-0.1126708984375,
-0.329833984375,
0.10894775390625,
-0.373046875,
-0.109130859375,
-0.62548828125,
1.23046875,
-0.6357421875,
-0.625,
0.453125,
0.99365234375,
-0.90869140625,
-1.302734375,
-0.2376708984375,
-0.3125,
-0.434326171875,
-0.86767578125,
-0.129638671875,
0.266357421875,
-0.2474365234375,
0.10369873046875,
0.31787109375,
-0.065185546875,
0.55712890625,
0.1260986328125,
0.5234375,
-0.1416015625,
0.4521484375,
0.69580078125,
-0.51171875,
-0.642578125,
-1.03125,
-0.048614501953125,
-0.361328125,
0.2294921875,
0.59814453125,
-0.2142333984375,
0.50537109375,
0.5419921875,
-0.15966796875,
0.77099609375,
-0.38818359375,
-0.462158203125,
0.2237548828125,
-1.134765625,
-0.451904296875,
0.026519775390625,
0.54345703125,
-0.47265625,
0.292236328125,
-0.79833984375,
-0.537109375,
0.343505859375,
0.54052734375,
-0.36767578125,
-1.0625,
-0.12274169921875,
-1.2109375,
-0.62841796875,
-0.58642578125,
-0.75439453125,
-0.1837158203125,
-0.1953125,
0.01244354248046875,
-0.7890625,
-0.08221435546875,
0.283203125,
-0.505859375,
0.8330078125,
-0.556640625,
0.54638671875,
-0.669921875,
-0.11895751953125,
-0.64501953125,
0.14404296875,
-0.54150390625,
-0.1407470703125,
-0.320068359375,
0.328125,
-0.17724609375,
0.56591796875,
-0.3173828125,
0.309326171875,
-0.2088623046875,
-0.40478515625,
-0.100341796875,
0.1590576171875,
-0.2288818359375,
0.673828125,
0.5224609375,
-0.2587890625,
0.333740234375,
-0.11639404296875,
-0.1492919921875,
-0.252685546875,
0.90380859375,
0.16015625,
-0.040679931640625,
-0.1749267578125,
-0.2362060546875,
0.371826171875,
-0.96826171875,
0.30810546875,
-0.141357421875,
0.533203125,
0.0002970695495605469,
-0.237548828125,
0.3564453125,
1.0888671875,
-0.119140625,
0.006641387939453125,
0.2333984375,
0.145263671875,
0.1314697265625,
0.1522216796875,
-0.0233612060546875,
0.484375,
-0.1982421875,
-0.343017578125,
-0.1400146484375,
0.3291015625,
0.06268310546875,
0.409912109375,
-0.1524658203125,
-0.76513671875,
-0.65673828125,
-0.288330078125,
-0.047698974609375,
0.51708984375,
0.5400390625,
-0.60009765625,
0.0209503173828125,
0.0628662109375,
-0.7783203125,
0.0950927734375,
-1.0166015625,
-1.0859375,
0.00504302978515625,
0.07574462890625,
-0.73974609375,
-0.10162353515625,
-0.48046875,
-0.200439453125,
0.01421356201171875,
0.2183837890625,
-0.89013671875,
0.3251953125,
0.0029048919677734375,
0.58203125,
-0.2322998046875,
-0.0160064697265625,
-0.017822265625,
0.353759765625,
-0.6044921875,
-0.2303466796875,
-0.348876953125,
0.5888671875,
0.27880859375,
-0.2353515625,
-0.22998046875,
0.1783447265625,
0.2152099609375,
0.207275390625,
-0.55908203125,
0.250732421875,
-0.0775146484375,
0.88818359375,
-0.77587890625,
-0.204345703125,
-0.396240234375,
0.272705078125,
0.10394287109375,
-0.53759765625,
-0.8154296875,
1.2626953125,
0.76513671875,
-0.1380615234375,
0.303466796875,
0.163330078125,
0.43994140625,
-0.304931640625,
0.11297607421875,
-0.48095703125,
0.8603515625,
0.443359375,
0.59326171875,
-0.1422119140625,
0.285400390625,
0.51806640625,
-0.06134033203125,
-0.57470703125,
0.380126953125,
0.286865234375,
0.045806884765625,
0.071533203125,
-0.27880859375,
-0.41943359375,
-0.04400634765625,
-0.8857421875,
0.2841796875,
-0.185302734375,
-0.0736083984375,
-0.51318359375,
-0.48974609375,
0.85791015625,
-0.53076171875,
-0.00977325439453125,
0.298828125,
-0.264404296875,
0.33740234375,
0.517578125,
0.140380859375,
0.1728515625,
0.955078125,
0.72998046875,
0.63623046875,
0.59130859375,
0.2509765625,
0.365234375,
-0.759765625,
0.1826171875,
0.3251953125,
0.01152801513671875,
0.056640625,
-0.1036376953125,
-0.876953125,
0.5654296875,
-0.331787109375,
-0.3291015625,
0.359130859375,
-0.61181640625,
-0.1983642578125,
-0.421142578125,
0.86279296875,
-0.673828125,
0.55517578125,
0.6484375,
-0.289306640625,
-0.5888671875,
1.1982421875,
-0.401123046875,
0.1790771484375,
0.165771484375,
1.1767578125,
0.362060546875,
1.4345703125,
0.484619140625,
-0.090576171875,
0.114501953125,
0.460693359375,
-0.2337646484375,
-0.71533203125,
-0.47265625,
-0.375,
0.200439453125,
-0.86962890625,
-0.469970703125,
-0.373046875,
1.0224609375,
0.08148193359375,
-0.7685546875,
-0.19873046875,
0.0633544921875,
-0.77587890625,
0.19970703125,
0.311767578125,
0.459716796875,
0.07763671875,
-0.204345703125,
-0.037445068359375,
-0.48876953125,
0.1180419921875,
-0.29150390625,
0.3603515625,
-0.60205078125,
-0.5361328125,
-0.30029296875,
-1.0400390625,
-0.669921875,
0.1705322265625,
-0.1593017578125,
-0.830078125,
0.6201171875,
0.75390625,
0.1885986328125,
0.310791015625,
-0.48095703125,
0.386962890625,
0.95166015625,
1.28515625,
-0.09161376953125,
0.78955078125,
0.415283203125,
-0.300048828125,
0.1549072265625,
-0.431640625,
0.57666015625,
0.06610107421875,
0.52783203125,
-0.33984375,
0.6826171875,
-0.6015625,
-1.1650390625,
0.11773681640625,
0.44384765625,
0.67578125,
-0.91259765625,
-1.2861328125,
-0.1861572265625,
-1.017578125,
-0.151611328125,
-0.44775390625,
0.83935546875,
-0.29443359375,
0.1649169921875,
0.05267333984375,
-1.0712890625,
4.3359375,
1.294921875,
1.021484375,
0.35107421875,
0.51708984375,
1.3828125,
0.37841796875,
-0.5771484375,
-0.54736328125,
-0.48583984375,
0.490234375,
-0.281494140625,
0.06439208984375,
0.8671875,
0.2191162109375,
0.62744140625,
-0.5048828125,
0.049957275390625,
-0.301513671875,
-0.83740234375,
-0.8251953125,
0.279541015625,
-0.00595855712890625,
0.2347412109375,
-0.2802734375,
0.19091796875,
0.62255859375,
-0.78271484375,
-0.315673828125,
-0.86572265625,
0.00533294677734375,
-0.580078125,
0.9365234375,
0.0963134765625,
0.19091796875,
0.595703125,
-0.036529541015625,
-0.42041015625,
-0.194091796875,
-0.11126708984375,
-0.1619873046875,
0.3232421875,
0.82666015625,
-0.58251953125,
-0.2149658203125,
0.59326171875,
-0.80810546875,
0.55615234375,
0.4140625,
-1.220703125,
1.0224609375,
-0.259765625,
0.6162109375,
-0.6376953125,
-0.77197265625,
0.0019245147705078125,
-0.06512451171875,
-0.059295654296875,
-0.2191162109375,
0.3798828125,
0.1728515625,
0.294921875,
0.12225341796875,
0.436767578125,
-0.86083984375,
0.52001953125,
-0.08843994140625,
0.364990234375,
-0.67236328125,
-0.11126708984375,
-0.342041015625,
-0.2418212890625,
-0.5,
-0.24169921875,
0.7529296875,
0.2376708984375,
-0.0904541015625,
0.5361328125,
0.64453125,
-0.5068359375,
0.2359619140625,
-0.35791015625,
-0.2493896484375,
-0.466064453125,
0.7509765625,
1.134765625,
-0.4853515625,
-0.10955810546875,
-0.1319580078125,
0.486328125,
0.60791015625,
0.533203125,
-0.1982421875,
-0.270751953125,
-0.32763671875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.
In this problem you should implement the similar functionality.
You are given a string which only consists of:
* uppercase and lowercase English letters,
* underscore symbols (they are used as separators),
* parentheses (both opening and closing).
It is guaranteed that each opening parenthesis has a succeeding closing parenthesis. Similarly, each closing parentheses has a preceding opening parentheses matching it. For each pair of matching parentheses there are no other parenthesis between them. In other words, each parenthesis in the string belongs to a matching "opening-closing" pair, and such pairs can't be nested.
For example, the following string is valid: "_Hello_Vasya(and_Petya)__bye_(and_OK)".
Word is a maximal sequence of consecutive letters, i.e. such sequence that the first character to the left and the first character to the right of it is an underscore, a parenthesis, or it just does not exist. For example, the string above consists of seven words: "Hello", "Vasya", "and", "Petya", "bye", "and" and "OK". Write a program that finds:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 255) — the length of the given string. The second line contains the string consisting of only lowercase and uppercase English letters, parentheses and underscore symbols.
Output
Print two space-separated integers:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Examples
Input
37
_Hello_Vasya(and_Petya)__bye_(and_OK)
Output
5 4
Input
37
_a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
Output
2 6
Input
27
(LoooonG)__shOrt__(LoooonG)
Output
5 2
Input
5
(___)
Output
0 0
Note
In the first sample, the words "Hello", "Vasya" and "bye" are outside any of the parentheses, and the words "and", "Petya", "and" and "OK" are inside. Note, that the word "and" is given twice and you should count it twice in the answer.
Tags: expression parsing, implementation, strings
Correct Solution:
```
n = int(input())
s = input()
ib = 0; mx = 0; foo = 0
for i in range(n):
if s[i]=='(':
k = i
while s[k]!=')':
if (s[k]=='(' or s[k]=='_') and (s[k+1]!=')' and s[k+1]!='_'): ib += 1
k += 1
for i in range(n):
if s[i]=='(':
k=i+1
while s[k]!=')':
k += 1
s = s.replace(s[i:k+1], len(s[i:k+1])*'_')
s += '_'
for i in range(n+1):
if s[i] != '_': mx += 1
else:
foo = max(mx, foo)
mx = 0
print(foo, ib)
```
| 70,328 | [
0.0736083984375,
-0.30712890625,
0.1131591796875,
0.1287841796875,
-0.008453369140625,
-0.316650390625,
-0.0017538070678710938,
-0.11553955078125,
0.0045013427734375,
0.5498046875,
0.6123046875,
-0.0794677734375,
-0.062744140625,
-0.93701171875,
-0.896484375,
0.054229736328125,
-0.6123046875,
-0.69140625,
-0.416015625,
-0.0748291015625,
-0.06475830078125,
0.173583984375,
-1.568359375,
-0.25927734375,
-0.1820068359375,
1.09375,
0.57568359375,
0.05914306640625,
0.89453125,
0.98681640625,
-0.4091796875,
-0.2198486328125,
0.2734375,
-0.7890625,
-0.462890625,
-0.56201171875,
0.80712890625,
-0.96435546875,
0.05694580078125,
-0.54541015625,
0.198486328125,
-0.4404296875,
0.57080078125,
-0.900390625,
-1.05078125,
0.001705169677734375,
-0.133544921875,
-0.195556640625,
0.12939453125,
-0.1446533203125,
0.2021484375,
-0.28515625,
0.362548828125,
-0.408935546875,
0.23876953125,
-0.00447845458984375,
0.2144775390625,
0.1539306640625,
-0.360595703125,
0.1878662109375,
-0.11285400390625,
0.204833984375,
-0.1168212890625,
-0.494140625,
-0.391845703125,
0.212890625,
0.285400390625,
0.12481689453125,
0.32373046875,
-1,
-0.09466552734375,
-0.04522705078125,
-0.267822265625,
-0.1588134765625,
-0.54052734375,
0.2269287109375,
0.75146484375,
-0.10906982421875,
-0.414306640625,
0.7734375,
0.06982421875,
1.0615234375,
0.69873046875,
0.092529296875,
-0.3330078125,
-0.82763671875,
-0.10791015625,
0.275146484375,
0.654296875,
-0.2169189453125,
-0.328369140625,
0.43603515625,
-0.2783203125,
-0.01065826416015625,
0.61865234375,
0.73291015625,
-0.5419921875,
0.2447509765625,
0.15673828125,
0.396240234375,
0.40283203125,
1.23046875,
-0.157470703125,
0.86962890625,
-0.69580078125,
0.340087890625,
0.3935546875,
-0.12432861328125,
-0.0718994140625,
-0.23828125,
-0.36279296875,
-0.35595703125,
0.37646484375,
0.12939453125,
-0.43408203125,
0.90185546875,
-0.492919921875,
0.2451171875,
-0.90283203125,
0.35546875,
0.48828125,
0.0992431640625,
0.2431640625,
-0.263916015625,
0.2685546875,
-0.356201171875,
-0.92431640625,
1.17578125,
-0.4951171875,
-0.44775390625,
0.259765625,
-0.1705322265625,
-0.240234375,
0.53857421875,
-0.2208251953125,
0.83154296875,
-0.2291259765625,
0.17138671875,
0.6943359375,
-1.23828125,
0.78173828125,
-0.163330078125,
0.045074462890625,
1.4990234375,
0.228515625,
0.07275390625,
0.69091796875,
0.48388671875,
-0.8154296875,
0.580078125,
-1.0185546875,
0.90283203125,
0.239990234375,
0.0400390625,
-0.482421875,
0.1451416015625,
-0.1658935546875,
0.1756591796875,
0.298583984375,
-0.18310546875,
-0.27099609375,
-0.053985595703125,
-0.43359375,
0.3798828125,
-0.5341796875,
0.451171875,
-0.505859375,
-0.276123046875,
-0.29296875,
-0.6181640625,
0.0665283203125,
-0.10284423828125,
-0.14208984375,
0.4404296875,
0.54150390625,
1.0966796875,
0.7109375,
-0.358154296875,
0.147705078125,
0.053955078125,
-0.51708984375,
0.114990234375,
-0.04376220703125,
0.65234375,
0.36669921875,
0.1201171875,
-0.00849151611328125,
-0.2314453125,
-1.0078125,
-0.85791015625,
0.43701171875,
0.72802734375,
-0.3681640625,
0.5048828125,
0.455810546875,
0.09930419921875,
-0.98974609375,
0.0982666015625,
0.01067352294921875,
-0.79541015625,
-0.4931640625,
0.69970703125,
-0.151123046875,
0.62109375,
-0.18408203125,
-0.402587890625,
0.225830078125,
1.0556640625,
-0.33154296875,
-0.1295166015625,
0.80615234375,
0.2529296875,
-0.01296234130859375,
0.051666259765625,
0.10052490234375,
-0.310546875,
-1.1806640625,
0.81689453125,
-0.490234375,
0.01183319091796875,
0.1923828125,
0.393310546875,
0.300048828125,
0.38916015625,
0.057037353515625,
-0.02276611328125,
0.379638671875,
1.0126953125,
0.013092041015625,
0.79541015625,
0.2998046875,
0.818359375,
0.446044921875,
0.478759765625,
0.5400390625,
0.47265625,
0.541015625,
0.689453125,
-0.07098388671875,
0.185546875,
-0.2103271484375,
0.54443359375,
0.307861328125,
0.6572265625,
0.08148193359375,
0.375,
-0.1796875,
0.17919921875,
-0.442138671875,
0.54833984375,
-0.313232421875,
0.85888671875,
0.29833984375,
0.53369140625,
-0.77197265625,
-0.347412109375,
0.265869140625,
0.6640625,
-0.94677734375,
-0.459228515625,
-0.1796875,
0.01361846923828125,
0.2130126953125,
0.300048828125,
0.23388671875,
0.2298583984375,
0.83349609375,
0.5947265625,
-0.27490234375,
-0.7001953125,
-0.63232421875,
-0.53759765625,
-1.0185546875,
-0.252685546875,
-0.6103515625,
0.089111328125,
0.356201171875,
-0.9951171875,
0.13134765625,
-0.1824951171875,
-0.2236328125,
-0.1759033203125,
-0.490966796875,
0.48095703125,
-0.42431640625,
0.65283203125,
-0.87890625,
0.59228515625,
0.1209716796875,
0.82177734375,
-0.74169921875,
-0.2158203125,
-0.51123046875,
-0.68310546875,
0.88427734375,
-0.0278778076171875,
0.0902099609375,
-0.14208984375,
-0.74609375,
-0.74560546875,
-0.71240234375,
-0.425537109375,
-0.419921875,
0.40673828125,
-1.015625,
0.79443359375,
0.2425537109375,
-0.412109375,
0.650390625,
1.01953125,
-0.97265625,
0.6650390625,
0.5712890625,
0.2120361328125,
-0.87548828125,
1.14453125,
0.28271484375,
0.10882568359375,
-0.4150390625,
-0.371337890625,
-0.26611328125,
0.09210205078125,
-0.0035610198974609375,
-0.5283203125,
-0.5361328125,
0.71630859375,
0.1851806640625,
-1.0390625,
0.50830078125,
-1.0048828125,
-0.5107421875,
-0.5224609375,
-0.3017578125,
0.85205078125,
1.0078125,
0.004543304443359375,
-0.576171875,
-0.305419921875,
-0.1947021484375,
0.78515625,
0.43359375,
-0.68896484375,
0.06182861328125,
0.7578125,
-0.238037109375,
0.048553466796875,
0.1715087890625,
-0.213134765625,
-0.25390625,
0.17236328125,
0.368408203125,
0.99658203125,
0.10198974609375,
0.2481689453125,
-0.138916015625,
0.5703125,
-0.94970703125,
-0.391357421875,
-0.49462890625,
0.73486328125,
0.280517578125,
0.281494140625,
0.54248046875,
-0.1861572265625,
-0.47314453125,
-1.0712890625,
0.433349609375,
-0.02496337890625,
0.931640625,
-0.787109375,
0.53759765625,
0.58251953125,
-0.7890625,
0.77001953125,
-1.060546875,
-0.1597900390625,
1.3515625,
-0.235595703125,
0.92236328125,
-0.1856689453125,
0.0697021484375,
-0.87158203125,
-0.205810546875,
1.19140625,
0.0010309219360351562,
0.73486328125,
-0.4599609375,
-0.57958984375,
-0.10650634765625,
0.06048583984375,
-0.63134765625,
-0.6015625,
0.349609375,
-0.481689453125,
-0.25439453125,
-0.685546875,
0.67822265625,
1.2431640625,
0.1510009765625,
0.2958984375,
0.60498046875,
0.08660888671875,
0.53662109375,
0.65185546875,
-0.315673828125,
-0.0214996337890625,
-0.8935546875,
0.73779296875,
0.0244140625,
0.11297607421875,
-0.708984375,
-0.08831787109375,
-0.57861328125,
0.28955078125,
-0.45556640625,
-0.21484375,
-0.9619140625,
0.478759765625,
0.1015625,
0.630859375,
-0.796875,
0.09039306640625,
-0.251220703125,
-0.0294189453125,
0.42724609375,
-0.79638671875,
0.236328125,
-1.1298828125,
0.6240234375,
0.423828125,
-0.1917724609375,
-0.6279296875,
-0.08709716796875,
-0.61767578125,
-0.71826171875,
0.0029010772705078125,
0.97119140625,
0.1175537109375,
0.283203125,
-1.09375,
0.212158203125,
0.169189453125,
-0.181396484375,
0.166015625,
0.08221435546875,
0.35888671875,
0.480712890625,
0.80322265625,
-0.46533203125,
-0.76416015625,
-0.0114593505859375,
-1.12890625,
0.7744140625,
-0.41943359375,
0.28125,
-0.08221435546875,
-0.20556640625,
-0.156494140625,
0.296630859375,
0.0673828125,
0.1578369140625,
-0.29736328125,
0.197509765625,
-0.7998046875,
-0.74755859375,
0.712890625,
-0.3935546875,
-0.66748046875,
0.77490234375,
0.2431640625,
-0.14990234375,
0.12152099609375,
0.45458984375,
-0.214111328125,
-0.049774169921875,
-0.5849609375,
0.369140625,
-0.477783203125,
-0.5947265625,
0.037200927734375,
-0.56640625,
0.7373046875,
-0.0255279541015625,
-0.962890625,
-0.103271484375,
-1.451171875,
-0.30615234375,
0.09332275390625,
-0.57177734375,
0.335205078125,
0.215576171875,
0.00484466552734375,
0.272705078125,
-0.6533203125,
-0.55712890625,
-0.2890625,
-0.529296875,
-0.29443359375,
-0.0721435546875,
0.57861328125,
0.6318359375,
0.00890350341796875,
-0.1260986328125,
0.2154541015625,
0.387451171875,
-0.08685302734375,
-0.52392578125,
-0.2076416015625,
-0.458740234375,
-0.04156494140625,
-0.02398681640625,
0.50048828125,
0.239990234375,
0.2281494140625,
0.802734375,
0.419921875,
0.312255859375,
0.53466796875,
-0.335693359375,
0.80517578125,
0.346435546875,
-1.10546875,
-0.446044921875,
0.9443359375,
-0.41748046875,
0.5458984375,
0.1048583984375,
-0.5087890625,
-1.0546875,
-0.88330078125,
0.0938720703125,
-0.35791015625,
-0.295654296875,
-0.7880859375,
-0.357666015625,
-0.1356201171875,
0.5458984375,
0.06744384765625,
-0.51025390625,
0.30029296875,
-1.1611328125,
0.1385498046875,
-0.685546875,
-0.44921875,
-0.53955078125,
-0.6943359375,
-0.465087890625,
0.71875,
0.317138671875,
0.392333984375,
0.1817626953125,
-0.408203125,
0.170166015625,
0.01171875,
-0.7275390625,
-0.316650390625,
0.0030727386474609375,
0.08209228515625,
0.00547027587890625,
-0.1595458984375,
-0.41845703125,
0.955078125,
-1.46484375,
0.110595703125,
-0.0650634765625,
-0.493896484375,
-0.280517578125,
-0.265869140625,
0.869140625,
-0.06097412109375,
-0.28369140625,
-0.284423828125,
0.5986328125,
0.447021484375,
-0.1805419921875,
-0.70458984375,
-0.76416015625,
-0.64697265625,
-0.84814453125,
0.50341796875,
-0.364501953125,
0.32177734375,
-0.60986328125,
0.11273193359375,
1.2294921875,
-0.64892578125,
0.515625,
1.0419921875,
0.5166015625,
0.27978515625,
-0.69580078125,
0.388916015625,
0.00424957275390625,
-0.78125,
-0.0297393798828125,
-0.00830841064453125,
-0.74658203125,
0.347412109375,
-0.2205810546875,
-1.078125,
-0.5986328125,
0.135009765625,
1.5205078125,
-0.24169921875,
1.0146484375,
0.35107421875,
-0.984375,
-0.494140625,
1.1484375,
-0.0008020401000976562,
0.181396484375,
0.97900390625,
-0.6484375,
-0.1783447265625,
-0.106689453125,
-0.2379150390625,
-0.30126953125,
-0.646484375,
0.85693359375,
-0.25244140625,
-0.355712890625,
0.60107421875,
0.923828125,
-0.9208984375,
-0.9873046875,
0.2269287109375,
-0.05047607421875,
-0.0146331787109375,
-0.81396484375,
0.25390625,
0.83935546875,
-0.472900390625,
-0.013214111328125,
0.400390625,
0.111572265625,
0.494384765625,
-0.01708984375,
0.2164306640625,
-0.399169921875,
0.57666015625,
0.50146484375,
-0.54296875,
-0.368896484375,
-0.9921875,
-0.1021728515625,
-0.10870361328125,
0.032012939453125,
0.591796875,
-0.1622314453125,
0.2254638671875,
0.71142578125,
-0.11700439453125,
0.84765625,
-0.6904296875,
-0.332763671875,
0.447509765625,
-0.454833984375,
-0.74755859375,
-0.0194549560546875,
0.33935546875,
-0.23486328125,
0.28466796875,
-0.6484375,
-0.309814453125,
0.48681640625,
0.307373046875,
-0.34619140625,
-0.63037109375,
-0.1630859375,
-0.9365234375,
-0.81884765625,
-0.408203125,
-0.654296875,
-0.2449951171875,
0.03564453125,
0.1995849609375,
-0.06304931640625,
-0.00864410400390625,
0.81689453125,
-1.01171875,
0.9814453125,
-0.34228515625,
0.70068359375,
-0.7705078125,
-0.1533203125,
-0.6474609375,
0.1732177734375,
-0.416259765625,
-0.3369140625,
-0.40380859375,
0.34521484375,
-0.189453125,
0.3212890625,
-0.2479248046875,
0.2783203125,
-0.3017578125,
-0.388427734375,
0.5146484375,
0.09576416015625,
-0.209716796875,
0.72998046875,
0.474365234375,
-0.142333984375,
0.042510986328125,
-0.08551025390625,
-0.308837890625,
-0.5078125,
0.4150390625,
0.59033203125,
-0.400634765625,
-0.1279296875,
-0.379150390625,
-0.0134735107421875,
-0.94580078125,
0.09991455078125,
-0.1441650390625,
0.178955078125,
0.31201171875,
-0.460693359375,
0.36865234375,
0.990234375,
-0.18603515625,
0.273681640625,
-0.1414794921875,
0.1771240234375,
0.5927734375,
0.3154296875,
0.12548828125,
0.5703125,
0.50634765625,
-0.1978759765625,
0.094970703125,
0.1851806640625,
-0.07464599609375,
0.234619140625,
-0.147216796875,
-0.85986328125,
-1.16796875,
-0.1744384765625,
0.014129638671875,
0.5869140625,
-0.041748046875,
-0.61865234375,
0.084228515625,
-0.08856201171875,
-0.66162109375,
0.27001953125,
-0.841796875,
-0.74560546875,
0.525390625,
-0.084716796875,
-0.36376953125,
-0.257568359375,
-0.32958984375,
0.050567626953125,
0.331298828125,
0.498046875,
-0.71826171875,
0.60400390625,
-0.0689697265625,
0.64501953125,
-0.285888671875,
0.043853759765625,
0.305419921875,
0.451904296875,
-0.313720703125,
-0.69189453125,
0.277587890625,
0.962890625,
0.246826171875,
-0.11016845703125,
-0.392578125,
0.18603515625,
-0.199951171875,
0.1357421875,
-0.2095947265625,
-0.064697265625,
-0.16845703125,
0.61962890625,
-1.4453125,
-0.0204010009765625,
-0.269775390625,
0.53857421875,
0.454833984375,
-0.1201171875,
-0.63427734375,
0.67626953125,
0.81298828125,
-0.10443115234375,
0.197509765625,
0.57568359375,
0.406005859375,
-0.197998046875,
-0.12176513671875,
-0.273681640625,
1.025390625,
0.476318359375,
0.494140625,
-0.1917724609375,
0.430908203125,
0.70263671875,
0.369140625,
-0.01317596435546875,
0.492919921875,
0.444091796875,
-0.140625,
-0.04803466796875,
-0.1175537109375,
-0.4580078125,
0.1240234375,
-0.71435546875,
0.623046875,
-0.435302734375,
-0.450439453125,
-0.62939453125,
-0.67724609375,
0.81787109375,
0.1669921875,
-0.58837890625,
0.0672607421875,
-0.2744140625,
0.340087890625,
0.7705078125,
0.11004638671875,
0.00666046142578125,
0.70263671875,
0.75146484375,
0.5625,
0.6884765625,
0.392822265625,
0.6337890625,
-0.61328125,
-0.08782958984375,
-0.002056121826171875,
0.2470703125,
-0.39990234375,
-0.60986328125,
-0.97607421875,
0.79248046875,
-0.54833984375,
0.1680908203125,
0.779296875,
-0.662109375,
-0.12054443359375,
-0.171142578125,
0.732421875,
-0.54296875,
0.2015380859375,
0.368408203125,
-0.6494140625,
-0.51708984375,
0.8828125,
0.06982421875,
0.399169921875,
0.173828125,
0.84521484375,
-0.022552490234375,
1.4931640625,
0.401123046875,
-0.359619140625,
0.1346435546875,
0.37939453125,
-0.35400390625,
-0.6494140625,
-0.478759765625,
-0.25537109375,
-0.1956787109375,
-0.412353515625,
-0.75,
-0.1971435546875,
0.923828125,
-0.04736328125,
-1.052734375,
-0.5732421875,
0.306640625,
-0.88232421875,
0.4326171875,
0.020721435546875,
-0.005443572998046875,
-0.05010986328125,
0.1248779296875,
-0.002262115478515625,
-0.47998046875,
0.348388671875,
-0.416748046875,
0.295654296875,
-0.399169921875,
-0.46533203125,
-0.50732421875,
-0.6552734375,
-0.464599609375,
-0.0675048828125,
-0.447509765625,
-1.146484375,
0.5771484375,
0.367431640625,
0.7919921875,
0.456298828125,
-0.5654296875,
0.399658203125,
0.76611328125,
1.021484375,
0.0982666015625,
1.0634765625,
0.54833984375,
-0.00330352783203125,
0.028594970703125,
-0.1998291015625,
0.80908203125,
-0.2001953125,
0.325439453125,
-0.599609375,
0.71630859375,
-0.31396484375,
-1.234375,
0.03515625,
0.66552734375,
0.470947265625,
-0.802734375,
-1.109375,
-0.22900390625,
-0.85498046875,
-0.1119384765625,
-0.68994140625,
0.64599609375,
-0.075927734375,
0.33349609375,
-0.36962890625,
-1.318359375,
4.3046875,
1.0751953125,
0.697265625,
0.5556640625,
0.350341796875,
0.8701171875,
0.19873046875,
-0.7607421875,
-0.280029296875,
-0.416748046875,
0.63427734375,
-0.6552734375,
-0.0323486328125,
0.90283203125,
0.5126953125,
0.51318359375,
-0.63037109375,
-0.0447998046875,
-0.1463623046875,
-0.97607421875,
-1.169921875,
0.2349853515625,
-0.1737060546875,
0.422119140625,
-0.0126953125,
0.490478515625,
0.76416015625,
-0.454833984375,
-0.28515625,
-0.79345703125,
0.118408203125,
-0.57177734375,
1.005859375,
0.260986328125,
-0.52783203125,
0.6025390625,
-0.2391357421875,
-0.42919921875,
-0.006847381591796875,
0.52734375,
-0.259033203125,
-0.064453125,
0.76123046875,
-0.380859375,
0.0706787109375,
0.65869140625,
-0.544921875,
0.4248046875,
0.1573486328125,
-0.9619140625,
1.212890625,
0.186279296875,
0.0938720703125,
-0.759765625,
-0.499267578125,
0.31689453125,
0.30078125,
-0.329833984375,
-0.419189453125,
0.595703125,
0.1639404296875,
0.2442626953125,
0.0255584716796875,
0.7314453125,
-1.2861328125,
0.90087890625,
-0.247802734375,
0.358642578125,
-0.6591796875,
-0.2822265625,
0.38330078125,
-0.418212890625,
-0.3935546875,
-0.024261474609375,
0.5712890625,
0.2247314453125,
-0.38134765625,
0.455078125,
0.61279296875,
-0.873046875,
0.33251953125,
0.062164306640625,
-0.46484375,
-0.0280914306640625,
0.2919921875,
1.1181640625,
-0.703125,
-0.30859375,
-0.51904296875,
0.42333984375,
0.69921875,
0.340576171875,
0.0328369140625,
-0.3896484375,
0.07806396484375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.
In this problem you should implement the similar functionality.
You are given a string which only consists of:
* uppercase and lowercase English letters,
* underscore symbols (they are used as separators),
* parentheses (both opening and closing).
It is guaranteed that each opening parenthesis has a succeeding closing parenthesis. Similarly, each closing parentheses has a preceding opening parentheses matching it. For each pair of matching parentheses there are no other parenthesis between them. In other words, each parenthesis in the string belongs to a matching "opening-closing" pair, and such pairs can't be nested.
For example, the following string is valid: "_Hello_Vasya(and_Petya)__bye_(and_OK)".
Word is a maximal sequence of consecutive letters, i.e. such sequence that the first character to the left and the first character to the right of it is an underscore, a parenthesis, or it just does not exist. For example, the string above consists of seven words: "Hello", "Vasya", "and", "Petya", "bye", "and" and "OK". Write a program that finds:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 255) — the length of the given string. The second line contains the string consisting of only lowercase and uppercase English letters, parentheses and underscore symbols.
Output
Print two space-separated integers:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Examples
Input
37
_Hello_Vasya(and_Petya)__bye_(and_OK)
Output
5 4
Input
37
_a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
Output
2 6
Input
27
(LoooonG)__shOrt__(LoooonG)
Output
5 2
Input
5
(___)
Output
0 0
Note
In the first sample, the words "Hello", "Vasya" and "bye" are outside any of the parentheses, and the words "and", "Petya", "and" and "OK" are inside. Note, that the word "and" is given twice and you should count it twice in the answer.
Tags: expression parsing, implementation, strings
Correct Solution:
```
n = int(input())
len_out, count_in = 0, 0
balance, cur = 0, 0
for c in input():
if not (('a' <= c <= 'z') or ('A' <= c <= 'Z')) and cur:
if balance:
count_in += 1
else:
len_out = max(len_out, cur)
cur = 0
if c == '(':
balance += 1
elif c == ')':
balance -= 1
elif ('a' <= c <= 'z') or ('A' <= c <= 'Z'):
cur += 1
if cur:
len_out = max(len_out, cur)
print(len_out, count_in)
```
| 70,329 | [
0.0736083984375,
-0.30712890625,
0.1131591796875,
0.1287841796875,
-0.008453369140625,
-0.316650390625,
-0.0017538070678710938,
-0.11553955078125,
0.0045013427734375,
0.5498046875,
0.6123046875,
-0.0794677734375,
-0.062744140625,
-0.93701171875,
-0.896484375,
0.054229736328125,
-0.6123046875,
-0.69140625,
-0.416015625,
-0.0748291015625,
-0.06475830078125,
0.173583984375,
-1.568359375,
-0.25927734375,
-0.1820068359375,
1.09375,
0.57568359375,
0.05914306640625,
0.89453125,
0.98681640625,
-0.4091796875,
-0.2198486328125,
0.2734375,
-0.7890625,
-0.462890625,
-0.56201171875,
0.80712890625,
-0.96435546875,
0.05694580078125,
-0.54541015625,
0.198486328125,
-0.4404296875,
0.57080078125,
-0.900390625,
-1.05078125,
0.001705169677734375,
-0.133544921875,
-0.195556640625,
0.12939453125,
-0.1446533203125,
0.2021484375,
-0.28515625,
0.362548828125,
-0.408935546875,
0.23876953125,
-0.00447845458984375,
0.2144775390625,
0.1539306640625,
-0.360595703125,
0.1878662109375,
-0.11285400390625,
0.204833984375,
-0.1168212890625,
-0.494140625,
-0.391845703125,
0.212890625,
0.285400390625,
0.12481689453125,
0.32373046875,
-1,
-0.09466552734375,
-0.04522705078125,
-0.267822265625,
-0.1588134765625,
-0.54052734375,
0.2269287109375,
0.75146484375,
-0.10906982421875,
-0.414306640625,
0.7734375,
0.06982421875,
1.0615234375,
0.69873046875,
0.092529296875,
-0.3330078125,
-0.82763671875,
-0.10791015625,
0.275146484375,
0.654296875,
-0.2169189453125,
-0.328369140625,
0.43603515625,
-0.2783203125,
-0.01065826416015625,
0.61865234375,
0.73291015625,
-0.5419921875,
0.2447509765625,
0.15673828125,
0.396240234375,
0.40283203125,
1.23046875,
-0.157470703125,
0.86962890625,
-0.69580078125,
0.340087890625,
0.3935546875,
-0.12432861328125,
-0.0718994140625,
-0.23828125,
-0.36279296875,
-0.35595703125,
0.37646484375,
0.12939453125,
-0.43408203125,
0.90185546875,
-0.492919921875,
0.2451171875,
-0.90283203125,
0.35546875,
0.48828125,
0.0992431640625,
0.2431640625,
-0.263916015625,
0.2685546875,
-0.356201171875,
-0.92431640625,
1.17578125,
-0.4951171875,
-0.44775390625,
0.259765625,
-0.1705322265625,
-0.240234375,
0.53857421875,
-0.2208251953125,
0.83154296875,
-0.2291259765625,
0.17138671875,
0.6943359375,
-1.23828125,
0.78173828125,
-0.163330078125,
0.045074462890625,
1.4990234375,
0.228515625,
0.07275390625,
0.69091796875,
0.48388671875,
-0.8154296875,
0.580078125,
-1.0185546875,
0.90283203125,
0.239990234375,
0.0400390625,
-0.482421875,
0.1451416015625,
-0.1658935546875,
0.1756591796875,
0.298583984375,
-0.18310546875,
-0.27099609375,
-0.053985595703125,
-0.43359375,
0.3798828125,
-0.5341796875,
0.451171875,
-0.505859375,
-0.276123046875,
-0.29296875,
-0.6181640625,
0.0665283203125,
-0.10284423828125,
-0.14208984375,
0.4404296875,
0.54150390625,
1.0966796875,
0.7109375,
-0.358154296875,
0.147705078125,
0.053955078125,
-0.51708984375,
0.114990234375,
-0.04376220703125,
0.65234375,
0.36669921875,
0.1201171875,
-0.00849151611328125,
-0.2314453125,
-1.0078125,
-0.85791015625,
0.43701171875,
0.72802734375,
-0.3681640625,
0.5048828125,
0.455810546875,
0.09930419921875,
-0.98974609375,
0.0982666015625,
0.01067352294921875,
-0.79541015625,
-0.4931640625,
0.69970703125,
-0.151123046875,
0.62109375,
-0.18408203125,
-0.402587890625,
0.225830078125,
1.0556640625,
-0.33154296875,
-0.1295166015625,
0.80615234375,
0.2529296875,
-0.01296234130859375,
0.051666259765625,
0.10052490234375,
-0.310546875,
-1.1806640625,
0.81689453125,
-0.490234375,
0.01183319091796875,
0.1923828125,
0.393310546875,
0.300048828125,
0.38916015625,
0.057037353515625,
-0.02276611328125,
0.379638671875,
1.0126953125,
0.013092041015625,
0.79541015625,
0.2998046875,
0.818359375,
0.446044921875,
0.478759765625,
0.5400390625,
0.47265625,
0.541015625,
0.689453125,
-0.07098388671875,
0.185546875,
-0.2103271484375,
0.54443359375,
0.307861328125,
0.6572265625,
0.08148193359375,
0.375,
-0.1796875,
0.17919921875,
-0.442138671875,
0.54833984375,
-0.313232421875,
0.85888671875,
0.29833984375,
0.53369140625,
-0.77197265625,
-0.347412109375,
0.265869140625,
0.6640625,
-0.94677734375,
-0.459228515625,
-0.1796875,
0.01361846923828125,
0.2130126953125,
0.300048828125,
0.23388671875,
0.2298583984375,
0.83349609375,
0.5947265625,
-0.27490234375,
-0.7001953125,
-0.63232421875,
-0.53759765625,
-1.0185546875,
-0.252685546875,
-0.6103515625,
0.089111328125,
0.356201171875,
-0.9951171875,
0.13134765625,
-0.1824951171875,
-0.2236328125,
-0.1759033203125,
-0.490966796875,
0.48095703125,
-0.42431640625,
0.65283203125,
-0.87890625,
0.59228515625,
0.1209716796875,
0.82177734375,
-0.74169921875,
-0.2158203125,
-0.51123046875,
-0.68310546875,
0.88427734375,
-0.0278778076171875,
0.0902099609375,
-0.14208984375,
-0.74609375,
-0.74560546875,
-0.71240234375,
-0.425537109375,
-0.419921875,
0.40673828125,
-1.015625,
0.79443359375,
0.2425537109375,
-0.412109375,
0.650390625,
1.01953125,
-0.97265625,
0.6650390625,
0.5712890625,
0.2120361328125,
-0.87548828125,
1.14453125,
0.28271484375,
0.10882568359375,
-0.4150390625,
-0.371337890625,
-0.26611328125,
0.09210205078125,
-0.0035610198974609375,
-0.5283203125,
-0.5361328125,
0.71630859375,
0.1851806640625,
-1.0390625,
0.50830078125,
-1.0048828125,
-0.5107421875,
-0.5224609375,
-0.3017578125,
0.85205078125,
1.0078125,
0.004543304443359375,
-0.576171875,
-0.305419921875,
-0.1947021484375,
0.78515625,
0.43359375,
-0.68896484375,
0.06182861328125,
0.7578125,
-0.238037109375,
0.048553466796875,
0.1715087890625,
-0.213134765625,
-0.25390625,
0.17236328125,
0.368408203125,
0.99658203125,
0.10198974609375,
0.2481689453125,
-0.138916015625,
0.5703125,
-0.94970703125,
-0.391357421875,
-0.49462890625,
0.73486328125,
0.280517578125,
0.281494140625,
0.54248046875,
-0.1861572265625,
-0.47314453125,
-1.0712890625,
0.433349609375,
-0.02496337890625,
0.931640625,
-0.787109375,
0.53759765625,
0.58251953125,
-0.7890625,
0.77001953125,
-1.060546875,
-0.1597900390625,
1.3515625,
-0.235595703125,
0.92236328125,
-0.1856689453125,
0.0697021484375,
-0.87158203125,
-0.205810546875,
1.19140625,
0.0010309219360351562,
0.73486328125,
-0.4599609375,
-0.57958984375,
-0.10650634765625,
0.06048583984375,
-0.63134765625,
-0.6015625,
0.349609375,
-0.481689453125,
-0.25439453125,
-0.685546875,
0.67822265625,
1.2431640625,
0.1510009765625,
0.2958984375,
0.60498046875,
0.08660888671875,
0.53662109375,
0.65185546875,
-0.315673828125,
-0.0214996337890625,
-0.8935546875,
0.73779296875,
0.0244140625,
0.11297607421875,
-0.708984375,
-0.08831787109375,
-0.57861328125,
0.28955078125,
-0.45556640625,
-0.21484375,
-0.9619140625,
0.478759765625,
0.1015625,
0.630859375,
-0.796875,
0.09039306640625,
-0.251220703125,
-0.0294189453125,
0.42724609375,
-0.79638671875,
0.236328125,
-1.1298828125,
0.6240234375,
0.423828125,
-0.1917724609375,
-0.6279296875,
-0.08709716796875,
-0.61767578125,
-0.71826171875,
0.0029010772705078125,
0.97119140625,
0.1175537109375,
0.283203125,
-1.09375,
0.212158203125,
0.169189453125,
-0.181396484375,
0.166015625,
0.08221435546875,
0.35888671875,
0.480712890625,
0.80322265625,
-0.46533203125,
-0.76416015625,
-0.0114593505859375,
-1.12890625,
0.7744140625,
-0.41943359375,
0.28125,
-0.08221435546875,
-0.20556640625,
-0.156494140625,
0.296630859375,
0.0673828125,
0.1578369140625,
-0.29736328125,
0.197509765625,
-0.7998046875,
-0.74755859375,
0.712890625,
-0.3935546875,
-0.66748046875,
0.77490234375,
0.2431640625,
-0.14990234375,
0.12152099609375,
0.45458984375,
-0.214111328125,
-0.049774169921875,
-0.5849609375,
0.369140625,
-0.477783203125,
-0.5947265625,
0.037200927734375,
-0.56640625,
0.7373046875,
-0.0255279541015625,
-0.962890625,
-0.103271484375,
-1.451171875,
-0.30615234375,
0.09332275390625,
-0.57177734375,
0.335205078125,
0.215576171875,
0.00484466552734375,
0.272705078125,
-0.6533203125,
-0.55712890625,
-0.2890625,
-0.529296875,
-0.29443359375,
-0.0721435546875,
0.57861328125,
0.6318359375,
0.00890350341796875,
-0.1260986328125,
0.2154541015625,
0.387451171875,
-0.08685302734375,
-0.52392578125,
-0.2076416015625,
-0.458740234375,
-0.04156494140625,
-0.02398681640625,
0.50048828125,
0.239990234375,
0.2281494140625,
0.802734375,
0.419921875,
0.312255859375,
0.53466796875,
-0.335693359375,
0.80517578125,
0.346435546875,
-1.10546875,
-0.446044921875,
0.9443359375,
-0.41748046875,
0.5458984375,
0.1048583984375,
-0.5087890625,
-1.0546875,
-0.88330078125,
0.0938720703125,
-0.35791015625,
-0.295654296875,
-0.7880859375,
-0.357666015625,
-0.1356201171875,
0.5458984375,
0.06744384765625,
-0.51025390625,
0.30029296875,
-1.1611328125,
0.1385498046875,
-0.685546875,
-0.44921875,
-0.53955078125,
-0.6943359375,
-0.465087890625,
0.71875,
0.317138671875,
0.392333984375,
0.1817626953125,
-0.408203125,
0.170166015625,
0.01171875,
-0.7275390625,
-0.316650390625,
0.0030727386474609375,
0.08209228515625,
0.00547027587890625,
-0.1595458984375,
-0.41845703125,
0.955078125,
-1.46484375,
0.110595703125,
-0.0650634765625,
-0.493896484375,
-0.280517578125,
-0.265869140625,
0.869140625,
-0.06097412109375,
-0.28369140625,
-0.284423828125,
0.5986328125,
0.447021484375,
-0.1805419921875,
-0.70458984375,
-0.76416015625,
-0.64697265625,
-0.84814453125,
0.50341796875,
-0.364501953125,
0.32177734375,
-0.60986328125,
0.11273193359375,
1.2294921875,
-0.64892578125,
0.515625,
1.0419921875,
0.5166015625,
0.27978515625,
-0.69580078125,
0.388916015625,
0.00424957275390625,
-0.78125,
-0.0297393798828125,
-0.00830841064453125,
-0.74658203125,
0.347412109375,
-0.2205810546875,
-1.078125,
-0.5986328125,
0.135009765625,
1.5205078125,
-0.24169921875,
1.0146484375,
0.35107421875,
-0.984375,
-0.494140625,
1.1484375,
-0.0008020401000976562,
0.181396484375,
0.97900390625,
-0.6484375,
-0.1783447265625,
-0.106689453125,
-0.2379150390625,
-0.30126953125,
-0.646484375,
0.85693359375,
-0.25244140625,
-0.355712890625,
0.60107421875,
0.923828125,
-0.9208984375,
-0.9873046875,
0.2269287109375,
-0.05047607421875,
-0.0146331787109375,
-0.81396484375,
0.25390625,
0.83935546875,
-0.472900390625,
-0.013214111328125,
0.400390625,
0.111572265625,
0.494384765625,
-0.01708984375,
0.2164306640625,
-0.399169921875,
0.57666015625,
0.50146484375,
-0.54296875,
-0.368896484375,
-0.9921875,
-0.1021728515625,
-0.10870361328125,
0.032012939453125,
0.591796875,
-0.1622314453125,
0.2254638671875,
0.71142578125,
-0.11700439453125,
0.84765625,
-0.6904296875,
-0.332763671875,
0.447509765625,
-0.454833984375,
-0.74755859375,
-0.0194549560546875,
0.33935546875,
-0.23486328125,
0.28466796875,
-0.6484375,
-0.309814453125,
0.48681640625,
0.307373046875,
-0.34619140625,
-0.63037109375,
-0.1630859375,
-0.9365234375,
-0.81884765625,
-0.408203125,
-0.654296875,
-0.2449951171875,
0.03564453125,
0.1995849609375,
-0.06304931640625,
-0.00864410400390625,
0.81689453125,
-1.01171875,
0.9814453125,
-0.34228515625,
0.70068359375,
-0.7705078125,
-0.1533203125,
-0.6474609375,
0.1732177734375,
-0.416259765625,
-0.3369140625,
-0.40380859375,
0.34521484375,
-0.189453125,
0.3212890625,
-0.2479248046875,
0.2783203125,
-0.3017578125,
-0.388427734375,
0.5146484375,
0.09576416015625,
-0.209716796875,
0.72998046875,
0.474365234375,
-0.142333984375,
0.042510986328125,
-0.08551025390625,
-0.308837890625,
-0.5078125,
0.4150390625,
0.59033203125,
-0.400634765625,
-0.1279296875,
-0.379150390625,
-0.0134735107421875,
-0.94580078125,
0.09991455078125,
-0.1441650390625,
0.178955078125,
0.31201171875,
-0.460693359375,
0.36865234375,
0.990234375,
-0.18603515625,
0.273681640625,
-0.1414794921875,
0.1771240234375,
0.5927734375,
0.3154296875,
0.12548828125,
0.5703125,
0.50634765625,
-0.1978759765625,
0.094970703125,
0.1851806640625,
-0.07464599609375,
0.234619140625,
-0.147216796875,
-0.85986328125,
-1.16796875,
-0.1744384765625,
0.014129638671875,
0.5869140625,
-0.041748046875,
-0.61865234375,
0.084228515625,
-0.08856201171875,
-0.66162109375,
0.27001953125,
-0.841796875,
-0.74560546875,
0.525390625,
-0.084716796875,
-0.36376953125,
-0.257568359375,
-0.32958984375,
0.050567626953125,
0.331298828125,
0.498046875,
-0.71826171875,
0.60400390625,
-0.0689697265625,
0.64501953125,
-0.285888671875,
0.043853759765625,
0.305419921875,
0.451904296875,
-0.313720703125,
-0.69189453125,
0.277587890625,
0.962890625,
0.246826171875,
-0.11016845703125,
-0.392578125,
0.18603515625,
-0.199951171875,
0.1357421875,
-0.2095947265625,
-0.064697265625,
-0.16845703125,
0.61962890625,
-1.4453125,
-0.0204010009765625,
-0.269775390625,
0.53857421875,
0.454833984375,
-0.1201171875,
-0.63427734375,
0.67626953125,
0.81298828125,
-0.10443115234375,
0.197509765625,
0.57568359375,
0.406005859375,
-0.197998046875,
-0.12176513671875,
-0.273681640625,
1.025390625,
0.476318359375,
0.494140625,
-0.1917724609375,
0.430908203125,
0.70263671875,
0.369140625,
-0.01317596435546875,
0.492919921875,
0.444091796875,
-0.140625,
-0.04803466796875,
-0.1175537109375,
-0.4580078125,
0.1240234375,
-0.71435546875,
0.623046875,
-0.435302734375,
-0.450439453125,
-0.62939453125,
-0.67724609375,
0.81787109375,
0.1669921875,
-0.58837890625,
0.0672607421875,
-0.2744140625,
0.340087890625,
0.7705078125,
0.11004638671875,
0.00666046142578125,
0.70263671875,
0.75146484375,
0.5625,
0.6884765625,
0.392822265625,
0.6337890625,
-0.61328125,
-0.08782958984375,
-0.002056121826171875,
0.2470703125,
-0.39990234375,
-0.60986328125,
-0.97607421875,
0.79248046875,
-0.54833984375,
0.1680908203125,
0.779296875,
-0.662109375,
-0.12054443359375,
-0.171142578125,
0.732421875,
-0.54296875,
0.2015380859375,
0.368408203125,
-0.6494140625,
-0.51708984375,
0.8828125,
0.06982421875,
0.399169921875,
0.173828125,
0.84521484375,
-0.022552490234375,
1.4931640625,
0.401123046875,
-0.359619140625,
0.1346435546875,
0.37939453125,
-0.35400390625,
-0.6494140625,
-0.478759765625,
-0.25537109375,
-0.1956787109375,
-0.412353515625,
-0.75,
-0.1971435546875,
0.923828125,
-0.04736328125,
-1.052734375,
-0.5732421875,
0.306640625,
-0.88232421875,
0.4326171875,
0.020721435546875,
-0.005443572998046875,
-0.05010986328125,
0.1248779296875,
-0.002262115478515625,
-0.47998046875,
0.348388671875,
-0.416748046875,
0.295654296875,
-0.399169921875,
-0.46533203125,
-0.50732421875,
-0.6552734375,
-0.464599609375,
-0.0675048828125,
-0.447509765625,
-1.146484375,
0.5771484375,
0.367431640625,
0.7919921875,
0.456298828125,
-0.5654296875,
0.399658203125,
0.76611328125,
1.021484375,
0.0982666015625,
1.0634765625,
0.54833984375,
-0.00330352783203125,
0.028594970703125,
-0.1998291015625,
0.80908203125,
-0.2001953125,
0.325439453125,
-0.599609375,
0.71630859375,
-0.31396484375,
-1.234375,
0.03515625,
0.66552734375,
0.470947265625,
-0.802734375,
-1.109375,
-0.22900390625,
-0.85498046875,
-0.1119384765625,
-0.68994140625,
0.64599609375,
-0.075927734375,
0.33349609375,
-0.36962890625,
-1.318359375,
4.3046875,
1.0751953125,
0.697265625,
0.5556640625,
0.350341796875,
0.8701171875,
0.19873046875,
-0.7607421875,
-0.280029296875,
-0.416748046875,
0.63427734375,
-0.6552734375,
-0.0323486328125,
0.90283203125,
0.5126953125,
0.51318359375,
-0.63037109375,
-0.0447998046875,
-0.1463623046875,
-0.97607421875,
-1.169921875,
0.2349853515625,
-0.1737060546875,
0.422119140625,
-0.0126953125,
0.490478515625,
0.76416015625,
-0.454833984375,
-0.28515625,
-0.79345703125,
0.118408203125,
-0.57177734375,
1.005859375,
0.260986328125,
-0.52783203125,
0.6025390625,
-0.2391357421875,
-0.42919921875,
-0.006847381591796875,
0.52734375,
-0.259033203125,
-0.064453125,
0.76123046875,
-0.380859375,
0.0706787109375,
0.65869140625,
-0.544921875,
0.4248046875,
0.1573486328125,
-0.9619140625,
1.212890625,
0.186279296875,
0.0938720703125,
-0.759765625,
-0.499267578125,
0.31689453125,
0.30078125,
-0.329833984375,
-0.419189453125,
0.595703125,
0.1639404296875,
0.2442626953125,
0.0255584716796875,
0.7314453125,
-1.2861328125,
0.90087890625,
-0.247802734375,
0.358642578125,
-0.6591796875,
-0.2822265625,
0.38330078125,
-0.418212890625,
-0.3935546875,
-0.024261474609375,
0.5712890625,
0.2247314453125,
-0.38134765625,
0.455078125,
0.61279296875,
-0.873046875,
0.33251953125,
0.062164306640625,
-0.46484375,
-0.0280914306640625,
0.2919921875,
1.1181640625,
-0.703125,
-0.30859375,
-0.51904296875,
0.42333984375,
0.69921875,
0.340576171875,
0.0328369140625,
-0.3896484375,
0.07806396484375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.
In this problem you should implement the similar functionality.
You are given a string which only consists of:
* uppercase and lowercase English letters,
* underscore symbols (they are used as separators),
* parentheses (both opening and closing).
It is guaranteed that each opening parenthesis has a succeeding closing parenthesis. Similarly, each closing parentheses has a preceding opening parentheses matching it. For each pair of matching parentheses there are no other parenthesis between them. In other words, each parenthesis in the string belongs to a matching "opening-closing" pair, and such pairs can't be nested.
For example, the following string is valid: "_Hello_Vasya(and_Petya)__bye_(and_OK)".
Word is a maximal sequence of consecutive letters, i.e. such sequence that the first character to the left and the first character to the right of it is an underscore, a parenthesis, or it just does not exist. For example, the string above consists of seven words: "Hello", "Vasya", "and", "Petya", "bye", "and" and "OK". Write a program that finds:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 255) — the length of the given string. The second line contains the string consisting of only lowercase and uppercase English letters, parentheses and underscore symbols.
Output
Print two space-separated integers:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Examples
Input
37
_Hello_Vasya(and_Petya)__bye_(and_OK)
Output
5 4
Input
37
_a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
Output
2 6
Input
27
(LoooonG)__shOrt__(LoooonG)
Output
5 2
Input
5
(___)
Output
0 0
Note
In the first sample, the words "Hello", "Vasya" and "bye" are outside any of the parentheses, and the words "and", "Petya", "and" and "OK" are inside. Note, that the word "and" is given twice and you should count it twice in the answer.
Tags: expression parsing, implementation, strings
Correct Solution:
```
n=int(input())
text= input()[:n]
# words_with_paren=input().split('_')
len_long_word_out=0
numb_words_in_paren=0
if '(' in text:
open_ind = [i for i, x in enumerate(text) if x == "("]
close_ind= [i for i, x in enumerate(text) if x == ")"]
for (i,offset) in enumerate(open_ind):
tmp=text[offset+1:close_ind[i]]
numb_words_in_paren+=len(list(filter(None,tmp.split('_'))))
begin=0
for (i, offset) in enumerate(open_ind):
substr=text[begin:offset].split('_')
for word in filter(None,substr):
if len(word)>len_long_word_out:
len_long_word_out=len(word)
begin=close_ind[i]+1
if begin < len(text):
for word in text[begin:].split('_'):
if len(word)>len_long_word_out:
len_long_word_out=len(word)
else:
words=text.split('_')
for word in filter(None,words):
if len(word) > len_long_word_out:
len_long_word_out=len(word)
print("%d %d" %(len_long_word_out,numb_words_in_paren))
```
| 70,330 | [
0.0736083984375,
-0.30712890625,
0.1131591796875,
0.1287841796875,
-0.008453369140625,
-0.316650390625,
-0.0017538070678710938,
-0.11553955078125,
0.0045013427734375,
0.5498046875,
0.6123046875,
-0.0794677734375,
-0.062744140625,
-0.93701171875,
-0.896484375,
0.054229736328125,
-0.6123046875,
-0.69140625,
-0.416015625,
-0.0748291015625,
-0.06475830078125,
0.173583984375,
-1.568359375,
-0.25927734375,
-0.1820068359375,
1.09375,
0.57568359375,
0.05914306640625,
0.89453125,
0.98681640625,
-0.4091796875,
-0.2198486328125,
0.2734375,
-0.7890625,
-0.462890625,
-0.56201171875,
0.80712890625,
-0.96435546875,
0.05694580078125,
-0.54541015625,
0.198486328125,
-0.4404296875,
0.57080078125,
-0.900390625,
-1.05078125,
0.001705169677734375,
-0.133544921875,
-0.195556640625,
0.12939453125,
-0.1446533203125,
0.2021484375,
-0.28515625,
0.362548828125,
-0.408935546875,
0.23876953125,
-0.00447845458984375,
0.2144775390625,
0.1539306640625,
-0.360595703125,
0.1878662109375,
-0.11285400390625,
0.204833984375,
-0.1168212890625,
-0.494140625,
-0.391845703125,
0.212890625,
0.285400390625,
0.12481689453125,
0.32373046875,
-1,
-0.09466552734375,
-0.04522705078125,
-0.267822265625,
-0.1588134765625,
-0.54052734375,
0.2269287109375,
0.75146484375,
-0.10906982421875,
-0.414306640625,
0.7734375,
0.06982421875,
1.0615234375,
0.69873046875,
0.092529296875,
-0.3330078125,
-0.82763671875,
-0.10791015625,
0.275146484375,
0.654296875,
-0.2169189453125,
-0.328369140625,
0.43603515625,
-0.2783203125,
-0.01065826416015625,
0.61865234375,
0.73291015625,
-0.5419921875,
0.2447509765625,
0.15673828125,
0.396240234375,
0.40283203125,
1.23046875,
-0.157470703125,
0.86962890625,
-0.69580078125,
0.340087890625,
0.3935546875,
-0.12432861328125,
-0.0718994140625,
-0.23828125,
-0.36279296875,
-0.35595703125,
0.37646484375,
0.12939453125,
-0.43408203125,
0.90185546875,
-0.492919921875,
0.2451171875,
-0.90283203125,
0.35546875,
0.48828125,
0.0992431640625,
0.2431640625,
-0.263916015625,
0.2685546875,
-0.356201171875,
-0.92431640625,
1.17578125,
-0.4951171875,
-0.44775390625,
0.259765625,
-0.1705322265625,
-0.240234375,
0.53857421875,
-0.2208251953125,
0.83154296875,
-0.2291259765625,
0.17138671875,
0.6943359375,
-1.23828125,
0.78173828125,
-0.163330078125,
0.045074462890625,
1.4990234375,
0.228515625,
0.07275390625,
0.69091796875,
0.48388671875,
-0.8154296875,
0.580078125,
-1.0185546875,
0.90283203125,
0.239990234375,
0.0400390625,
-0.482421875,
0.1451416015625,
-0.1658935546875,
0.1756591796875,
0.298583984375,
-0.18310546875,
-0.27099609375,
-0.053985595703125,
-0.43359375,
0.3798828125,
-0.5341796875,
0.451171875,
-0.505859375,
-0.276123046875,
-0.29296875,
-0.6181640625,
0.0665283203125,
-0.10284423828125,
-0.14208984375,
0.4404296875,
0.54150390625,
1.0966796875,
0.7109375,
-0.358154296875,
0.147705078125,
0.053955078125,
-0.51708984375,
0.114990234375,
-0.04376220703125,
0.65234375,
0.36669921875,
0.1201171875,
-0.00849151611328125,
-0.2314453125,
-1.0078125,
-0.85791015625,
0.43701171875,
0.72802734375,
-0.3681640625,
0.5048828125,
0.455810546875,
0.09930419921875,
-0.98974609375,
0.0982666015625,
0.01067352294921875,
-0.79541015625,
-0.4931640625,
0.69970703125,
-0.151123046875,
0.62109375,
-0.18408203125,
-0.402587890625,
0.225830078125,
1.0556640625,
-0.33154296875,
-0.1295166015625,
0.80615234375,
0.2529296875,
-0.01296234130859375,
0.051666259765625,
0.10052490234375,
-0.310546875,
-1.1806640625,
0.81689453125,
-0.490234375,
0.01183319091796875,
0.1923828125,
0.393310546875,
0.300048828125,
0.38916015625,
0.057037353515625,
-0.02276611328125,
0.379638671875,
1.0126953125,
0.013092041015625,
0.79541015625,
0.2998046875,
0.818359375,
0.446044921875,
0.478759765625,
0.5400390625,
0.47265625,
0.541015625,
0.689453125,
-0.07098388671875,
0.185546875,
-0.2103271484375,
0.54443359375,
0.307861328125,
0.6572265625,
0.08148193359375,
0.375,
-0.1796875,
0.17919921875,
-0.442138671875,
0.54833984375,
-0.313232421875,
0.85888671875,
0.29833984375,
0.53369140625,
-0.77197265625,
-0.347412109375,
0.265869140625,
0.6640625,
-0.94677734375,
-0.459228515625,
-0.1796875,
0.01361846923828125,
0.2130126953125,
0.300048828125,
0.23388671875,
0.2298583984375,
0.83349609375,
0.5947265625,
-0.27490234375,
-0.7001953125,
-0.63232421875,
-0.53759765625,
-1.0185546875,
-0.252685546875,
-0.6103515625,
0.089111328125,
0.356201171875,
-0.9951171875,
0.13134765625,
-0.1824951171875,
-0.2236328125,
-0.1759033203125,
-0.490966796875,
0.48095703125,
-0.42431640625,
0.65283203125,
-0.87890625,
0.59228515625,
0.1209716796875,
0.82177734375,
-0.74169921875,
-0.2158203125,
-0.51123046875,
-0.68310546875,
0.88427734375,
-0.0278778076171875,
0.0902099609375,
-0.14208984375,
-0.74609375,
-0.74560546875,
-0.71240234375,
-0.425537109375,
-0.419921875,
0.40673828125,
-1.015625,
0.79443359375,
0.2425537109375,
-0.412109375,
0.650390625,
1.01953125,
-0.97265625,
0.6650390625,
0.5712890625,
0.2120361328125,
-0.87548828125,
1.14453125,
0.28271484375,
0.10882568359375,
-0.4150390625,
-0.371337890625,
-0.26611328125,
0.09210205078125,
-0.0035610198974609375,
-0.5283203125,
-0.5361328125,
0.71630859375,
0.1851806640625,
-1.0390625,
0.50830078125,
-1.0048828125,
-0.5107421875,
-0.5224609375,
-0.3017578125,
0.85205078125,
1.0078125,
0.004543304443359375,
-0.576171875,
-0.305419921875,
-0.1947021484375,
0.78515625,
0.43359375,
-0.68896484375,
0.06182861328125,
0.7578125,
-0.238037109375,
0.048553466796875,
0.1715087890625,
-0.213134765625,
-0.25390625,
0.17236328125,
0.368408203125,
0.99658203125,
0.10198974609375,
0.2481689453125,
-0.138916015625,
0.5703125,
-0.94970703125,
-0.391357421875,
-0.49462890625,
0.73486328125,
0.280517578125,
0.281494140625,
0.54248046875,
-0.1861572265625,
-0.47314453125,
-1.0712890625,
0.433349609375,
-0.02496337890625,
0.931640625,
-0.787109375,
0.53759765625,
0.58251953125,
-0.7890625,
0.77001953125,
-1.060546875,
-0.1597900390625,
1.3515625,
-0.235595703125,
0.92236328125,
-0.1856689453125,
0.0697021484375,
-0.87158203125,
-0.205810546875,
1.19140625,
0.0010309219360351562,
0.73486328125,
-0.4599609375,
-0.57958984375,
-0.10650634765625,
0.06048583984375,
-0.63134765625,
-0.6015625,
0.349609375,
-0.481689453125,
-0.25439453125,
-0.685546875,
0.67822265625,
1.2431640625,
0.1510009765625,
0.2958984375,
0.60498046875,
0.08660888671875,
0.53662109375,
0.65185546875,
-0.315673828125,
-0.0214996337890625,
-0.8935546875,
0.73779296875,
0.0244140625,
0.11297607421875,
-0.708984375,
-0.08831787109375,
-0.57861328125,
0.28955078125,
-0.45556640625,
-0.21484375,
-0.9619140625,
0.478759765625,
0.1015625,
0.630859375,
-0.796875,
0.09039306640625,
-0.251220703125,
-0.0294189453125,
0.42724609375,
-0.79638671875,
0.236328125,
-1.1298828125,
0.6240234375,
0.423828125,
-0.1917724609375,
-0.6279296875,
-0.08709716796875,
-0.61767578125,
-0.71826171875,
0.0029010772705078125,
0.97119140625,
0.1175537109375,
0.283203125,
-1.09375,
0.212158203125,
0.169189453125,
-0.181396484375,
0.166015625,
0.08221435546875,
0.35888671875,
0.480712890625,
0.80322265625,
-0.46533203125,
-0.76416015625,
-0.0114593505859375,
-1.12890625,
0.7744140625,
-0.41943359375,
0.28125,
-0.08221435546875,
-0.20556640625,
-0.156494140625,
0.296630859375,
0.0673828125,
0.1578369140625,
-0.29736328125,
0.197509765625,
-0.7998046875,
-0.74755859375,
0.712890625,
-0.3935546875,
-0.66748046875,
0.77490234375,
0.2431640625,
-0.14990234375,
0.12152099609375,
0.45458984375,
-0.214111328125,
-0.049774169921875,
-0.5849609375,
0.369140625,
-0.477783203125,
-0.5947265625,
0.037200927734375,
-0.56640625,
0.7373046875,
-0.0255279541015625,
-0.962890625,
-0.103271484375,
-1.451171875,
-0.30615234375,
0.09332275390625,
-0.57177734375,
0.335205078125,
0.215576171875,
0.00484466552734375,
0.272705078125,
-0.6533203125,
-0.55712890625,
-0.2890625,
-0.529296875,
-0.29443359375,
-0.0721435546875,
0.57861328125,
0.6318359375,
0.00890350341796875,
-0.1260986328125,
0.2154541015625,
0.387451171875,
-0.08685302734375,
-0.52392578125,
-0.2076416015625,
-0.458740234375,
-0.04156494140625,
-0.02398681640625,
0.50048828125,
0.239990234375,
0.2281494140625,
0.802734375,
0.419921875,
0.312255859375,
0.53466796875,
-0.335693359375,
0.80517578125,
0.346435546875,
-1.10546875,
-0.446044921875,
0.9443359375,
-0.41748046875,
0.5458984375,
0.1048583984375,
-0.5087890625,
-1.0546875,
-0.88330078125,
0.0938720703125,
-0.35791015625,
-0.295654296875,
-0.7880859375,
-0.357666015625,
-0.1356201171875,
0.5458984375,
0.06744384765625,
-0.51025390625,
0.30029296875,
-1.1611328125,
0.1385498046875,
-0.685546875,
-0.44921875,
-0.53955078125,
-0.6943359375,
-0.465087890625,
0.71875,
0.317138671875,
0.392333984375,
0.1817626953125,
-0.408203125,
0.170166015625,
0.01171875,
-0.7275390625,
-0.316650390625,
0.0030727386474609375,
0.08209228515625,
0.00547027587890625,
-0.1595458984375,
-0.41845703125,
0.955078125,
-1.46484375,
0.110595703125,
-0.0650634765625,
-0.493896484375,
-0.280517578125,
-0.265869140625,
0.869140625,
-0.06097412109375,
-0.28369140625,
-0.284423828125,
0.5986328125,
0.447021484375,
-0.1805419921875,
-0.70458984375,
-0.76416015625,
-0.64697265625,
-0.84814453125,
0.50341796875,
-0.364501953125,
0.32177734375,
-0.60986328125,
0.11273193359375,
1.2294921875,
-0.64892578125,
0.515625,
1.0419921875,
0.5166015625,
0.27978515625,
-0.69580078125,
0.388916015625,
0.00424957275390625,
-0.78125,
-0.0297393798828125,
-0.00830841064453125,
-0.74658203125,
0.347412109375,
-0.2205810546875,
-1.078125,
-0.5986328125,
0.135009765625,
1.5205078125,
-0.24169921875,
1.0146484375,
0.35107421875,
-0.984375,
-0.494140625,
1.1484375,
-0.0008020401000976562,
0.181396484375,
0.97900390625,
-0.6484375,
-0.1783447265625,
-0.106689453125,
-0.2379150390625,
-0.30126953125,
-0.646484375,
0.85693359375,
-0.25244140625,
-0.355712890625,
0.60107421875,
0.923828125,
-0.9208984375,
-0.9873046875,
0.2269287109375,
-0.05047607421875,
-0.0146331787109375,
-0.81396484375,
0.25390625,
0.83935546875,
-0.472900390625,
-0.013214111328125,
0.400390625,
0.111572265625,
0.494384765625,
-0.01708984375,
0.2164306640625,
-0.399169921875,
0.57666015625,
0.50146484375,
-0.54296875,
-0.368896484375,
-0.9921875,
-0.1021728515625,
-0.10870361328125,
0.032012939453125,
0.591796875,
-0.1622314453125,
0.2254638671875,
0.71142578125,
-0.11700439453125,
0.84765625,
-0.6904296875,
-0.332763671875,
0.447509765625,
-0.454833984375,
-0.74755859375,
-0.0194549560546875,
0.33935546875,
-0.23486328125,
0.28466796875,
-0.6484375,
-0.309814453125,
0.48681640625,
0.307373046875,
-0.34619140625,
-0.63037109375,
-0.1630859375,
-0.9365234375,
-0.81884765625,
-0.408203125,
-0.654296875,
-0.2449951171875,
0.03564453125,
0.1995849609375,
-0.06304931640625,
-0.00864410400390625,
0.81689453125,
-1.01171875,
0.9814453125,
-0.34228515625,
0.70068359375,
-0.7705078125,
-0.1533203125,
-0.6474609375,
0.1732177734375,
-0.416259765625,
-0.3369140625,
-0.40380859375,
0.34521484375,
-0.189453125,
0.3212890625,
-0.2479248046875,
0.2783203125,
-0.3017578125,
-0.388427734375,
0.5146484375,
0.09576416015625,
-0.209716796875,
0.72998046875,
0.474365234375,
-0.142333984375,
0.042510986328125,
-0.08551025390625,
-0.308837890625,
-0.5078125,
0.4150390625,
0.59033203125,
-0.400634765625,
-0.1279296875,
-0.379150390625,
-0.0134735107421875,
-0.94580078125,
0.09991455078125,
-0.1441650390625,
0.178955078125,
0.31201171875,
-0.460693359375,
0.36865234375,
0.990234375,
-0.18603515625,
0.273681640625,
-0.1414794921875,
0.1771240234375,
0.5927734375,
0.3154296875,
0.12548828125,
0.5703125,
0.50634765625,
-0.1978759765625,
0.094970703125,
0.1851806640625,
-0.07464599609375,
0.234619140625,
-0.147216796875,
-0.85986328125,
-1.16796875,
-0.1744384765625,
0.014129638671875,
0.5869140625,
-0.041748046875,
-0.61865234375,
0.084228515625,
-0.08856201171875,
-0.66162109375,
0.27001953125,
-0.841796875,
-0.74560546875,
0.525390625,
-0.084716796875,
-0.36376953125,
-0.257568359375,
-0.32958984375,
0.050567626953125,
0.331298828125,
0.498046875,
-0.71826171875,
0.60400390625,
-0.0689697265625,
0.64501953125,
-0.285888671875,
0.043853759765625,
0.305419921875,
0.451904296875,
-0.313720703125,
-0.69189453125,
0.277587890625,
0.962890625,
0.246826171875,
-0.11016845703125,
-0.392578125,
0.18603515625,
-0.199951171875,
0.1357421875,
-0.2095947265625,
-0.064697265625,
-0.16845703125,
0.61962890625,
-1.4453125,
-0.0204010009765625,
-0.269775390625,
0.53857421875,
0.454833984375,
-0.1201171875,
-0.63427734375,
0.67626953125,
0.81298828125,
-0.10443115234375,
0.197509765625,
0.57568359375,
0.406005859375,
-0.197998046875,
-0.12176513671875,
-0.273681640625,
1.025390625,
0.476318359375,
0.494140625,
-0.1917724609375,
0.430908203125,
0.70263671875,
0.369140625,
-0.01317596435546875,
0.492919921875,
0.444091796875,
-0.140625,
-0.04803466796875,
-0.1175537109375,
-0.4580078125,
0.1240234375,
-0.71435546875,
0.623046875,
-0.435302734375,
-0.450439453125,
-0.62939453125,
-0.67724609375,
0.81787109375,
0.1669921875,
-0.58837890625,
0.0672607421875,
-0.2744140625,
0.340087890625,
0.7705078125,
0.11004638671875,
0.00666046142578125,
0.70263671875,
0.75146484375,
0.5625,
0.6884765625,
0.392822265625,
0.6337890625,
-0.61328125,
-0.08782958984375,
-0.002056121826171875,
0.2470703125,
-0.39990234375,
-0.60986328125,
-0.97607421875,
0.79248046875,
-0.54833984375,
0.1680908203125,
0.779296875,
-0.662109375,
-0.12054443359375,
-0.171142578125,
0.732421875,
-0.54296875,
0.2015380859375,
0.368408203125,
-0.6494140625,
-0.51708984375,
0.8828125,
0.06982421875,
0.399169921875,
0.173828125,
0.84521484375,
-0.022552490234375,
1.4931640625,
0.401123046875,
-0.359619140625,
0.1346435546875,
0.37939453125,
-0.35400390625,
-0.6494140625,
-0.478759765625,
-0.25537109375,
-0.1956787109375,
-0.412353515625,
-0.75,
-0.1971435546875,
0.923828125,
-0.04736328125,
-1.052734375,
-0.5732421875,
0.306640625,
-0.88232421875,
0.4326171875,
0.020721435546875,
-0.005443572998046875,
-0.05010986328125,
0.1248779296875,
-0.002262115478515625,
-0.47998046875,
0.348388671875,
-0.416748046875,
0.295654296875,
-0.399169921875,
-0.46533203125,
-0.50732421875,
-0.6552734375,
-0.464599609375,
-0.0675048828125,
-0.447509765625,
-1.146484375,
0.5771484375,
0.367431640625,
0.7919921875,
0.456298828125,
-0.5654296875,
0.399658203125,
0.76611328125,
1.021484375,
0.0982666015625,
1.0634765625,
0.54833984375,
-0.00330352783203125,
0.028594970703125,
-0.1998291015625,
0.80908203125,
-0.2001953125,
0.325439453125,
-0.599609375,
0.71630859375,
-0.31396484375,
-1.234375,
0.03515625,
0.66552734375,
0.470947265625,
-0.802734375,
-1.109375,
-0.22900390625,
-0.85498046875,
-0.1119384765625,
-0.68994140625,
0.64599609375,
-0.075927734375,
0.33349609375,
-0.36962890625,
-1.318359375,
4.3046875,
1.0751953125,
0.697265625,
0.5556640625,
0.350341796875,
0.8701171875,
0.19873046875,
-0.7607421875,
-0.280029296875,
-0.416748046875,
0.63427734375,
-0.6552734375,
-0.0323486328125,
0.90283203125,
0.5126953125,
0.51318359375,
-0.63037109375,
-0.0447998046875,
-0.1463623046875,
-0.97607421875,
-1.169921875,
0.2349853515625,
-0.1737060546875,
0.422119140625,
-0.0126953125,
0.490478515625,
0.76416015625,
-0.454833984375,
-0.28515625,
-0.79345703125,
0.118408203125,
-0.57177734375,
1.005859375,
0.260986328125,
-0.52783203125,
0.6025390625,
-0.2391357421875,
-0.42919921875,
-0.006847381591796875,
0.52734375,
-0.259033203125,
-0.064453125,
0.76123046875,
-0.380859375,
0.0706787109375,
0.65869140625,
-0.544921875,
0.4248046875,
0.1573486328125,
-0.9619140625,
1.212890625,
0.186279296875,
0.0938720703125,
-0.759765625,
-0.499267578125,
0.31689453125,
0.30078125,
-0.329833984375,
-0.419189453125,
0.595703125,
0.1639404296875,
0.2442626953125,
0.0255584716796875,
0.7314453125,
-1.2861328125,
0.90087890625,
-0.247802734375,
0.358642578125,
-0.6591796875,
-0.2822265625,
0.38330078125,
-0.418212890625,
-0.3935546875,
-0.024261474609375,
0.5712890625,
0.2247314453125,
-0.38134765625,
0.455078125,
0.61279296875,
-0.873046875,
0.33251953125,
0.062164306640625,
-0.46484375,
-0.0280914306640625,
0.2919921875,
1.1181640625,
-0.703125,
-0.30859375,
-0.51904296875,
0.42333984375,
0.69921875,
0.340576171875,
0.0328369140625,
-0.3896484375,
0.07806396484375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.
In this problem you should implement the similar functionality.
You are given a string which only consists of:
* uppercase and lowercase English letters,
* underscore symbols (they are used as separators),
* parentheses (both opening and closing).
It is guaranteed that each opening parenthesis has a succeeding closing parenthesis. Similarly, each closing parentheses has a preceding opening parentheses matching it. For each pair of matching parentheses there are no other parenthesis between them. In other words, each parenthesis in the string belongs to a matching "opening-closing" pair, and such pairs can't be nested.
For example, the following string is valid: "_Hello_Vasya(and_Petya)__bye_(and_OK)".
Word is a maximal sequence of consecutive letters, i.e. such sequence that the first character to the left and the first character to the right of it is an underscore, a parenthesis, or it just does not exist. For example, the string above consists of seven words: "Hello", "Vasya", "and", "Petya", "bye", "and" and "OK". Write a program that finds:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 255) — the length of the given string. The second line contains the string consisting of only lowercase and uppercase English letters, parentheses and underscore symbols.
Output
Print two space-separated integers:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Examples
Input
37
_Hello_Vasya(and_Petya)__bye_(and_OK)
Output
5 4
Input
37
_a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
Output
2 6
Input
27
(LoooonG)__shOrt__(LoooonG)
Output
5 2
Input
5
(___)
Output
0 0
Note
In the first sample, the words "Hello", "Vasya" and "bye" are outside any of the parentheses, and the words "and", "Petya", "and" and "OK" are inside. Note, that the word "and" is given twice and you should count it twice in the answer.
Tags: expression parsing, implementation, strings
Correct Solution:
```
from string import ascii_lowercase
n = int(input())
s = input()
wordsLen = 0
wordsInside = 0
flagInside = False
currWord = ""
for i in range(n):
if(s[i]=='_'):
currWord = ""
continue
elif(s[i]=='('):
currWord = ""
flagInside = True
elif(s[i]==')'):
currWord = ""
flagInside = False
elif s[i].lower() in ascii_lowercase:
currWord+=s[i]
if i+1<n:
if s[i+1]=='_' or s[i+1]==')' or s[i+1]=='(':
if flagInside:
wordsInside+=1
else:
wordsLen = max(wordsLen, len(currWord))
if s[n-1].lower() in ascii_lowercase:
wordsLen = max(wordsLen, len(currWord))
print(wordsLen, wordsInside)
```
| 70,331 | [
0.0736083984375,
-0.30712890625,
0.1131591796875,
0.1287841796875,
-0.008453369140625,
-0.316650390625,
-0.0017538070678710938,
-0.11553955078125,
0.0045013427734375,
0.5498046875,
0.6123046875,
-0.0794677734375,
-0.062744140625,
-0.93701171875,
-0.896484375,
0.054229736328125,
-0.6123046875,
-0.69140625,
-0.416015625,
-0.0748291015625,
-0.06475830078125,
0.173583984375,
-1.568359375,
-0.25927734375,
-0.1820068359375,
1.09375,
0.57568359375,
0.05914306640625,
0.89453125,
0.98681640625,
-0.4091796875,
-0.2198486328125,
0.2734375,
-0.7890625,
-0.462890625,
-0.56201171875,
0.80712890625,
-0.96435546875,
0.05694580078125,
-0.54541015625,
0.198486328125,
-0.4404296875,
0.57080078125,
-0.900390625,
-1.05078125,
0.001705169677734375,
-0.133544921875,
-0.195556640625,
0.12939453125,
-0.1446533203125,
0.2021484375,
-0.28515625,
0.362548828125,
-0.408935546875,
0.23876953125,
-0.00447845458984375,
0.2144775390625,
0.1539306640625,
-0.360595703125,
0.1878662109375,
-0.11285400390625,
0.204833984375,
-0.1168212890625,
-0.494140625,
-0.391845703125,
0.212890625,
0.285400390625,
0.12481689453125,
0.32373046875,
-1,
-0.09466552734375,
-0.04522705078125,
-0.267822265625,
-0.1588134765625,
-0.54052734375,
0.2269287109375,
0.75146484375,
-0.10906982421875,
-0.414306640625,
0.7734375,
0.06982421875,
1.0615234375,
0.69873046875,
0.092529296875,
-0.3330078125,
-0.82763671875,
-0.10791015625,
0.275146484375,
0.654296875,
-0.2169189453125,
-0.328369140625,
0.43603515625,
-0.2783203125,
-0.01065826416015625,
0.61865234375,
0.73291015625,
-0.5419921875,
0.2447509765625,
0.15673828125,
0.396240234375,
0.40283203125,
1.23046875,
-0.157470703125,
0.86962890625,
-0.69580078125,
0.340087890625,
0.3935546875,
-0.12432861328125,
-0.0718994140625,
-0.23828125,
-0.36279296875,
-0.35595703125,
0.37646484375,
0.12939453125,
-0.43408203125,
0.90185546875,
-0.492919921875,
0.2451171875,
-0.90283203125,
0.35546875,
0.48828125,
0.0992431640625,
0.2431640625,
-0.263916015625,
0.2685546875,
-0.356201171875,
-0.92431640625,
1.17578125,
-0.4951171875,
-0.44775390625,
0.259765625,
-0.1705322265625,
-0.240234375,
0.53857421875,
-0.2208251953125,
0.83154296875,
-0.2291259765625,
0.17138671875,
0.6943359375,
-1.23828125,
0.78173828125,
-0.163330078125,
0.045074462890625,
1.4990234375,
0.228515625,
0.07275390625,
0.69091796875,
0.48388671875,
-0.8154296875,
0.580078125,
-1.0185546875,
0.90283203125,
0.239990234375,
0.0400390625,
-0.482421875,
0.1451416015625,
-0.1658935546875,
0.1756591796875,
0.298583984375,
-0.18310546875,
-0.27099609375,
-0.053985595703125,
-0.43359375,
0.3798828125,
-0.5341796875,
0.451171875,
-0.505859375,
-0.276123046875,
-0.29296875,
-0.6181640625,
0.0665283203125,
-0.10284423828125,
-0.14208984375,
0.4404296875,
0.54150390625,
1.0966796875,
0.7109375,
-0.358154296875,
0.147705078125,
0.053955078125,
-0.51708984375,
0.114990234375,
-0.04376220703125,
0.65234375,
0.36669921875,
0.1201171875,
-0.00849151611328125,
-0.2314453125,
-1.0078125,
-0.85791015625,
0.43701171875,
0.72802734375,
-0.3681640625,
0.5048828125,
0.455810546875,
0.09930419921875,
-0.98974609375,
0.0982666015625,
0.01067352294921875,
-0.79541015625,
-0.4931640625,
0.69970703125,
-0.151123046875,
0.62109375,
-0.18408203125,
-0.402587890625,
0.225830078125,
1.0556640625,
-0.33154296875,
-0.1295166015625,
0.80615234375,
0.2529296875,
-0.01296234130859375,
0.051666259765625,
0.10052490234375,
-0.310546875,
-1.1806640625,
0.81689453125,
-0.490234375,
0.01183319091796875,
0.1923828125,
0.393310546875,
0.300048828125,
0.38916015625,
0.057037353515625,
-0.02276611328125,
0.379638671875,
1.0126953125,
0.013092041015625,
0.79541015625,
0.2998046875,
0.818359375,
0.446044921875,
0.478759765625,
0.5400390625,
0.47265625,
0.541015625,
0.689453125,
-0.07098388671875,
0.185546875,
-0.2103271484375,
0.54443359375,
0.307861328125,
0.6572265625,
0.08148193359375,
0.375,
-0.1796875,
0.17919921875,
-0.442138671875,
0.54833984375,
-0.313232421875,
0.85888671875,
0.29833984375,
0.53369140625,
-0.77197265625,
-0.347412109375,
0.265869140625,
0.6640625,
-0.94677734375,
-0.459228515625,
-0.1796875,
0.01361846923828125,
0.2130126953125,
0.300048828125,
0.23388671875,
0.2298583984375,
0.83349609375,
0.5947265625,
-0.27490234375,
-0.7001953125,
-0.63232421875,
-0.53759765625,
-1.0185546875,
-0.252685546875,
-0.6103515625,
0.089111328125,
0.356201171875,
-0.9951171875,
0.13134765625,
-0.1824951171875,
-0.2236328125,
-0.1759033203125,
-0.490966796875,
0.48095703125,
-0.42431640625,
0.65283203125,
-0.87890625,
0.59228515625,
0.1209716796875,
0.82177734375,
-0.74169921875,
-0.2158203125,
-0.51123046875,
-0.68310546875,
0.88427734375,
-0.0278778076171875,
0.0902099609375,
-0.14208984375,
-0.74609375,
-0.74560546875,
-0.71240234375,
-0.425537109375,
-0.419921875,
0.40673828125,
-1.015625,
0.79443359375,
0.2425537109375,
-0.412109375,
0.650390625,
1.01953125,
-0.97265625,
0.6650390625,
0.5712890625,
0.2120361328125,
-0.87548828125,
1.14453125,
0.28271484375,
0.10882568359375,
-0.4150390625,
-0.371337890625,
-0.26611328125,
0.09210205078125,
-0.0035610198974609375,
-0.5283203125,
-0.5361328125,
0.71630859375,
0.1851806640625,
-1.0390625,
0.50830078125,
-1.0048828125,
-0.5107421875,
-0.5224609375,
-0.3017578125,
0.85205078125,
1.0078125,
0.004543304443359375,
-0.576171875,
-0.305419921875,
-0.1947021484375,
0.78515625,
0.43359375,
-0.68896484375,
0.06182861328125,
0.7578125,
-0.238037109375,
0.048553466796875,
0.1715087890625,
-0.213134765625,
-0.25390625,
0.17236328125,
0.368408203125,
0.99658203125,
0.10198974609375,
0.2481689453125,
-0.138916015625,
0.5703125,
-0.94970703125,
-0.391357421875,
-0.49462890625,
0.73486328125,
0.280517578125,
0.281494140625,
0.54248046875,
-0.1861572265625,
-0.47314453125,
-1.0712890625,
0.433349609375,
-0.02496337890625,
0.931640625,
-0.787109375,
0.53759765625,
0.58251953125,
-0.7890625,
0.77001953125,
-1.060546875,
-0.1597900390625,
1.3515625,
-0.235595703125,
0.92236328125,
-0.1856689453125,
0.0697021484375,
-0.87158203125,
-0.205810546875,
1.19140625,
0.0010309219360351562,
0.73486328125,
-0.4599609375,
-0.57958984375,
-0.10650634765625,
0.06048583984375,
-0.63134765625,
-0.6015625,
0.349609375,
-0.481689453125,
-0.25439453125,
-0.685546875,
0.67822265625,
1.2431640625,
0.1510009765625,
0.2958984375,
0.60498046875,
0.08660888671875,
0.53662109375,
0.65185546875,
-0.315673828125,
-0.0214996337890625,
-0.8935546875,
0.73779296875,
0.0244140625,
0.11297607421875,
-0.708984375,
-0.08831787109375,
-0.57861328125,
0.28955078125,
-0.45556640625,
-0.21484375,
-0.9619140625,
0.478759765625,
0.1015625,
0.630859375,
-0.796875,
0.09039306640625,
-0.251220703125,
-0.0294189453125,
0.42724609375,
-0.79638671875,
0.236328125,
-1.1298828125,
0.6240234375,
0.423828125,
-0.1917724609375,
-0.6279296875,
-0.08709716796875,
-0.61767578125,
-0.71826171875,
0.0029010772705078125,
0.97119140625,
0.1175537109375,
0.283203125,
-1.09375,
0.212158203125,
0.169189453125,
-0.181396484375,
0.166015625,
0.08221435546875,
0.35888671875,
0.480712890625,
0.80322265625,
-0.46533203125,
-0.76416015625,
-0.0114593505859375,
-1.12890625,
0.7744140625,
-0.41943359375,
0.28125,
-0.08221435546875,
-0.20556640625,
-0.156494140625,
0.296630859375,
0.0673828125,
0.1578369140625,
-0.29736328125,
0.197509765625,
-0.7998046875,
-0.74755859375,
0.712890625,
-0.3935546875,
-0.66748046875,
0.77490234375,
0.2431640625,
-0.14990234375,
0.12152099609375,
0.45458984375,
-0.214111328125,
-0.049774169921875,
-0.5849609375,
0.369140625,
-0.477783203125,
-0.5947265625,
0.037200927734375,
-0.56640625,
0.7373046875,
-0.0255279541015625,
-0.962890625,
-0.103271484375,
-1.451171875,
-0.30615234375,
0.09332275390625,
-0.57177734375,
0.335205078125,
0.215576171875,
0.00484466552734375,
0.272705078125,
-0.6533203125,
-0.55712890625,
-0.2890625,
-0.529296875,
-0.29443359375,
-0.0721435546875,
0.57861328125,
0.6318359375,
0.00890350341796875,
-0.1260986328125,
0.2154541015625,
0.387451171875,
-0.08685302734375,
-0.52392578125,
-0.2076416015625,
-0.458740234375,
-0.04156494140625,
-0.02398681640625,
0.50048828125,
0.239990234375,
0.2281494140625,
0.802734375,
0.419921875,
0.312255859375,
0.53466796875,
-0.335693359375,
0.80517578125,
0.346435546875,
-1.10546875,
-0.446044921875,
0.9443359375,
-0.41748046875,
0.5458984375,
0.1048583984375,
-0.5087890625,
-1.0546875,
-0.88330078125,
0.0938720703125,
-0.35791015625,
-0.295654296875,
-0.7880859375,
-0.357666015625,
-0.1356201171875,
0.5458984375,
0.06744384765625,
-0.51025390625,
0.30029296875,
-1.1611328125,
0.1385498046875,
-0.685546875,
-0.44921875,
-0.53955078125,
-0.6943359375,
-0.465087890625,
0.71875,
0.317138671875,
0.392333984375,
0.1817626953125,
-0.408203125,
0.170166015625,
0.01171875,
-0.7275390625,
-0.316650390625,
0.0030727386474609375,
0.08209228515625,
0.00547027587890625,
-0.1595458984375,
-0.41845703125,
0.955078125,
-1.46484375,
0.110595703125,
-0.0650634765625,
-0.493896484375,
-0.280517578125,
-0.265869140625,
0.869140625,
-0.06097412109375,
-0.28369140625,
-0.284423828125,
0.5986328125,
0.447021484375,
-0.1805419921875,
-0.70458984375,
-0.76416015625,
-0.64697265625,
-0.84814453125,
0.50341796875,
-0.364501953125,
0.32177734375,
-0.60986328125,
0.11273193359375,
1.2294921875,
-0.64892578125,
0.515625,
1.0419921875,
0.5166015625,
0.27978515625,
-0.69580078125,
0.388916015625,
0.00424957275390625,
-0.78125,
-0.0297393798828125,
-0.00830841064453125,
-0.74658203125,
0.347412109375,
-0.2205810546875,
-1.078125,
-0.5986328125,
0.135009765625,
1.5205078125,
-0.24169921875,
1.0146484375,
0.35107421875,
-0.984375,
-0.494140625,
1.1484375,
-0.0008020401000976562,
0.181396484375,
0.97900390625,
-0.6484375,
-0.1783447265625,
-0.106689453125,
-0.2379150390625,
-0.30126953125,
-0.646484375,
0.85693359375,
-0.25244140625,
-0.355712890625,
0.60107421875,
0.923828125,
-0.9208984375,
-0.9873046875,
0.2269287109375,
-0.05047607421875,
-0.0146331787109375,
-0.81396484375,
0.25390625,
0.83935546875,
-0.472900390625,
-0.013214111328125,
0.400390625,
0.111572265625,
0.494384765625,
-0.01708984375,
0.2164306640625,
-0.399169921875,
0.57666015625,
0.50146484375,
-0.54296875,
-0.368896484375,
-0.9921875,
-0.1021728515625,
-0.10870361328125,
0.032012939453125,
0.591796875,
-0.1622314453125,
0.2254638671875,
0.71142578125,
-0.11700439453125,
0.84765625,
-0.6904296875,
-0.332763671875,
0.447509765625,
-0.454833984375,
-0.74755859375,
-0.0194549560546875,
0.33935546875,
-0.23486328125,
0.28466796875,
-0.6484375,
-0.309814453125,
0.48681640625,
0.307373046875,
-0.34619140625,
-0.63037109375,
-0.1630859375,
-0.9365234375,
-0.81884765625,
-0.408203125,
-0.654296875,
-0.2449951171875,
0.03564453125,
0.1995849609375,
-0.06304931640625,
-0.00864410400390625,
0.81689453125,
-1.01171875,
0.9814453125,
-0.34228515625,
0.70068359375,
-0.7705078125,
-0.1533203125,
-0.6474609375,
0.1732177734375,
-0.416259765625,
-0.3369140625,
-0.40380859375,
0.34521484375,
-0.189453125,
0.3212890625,
-0.2479248046875,
0.2783203125,
-0.3017578125,
-0.388427734375,
0.5146484375,
0.09576416015625,
-0.209716796875,
0.72998046875,
0.474365234375,
-0.142333984375,
0.042510986328125,
-0.08551025390625,
-0.308837890625,
-0.5078125,
0.4150390625,
0.59033203125,
-0.400634765625,
-0.1279296875,
-0.379150390625,
-0.0134735107421875,
-0.94580078125,
0.09991455078125,
-0.1441650390625,
0.178955078125,
0.31201171875,
-0.460693359375,
0.36865234375,
0.990234375,
-0.18603515625,
0.273681640625,
-0.1414794921875,
0.1771240234375,
0.5927734375,
0.3154296875,
0.12548828125,
0.5703125,
0.50634765625,
-0.1978759765625,
0.094970703125,
0.1851806640625,
-0.07464599609375,
0.234619140625,
-0.147216796875,
-0.85986328125,
-1.16796875,
-0.1744384765625,
0.014129638671875,
0.5869140625,
-0.041748046875,
-0.61865234375,
0.084228515625,
-0.08856201171875,
-0.66162109375,
0.27001953125,
-0.841796875,
-0.74560546875,
0.525390625,
-0.084716796875,
-0.36376953125,
-0.257568359375,
-0.32958984375,
0.050567626953125,
0.331298828125,
0.498046875,
-0.71826171875,
0.60400390625,
-0.0689697265625,
0.64501953125,
-0.285888671875,
0.043853759765625,
0.305419921875,
0.451904296875,
-0.313720703125,
-0.69189453125,
0.277587890625,
0.962890625,
0.246826171875,
-0.11016845703125,
-0.392578125,
0.18603515625,
-0.199951171875,
0.1357421875,
-0.2095947265625,
-0.064697265625,
-0.16845703125,
0.61962890625,
-1.4453125,
-0.0204010009765625,
-0.269775390625,
0.53857421875,
0.454833984375,
-0.1201171875,
-0.63427734375,
0.67626953125,
0.81298828125,
-0.10443115234375,
0.197509765625,
0.57568359375,
0.406005859375,
-0.197998046875,
-0.12176513671875,
-0.273681640625,
1.025390625,
0.476318359375,
0.494140625,
-0.1917724609375,
0.430908203125,
0.70263671875,
0.369140625,
-0.01317596435546875,
0.492919921875,
0.444091796875,
-0.140625,
-0.04803466796875,
-0.1175537109375,
-0.4580078125,
0.1240234375,
-0.71435546875,
0.623046875,
-0.435302734375,
-0.450439453125,
-0.62939453125,
-0.67724609375,
0.81787109375,
0.1669921875,
-0.58837890625,
0.0672607421875,
-0.2744140625,
0.340087890625,
0.7705078125,
0.11004638671875,
0.00666046142578125,
0.70263671875,
0.75146484375,
0.5625,
0.6884765625,
0.392822265625,
0.6337890625,
-0.61328125,
-0.08782958984375,
-0.002056121826171875,
0.2470703125,
-0.39990234375,
-0.60986328125,
-0.97607421875,
0.79248046875,
-0.54833984375,
0.1680908203125,
0.779296875,
-0.662109375,
-0.12054443359375,
-0.171142578125,
0.732421875,
-0.54296875,
0.2015380859375,
0.368408203125,
-0.6494140625,
-0.51708984375,
0.8828125,
0.06982421875,
0.399169921875,
0.173828125,
0.84521484375,
-0.022552490234375,
1.4931640625,
0.401123046875,
-0.359619140625,
0.1346435546875,
0.37939453125,
-0.35400390625,
-0.6494140625,
-0.478759765625,
-0.25537109375,
-0.1956787109375,
-0.412353515625,
-0.75,
-0.1971435546875,
0.923828125,
-0.04736328125,
-1.052734375,
-0.5732421875,
0.306640625,
-0.88232421875,
0.4326171875,
0.020721435546875,
-0.005443572998046875,
-0.05010986328125,
0.1248779296875,
-0.002262115478515625,
-0.47998046875,
0.348388671875,
-0.416748046875,
0.295654296875,
-0.399169921875,
-0.46533203125,
-0.50732421875,
-0.6552734375,
-0.464599609375,
-0.0675048828125,
-0.447509765625,
-1.146484375,
0.5771484375,
0.367431640625,
0.7919921875,
0.456298828125,
-0.5654296875,
0.399658203125,
0.76611328125,
1.021484375,
0.0982666015625,
1.0634765625,
0.54833984375,
-0.00330352783203125,
0.028594970703125,
-0.1998291015625,
0.80908203125,
-0.2001953125,
0.325439453125,
-0.599609375,
0.71630859375,
-0.31396484375,
-1.234375,
0.03515625,
0.66552734375,
0.470947265625,
-0.802734375,
-1.109375,
-0.22900390625,
-0.85498046875,
-0.1119384765625,
-0.68994140625,
0.64599609375,
-0.075927734375,
0.33349609375,
-0.36962890625,
-1.318359375,
4.3046875,
1.0751953125,
0.697265625,
0.5556640625,
0.350341796875,
0.8701171875,
0.19873046875,
-0.7607421875,
-0.280029296875,
-0.416748046875,
0.63427734375,
-0.6552734375,
-0.0323486328125,
0.90283203125,
0.5126953125,
0.51318359375,
-0.63037109375,
-0.0447998046875,
-0.1463623046875,
-0.97607421875,
-1.169921875,
0.2349853515625,
-0.1737060546875,
0.422119140625,
-0.0126953125,
0.490478515625,
0.76416015625,
-0.454833984375,
-0.28515625,
-0.79345703125,
0.118408203125,
-0.57177734375,
1.005859375,
0.260986328125,
-0.52783203125,
0.6025390625,
-0.2391357421875,
-0.42919921875,
-0.006847381591796875,
0.52734375,
-0.259033203125,
-0.064453125,
0.76123046875,
-0.380859375,
0.0706787109375,
0.65869140625,
-0.544921875,
0.4248046875,
0.1573486328125,
-0.9619140625,
1.212890625,
0.186279296875,
0.0938720703125,
-0.759765625,
-0.499267578125,
0.31689453125,
0.30078125,
-0.329833984375,
-0.419189453125,
0.595703125,
0.1639404296875,
0.2442626953125,
0.0255584716796875,
0.7314453125,
-1.2861328125,
0.90087890625,
-0.247802734375,
0.358642578125,
-0.6591796875,
-0.2822265625,
0.38330078125,
-0.418212890625,
-0.3935546875,
-0.024261474609375,
0.5712890625,
0.2247314453125,
-0.38134765625,
0.455078125,
0.61279296875,
-0.873046875,
0.33251953125,
0.062164306640625,
-0.46484375,
-0.0280914306640625,
0.2919921875,
1.1181640625,
-0.703125,
-0.30859375,
-0.51904296875,
0.42333984375,
0.69921875,
0.340576171875,
0.0328369140625,
-0.3896484375,
0.07806396484375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.
In this problem you should implement the similar functionality.
You are given a string which only consists of:
* uppercase and lowercase English letters,
* underscore symbols (they are used as separators),
* parentheses (both opening and closing).
It is guaranteed that each opening parenthesis has a succeeding closing parenthesis. Similarly, each closing parentheses has a preceding opening parentheses matching it. For each pair of matching parentheses there are no other parenthesis between them. In other words, each parenthesis in the string belongs to a matching "opening-closing" pair, and such pairs can't be nested.
For example, the following string is valid: "_Hello_Vasya(and_Petya)__bye_(and_OK)".
Word is a maximal sequence of consecutive letters, i.e. such sequence that the first character to the left and the first character to the right of it is an underscore, a parenthesis, or it just does not exist. For example, the string above consists of seven words: "Hello", "Vasya", "and", "Petya", "bye", "and" and "OK". Write a program that finds:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 255) — the length of the given string. The second line contains the string consisting of only lowercase and uppercase English letters, parentheses and underscore symbols.
Output
Print two space-separated integers:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Examples
Input
37
_Hello_Vasya(and_Petya)__bye_(and_OK)
Output
5 4
Input
37
_a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
Output
2 6
Input
27
(LoooonG)__shOrt__(LoooonG)
Output
5 2
Input
5
(___)
Output
0 0
Note
In the first sample, the words "Hello", "Vasya" and "bye" are outside any of the parentheses, and the words "and", "Petya", "and" and "OK" are inside. Note, that the word "and" is given twice and you should count it twice in the answer.
Tags: expression parsing, implementation, strings
Correct Solution:
```
import math,sys,re,itertools,pprint
ri,rai=lambda:int(input()),lambda:list(map(int, input().split()))
n = ri()
s = input()
out = True
w = 0
r1, r2 = 0, 0
for c in s:
if c in '_()':
if w > 0 and not out:
r2 += 1
w = 0
else:
w += 1
if out:
r1 = max(r1, w)
if c == '(':
out = False
if c == ')':
out = True
print(r1, r2)
```
| 70,332 | [
0.0736083984375,
-0.30712890625,
0.1131591796875,
0.1287841796875,
-0.008453369140625,
-0.316650390625,
-0.0017538070678710938,
-0.11553955078125,
0.0045013427734375,
0.5498046875,
0.6123046875,
-0.0794677734375,
-0.062744140625,
-0.93701171875,
-0.896484375,
0.054229736328125,
-0.6123046875,
-0.69140625,
-0.416015625,
-0.0748291015625,
-0.06475830078125,
0.173583984375,
-1.568359375,
-0.25927734375,
-0.1820068359375,
1.09375,
0.57568359375,
0.05914306640625,
0.89453125,
0.98681640625,
-0.4091796875,
-0.2198486328125,
0.2734375,
-0.7890625,
-0.462890625,
-0.56201171875,
0.80712890625,
-0.96435546875,
0.05694580078125,
-0.54541015625,
0.198486328125,
-0.4404296875,
0.57080078125,
-0.900390625,
-1.05078125,
0.001705169677734375,
-0.133544921875,
-0.195556640625,
0.12939453125,
-0.1446533203125,
0.2021484375,
-0.28515625,
0.362548828125,
-0.408935546875,
0.23876953125,
-0.00447845458984375,
0.2144775390625,
0.1539306640625,
-0.360595703125,
0.1878662109375,
-0.11285400390625,
0.204833984375,
-0.1168212890625,
-0.494140625,
-0.391845703125,
0.212890625,
0.285400390625,
0.12481689453125,
0.32373046875,
-1,
-0.09466552734375,
-0.04522705078125,
-0.267822265625,
-0.1588134765625,
-0.54052734375,
0.2269287109375,
0.75146484375,
-0.10906982421875,
-0.414306640625,
0.7734375,
0.06982421875,
1.0615234375,
0.69873046875,
0.092529296875,
-0.3330078125,
-0.82763671875,
-0.10791015625,
0.275146484375,
0.654296875,
-0.2169189453125,
-0.328369140625,
0.43603515625,
-0.2783203125,
-0.01065826416015625,
0.61865234375,
0.73291015625,
-0.5419921875,
0.2447509765625,
0.15673828125,
0.396240234375,
0.40283203125,
1.23046875,
-0.157470703125,
0.86962890625,
-0.69580078125,
0.340087890625,
0.3935546875,
-0.12432861328125,
-0.0718994140625,
-0.23828125,
-0.36279296875,
-0.35595703125,
0.37646484375,
0.12939453125,
-0.43408203125,
0.90185546875,
-0.492919921875,
0.2451171875,
-0.90283203125,
0.35546875,
0.48828125,
0.0992431640625,
0.2431640625,
-0.263916015625,
0.2685546875,
-0.356201171875,
-0.92431640625,
1.17578125,
-0.4951171875,
-0.44775390625,
0.259765625,
-0.1705322265625,
-0.240234375,
0.53857421875,
-0.2208251953125,
0.83154296875,
-0.2291259765625,
0.17138671875,
0.6943359375,
-1.23828125,
0.78173828125,
-0.163330078125,
0.045074462890625,
1.4990234375,
0.228515625,
0.07275390625,
0.69091796875,
0.48388671875,
-0.8154296875,
0.580078125,
-1.0185546875,
0.90283203125,
0.239990234375,
0.0400390625,
-0.482421875,
0.1451416015625,
-0.1658935546875,
0.1756591796875,
0.298583984375,
-0.18310546875,
-0.27099609375,
-0.053985595703125,
-0.43359375,
0.3798828125,
-0.5341796875,
0.451171875,
-0.505859375,
-0.276123046875,
-0.29296875,
-0.6181640625,
0.0665283203125,
-0.10284423828125,
-0.14208984375,
0.4404296875,
0.54150390625,
1.0966796875,
0.7109375,
-0.358154296875,
0.147705078125,
0.053955078125,
-0.51708984375,
0.114990234375,
-0.04376220703125,
0.65234375,
0.36669921875,
0.1201171875,
-0.00849151611328125,
-0.2314453125,
-1.0078125,
-0.85791015625,
0.43701171875,
0.72802734375,
-0.3681640625,
0.5048828125,
0.455810546875,
0.09930419921875,
-0.98974609375,
0.0982666015625,
0.01067352294921875,
-0.79541015625,
-0.4931640625,
0.69970703125,
-0.151123046875,
0.62109375,
-0.18408203125,
-0.402587890625,
0.225830078125,
1.0556640625,
-0.33154296875,
-0.1295166015625,
0.80615234375,
0.2529296875,
-0.01296234130859375,
0.051666259765625,
0.10052490234375,
-0.310546875,
-1.1806640625,
0.81689453125,
-0.490234375,
0.01183319091796875,
0.1923828125,
0.393310546875,
0.300048828125,
0.38916015625,
0.057037353515625,
-0.02276611328125,
0.379638671875,
1.0126953125,
0.013092041015625,
0.79541015625,
0.2998046875,
0.818359375,
0.446044921875,
0.478759765625,
0.5400390625,
0.47265625,
0.541015625,
0.689453125,
-0.07098388671875,
0.185546875,
-0.2103271484375,
0.54443359375,
0.307861328125,
0.6572265625,
0.08148193359375,
0.375,
-0.1796875,
0.17919921875,
-0.442138671875,
0.54833984375,
-0.313232421875,
0.85888671875,
0.29833984375,
0.53369140625,
-0.77197265625,
-0.347412109375,
0.265869140625,
0.6640625,
-0.94677734375,
-0.459228515625,
-0.1796875,
0.01361846923828125,
0.2130126953125,
0.300048828125,
0.23388671875,
0.2298583984375,
0.83349609375,
0.5947265625,
-0.27490234375,
-0.7001953125,
-0.63232421875,
-0.53759765625,
-1.0185546875,
-0.252685546875,
-0.6103515625,
0.089111328125,
0.356201171875,
-0.9951171875,
0.13134765625,
-0.1824951171875,
-0.2236328125,
-0.1759033203125,
-0.490966796875,
0.48095703125,
-0.42431640625,
0.65283203125,
-0.87890625,
0.59228515625,
0.1209716796875,
0.82177734375,
-0.74169921875,
-0.2158203125,
-0.51123046875,
-0.68310546875,
0.88427734375,
-0.0278778076171875,
0.0902099609375,
-0.14208984375,
-0.74609375,
-0.74560546875,
-0.71240234375,
-0.425537109375,
-0.419921875,
0.40673828125,
-1.015625,
0.79443359375,
0.2425537109375,
-0.412109375,
0.650390625,
1.01953125,
-0.97265625,
0.6650390625,
0.5712890625,
0.2120361328125,
-0.87548828125,
1.14453125,
0.28271484375,
0.10882568359375,
-0.4150390625,
-0.371337890625,
-0.26611328125,
0.09210205078125,
-0.0035610198974609375,
-0.5283203125,
-0.5361328125,
0.71630859375,
0.1851806640625,
-1.0390625,
0.50830078125,
-1.0048828125,
-0.5107421875,
-0.5224609375,
-0.3017578125,
0.85205078125,
1.0078125,
0.004543304443359375,
-0.576171875,
-0.305419921875,
-0.1947021484375,
0.78515625,
0.43359375,
-0.68896484375,
0.06182861328125,
0.7578125,
-0.238037109375,
0.048553466796875,
0.1715087890625,
-0.213134765625,
-0.25390625,
0.17236328125,
0.368408203125,
0.99658203125,
0.10198974609375,
0.2481689453125,
-0.138916015625,
0.5703125,
-0.94970703125,
-0.391357421875,
-0.49462890625,
0.73486328125,
0.280517578125,
0.281494140625,
0.54248046875,
-0.1861572265625,
-0.47314453125,
-1.0712890625,
0.433349609375,
-0.02496337890625,
0.931640625,
-0.787109375,
0.53759765625,
0.58251953125,
-0.7890625,
0.77001953125,
-1.060546875,
-0.1597900390625,
1.3515625,
-0.235595703125,
0.92236328125,
-0.1856689453125,
0.0697021484375,
-0.87158203125,
-0.205810546875,
1.19140625,
0.0010309219360351562,
0.73486328125,
-0.4599609375,
-0.57958984375,
-0.10650634765625,
0.06048583984375,
-0.63134765625,
-0.6015625,
0.349609375,
-0.481689453125,
-0.25439453125,
-0.685546875,
0.67822265625,
1.2431640625,
0.1510009765625,
0.2958984375,
0.60498046875,
0.08660888671875,
0.53662109375,
0.65185546875,
-0.315673828125,
-0.0214996337890625,
-0.8935546875,
0.73779296875,
0.0244140625,
0.11297607421875,
-0.708984375,
-0.08831787109375,
-0.57861328125,
0.28955078125,
-0.45556640625,
-0.21484375,
-0.9619140625,
0.478759765625,
0.1015625,
0.630859375,
-0.796875,
0.09039306640625,
-0.251220703125,
-0.0294189453125,
0.42724609375,
-0.79638671875,
0.236328125,
-1.1298828125,
0.6240234375,
0.423828125,
-0.1917724609375,
-0.6279296875,
-0.08709716796875,
-0.61767578125,
-0.71826171875,
0.0029010772705078125,
0.97119140625,
0.1175537109375,
0.283203125,
-1.09375,
0.212158203125,
0.169189453125,
-0.181396484375,
0.166015625,
0.08221435546875,
0.35888671875,
0.480712890625,
0.80322265625,
-0.46533203125,
-0.76416015625,
-0.0114593505859375,
-1.12890625,
0.7744140625,
-0.41943359375,
0.28125,
-0.08221435546875,
-0.20556640625,
-0.156494140625,
0.296630859375,
0.0673828125,
0.1578369140625,
-0.29736328125,
0.197509765625,
-0.7998046875,
-0.74755859375,
0.712890625,
-0.3935546875,
-0.66748046875,
0.77490234375,
0.2431640625,
-0.14990234375,
0.12152099609375,
0.45458984375,
-0.214111328125,
-0.049774169921875,
-0.5849609375,
0.369140625,
-0.477783203125,
-0.5947265625,
0.037200927734375,
-0.56640625,
0.7373046875,
-0.0255279541015625,
-0.962890625,
-0.103271484375,
-1.451171875,
-0.30615234375,
0.09332275390625,
-0.57177734375,
0.335205078125,
0.215576171875,
0.00484466552734375,
0.272705078125,
-0.6533203125,
-0.55712890625,
-0.2890625,
-0.529296875,
-0.29443359375,
-0.0721435546875,
0.57861328125,
0.6318359375,
0.00890350341796875,
-0.1260986328125,
0.2154541015625,
0.387451171875,
-0.08685302734375,
-0.52392578125,
-0.2076416015625,
-0.458740234375,
-0.04156494140625,
-0.02398681640625,
0.50048828125,
0.239990234375,
0.2281494140625,
0.802734375,
0.419921875,
0.312255859375,
0.53466796875,
-0.335693359375,
0.80517578125,
0.346435546875,
-1.10546875,
-0.446044921875,
0.9443359375,
-0.41748046875,
0.5458984375,
0.1048583984375,
-0.5087890625,
-1.0546875,
-0.88330078125,
0.0938720703125,
-0.35791015625,
-0.295654296875,
-0.7880859375,
-0.357666015625,
-0.1356201171875,
0.5458984375,
0.06744384765625,
-0.51025390625,
0.30029296875,
-1.1611328125,
0.1385498046875,
-0.685546875,
-0.44921875,
-0.53955078125,
-0.6943359375,
-0.465087890625,
0.71875,
0.317138671875,
0.392333984375,
0.1817626953125,
-0.408203125,
0.170166015625,
0.01171875,
-0.7275390625,
-0.316650390625,
0.0030727386474609375,
0.08209228515625,
0.00547027587890625,
-0.1595458984375,
-0.41845703125,
0.955078125,
-1.46484375,
0.110595703125,
-0.0650634765625,
-0.493896484375,
-0.280517578125,
-0.265869140625,
0.869140625,
-0.06097412109375,
-0.28369140625,
-0.284423828125,
0.5986328125,
0.447021484375,
-0.1805419921875,
-0.70458984375,
-0.76416015625,
-0.64697265625,
-0.84814453125,
0.50341796875,
-0.364501953125,
0.32177734375,
-0.60986328125,
0.11273193359375,
1.2294921875,
-0.64892578125,
0.515625,
1.0419921875,
0.5166015625,
0.27978515625,
-0.69580078125,
0.388916015625,
0.00424957275390625,
-0.78125,
-0.0297393798828125,
-0.00830841064453125,
-0.74658203125,
0.347412109375,
-0.2205810546875,
-1.078125,
-0.5986328125,
0.135009765625,
1.5205078125,
-0.24169921875,
1.0146484375,
0.35107421875,
-0.984375,
-0.494140625,
1.1484375,
-0.0008020401000976562,
0.181396484375,
0.97900390625,
-0.6484375,
-0.1783447265625,
-0.106689453125,
-0.2379150390625,
-0.30126953125,
-0.646484375,
0.85693359375,
-0.25244140625,
-0.355712890625,
0.60107421875,
0.923828125,
-0.9208984375,
-0.9873046875,
0.2269287109375,
-0.05047607421875,
-0.0146331787109375,
-0.81396484375,
0.25390625,
0.83935546875,
-0.472900390625,
-0.013214111328125,
0.400390625,
0.111572265625,
0.494384765625,
-0.01708984375,
0.2164306640625,
-0.399169921875,
0.57666015625,
0.50146484375,
-0.54296875,
-0.368896484375,
-0.9921875,
-0.1021728515625,
-0.10870361328125,
0.032012939453125,
0.591796875,
-0.1622314453125,
0.2254638671875,
0.71142578125,
-0.11700439453125,
0.84765625,
-0.6904296875,
-0.332763671875,
0.447509765625,
-0.454833984375,
-0.74755859375,
-0.0194549560546875,
0.33935546875,
-0.23486328125,
0.28466796875,
-0.6484375,
-0.309814453125,
0.48681640625,
0.307373046875,
-0.34619140625,
-0.63037109375,
-0.1630859375,
-0.9365234375,
-0.81884765625,
-0.408203125,
-0.654296875,
-0.2449951171875,
0.03564453125,
0.1995849609375,
-0.06304931640625,
-0.00864410400390625,
0.81689453125,
-1.01171875,
0.9814453125,
-0.34228515625,
0.70068359375,
-0.7705078125,
-0.1533203125,
-0.6474609375,
0.1732177734375,
-0.416259765625,
-0.3369140625,
-0.40380859375,
0.34521484375,
-0.189453125,
0.3212890625,
-0.2479248046875,
0.2783203125,
-0.3017578125,
-0.388427734375,
0.5146484375,
0.09576416015625,
-0.209716796875,
0.72998046875,
0.474365234375,
-0.142333984375,
0.042510986328125,
-0.08551025390625,
-0.308837890625,
-0.5078125,
0.4150390625,
0.59033203125,
-0.400634765625,
-0.1279296875,
-0.379150390625,
-0.0134735107421875,
-0.94580078125,
0.09991455078125,
-0.1441650390625,
0.178955078125,
0.31201171875,
-0.460693359375,
0.36865234375,
0.990234375,
-0.18603515625,
0.273681640625,
-0.1414794921875,
0.1771240234375,
0.5927734375,
0.3154296875,
0.12548828125,
0.5703125,
0.50634765625,
-0.1978759765625,
0.094970703125,
0.1851806640625,
-0.07464599609375,
0.234619140625,
-0.147216796875,
-0.85986328125,
-1.16796875,
-0.1744384765625,
0.014129638671875,
0.5869140625,
-0.041748046875,
-0.61865234375,
0.084228515625,
-0.08856201171875,
-0.66162109375,
0.27001953125,
-0.841796875,
-0.74560546875,
0.525390625,
-0.084716796875,
-0.36376953125,
-0.257568359375,
-0.32958984375,
0.050567626953125,
0.331298828125,
0.498046875,
-0.71826171875,
0.60400390625,
-0.0689697265625,
0.64501953125,
-0.285888671875,
0.043853759765625,
0.305419921875,
0.451904296875,
-0.313720703125,
-0.69189453125,
0.277587890625,
0.962890625,
0.246826171875,
-0.11016845703125,
-0.392578125,
0.18603515625,
-0.199951171875,
0.1357421875,
-0.2095947265625,
-0.064697265625,
-0.16845703125,
0.61962890625,
-1.4453125,
-0.0204010009765625,
-0.269775390625,
0.53857421875,
0.454833984375,
-0.1201171875,
-0.63427734375,
0.67626953125,
0.81298828125,
-0.10443115234375,
0.197509765625,
0.57568359375,
0.406005859375,
-0.197998046875,
-0.12176513671875,
-0.273681640625,
1.025390625,
0.476318359375,
0.494140625,
-0.1917724609375,
0.430908203125,
0.70263671875,
0.369140625,
-0.01317596435546875,
0.492919921875,
0.444091796875,
-0.140625,
-0.04803466796875,
-0.1175537109375,
-0.4580078125,
0.1240234375,
-0.71435546875,
0.623046875,
-0.435302734375,
-0.450439453125,
-0.62939453125,
-0.67724609375,
0.81787109375,
0.1669921875,
-0.58837890625,
0.0672607421875,
-0.2744140625,
0.340087890625,
0.7705078125,
0.11004638671875,
0.00666046142578125,
0.70263671875,
0.75146484375,
0.5625,
0.6884765625,
0.392822265625,
0.6337890625,
-0.61328125,
-0.08782958984375,
-0.002056121826171875,
0.2470703125,
-0.39990234375,
-0.60986328125,
-0.97607421875,
0.79248046875,
-0.54833984375,
0.1680908203125,
0.779296875,
-0.662109375,
-0.12054443359375,
-0.171142578125,
0.732421875,
-0.54296875,
0.2015380859375,
0.368408203125,
-0.6494140625,
-0.51708984375,
0.8828125,
0.06982421875,
0.399169921875,
0.173828125,
0.84521484375,
-0.022552490234375,
1.4931640625,
0.401123046875,
-0.359619140625,
0.1346435546875,
0.37939453125,
-0.35400390625,
-0.6494140625,
-0.478759765625,
-0.25537109375,
-0.1956787109375,
-0.412353515625,
-0.75,
-0.1971435546875,
0.923828125,
-0.04736328125,
-1.052734375,
-0.5732421875,
0.306640625,
-0.88232421875,
0.4326171875,
0.020721435546875,
-0.005443572998046875,
-0.05010986328125,
0.1248779296875,
-0.002262115478515625,
-0.47998046875,
0.348388671875,
-0.416748046875,
0.295654296875,
-0.399169921875,
-0.46533203125,
-0.50732421875,
-0.6552734375,
-0.464599609375,
-0.0675048828125,
-0.447509765625,
-1.146484375,
0.5771484375,
0.367431640625,
0.7919921875,
0.456298828125,
-0.5654296875,
0.399658203125,
0.76611328125,
1.021484375,
0.0982666015625,
1.0634765625,
0.54833984375,
-0.00330352783203125,
0.028594970703125,
-0.1998291015625,
0.80908203125,
-0.2001953125,
0.325439453125,
-0.599609375,
0.71630859375,
-0.31396484375,
-1.234375,
0.03515625,
0.66552734375,
0.470947265625,
-0.802734375,
-1.109375,
-0.22900390625,
-0.85498046875,
-0.1119384765625,
-0.68994140625,
0.64599609375,
-0.075927734375,
0.33349609375,
-0.36962890625,
-1.318359375,
4.3046875,
1.0751953125,
0.697265625,
0.5556640625,
0.350341796875,
0.8701171875,
0.19873046875,
-0.7607421875,
-0.280029296875,
-0.416748046875,
0.63427734375,
-0.6552734375,
-0.0323486328125,
0.90283203125,
0.5126953125,
0.51318359375,
-0.63037109375,
-0.0447998046875,
-0.1463623046875,
-0.97607421875,
-1.169921875,
0.2349853515625,
-0.1737060546875,
0.422119140625,
-0.0126953125,
0.490478515625,
0.76416015625,
-0.454833984375,
-0.28515625,
-0.79345703125,
0.118408203125,
-0.57177734375,
1.005859375,
0.260986328125,
-0.52783203125,
0.6025390625,
-0.2391357421875,
-0.42919921875,
-0.006847381591796875,
0.52734375,
-0.259033203125,
-0.064453125,
0.76123046875,
-0.380859375,
0.0706787109375,
0.65869140625,
-0.544921875,
0.4248046875,
0.1573486328125,
-0.9619140625,
1.212890625,
0.186279296875,
0.0938720703125,
-0.759765625,
-0.499267578125,
0.31689453125,
0.30078125,
-0.329833984375,
-0.419189453125,
0.595703125,
0.1639404296875,
0.2442626953125,
0.0255584716796875,
0.7314453125,
-1.2861328125,
0.90087890625,
-0.247802734375,
0.358642578125,
-0.6591796875,
-0.2822265625,
0.38330078125,
-0.418212890625,
-0.3935546875,
-0.024261474609375,
0.5712890625,
0.2247314453125,
-0.38134765625,
0.455078125,
0.61279296875,
-0.873046875,
0.33251953125,
0.062164306640625,
-0.46484375,
-0.0280914306640625,
0.2919921875,
1.1181640625,
-0.703125,
-0.30859375,
-0.51904296875,
0.42333984375,
0.69921875,
0.340576171875,
0.0328369140625,
-0.3896484375,
0.07806396484375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.
In this problem you should implement the similar functionality.
You are given a string which only consists of:
* uppercase and lowercase English letters,
* underscore symbols (they are used as separators),
* parentheses (both opening and closing).
It is guaranteed that each opening parenthesis has a succeeding closing parenthesis. Similarly, each closing parentheses has a preceding opening parentheses matching it. For each pair of matching parentheses there are no other parenthesis between them. In other words, each parenthesis in the string belongs to a matching "opening-closing" pair, and such pairs can't be nested.
For example, the following string is valid: "_Hello_Vasya(and_Petya)__bye_(and_OK)".
Word is a maximal sequence of consecutive letters, i.e. such sequence that the first character to the left and the first character to the right of it is an underscore, a parenthesis, or it just does not exist. For example, the string above consists of seven words: "Hello", "Vasya", "and", "Petya", "bye", "and" and "OK". Write a program that finds:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 255) — the length of the given string. The second line contains the string consisting of only lowercase and uppercase English letters, parentheses and underscore symbols.
Output
Print two space-separated integers:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Examples
Input
37
_Hello_Vasya(and_Petya)__bye_(and_OK)
Output
5 4
Input
37
_a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
Output
2 6
Input
27
(LoooonG)__shOrt__(LoooonG)
Output
5 2
Input
5
(___)
Output
0 0
Note
In the first sample, the words "Hello", "Vasya" and "bye" are outside any of the parentheses, and the words "and", "Petya", "and" and "OK" are inside. Note, that the word "and" is given twice and you should count it twice in the answer.
Tags: expression parsing, implementation, strings
Correct Solution:
```
n = int(input())
s = input()
s += '_'
skob = 0
cnt = 0
maxL = 0
word = ''
for i in range(len(s)):
cur = s[i]
if cur == '_':
if skob > 0 and len(word) != 0:
cnt += 1
else:
if len(word) != 0:
if len(word) > maxL:
maxL = len(word)
word = ''
elif cur == '(':
if skob == 0:
if len(word) > maxL:
maxL = len(word)
else:
cnt += 1
skob += 1
word = ''
elif cur == ')':
if s[i - 1] != '_' and s[i - 1] != '(':
cnt += 1
word = ''
skob -= 1
else:
word += cur
print(maxL, cnt)
```
| 70,333 | [
0.0736083984375,
-0.30712890625,
0.1131591796875,
0.1287841796875,
-0.008453369140625,
-0.316650390625,
-0.0017538070678710938,
-0.11553955078125,
0.0045013427734375,
0.5498046875,
0.6123046875,
-0.0794677734375,
-0.062744140625,
-0.93701171875,
-0.896484375,
0.054229736328125,
-0.6123046875,
-0.69140625,
-0.416015625,
-0.0748291015625,
-0.06475830078125,
0.173583984375,
-1.568359375,
-0.25927734375,
-0.1820068359375,
1.09375,
0.57568359375,
0.05914306640625,
0.89453125,
0.98681640625,
-0.4091796875,
-0.2198486328125,
0.2734375,
-0.7890625,
-0.462890625,
-0.56201171875,
0.80712890625,
-0.96435546875,
0.05694580078125,
-0.54541015625,
0.198486328125,
-0.4404296875,
0.57080078125,
-0.900390625,
-1.05078125,
0.001705169677734375,
-0.133544921875,
-0.195556640625,
0.12939453125,
-0.1446533203125,
0.2021484375,
-0.28515625,
0.362548828125,
-0.408935546875,
0.23876953125,
-0.00447845458984375,
0.2144775390625,
0.1539306640625,
-0.360595703125,
0.1878662109375,
-0.11285400390625,
0.204833984375,
-0.1168212890625,
-0.494140625,
-0.391845703125,
0.212890625,
0.285400390625,
0.12481689453125,
0.32373046875,
-1,
-0.09466552734375,
-0.04522705078125,
-0.267822265625,
-0.1588134765625,
-0.54052734375,
0.2269287109375,
0.75146484375,
-0.10906982421875,
-0.414306640625,
0.7734375,
0.06982421875,
1.0615234375,
0.69873046875,
0.092529296875,
-0.3330078125,
-0.82763671875,
-0.10791015625,
0.275146484375,
0.654296875,
-0.2169189453125,
-0.328369140625,
0.43603515625,
-0.2783203125,
-0.01065826416015625,
0.61865234375,
0.73291015625,
-0.5419921875,
0.2447509765625,
0.15673828125,
0.396240234375,
0.40283203125,
1.23046875,
-0.157470703125,
0.86962890625,
-0.69580078125,
0.340087890625,
0.3935546875,
-0.12432861328125,
-0.0718994140625,
-0.23828125,
-0.36279296875,
-0.35595703125,
0.37646484375,
0.12939453125,
-0.43408203125,
0.90185546875,
-0.492919921875,
0.2451171875,
-0.90283203125,
0.35546875,
0.48828125,
0.0992431640625,
0.2431640625,
-0.263916015625,
0.2685546875,
-0.356201171875,
-0.92431640625,
1.17578125,
-0.4951171875,
-0.44775390625,
0.259765625,
-0.1705322265625,
-0.240234375,
0.53857421875,
-0.2208251953125,
0.83154296875,
-0.2291259765625,
0.17138671875,
0.6943359375,
-1.23828125,
0.78173828125,
-0.163330078125,
0.045074462890625,
1.4990234375,
0.228515625,
0.07275390625,
0.69091796875,
0.48388671875,
-0.8154296875,
0.580078125,
-1.0185546875,
0.90283203125,
0.239990234375,
0.0400390625,
-0.482421875,
0.1451416015625,
-0.1658935546875,
0.1756591796875,
0.298583984375,
-0.18310546875,
-0.27099609375,
-0.053985595703125,
-0.43359375,
0.3798828125,
-0.5341796875,
0.451171875,
-0.505859375,
-0.276123046875,
-0.29296875,
-0.6181640625,
0.0665283203125,
-0.10284423828125,
-0.14208984375,
0.4404296875,
0.54150390625,
1.0966796875,
0.7109375,
-0.358154296875,
0.147705078125,
0.053955078125,
-0.51708984375,
0.114990234375,
-0.04376220703125,
0.65234375,
0.36669921875,
0.1201171875,
-0.00849151611328125,
-0.2314453125,
-1.0078125,
-0.85791015625,
0.43701171875,
0.72802734375,
-0.3681640625,
0.5048828125,
0.455810546875,
0.09930419921875,
-0.98974609375,
0.0982666015625,
0.01067352294921875,
-0.79541015625,
-0.4931640625,
0.69970703125,
-0.151123046875,
0.62109375,
-0.18408203125,
-0.402587890625,
0.225830078125,
1.0556640625,
-0.33154296875,
-0.1295166015625,
0.80615234375,
0.2529296875,
-0.01296234130859375,
0.051666259765625,
0.10052490234375,
-0.310546875,
-1.1806640625,
0.81689453125,
-0.490234375,
0.01183319091796875,
0.1923828125,
0.393310546875,
0.300048828125,
0.38916015625,
0.057037353515625,
-0.02276611328125,
0.379638671875,
1.0126953125,
0.013092041015625,
0.79541015625,
0.2998046875,
0.818359375,
0.446044921875,
0.478759765625,
0.5400390625,
0.47265625,
0.541015625,
0.689453125,
-0.07098388671875,
0.185546875,
-0.2103271484375,
0.54443359375,
0.307861328125,
0.6572265625,
0.08148193359375,
0.375,
-0.1796875,
0.17919921875,
-0.442138671875,
0.54833984375,
-0.313232421875,
0.85888671875,
0.29833984375,
0.53369140625,
-0.77197265625,
-0.347412109375,
0.265869140625,
0.6640625,
-0.94677734375,
-0.459228515625,
-0.1796875,
0.01361846923828125,
0.2130126953125,
0.300048828125,
0.23388671875,
0.2298583984375,
0.83349609375,
0.5947265625,
-0.27490234375,
-0.7001953125,
-0.63232421875,
-0.53759765625,
-1.0185546875,
-0.252685546875,
-0.6103515625,
0.089111328125,
0.356201171875,
-0.9951171875,
0.13134765625,
-0.1824951171875,
-0.2236328125,
-0.1759033203125,
-0.490966796875,
0.48095703125,
-0.42431640625,
0.65283203125,
-0.87890625,
0.59228515625,
0.1209716796875,
0.82177734375,
-0.74169921875,
-0.2158203125,
-0.51123046875,
-0.68310546875,
0.88427734375,
-0.0278778076171875,
0.0902099609375,
-0.14208984375,
-0.74609375,
-0.74560546875,
-0.71240234375,
-0.425537109375,
-0.419921875,
0.40673828125,
-1.015625,
0.79443359375,
0.2425537109375,
-0.412109375,
0.650390625,
1.01953125,
-0.97265625,
0.6650390625,
0.5712890625,
0.2120361328125,
-0.87548828125,
1.14453125,
0.28271484375,
0.10882568359375,
-0.4150390625,
-0.371337890625,
-0.26611328125,
0.09210205078125,
-0.0035610198974609375,
-0.5283203125,
-0.5361328125,
0.71630859375,
0.1851806640625,
-1.0390625,
0.50830078125,
-1.0048828125,
-0.5107421875,
-0.5224609375,
-0.3017578125,
0.85205078125,
1.0078125,
0.004543304443359375,
-0.576171875,
-0.305419921875,
-0.1947021484375,
0.78515625,
0.43359375,
-0.68896484375,
0.06182861328125,
0.7578125,
-0.238037109375,
0.048553466796875,
0.1715087890625,
-0.213134765625,
-0.25390625,
0.17236328125,
0.368408203125,
0.99658203125,
0.10198974609375,
0.2481689453125,
-0.138916015625,
0.5703125,
-0.94970703125,
-0.391357421875,
-0.49462890625,
0.73486328125,
0.280517578125,
0.281494140625,
0.54248046875,
-0.1861572265625,
-0.47314453125,
-1.0712890625,
0.433349609375,
-0.02496337890625,
0.931640625,
-0.787109375,
0.53759765625,
0.58251953125,
-0.7890625,
0.77001953125,
-1.060546875,
-0.1597900390625,
1.3515625,
-0.235595703125,
0.92236328125,
-0.1856689453125,
0.0697021484375,
-0.87158203125,
-0.205810546875,
1.19140625,
0.0010309219360351562,
0.73486328125,
-0.4599609375,
-0.57958984375,
-0.10650634765625,
0.06048583984375,
-0.63134765625,
-0.6015625,
0.349609375,
-0.481689453125,
-0.25439453125,
-0.685546875,
0.67822265625,
1.2431640625,
0.1510009765625,
0.2958984375,
0.60498046875,
0.08660888671875,
0.53662109375,
0.65185546875,
-0.315673828125,
-0.0214996337890625,
-0.8935546875,
0.73779296875,
0.0244140625,
0.11297607421875,
-0.708984375,
-0.08831787109375,
-0.57861328125,
0.28955078125,
-0.45556640625,
-0.21484375,
-0.9619140625,
0.478759765625,
0.1015625,
0.630859375,
-0.796875,
0.09039306640625,
-0.251220703125,
-0.0294189453125,
0.42724609375,
-0.79638671875,
0.236328125,
-1.1298828125,
0.6240234375,
0.423828125,
-0.1917724609375,
-0.6279296875,
-0.08709716796875,
-0.61767578125,
-0.71826171875,
0.0029010772705078125,
0.97119140625,
0.1175537109375,
0.283203125,
-1.09375,
0.212158203125,
0.169189453125,
-0.181396484375,
0.166015625,
0.08221435546875,
0.35888671875,
0.480712890625,
0.80322265625,
-0.46533203125,
-0.76416015625,
-0.0114593505859375,
-1.12890625,
0.7744140625,
-0.41943359375,
0.28125,
-0.08221435546875,
-0.20556640625,
-0.156494140625,
0.296630859375,
0.0673828125,
0.1578369140625,
-0.29736328125,
0.197509765625,
-0.7998046875,
-0.74755859375,
0.712890625,
-0.3935546875,
-0.66748046875,
0.77490234375,
0.2431640625,
-0.14990234375,
0.12152099609375,
0.45458984375,
-0.214111328125,
-0.049774169921875,
-0.5849609375,
0.369140625,
-0.477783203125,
-0.5947265625,
0.037200927734375,
-0.56640625,
0.7373046875,
-0.0255279541015625,
-0.962890625,
-0.103271484375,
-1.451171875,
-0.30615234375,
0.09332275390625,
-0.57177734375,
0.335205078125,
0.215576171875,
0.00484466552734375,
0.272705078125,
-0.6533203125,
-0.55712890625,
-0.2890625,
-0.529296875,
-0.29443359375,
-0.0721435546875,
0.57861328125,
0.6318359375,
0.00890350341796875,
-0.1260986328125,
0.2154541015625,
0.387451171875,
-0.08685302734375,
-0.52392578125,
-0.2076416015625,
-0.458740234375,
-0.04156494140625,
-0.02398681640625,
0.50048828125,
0.239990234375,
0.2281494140625,
0.802734375,
0.419921875,
0.312255859375,
0.53466796875,
-0.335693359375,
0.80517578125,
0.346435546875,
-1.10546875,
-0.446044921875,
0.9443359375,
-0.41748046875,
0.5458984375,
0.1048583984375,
-0.5087890625,
-1.0546875,
-0.88330078125,
0.0938720703125,
-0.35791015625,
-0.295654296875,
-0.7880859375,
-0.357666015625,
-0.1356201171875,
0.5458984375,
0.06744384765625,
-0.51025390625,
0.30029296875,
-1.1611328125,
0.1385498046875,
-0.685546875,
-0.44921875,
-0.53955078125,
-0.6943359375,
-0.465087890625,
0.71875,
0.317138671875,
0.392333984375,
0.1817626953125,
-0.408203125,
0.170166015625,
0.01171875,
-0.7275390625,
-0.316650390625,
0.0030727386474609375,
0.08209228515625,
0.00547027587890625,
-0.1595458984375,
-0.41845703125,
0.955078125,
-1.46484375,
0.110595703125,
-0.0650634765625,
-0.493896484375,
-0.280517578125,
-0.265869140625,
0.869140625,
-0.06097412109375,
-0.28369140625,
-0.284423828125,
0.5986328125,
0.447021484375,
-0.1805419921875,
-0.70458984375,
-0.76416015625,
-0.64697265625,
-0.84814453125,
0.50341796875,
-0.364501953125,
0.32177734375,
-0.60986328125,
0.11273193359375,
1.2294921875,
-0.64892578125,
0.515625,
1.0419921875,
0.5166015625,
0.27978515625,
-0.69580078125,
0.388916015625,
0.00424957275390625,
-0.78125,
-0.0297393798828125,
-0.00830841064453125,
-0.74658203125,
0.347412109375,
-0.2205810546875,
-1.078125,
-0.5986328125,
0.135009765625,
1.5205078125,
-0.24169921875,
1.0146484375,
0.35107421875,
-0.984375,
-0.494140625,
1.1484375,
-0.0008020401000976562,
0.181396484375,
0.97900390625,
-0.6484375,
-0.1783447265625,
-0.106689453125,
-0.2379150390625,
-0.30126953125,
-0.646484375,
0.85693359375,
-0.25244140625,
-0.355712890625,
0.60107421875,
0.923828125,
-0.9208984375,
-0.9873046875,
0.2269287109375,
-0.05047607421875,
-0.0146331787109375,
-0.81396484375,
0.25390625,
0.83935546875,
-0.472900390625,
-0.013214111328125,
0.400390625,
0.111572265625,
0.494384765625,
-0.01708984375,
0.2164306640625,
-0.399169921875,
0.57666015625,
0.50146484375,
-0.54296875,
-0.368896484375,
-0.9921875,
-0.1021728515625,
-0.10870361328125,
0.032012939453125,
0.591796875,
-0.1622314453125,
0.2254638671875,
0.71142578125,
-0.11700439453125,
0.84765625,
-0.6904296875,
-0.332763671875,
0.447509765625,
-0.454833984375,
-0.74755859375,
-0.0194549560546875,
0.33935546875,
-0.23486328125,
0.28466796875,
-0.6484375,
-0.309814453125,
0.48681640625,
0.307373046875,
-0.34619140625,
-0.63037109375,
-0.1630859375,
-0.9365234375,
-0.81884765625,
-0.408203125,
-0.654296875,
-0.2449951171875,
0.03564453125,
0.1995849609375,
-0.06304931640625,
-0.00864410400390625,
0.81689453125,
-1.01171875,
0.9814453125,
-0.34228515625,
0.70068359375,
-0.7705078125,
-0.1533203125,
-0.6474609375,
0.1732177734375,
-0.416259765625,
-0.3369140625,
-0.40380859375,
0.34521484375,
-0.189453125,
0.3212890625,
-0.2479248046875,
0.2783203125,
-0.3017578125,
-0.388427734375,
0.5146484375,
0.09576416015625,
-0.209716796875,
0.72998046875,
0.474365234375,
-0.142333984375,
0.042510986328125,
-0.08551025390625,
-0.308837890625,
-0.5078125,
0.4150390625,
0.59033203125,
-0.400634765625,
-0.1279296875,
-0.379150390625,
-0.0134735107421875,
-0.94580078125,
0.09991455078125,
-0.1441650390625,
0.178955078125,
0.31201171875,
-0.460693359375,
0.36865234375,
0.990234375,
-0.18603515625,
0.273681640625,
-0.1414794921875,
0.1771240234375,
0.5927734375,
0.3154296875,
0.12548828125,
0.5703125,
0.50634765625,
-0.1978759765625,
0.094970703125,
0.1851806640625,
-0.07464599609375,
0.234619140625,
-0.147216796875,
-0.85986328125,
-1.16796875,
-0.1744384765625,
0.014129638671875,
0.5869140625,
-0.041748046875,
-0.61865234375,
0.084228515625,
-0.08856201171875,
-0.66162109375,
0.27001953125,
-0.841796875,
-0.74560546875,
0.525390625,
-0.084716796875,
-0.36376953125,
-0.257568359375,
-0.32958984375,
0.050567626953125,
0.331298828125,
0.498046875,
-0.71826171875,
0.60400390625,
-0.0689697265625,
0.64501953125,
-0.285888671875,
0.043853759765625,
0.305419921875,
0.451904296875,
-0.313720703125,
-0.69189453125,
0.277587890625,
0.962890625,
0.246826171875,
-0.11016845703125,
-0.392578125,
0.18603515625,
-0.199951171875,
0.1357421875,
-0.2095947265625,
-0.064697265625,
-0.16845703125,
0.61962890625,
-1.4453125,
-0.0204010009765625,
-0.269775390625,
0.53857421875,
0.454833984375,
-0.1201171875,
-0.63427734375,
0.67626953125,
0.81298828125,
-0.10443115234375,
0.197509765625,
0.57568359375,
0.406005859375,
-0.197998046875,
-0.12176513671875,
-0.273681640625,
1.025390625,
0.476318359375,
0.494140625,
-0.1917724609375,
0.430908203125,
0.70263671875,
0.369140625,
-0.01317596435546875,
0.492919921875,
0.444091796875,
-0.140625,
-0.04803466796875,
-0.1175537109375,
-0.4580078125,
0.1240234375,
-0.71435546875,
0.623046875,
-0.435302734375,
-0.450439453125,
-0.62939453125,
-0.67724609375,
0.81787109375,
0.1669921875,
-0.58837890625,
0.0672607421875,
-0.2744140625,
0.340087890625,
0.7705078125,
0.11004638671875,
0.00666046142578125,
0.70263671875,
0.75146484375,
0.5625,
0.6884765625,
0.392822265625,
0.6337890625,
-0.61328125,
-0.08782958984375,
-0.002056121826171875,
0.2470703125,
-0.39990234375,
-0.60986328125,
-0.97607421875,
0.79248046875,
-0.54833984375,
0.1680908203125,
0.779296875,
-0.662109375,
-0.12054443359375,
-0.171142578125,
0.732421875,
-0.54296875,
0.2015380859375,
0.368408203125,
-0.6494140625,
-0.51708984375,
0.8828125,
0.06982421875,
0.399169921875,
0.173828125,
0.84521484375,
-0.022552490234375,
1.4931640625,
0.401123046875,
-0.359619140625,
0.1346435546875,
0.37939453125,
-0.35400390625,
-0.6494140625,
-0.478759765625,
-0.25537109375,
-0.1956787109375,
-0.412353515625,
-0.75,
-0.1971435546875,
0.923828125,
-0.04736328125,
-1.052734375,
-0.5732421875,
0.306640625,
-0.88232421875,
0.4326171875,
0.020721435546875,
-0.005443572998046875,
-0.05010986328125,
0.1248779296875,
-0.002262115478515625,
-0.47998046875,
0.348388671875,
-0.416748046875,
0.295654296875,
-0.399169921875,
-0.46533203125,
-0.50732421875,
-0.6552734375,
-0.464599609375,
-0.0675048828125,
-0.447509765625,
-1.146484375,
0.5771484375,
0.367431640625,
0.7919921875,
0.456298828125,
-0.5654296875,
0.399658203125,
0.76611328125,
1.021484375,
0.0982666015625,
1.0634765625,
0.54833984375,
-0.00330352783203125,
0.028594970703125,
-0.1998291015625,
0.80908203125,
-0.2001953125,
0.325439453125,
-0.599609375,
0.71630859375,
-0.31396484375,
-1.234375,
0.03515625,
0.66552734375,
0.470947265625,
-0.802734375,
-1.109375,
-0.22900390625,
-0.85498046875,
-0.1119384765625,
-0.68994140625,
0.64599609375,
-0.075927734375,
0.33349609375,
-0.36962890625,
-1.318359375,
4.3046875,
1.0751953125,
0.697265625,
0.5556640625,
0.350341796875,
0.8701171875,
0.19873046875,
-0.7607421875,
-0.280029296875,
-0.416748046875,
0.63427734375,
-0.6552734375,
-0.0323486328125,
0.90283203125,
0.5126953125,
0.51318359375,
-0.63037109375,
-0.0447998046875,
-0.1463623046875,
-0.97607421875,
-1.169921875,
0.2349853515625,
-0.1737060546875,
0.422119140625,
-0.0126953125,
0.490478515625,
0.76416015625,
-0.454833984375,
-0.28515625,
-0.79345703125,
0.118408203125,
-0.57177734375,
1.005859375,
0.260986328125,
-0.52783203125,
0.6025390625,
-0.2391357421875,
-0.42919921875,
-0.006847381591796875,
0.52734375,
-0.259033203125,
-0.064453125,
0.76123046875,
-0.380859375,
0.0706787109375,
0.65869140625,
-0.544921875,
0.4248046875,
0.1573486328125,
-0.9619140625,
1.212890625,
0.186279296875,
0.0938720703125,
-0.759765625,
-0.499267578125,
0.31689453125,
0.30078125,
-0.329833984375,
-0.419189453125,
0.595703125,
0.1639404296875,
0.2442626953125,
0.0255584716796875,
0.7314453125,
-1.2861328125,
0.90087890625,
-0.247802734375,
0.358642578125,
-0.6591796875,
-0.2822265625,
0.38330078125,
-0.418212890625,
-0.3935546875,
-0.024261474609375,
0.5712890625,
0.2247314453125,
-0.38134765625,
0.455078125,
0.61279296875,
-0.873046875,
0.33251953125,
0.062164306640625,
-0.46484375,
-0.0280914306640625,
0.2919921875,
1.1181640625,
-0.703125,
-0.30859375,
-0.51904296875,
0.42333984375,
0.69921875,
0.340576171875,
0.0328369140625,
-0.3896484375,
0.07806396484375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.
In this problem you should implement the similar functionality.
You are given a string which only consists of:
* uppercase and lowercase English letters,
* underscore symbols (they are used as separators),
* parentheses (both opening and closing).
It is guaranteed that each opening parenthesis has a succeeding closing parenthesis. Similarly, each closing parentheses has a preceding opening parentheses matching it. For each pair of matching parentheses there are no other parenthesis between them. In other words, each parenthesis in the string belongs to a matching "opening-closing" pair, and such pairs can't be nested.
For example, the following string is valid: "_Hello_Vasya(and_Petya)__bye_(and_OK)".
Word is a maximal sequence of consecutive letters, i.e. such sequence that the first character to the left and the first character to the right of it is an underscore, a parenthesis, or it just does not exist. For example, the string above consists of seven words: "Hello", "Vasya", "and", "Petya", "bye", "and" and "OK". Write a program that finds:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 255) — the length of the given string. The second line contains the string consisting of only lowercase and uppercase English letters, parentheses and underscore symbols.
Output
Print two space-separated integers:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Examples
Input
37
_Hello_Vasya(and_Petya)__bye_(and_OK)
Output
5 4
Input
37
_a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
Output
2 6
Input
27
(LoooonG)__shOrt__(LoooonG)
Output
5 2
Input
5
(___)
Output
0 0
Note
In the first sample, the words "Hello", "Vasya" and "bye" are outside any of the parentheses, and the words "and", "Petya", "and" and "OK" are inside. Note, that the word "and" is given twice and you should count it twice in the answer.
Tags: expression parsing, implementation, strings
Correct Solution:
```
n = int(input())
s = str(input())
s = s.replace("(", " ( ")
s = s.replace(")", " ) ")
s = s.replace("_", " ")
answer = s.split()
a = 0
b = 0
op = False
for element in answer:
if element == "(":
op = True
elif element == ")":
op = False
else:
if op:
b += 1
else:
a = max(len(element), a)
print(a, b)
```
| 70,334 | [
0.0736083984375,
-0.30712890625,
0.1131591796875,
0.1287841796875,
-0.008453369140625,
-0.316650390625,
-0.0017538070678710938,
-0.11553955078125,
0.0045013427734375,
0.5498046875,
0.6123046875,
-0.0794677734375,
-0.062744140625,
-0.93701171875,
-0.896484375,
0.054229736328125,
-0.6123046875,
-0.69140625,
-0.416015625,
-0.0748291015625,
-0.06475830078125,
0.173583984375,
-1.568359375,
-0.25927734375,
-0.1820068359375,
1.09375,
0.57568359375,
0.05914306640625,
0.89453125,
0.98681640625,
-0.4091796875,
-0.2198486328125,
0.2734375,
-0.7890625,
-0.462890625,
-0.56201171875,
0.80712890625,
-0.96435546875,
0.05694580078125,
-0.54541015625,
0.198486328125,
-0.4404296875,
0.57080078125,
-0.900390625,
-1.05078125,
0.001705169677734375,
-0.133544921875,
-0.195556640625,
0.12939453125,
-0.1446533203125,
0.2021484375,
-0.28515625,
0.362548828125,
-0.408935546875,
0.23876953125,
-0.00447845458984375,
0.2144775390625,
0.1539306640625,
-0.360595703125,
0.1878662109375,
-0.11285400390625,
0.204833984375,
-0.1168212890625,
-0.494140625,
-0.391845703125,
0.212890625,
0.285400390625,
0.12481689453125,
0.32373046875,
-1,
-0.09466552734375,
-0.04522705078125,
-0.267822265625,
-0.1588134765625,
-0.54052734375,
0.2269287109375,
0.75146484375,
-0.10906982421875,
-0.414306640625,
0.7734375,
0.06982421875,
1.0615234375,
0.69873046875,
0.092529296875,
-0.3330078125,
-0.82763671875,
-0.10791015625,
0.275146484375,
0.654296875,
-0.2169189453125,
-0.328369140625,
0.43603515625,
-0.2783203125,
-0.01065826416015625,
0.61865234375,
0.73291015625,
-0.5419921875,
0.2447509765625,
0.15673828125,
0.396240234375,
0.40283203125,
1.23046875,
-0.157470703125,
0.86962890625,
-0.69580078125,
0.340087890625,
0.3935546875,
-0.12432861328125,
-0.0718994140625,
-0.23828125,
-0.36279296875,
-0.35595703125,
0.37646484375,
0.12939453125,
-0.43408203125,
0.90185546875,
-0.492919921875,
0.2451171875,
-0.90283203125,
0.35546875,
0.48828125,
0.0992431640625,
0.2431640625,
-0.263916015625,
0.2685546875,
-0.356201171875,
-0.92431640625,
1.17578125,
-0.4951171875,
-0.44775390625,
0.259765625,
-0.1705322265625,
-0.240234375,
0.53857421875,
-0.2208251953125,
0.83154296875,
-0.2291259765625,
0.17138671875,
0.6943359375,
-1.23828125,
0.78173828125,
-0.163330078125,
0.045074462890625,
1.4990234375,
0.228515625,
0.07275390625,
0.69091796875,
0.48388671875,
-0.8154296875,
0.580078125,
-1.0185546875,
0.90283203125,
0.239990234375,
0.0400390625,
-0.482421875,
0.1451416015625,
-0.1658935546875,
0.1756591796875,
0.298583984375,
-0.18310546875,
-0.27099609375,
-0.053985595703125,
-0.43359375,
0.3798828125,
-0.5341796875,
0.451171875,
-0.505859375,
-0.276123046875,
-0.29296875,
-0.6181640625,
0.0665283203125,
-0.10284423828125,
-0.14208984375,
0.4404296875,
0.54150390625,
1.0966796875,
0.7109375,
-0.358154296875,
0.147705078125,
0.053955078125,
-0.51708984375,
0.114990234375,
-0.04376220703125,
0.65234375,
0.36669921875,
0.1201171875,
-0.00849151611328125,
-0.2314453125,
-1.0078125,
-0.85791015625,
0.43701171875,
0.72802734375,
-0.3681640625,
0.5048828125,
0.455810546875,
0.09930419921875,
-0.98974609375,
0.0982666015625,
0.01067352294921875,
-0.79541015625,
-0.4931640625,
0.69970703125,
-0.151123046875,
0.62109375,
-0.18408203125,
-0.402587890625,
0.225830078125,
1.0556640625,
-0.33154296875,
-0.1295166015625,
0.80615234375,
0.2529296875,
-0.01296234130859375,
0.051666259765625,
0.10052490234375,
-0.310546875,
-1.1806640625,
0.81689453125,
-0.490234375,
0.01183319091796875,
0.1923828125,
0.393310546875,
0.300048828125,
0.38916015625,
0.057037353515625,
-0.02276611328125,
0.379638671875,
1.0126953125,
0.013092041015625,
0.79541015625,
0.2998046875,
0.818359375,
0.446044921875,
0.478759765625,
0.5400390625,
0.47265625,
0.541015625,
0.689453125,
-0.07098388671875,
0.185546875,
-0.2103271484375,
0.54443359375,
0.307861328125,
0.6572265625,
0.08148193359375,
0.375,
-0.1796875,
0.17919921875,
-0.442138671875,
0.54833984375,
-0.313232421875,
0.85888671875,
0.29833984375,
0.53369140625,
-0.77197265625,
-0.347412109375,
0.265869140625,
0.6640625,
-0.94677734375,
-0.459228515625,
-0.1796875,
0.01361846923828125,
0.2130126953125,
0.300048828125,
0.23388671875,
0.2298583984375,
0.83349609375,
0.5947265625,
-0.27490234375,
-0.7001953125,
-0.63232421875,
-0.53759765625,
-1.0185546875,
-0.252685546875,
-0.6103515625,
0.089111328125,
0.356201171875,
-0.9951171875,
0.13134765625,
-0.1824951171875,
-0.2236328125,
-0.1759033203125,
-0.490966796875,
0.48095703125,
-0.42431640625,
0.65283203125,
-0.87890625,
0.59228515625,
0.1209716796875,
0.82177734375,
-0.74169921875,
-0.2158203125,
-0.51123046875,
-0.68310546875,
0.88427734375,
-0.0278778076171875,
0.0902099609375,
-0.14208984375,
-0.74609375,
-0.74560546875,
-0.71240234375,
-0.425537109375,
-0.419921875,
0.40673828125,
-1.015625,
0.79443359375,
0.2425537109375,
-0.412109375,
0.650390625,
1.01953125,
-0.97265625,
0.6650390625,
0.5712890625,
0.2120361328125,
-0.87548828125,
1.14453125,
0.28271484375,
0.10882568359375,
-0.4150390625,
-0.371337890625,
-0.26611328125,
0.09210205078125,
-0.0035610198974609375,
-0.5283203125,
-0.5361328125,
0.71630859375,
0.1851806640625,
-1.0390625,
0.50830078125,
-1.0048828125,
-0.5107421875,
-0.5224609375,
-0.3017578125,
0.85205078125,
1.0078125,
0.004543304443359375,
-0.576171875,
-0.305419921875,
-0.1947021484375,
0.78515625,
0.43359375,
-0.68896484375,
0.06182861328125,
0.7578125,
-0.238037109375,
0.048553466796875,
0.1715087890625,
-0.213134765625,
-0.25390625,
0.17236328125,
0.368408203125,
0.99658203125,
0.10198974609375,
0.2481689453125,
-0.138916015625,
0.5703125,
-0.94970703125,
-0.391357421875,
-0.49462890625,
0.73486328125,
0.280517578125,
0.281494140625,
0.54248046875,
-0.1861572265625,
-0.47314453125,
-1.0712890625,
0.433349609375,
-0.02496337890625,
0.931640625,
-0.787109375,
0.53759765625,
0.58251953125,
-0.7890625,
0.77001953125,
-1.060546875,
-0.1597900390625,
1.3515625,
-0.235595703125,
0.92236328125,
-0.1856689453125,
0.0697021484375,
-0.87158203125,
-0.205810546875,
1.19140625,
0.0010309219360351562,
0.73486328125,
-0.4599609375,
-0.57958984375,
-0.10650634765625,
0.06048583984375,
-0.63134765625,
-0.6015625,
0.349609375,
-0.481689453125,
-0.25439453125,
-0.685546875,
0.67822265625,
1.2431640625,
0.1510009765625,
0.2958984375,
0.60498046875,
0.08660888671875,
0.53662109375,
0.65185546875,
-0.315673828125,
-0.0214996337890625,
-0.8935546875,
0.73779296875,
0.0244140625,
0.11297607421875,
-0.708984375,
-0.08831787109375,
-0.57861328125,
0.28955078125,
-0.45556640625,
-0.21484375,
-0.9619140625,
0.478759765625,
0.1015625,
0.630859375,
-0.796875,
0.09039306640625,
-0.251220703125,
-0.0294189453125,
0.42724609375,
-0.79638671875,
0.236328125,
-1.1298828125,
0.6240234375,
0.423828125,
-0.1917724609375,
-0.6279296875,
-0.08709716796875,
-0.61767578125,
-0.71826171875,
0.0029010772705078125,
0.97119140625,
0.1175537109375,
0.283203125,
-1.09375,
0.212158203125,
0.169189453125,
-0.181396484375,
0.166015625,
0.08221435546875,
0.35888671875,
0.480712890625,
0.80322265625,
-0.46533203125,
-0.76416015625,
-0.0114593505859375,
-1.12890625,
0.7744140625,
-0.41943359375,
0.28125,
-0.08221435546875,
-0.20556640625,
-0.156494140625,
0.296630859375,
0.0673828125,
0.1578369140625,
-0.29736328125,
0.197509765625,
-0.7998046875,
-0.74755859375,
0.712890625,
-0.3935546875,
-0.66748046875,
0.77490234375,
0.2431640625,
-0.14990234375,
0.12152099609375,
0.45458984375,
-0.214111328125,
-0.049774169921875,
-0.5849609375,
0.369140625,
-0.477783203125,
-0.5947265625,
0.037200927734375,
-0.56640625,
0.7373046875,
-0.0255279541015625,
-0.962890625,
-0.103271484375,
-1.451171875,
-0.30615234375,
0.09332275390625,
-0.57177734375,
0.335205078125,
0.215576171875,
0.00484466552734375,
0.272705078125,
-0.6533203125,
-0.55712890625,
-0.2890625,
-0.529296875,
-0.29443359375,
-0.0721435546875,
0.57861328125,
0.6318359375,
0.00890350341796875,
-0.1260986328125,
0.2154541015625,
0.387451171875,
-0.08685302734375,
-0.52392578125,
-0.2076416015625,
-0.458740234375,
-0.04156494140625,
-0.02398681640625,
0.50048828125,
0.239990234375,
0.2281494140625,
0.802734375,
0.419921875,
0.312255859375,
0.53466796875,
-0.335693359375,
0.80517578125,
0.346435546875,
-1.10546875,
-0.446044921875,
0.9443359375,
-0.41748046875,
0.5458984375,
0.1048583984375,
-0.5087890625,
-1.0546875,
-0.88330078125,
0.0938720703125,
-0.35791015625,
-0.295654296875,
-0.7880859375,
-0.357666015625,
-0.1356201171875,
0.5458984375,
0.06744384765625,
-0.51025390625,
0.30029296875,
-1.1611328125,
0.1385498046875,
-0.685546875,
-0.44921875,
-0.53955078125,
-0.6943359375,
-0.465087890625,
0.71875,
0.317138671875,
0.392333984375,
0.1817626953125,
-0.408203125,
0.170166015625,
0.01171875,
-0.7275390625,
-0.316650390625,
0.0030727386474609375,
0.08209228515625,
0.00547027587890625,
-0.1595458984375,
-0.41845703125,
0.955078125,
-1.46484375,
0.110595703125,
-0.0650634765625,
-0.493896484375,
-0.280517578125,
-0.265869140625,
0.869140625,
-0.06097412109375,
-0.28369140625,
-0.284423828125,
0.5986328125,
0.447021484375,
-0.1805419921875,
-0.70458984375,
-0.76416015625,
-0.64697265625,
-0.84814453125,
0.50341796875,
-0.364501953125,
0.32177734375,
-0.60986328125,
0.11273193359375,
1.2294921875,
-0.64892578125,
0.515625,
1.0419921875,
0.5166015625,
0.27978515625,
-0.69580078125,
0.388916015625,
0.00424957275390625,
-0.78125,
-0.0297393798828125,
-0.00830841064453125,
-0.74658203125,
0.347412109375,
-0.2205810546875,
-1.078125,
-0.5986328125,
0.135009765625,
1.5205078125,
-0.24169921875,
1.0146484375,
0.35107421875,
-0.984375,
-0.494140625,
1.1484375,
-0.0008020401000976562,
0.181396484375,
0.97900390625,
-0.6484375,
-0.1783447265625,
-0.106689453125,
-0.2379150390625,
-0.30126953125,
-0.646484375,
0.85693359375,
-0.25244140625,
-0.355712890625,
0.60107421875,
0.923828125,
-0.9208984375,
-0.9873046875,
0.2269287109375,
-0.05047607421875,
-0.0146331787109375,
-0.81396484375,
0.25390625,
0.83935546875,
-0.472900390625,
-0.013214111328125,
0.400390625,
0.111572265625,
0.494384765625,
-0.01708984375,
0.2164306640625,
-0.399169921875,
0.57666015625,
0.50146484375,
-0.54296875,
-0.368896484375,
-0.9921875,
-0.1021728515625,
-0.10870361328125,
0.032012939453125,
0.591796875,
-0.1622314453125,
0.2254638671875,
0.71142578125,
-0.11700439453125,
0.84765625,
-0.6904296875,
-0.332763671875,
0.447509765625,
-0.454833984375,
-0.74755859375,
-0.0194549560546875,
0.33935546875,
-0.23486328125,
0.28466796875,
-0.6484375,
-0.309814453125,
0.48681640625,
0.307373046875,
-0.34619140625,
-0.63037109375,
-0.1630859375,
-0.9365234375,
-0.81884765625,
-0.408203125,
-0.654296875,
-0.2449951171875,
0.03564453125,
0.1995849609375,
-0.06304931640625,
-0.00864410400390625,
0.81689453125,
-1.01171875,
0.9814453125,
-0.34228515625,
0.70068359375,
-0.7705078125,
-0.1533203125,
-0.6474609375,
0.1732177734375,
-0.416259765625,
-0.3369140625,
-0.40380859375,
0.34521484375,
-0.189453125,
0.3212890625,
-0.2479248046875,
0.2783203125,
-0.3017578125,
-0.388427734375,
0.5146484375,
0.09576416015625,
-0.209716796875,
0.72998046875,
0.474365234375,
-0.142333984375,
0.042510986328125,
-0.08551025390625,
-0.308837890625,
-0.5078125,
0.4150390625,
0.59033203125,
-0.400634765625,
-0.1279296875,
-0.379150390625,
-0.0134735107421875,
-0.94580078125,
0.09991455078125,
-0.1441650390625,
0.178955078125,
0.31201171875,
-0.460693359375,
0.36865234375,
0.990234375,
-0.18603515625,
0.273681640625,
-0.1414794921875,
0.1771240234375,
0.5927734375,
0.3154296875,
0.12548828125,
0.5703125,
0.50634765625,
-0.1978759765625,
0.094970703125,
0.1851806640625,
-0.07464599609375,
0.234619140625,
-0.147216796875,
-0.85986328125,
-1.16796875,
-0.1744384765625,
0.014129638671875,
0.5869140625,
-0.041748046875,
-0.61865234375,
0.084228515625,
-0.08856201171875,
-0.66162109375,
0.27001953125,
-0.841796875,
-0.74560546875,
0.525390625,
-0.084716796875,
-0.36376953125,
-0.257568359375,
-0.32958984375,
0.050567626953125,
0.331298828125,
0.498046875,
-0.71826171875,
0.60400390625,
-0.0689697265625,
0.64501953125,
-0.285888671875,
0.043853759765625,
0.305419921875,
0.451904296875,
-0.313720703125,
-0.69189453125,
0.277587890625,
0.962890625,
0.246826171875,
-0.11016845703125,
-0.392578125,
0.18603515625,
-0.199951171875,
0.1357421875,
-0.2095947265625,
-0.064697265625,
-0.16845703125,
0.61962890625,
-1.4453125,
-0.0204010009765625,
-0.269775390625,
0.53857421875,
0.454833984375,
-0.1201171875,
-0.63427734375,
0.67626953125,
0.81298828125,
-0.10443115234375,
0.197509765625,
0.57568359375,
0.406005859375,
-0.197998046875,
-0.12176513671875,
-0.273681640625,
1.025390625,
0.476318359375,
0.494140625,
-0.1917724609375,
0.430908203125,
0.70263671875,
0.369140625,
-0.01317596435546875,
0.492919921875,
0.444091796875,
-0.140625,
-0.04803466796875,
-0.1175537109375,
-0.4580078125,
0.1240234375,
-0.71435546875,
0.623046875,
-0.435302734375,
-0.450439453125,
-0.62939453125,
-0.67724609375,
0.81787109375,
0.1669921875,
-0.58837890625,
0.0672607421875,
-0.2744140625,
0.340087890625,
0.7705078125,
0.11004638671875,
0.00666046142578125,
0.70263671875,
0.75146484375,
0.5625,
0.6884765625,
0.392822265625,
0.6337890625,
-0.61328125,
-0.08782958984375,
-0.002056121826171875,
0.2470703125,
-0.39990234375,
-0.60986328125,
-0.97607421875,
0.79248046875,
-0.54833984375,
0.1680908203125,
0.779296875,
-0.662109375,
-0.12054443359375,
-0.171142578125,
0.732421875,
-0.54296875,
0.2015380859375,
0.368408203125,
-0.6494140625,
-0.51708984375,
0.8828125,
0.06982421875,
0.399169921875,
0.173828125,
0.84521484375,
-0.022552490234375,
1.4931640625,
0.401123046875,
-0.359619140625,
0.1346435546875,
0.37939453125,
-0.35400390625,
-0.6494140625,
-0.478759765625,
-0.25537109375,
-0.1956787109375,
-0.412353515625,
-0.75,
-0.1971435546875,
0.923828125,
-0.04736328125,
-1.052734375,
-0.5732421875,
0.306640625,
-0.88232421875,
0.4326171875,
0.020721435546875,
-0.005443572998046875,
-0.05010986328125,
0.1248779296875,
-0.002262115478515625,
-0.47998046875,
0.348388671875,
-0.416748046875,
0.295654296875,
-0.399169921875,
-0.46533203125,
-0.50732421875,
-0.6552734375,
-0.464599609375,
-0.0675048828125,
-0.447509765625,
-1.146484375,
0.5771484375,
0.367431640625,
0.7919921875,
0.456298828125,
-0.5654296875,
0.399658203125,
0.76611328125,
1.021484375,
0.0982666015625,
1.0634765625,
0.54833984375,
-0.00330352783203125,
0.028594970703125,
-0.1998291015625,
0.80908203125,
-0.2001953125,
0.325439453125,
-0.599609375,
0.71630859375,
-0.31396484375,
-1.234375,
0.03515625,
0.66552734375,
0.470947265625,
-0.802734375,
-1.109375,
-0.22900390625,
-0.85498046875,
-0.1119384765625,
-0.68994140625,
0.64599609375,
-0.075927734375,
0.33349609375,
-0.36962890625,
-1.318359375,
4.3046875,
1.0751953125,
0.697265625,
0.5556640625,
0.350341796875,
0.8701171875,
0.19873046875,
-0.7607421875,
-0.280029296875,
-0.416748046875,
0.63427734375,
-0.6552734375,
-0.0323486328125,
0.90283203125,
0.5126953125,
0.51318359375,
-0.63037109375,
-0.0447998046875,
-0.1463623046875,
-0.97607421875,
-1.169921875,
0.2349853515625,
-0.1737060546875,
0.422119140625,
-0.0126953125,
0.490478515625,
0.76416015625,
-0.454833984375,
-0.28515625,
-0.79345703125,
0.118408203125,
-0.57177734375,
1.005859375,
0.260986328125,
-0.52783203125,
0.6025390625,
-0.2391357421875,
-0.42919921875,
-0.006847381591796875,
0.52734375,
-0.259033203125,
-0.064453125,
0.76123046875,
-0.380859375,
0.0706787109375,
0.65869140625,
-0.544921875,
0.4248046875,
0.1573486328125,
-0.9619140625,
1.212890625,
0.186279296875,
0.0938720703125,
-0.759765625,
-0.499267578125,
0.31689453125,
0.30078125,
-0.329833984375,
-0.419189453125,
0.595703125,
0.1639404296875,
0.2442626953125,
0.0255584716796875,
0.7314453125,
-1.2861328125,
0.90087890625,
-0.247802734375,
0.358642578125,
-0.6591796875,
-0.2822265625,
0.38330078125,
-0.418212890625,
-0.3935546875,
-0.024261474609375,
0.5712890625,
0.2247314453125,
-0.38134765625,
0.455078125,
0.61279296875,
-0.873046875,
0.33251953125,
0.062164306640625,
-0.46484375,
-0.0280914306640625,
0.2919921875,
1.1181640625,
-0.703125,
-0.30859375,
-0.51904296875,
0.42333984375,
0.69921875,
0.340576171875,
0.0328369140625,
-0.3896484375,
0.07806396484375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.
In this problem you should implement the similar functionality.
You are given a string which only consists of:
* uppercase and lowercase English letters,
* underscore symbols (they are used as separators),
* parentheses (both opening and closing).
It is guaranteed that each opening parenthesis has a succeeding closing parenthesis. Similarly, each closing parentheses has a preceding opening parentheses matching it. For each pair of matching parentheses there are no other parenthesis between them. In other words, each parenthesis in the string belongs to a matching "opening-closing" pair, and such pairs can't be nested.
For example, the following string is valid: "_Hello_Vasya(and_Petya)__bye_(and_OK)".
Word is a maximal sequence of consecutive letters, i.e. such sequence that the first character to the left and the first character to the right of it is an underscore, a parenthesis, or it just does not exist. For example, the string above consists of seven words: "Hello", "Vasya", "and", "Petya", "bye", "and" and "OK". Write a program that finds:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 255) — the length of the given string. The second line contains the string consisting of only lowercase and uppercase English letters, parentheses and underscore symbols.
Output
Print two space-separated integers:
* the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
* the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
Examples
Input
37
_Hello_Vasya(and_Petya)__bye_(and_OK)
Output
5 4
Input
37
_a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
Output
2 6
Input
27
(LoooonG)__shOrt__(LoooonG)
Output
5 2
Input
5
(___)
Output
0 0
Note
In the first sample, the words "Hello", "Vasya" and "bye" are outside any of the parentheses, and the words "and", "Petya", "and" and "OK" are inside. Note, that the word "and" is given twice and you should count it twice in the answer.
Tags: expression parsing, implementation, strings
Correct Solution:
```
litter=input();inside=outside=0
s=input()
i=s.find('(')
while i != -1 :
last = s.find(')')
for j in s[i+1 : last].split('_') :
if j != '':
inside+=1
if i==0:
s=s[last+1:]
else:
s = s[:i]+'_'+s[last+1:]
i=s.find('(')
for i in s.split('_'):
if i!='':
if len(i)> outside :
outside = len(i)
print(outside , inside)
```
| 70,335 | [
0.0736083984375,
-0.30712890625,
0.1131591796875,
0.1287841796875,
-0.008453369140625,
-0.316650390625,
-0.0017538070678710938,
-0.11553955078125,
0.0045013427734375,
0.5498046875,
0.6123046875,
-0.0794677734375,
-0.062744140625,
-0.93701171875,
-0.896484375,
0.054229736328125,
-0.6123046875,
-0.69140625,
-0.416015625,
-0.0748291015625,
-0.06475830078125,
0.173583984375,
-1.568359375,
-0.25927734375,
-0.1820068359375,
1.09375,
0.57568359375,
0.05914306640625,
0.89453125,
0.98681640625,
-0.4091796875,
-0.2198486328125,
0.2734375,
-0.7890625,
-0.462890625,
-0.56201171875,
0.80712890625,
-0.96435546875,
0.05694580078125,
-0.54541015625,
0.198486328125,
-0.4404296875,
0.57080078125,
-0.900390625,
-1.05078125,
0.001705169677734375,
-0.133544921875,
-0.195556640625,
0.12939453125,
-0.1446533203125,
0.2021484375,
-0.28515625,
0.362548828125,
-0.408935546875,
0.23876953125,
-0.00447845458984375,
0.2144775390625,
0.1539306640625,
-0.360595703125,
0.1878662109375,
-0.11285400390625,
0.204833984375,
-0.1168212890625,
-0.494140625,
-0.391845703125,
0.212890625,
0.285400390625,
0.12481689453125,
0.32373046875,
-1,
-0.09466552734375,
-0.04522705078125,
-0.267822265625,
-0.1588134765625,
-0.54052734375,
0.2269287109375,
0.75146484375,
-0.10906982421875,
-0.414306640625,
0.7734375,
0.06982421875,
1.0615234375,
0.69873046875,
0.092529296875,
-0.3330078125,
-0.82763671875,
-0.10791015625,
0.275146484375,
0.654296875,
-0.2169189453125,
-0.328369140625,
0.43603515625,
-0.2783203125,
-0.01065826416015625,
0.61865234375,
0.73291015625,
-0.5419921875,
0.2447509765625,
0.15673828125,
0.396240234375,
0.40283203125,
1.23046875,
-0.157470703125,
0.86962890625,
-0.69580078125,
0.340087890625,
0.3935546875,
-0.12432861328125,
-0.0718994140625,
-0.23828125,
-0.36279296875,
-0.35595703125,
0.37646484375,
0.12939453125,
-0.43408203125,
0.90185546875,
-0.492919921875,
0.2451171875,
-0.90283203125,
0.35546875,
0.48828125,
0.0992431640625,
0.2431640625,
-0.263916015625,
0.2685546875,
-0.356201171875,
-0.92431640625,
1.17578125,
-0.4951171875,
-0.44775390625,
0.259765625,
-0.1705322265625,
-0.240234375,
0.53857421875,
-0.2208251953125,
0.83154296875,
-0.2291259765625,
0.17138671875,
0.6943359375,
-1.23828125,
0.78173828125,
-0.163330078125,
0.045074462890625,
1.4990234375,
0.228515625,
0.07275390625,
0.69091796875,
0.48388671875,
-0.8154296875,
0.580078125,
-1.0185546875,
0.90283203125,
0.239990234375,
0.0400390625,
-0.482421875,
0.1451416015625,
-0.1658935546875,
0.1756591796875,
0.298583984375,
-0.18310546875,
-0.27099609375,
-0.053985595703125,
-0.43359375,
0.3798828125,
-0.5341796875,
0.451171875,
-0.505859375,
-0.276123046875,
-0.29296875,
-0.6181640625,
0.0665283203125,
-0.10284423828125,
-0.14208984375,
0.4404296875,
0.54150390625,
1.0966796875,
0.7109375,
-0.358154296875,
0.147705078125,
0.053955078125,
-0.51708984375,
0.114990234375,
-0.04376220703125,
0.65234375,
0.36669921875,
0.1201171875,
-0.00849151611328125,
-0.2314453125,
-1.0078125,
-0.85791015625,
0.43701171875,
0.72802734375,
-0.3681640625,
0.5048828125,
0.455810546875,
0.09930419921875,
-0.98974609375,
0.0982666015625,
0.01067352294921875,
-0.79541015625,
-0.4931640625,
0.69970703125,
-0.151123046875,
0.62109375,
-0.18408203125,
-0.402587890625,
0.225830078125,
1.0556640625,
-0.33154296875,
-0.1295166015625,
0.80615234375,
0.2529296875,
-0.01296234130859375,
0.051666259765625,
0.10052490234375,
-0.310546875,
-1.1806640625,
0.81689453125,
-0.490234375,
0.01183319091796875,
0.1923828125,
0.393310546875,
0.300048828125,
0.38916015625,
0.057037353515625,
-0.02276611328125,
0.379638671875,
1.0126953125,
0.013092041015625,
0.79541015625,
0.2998046875,
0.818359375,
0.446044921875,
0.478759765625,
0.5400390625,
0.47265625,
0.541015625,
0.689453125,
-0.07098388671875,
0.185546875,
-0.2103271484375,
0.54443359375,
0.307861328125,
0.6572265625,
0.08148193359375,
0.375,
-0.1796875,
0.17919921875,
-0.442138671875,
0.54833984375,
-0.313232421875,
0.85888671875,
0.29833984375,
0.53369140625,
-0.77197265625,
-0.347412109375,
0.265869140625,
0.6640625,
-0.94677734375,
-0.459228515625,
-0.1796875,
0.01361846923828125,
0.2130126953125,
0.300048828125,
0.23388671875,
0.2298583984375,
0.83349609375,
0.5947265625,
-0.27490234375,
-0.7001953125,
-0.63232421875,
-0.53759765625,
-1.0185546875,
-0.252685546875,
-0.6103515625,
0.089111328125,
0.356201171875,
-0.9951171875,
0.13134765625,
-0.1824951171875,
-0.2236328125,
-0.1759033203125,
-0.490966796875,
0.48095703125,
-0.42431640625,
0.65283203125,
-0.87890625,
0.59228515625,
0.1209716796875,
0.82177734375,
-0.74169921875,
-0.2158203125,
-0.51123046875,
-0.68310546875,
0.88427734375,
-0.0278778076171875,
0.0902099609375,
-0.14208984375,
-0.74609375,
-0.74560546875,
-0.71240234375,
-0.425537109375,
-0.419921875,
0.40673828125,
-1.015625,
0.79443359375,
0.2425537109375,
-0.412109375,
0.650390625,
1.01953125,
-0.97265625,
0.6650390625,
0.5712890625,
0.2120361328125,
-0.87548828125,
1.14453125,
0.28271484375,
0.10882568359375,
-0.4150390625,
-0.371337890625,
-0.26611328125,
0.09210205078125,
-0.0035610198974609375,
-0.5283203125,
-0.5361328125,
0.71630859375,
0.1851806640625,
-1.0390625,
0.50830078125,
-1.0048828125,
-0.5107421875,
-0.5224609375,
-0.3017578125,
0.85205078125,
1.0078125,
0.004543304443359375,
-0.576171875,
-0.305419921875,
-0.1947021484375,
0.78515625,
0.43359375,
-0.68896484375,
0.06182861328125,
0.7578125,
-0.238037109375,
0.048553466796875,
0.1715087890625,
-0.213134765625,
-0.25390625,
0.17236328125,
0.368408203125,
0.99658203125,
0.10198974609375,
0.2481689453125,
-0.138916015625,
0.5703125,
-0.94970703125,
-0.391357421875,
-0.49462890625,
0.73486328125,
0.280517578125,
0.281494140625,
0.54248046875,
-0.1861572265625,
-0.47314453125,
-1.0712890625,
0.433349609375,
-0.02496337890625,
0.931640625,
-0.787109375,
0.53759765625,
0.58251953125,
-0.7890625,
0.77001953125,
-1.060546875,
-0.1597900390625,
1.3515625,
-0.235595703125,
0.92236328125,
-0.1856689453125,
0.0697021484375,
-0.87158203125,
-0.205810546875,
1.19140625,
0.0010309219360351562,
0.73486328125,
-0.4599609375,
-0.57958984375,
-0.10650634765625,
0.06048583984375,
-0.63134765625,
-0.6015625,
0.349609375,
-0.481689453125,
-0.25439453125,
-0.685546875,
0.67822265625,
1.2431640625,
0.1510009765625,
0.2958984375,
0.60498046875,
0.08660888671875,
0.53662109375,
0.65185546875,
-0.315673828125,
-0.0214996337890625,
-0.8935546875,
0.73779296875,
0.0244140625,
0.11297607421875,
-0.708984375,
-0.08831787109375,
-0.57861328125,
0.28955078125,
-0.45556640625,
-0.21484375,
-0.9619140625,
0.478759765625,
0.1015625,
0.630859375,
-0.796875,
0.09039306640625,
-0.251220703125,
-0.0294189453125,
0.42724609375,
-0.79638671875,
0.236328125,
-1.1298828125,
0.6240234375,
0.423828125,
-0.1917724609375,
-0.6279296875,
-0.08709716796875,
-0.61767578125,
-0.71826171875,
0.0029010772705078125,
0.97119140625,
0.1175537109375,
0.283203125,
-1.09375,
0.212158203125,
0.169189453125,
-0.181396484375,
0.166015625,
0.08221435546875,
0.35888671875,
0.480712890625,
0.80322265625,
-0.46533203125,
-0.76416015625,
-0.0114593505859375,
-1.12890625,
0.7744140625,
-0.41943359375,
0.28125,
-0.08221435546875,
-0.20556640625,
-0.156494140625,
0.296630859375,
0.0673828125,
0.1578369140625,
-0.29736328125,
0.197509765625,
-0.7998046875,
-0.74755859375,
0.712890625,
-0.3935546875,
-0.66748046875,
0.77490234375,
0.2431640625,
-0.14990234375,
0.12152099609375,
0.45458984375,
-0.214111328125,
-0.049774169921875,
-0.5849609375,
0.369140625,
-0.477783203125,
-0.5947265625,
0.037200927734375,
-0.56640625,
0.7373046875,
-0.0255279541015625,
-0.962890625,
-0.103271484375,
-1.451171875,
-0.30615234375,
0.09332275390625,
-0.57177734375,
0.335205078125,
0.215576171875,
0.00484466552734375,
0.272705078125,
-0.6533203125,
-0.55712890625,
-0.2890625,
-0.529296875,
-0.29443359375,
-0.0721435546875,
0.57861328125,
0.6318359375,
0.00890350341796875,
-0.1260986328125,
0.2154541015625,
0.387451171875,
-0.08685302734375,
-0.52392578125,
-0.2076416015625,
-0.458740234375,
-0.04156494140625,
-0.02398681640625,
0.50048828125,
0.239990234375,
0.2281494140625,
0.802734375,
0.419921875,
0.312255859375,
0.53466796875,
-0.335693359375,
0.80517578125,
0.346435546875,
-1.10546875,
-0.446044921875,
0.9443359375,
-0.41748046875,
0.5458984375,
0.1048583984375,
-0.5087890625,
-1.0546875,
-0.88330078125,
0.0938720703125,
-0.35791015625,
-0.295654296875,
-0.7880859375,
-0.357666015625,
-0.1356201171875,
0.5458984375,
0.06744384765625,
-0.51025390625,
0.30029296875,
-1.1611328125,
0.1385498046875,
-0.685546875,
-0.44921875,
-0.53955078125,
-0.6943359375,
-0.465087890625,
0.71875,
0.317138671875,
0.392333984375,
0.1817626953125,
-0.408203125,
0.170166015625,
0.01171875,
-0.7275390625,
-0.316650390625,
0.0030727386474609375,
0.08209228515625,
0.00547027587890625,
-0.1595458984375,
-0.41845703125,
0.955078125,
-1.46484375,
0.110595703125,
-0.0650634765625,
-0.493896484375,
-0.280517578125,
-0.265869140625,
0.869140625,
-0.06097412109375,
-0.28369140625,
-0.284423828125,
0.5986328125,
0.447021484375,
-0.1805419921875,
-0.70458984375,
-0.76416015625,
-0.64697265625,
-0.84814453125,
0.50341796875,
-0.364501953125,
0.32177734375,
-0.60986328125,
0.11273193359375,
1.2294921875,
-0.64892578125,
0.515625,
1.0419921875,
0.5166015625,
0.27978515625,
-0.69580078125,
0.388916015625,
0.00424957275390625,
-0.78125,
-0.0297393798828125,
-0.00830841064453125,
-0.74658203125,
0.347412109375,
-0.2205810546875,
-1.078125,
-0.5986328125,
0.135009765625,
1.5205078125,
-0.24169921875,
1.0146484375,
0.35107421875,
-0.984375,
-0.494140625,
1.1484375,
-0.0008020401000976562,
0.181396484375,
0.97900390625,
-0.6484375,
-0.1783447265625,
-0.106689453125,
-0.2379150390625,
-0.30126953125,
-0.646484375,
0.85693359375,
-0.25244140625,
-0.355712890625,
0.60107421875,
0.923828125,
-0.9208984375,
-0.9873046875,
0.2269287109375,
-0.05047607421875,
-0.0146331787109375,
-0.81396484375,
0.25390625,
0.83935546875,
-0.472900390625,
-0.013214111328125,
0.400390625,
0.111572265625,
0.494384765625,
-0.01708984375,
0.2164306640625,
-0.399169921875,
0.57666015625,
0.50146484375,
-0.54296875,
-0.368896484375,
-0.9921875,
-0.1021728515625,
-0.10870361328125,
0.032012939453125,
0.591796875,
-0.1622314453125,
0.2254638671875,
0.71142578125,
-0.11700439453125,
0.84765625,
-0.6904296875,
-0.332763671875,
0.447509765625,
-0.454833984375,
-0.74755859375,
-0.0194549560546875,
0.33935546875,
-0.23486328125,
0.28466796875,
-0.6484375,
-0.309814453125,
0.48681640625,
0.307373046875,
-0.34619140625,
-0.63037109375,
-0.1630859375,
-0.9365234375,
-0.81884765625,
-0.408203125,
-0.654296875,
-0.2449951171875,
0.03564453125,
0.1995849609375,
-0.06304931640625,
-0.00864410400390625,
0.81689453125,
-1.01171875,
0.9814453125,
-0.34228515625,
0.70068359375,
-0.7705078125,
-0.1533203125,
-0.6474609375,
0.1732177734375,
-0.416259765625,
-0.3369140625,
-0.40380859375,
0.34521484375,
-0.189453125,
0.3212890625,
-0.2479248046875,
0.2783203125,
-0.3017578125,
-0.388427734375,
0.5146484375,
0.09576416015625,
-0.209716796875,
0.72998046875,
0.474365234375,
-0.142333984375,
0.042510986328125,
-0.08551025390625,
-0.308837890625,
-0.5078125,
0.4150390625,
0.59033203125,
-0.400634765625,
-0.1279296875,
-0.379150390625,
-0.0134735107421875,
-0.94580078125,
0.09991455078125,
-0.1441650390625,
0.178955078125,
0.31201171875,
-0.460693359375,
0.36865234375,
0.990234375,
-0.18603515625,
0.273681640625,
-0.1414794921875,
0.1771240234375,
0.5927734375,
0.3154296875,
0.12548828125,
0.5703125,
0.50634765625,
-0.1978759765625,
0.094970703125,
0.1851806640625,
-0.07464599609375,
0.234619140625,
-0.147216796875,
-0.85986328125,
-1.16796875,
-0.1744384765625,
0.014129638671875,
0.5869140625,
-0.041748046875,
-0.61865234375,
0.084228515625,
-0.08856201171875,
-0.66162109375,
0.27001953125,
-0.841796875,
-0.74560546875,
0.525390625,
-0.084716796875,
-0.36376953125,
-0.257568359375,
-0.32958984375,
0.050567626953125,
0.331298828125,
0.498046875,
-0.71826171875,
0.60400390625,
-0.0689697265625,
0.64501953125,
-0.285888671875,
0.043853759765625,
0.305419921875,
0.451904296875,
-0.313720703125,
-0.69189453125,
0.277587890625,
0.962890625,
0.246826171875,
-0.11016845703125,
-0.392578125,
0.18603515625,
-0.199951171875,
0.1357421875,
-0.2095947265625,
-0.064697265625,
-0.16845703125,
0.61962890625,
-1.4453125,
-0.0204010009765625,
-0.269775390625,
0.53857421875,
0.454833984375,
-0.1201171875,
-0.63427734375,
0.67626953125,
0.81298828125,
-0.10443115234375,
0.197509765625,
0.57568359375,
0.406005859375,
-0.197998046875,
-0.12176513671875,
-0.273681640625,
1.025390625,
0.476318359375,
0.494140625,
-0.1917724609375,
0.430908203125,
0.70263671875,
0.369140625,
-0.01317596435546875,
0.492919921875,
0.444091796875,
-0.140625,
-0.04803466796875,
-0.1175537109375,
-0.4580078125,
0.1240234375,
-0.71435546875,
0.623046875,
-0.435302734375,
-0.450439453125,
-0.62939453125,
-0.67724609375,
0.81787109375,
0.1669921875,
-0.58837890625,
0.0672607421875,
-0.2744140625,
0.340087890625,
0.7705078125,
0.11004638671875,
0.00666046142578125,
0.70263671875,
0.75146484375,
0.5625,
0.6884765625,
0.392822265625,
0.6337890625,
-0.61328125,
-0.08782958984375,
-0.002056121826171875,
0.2470703125,
-0.39990234375,
-0.60986328125,
-0.97607421875,
0.79248046875,
-0.54833984375,
0.1680908203125,
0.779296875,
-0.662109375,
-0.12054443359375,
-0.171142578125,
0.732421875,
-0.54296875,
0.2015380859375,
0.368408203125,
-0.6494140625,
-0.51708984375,
0.8828125,
0.06982421875,
0.399169921875,
0.173828125,
0.84521484375,
-0.022552490234375,
1.4931640625,
0.401123046875,
-0.359619140625,
0.1346435546875,
0.37939453125,
-0.35400390625,
-0.6494140625,
-0.478759765625,
-0.25537109375,
-0.1956787109375,
-0.412353515625,
-0.75,
-0.1971435546875,
0.923828125,
-0.04736328125,
-1.052734375,
-0.5732421875,
0.306640625,
-0.88232421875,
0.4326171875,
0.020721435546875,
-0.005443572998046875,
-0.05010986328125,
0.1248779296875,
-0.002262115478515625,
-0.47998046875,
0.348388671875,
-0.416748046875,
0.295654296875,
-0.399169921875,
-0.46533203125,
-0.50732421875,
-0.6552734375,
-0.464599609375,
-0.0675048828125,
-0.447509765625,
-1.146484375,
0.5771484375,
0.367431640625,
0.7919921875,
0.456298828125,
-0.5654296875,
0.399658203125,
0.76611328125,
1.021484375,
0.0982666015625,
1.0634765625,
0.54833984375,
-0.00330352783203125,
0.028594970703125,
-0.1998291015625,
0.80908203125,
-0.2001953125,
0.325439453125,
-0.599609375,
0.71630859375,
-0.31396484375,
-1.234375,
0.03515625,
0.66552734375,
0.470947265625,
-0.802734375,
-1.109375,
-0.22900390625,
-0.85498046875,
-0.1119384765625,
-0.68994140625,
0.64599609375,
-0.075927734375,
0.33349609375,
-0.36962890625,
-1.318359375,
4.3046875,
1.0751953125,
0.697265625,
0.5556640625,
0.350341796875,
0.8701171875,
0.19873046875,
-0.7607421875,
-0.280029296875,
-0.416748046875,
0.63427734375,
-0.6552734375,
-0.0323486328125,
0.90283203125,
0.5126953125,
0.51318359375,
-0.63037109375,
-0.0447998046875,
-0.1463623046875,
-0.97607421875,
-1.169921875,
0.2349853515625,
-0.1737060546875,
0.422119140625,
-0.0126953125,
0.490478515625,
0.76416015625,
-0.454833984375,
-0.28515625,
-0.79345703125,
0.118408203125,
-0.57177734375,
1.005859375,
0.260986328125,
-0.52783203125,
0.6025390625,
-0.2391357421875,
-0.42919921875,
-0.006847381591796875,
0.52734375,
-0.259033203125,
-0.064453125,
0.76123046875,
-0.380859375,
0.0706787109375,
0.65869140625,
-0.544921875,
0.4248046875,
0.1573486328125,
-0.9619140625,
1.212890625,
0.186279296875,
0.0938720703125,
-0.759765625,
-0.499267578125,
0.31689453125,
0.30078125,
-0.329833984375,
-0.419189453125,
0.595703125,
0.1639404296875,
0.2442626953125,
0.0255584716796875,
0.7314453125,
-1.2861328125,
0.90087890625,
-0.247802734375,
0.358642578125,
-0.6591796875,
-0.2822265625,
0.38330078125,
-0.418212890625,
-0.3935546875,
-0.024261474609375,
0.5712890625,
0.2247314453125,
-0.38134765625,
0.455078125,
0.61279296875,
-0.873046875,
0.33251953125,
0.062164306640625,
-0.46484375,
-0.0280914306640625,
0.2919921875,
1.1181640625,
-0.703125,
-0.30859375,
-0.51904296875,
0.42333984375,
0.69921875,
0.340576171875,
0.0328369140625,
-0.3896484375,
0.07806396484375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Tags: implementation, strings
Correct Solution:
```
count={}
str=input()
count[str]=1
l=(len(str))
for i in range(l):
str=str[-1]+str[0:l-1]
count[str]=(count.get(str,0))
print(len(count))
```
| 70,344 | [
0.56201171875,
-0.0160064697265625,
-0.12060546875,
0.406494140625,
-0.441650390625,
-0.53515625,
-0.12322998046875,
-0.0241851806640625,
0.209228515625,
0.87109375,
1.080078125,
-0.62841796875,
0.1763916015625,
-0.84716796875,
-0.477294921875,
-0.72900390625,
-0.74462890625,
-0.5693359375,
-0.7822265625,
0.03460693359375,
0.2357177734375,
-0.30517578125,
-1.20703125,
-0.53564453125,
-0.6865234375,
1.203125,
0.46337890625,
-0.12646484375,
1.0966796875,
1.3095703125,
-0.6259765625,
-0.61767578125,
0.529296875,
-0.87158203125,
-0.3544921875,
-0.560546875,
0.420166015625,
-0.53271484375,
-0.132568359375,
-0.75732421875,
0.04864501953125,
-0.67431640625,
0.537109375,
-0.62548828125,
-1.2900390625,
-0.37890625,
-0.459228515625,
-0.59765625,
-0.10791015625,
-0.642578125,
0.1268310546875,
-0.1990966796875,
0.669921875,
-0.339111328125,
0.40869140625,
0.1065673828125,
-0.45263671875,
-0.33154296875,
-0.54931640625,
0.331787109375,
0.1292724609375,
0.017242431640625,
-0.2249755859375,
-0.71533203125,
-0.461181640625,
0.2056884765625,
-0.0240936279296875,
-0.0787353515625,
0.2261962890625,
-0.96533203125,
-0.34912109375,
0.07568359375,
-0.2235107421875,
-0.419921875,
-0.403076171875,
-0.3193359375,
0.45556640625,
0.056304931640625,
-0.94970703125,
0.92822265625,
-0.0919189453125,
0.93603515625,
0.06268310546875,
0.548828125,
-0.433837890625,
-0.556640625,
0.0975341796875,
0.2939453125,
0.150390625,
-0.46728515625,
0.142333984375,
0.48828125,
-0.77099609375,
-0.03570556640625,
0.5849609375,
0.416259765625,
-0.0770263671875,
0.09063720703125,
-0.07379150390625,
0.14208984375,
0.875,
0.96923828125,
-0.603515625,
1.126953125,
-0.34228515625,
-0.494873046875,
0.1119384765625,
0.30078125,
-0.177978515625,
-0.456298828125,
-0.41357421875,
-0.22216796875,
0.4384765625,
0.178955078125,
-0.159912109375,
1.0244140625,
0.05487060546875,
0.6044921875,
-0.5400390625,
0.149169921875,
0.434326171875,
0.1051025390625,
0.3212890625,
-0.204833984375,
0.470947265625,
0.01357269287109375,
-0.7939453125,
1.0419921875,
-0.7099609375,
0.047637939453125,
0.294189453125,
0.1302490234375,
-0.2061767578125,
0.431396484375,
0.035430908203125,
1.0966796875,
-0.2880859375,
0.89208984375,
0.462158203125,
-0.884765625,
0.931640625,
-0.1614990234375,
0.0031108856201171875,
1.5693359375,
0.354736328125,
0.2081298828125,
0.84326171875,
0.2225341796875,
-0.6328125,
0.391357421875,
-1.0712890625,
0.6171875,
0.382568359375,
0.303466796875,
-0.5009765625,
0.10223388671875,
-0.3837890625,
0.77734375,
0.042999267578125,
0.181884765625,
-0.462646484375,
0.09332275390625,
-0.1026611328125,
1.134765625,
-0.65283203125,
0.93212890625,
-0.295166015625,
-0.407958984375,
-0.2415771484375,
-0.7236328125,
0.16357421875,
0.14501953125,
-0.1544189453125,
0.7158203125,
0.4814453125,
1.3466796875,
1.072265625,
0.08062744140625,
0.2388916015625,
-0.022674560546875,
-0.4150390625,
0.46240234375,
0.127685546875,
0.76904296875,
0.68310546875,
0.28759765625,
-0.419189453125,
-0.1793212890625,
-0.30615234375,
-0.6669921875,
-0.18310546875,
0.580078125,
-0.7314453125,
-0.06341552734375,
0.2119140625,
0.3251953125,
-1.111328125,
-0.5625,
0.1990966796875,
-0.9794921875,
-0.1064453125,
0.849609375,
-0.1689453125,
0.6884765625,
-0.33935546875,
-0.4033203125,
0.60498046875,
0.5361328125,
-0.62841796875,
0.2015380859375,
0.1776123046875,
-0.05029296875,
-0.25732421875,
-0.1785888671875,
0.63818359375,
-0.18798828125,
-1.037109375,
0.568359375,
-0.158935546875,
-0.428955078125,
0.302001953125,
1.064453125,
0.42333984375,
0.331787109375,
-0.37890625,
-0.310546875,
0.364501953125,
1.310546875,
0.06072998046875,
0.88671875,
0.395263671875,
0.89306640625,
0.279052734375,
0.55224609375,
0.23388671875,
0.060302734375,
0.2578125,
0.87548828125,
0.208984375,
0.10784912109375,
0.09423828125,
0.35400390625,
0.6279296875,
0.55859375,
0.09027099609375,
0.70849609375,
-0.143310546875,
-0.1912841796875,
-0.418701171875,
0.439208984375,
-0.295654296875,
0.67431640625,
0.376708984375,
0.319580078125,
-0.277587890625,
-0.349609375,
0.495361328125,
0.70068359375,
-0.2646484375,
-0.5615234375,
-0.0958251953125,
0.2802734375,
0.2410888671875,
0.030242919921875,
0.5986328125,
0.42919921875,
0.59521484375,
0.51123046875,
-0.2978515625,
-0.521484375,
-0.73583984375,
-1.0029296875,
-0.83349609375,
-0.300048828125,
-0.6689453125,
0.061431884765625,
-0.024932861328125,
-0.6435546875,
0.69580078125,
-0.1480712890625,
-0.4208984375,
-0.00994110107421875,
-0.9111328125,
0.85498046875,
-0.353759765625,
0.71240234375,
-0.77099609375,
0.2266845703125,
-0.253662109375,
0.91748046875,
-0.53662109375,
-0.10174560546875,
-0.244384765625,
-0.40576171875,
0.2183837890625,
0.2490234375,
0.45263671875,
-0.111328125,
-0.560546875,
-0.60302734375,
-0.399658203125,
0.01172637939453125,
-0.413330078125,
0.1612548828125,
-0.413818359375,
0.99560546875,
0.490478515625,
-0.5361328125,
0.958984375,
1.205078125,
-1.05859375,
0.37451171875,
0.14501953125,
0.38623046875,
-0.7919921875,
1.43359375,
0.79638671875,
0.2379150390625,
-0.368408203125,
-0.389892578125,
-0.8017578125,
0.2200927734375,
0.10186767578125,
-0.445556640625,
-0.71142578125,
0.51904296875,
0.05322265625,
-1.1806640625,
0.6142578125,
-1.083984375,
-0.97509765625,
-0.1363525390625,
-0.271240234375,
0.77734375,
0.96435546875,
-0.1092529296875,
-0.318603515625,
-0.197509765625,
-0.4306640625,
0.57666015625,
0.329345703125,
-0.347412109375,
0.310791015625,
0.7431640625,
0.260009765625,
-0.01070404052734375,
0.342529296875,
-0.51416015625,
-0.31884765625,
0.20556640625,
0.2315673828125,
0.491943359375,
0.290771484375,
0.52880859375,
0.10626220703125,
0.7685546875,
-0.80517578125,
-0.58349609375,
-0.1839599609375,
0.6318359375,
0.373046875,
0.3681640625,
-0.042633056640625,
-0.43408203125,
-0.52294921875,
-0.57177734375,
0.56298828125,
0.1695556640625,
0.82275390625,
-0.54638671875,
0.76904296875,
0.2095947265625,
-0.54052734375,
0.55029296875,
-0.6181640625,
-0.1981201171875,
1.0556640625,
-0.55224609375,
0.845703125,
-0.35595703125,
0.330078125,
-0.02569580078125,
-0.00856781005859375,
0.66796875,
0.39794921875,
0.51318359375,
-0.55859375,
-0.275390625,
0.05438232421875,
-0.0648193359375,
-0.1883544921875,
-0.7001953125,
0.344970703125,
-0.2447509765625,
-0.1986083984375,
-1.166015625,
0.479736328125,
0.8486328125,
0.44189453125,
0.005855560302734375,
0.66064453125,
0.14453125,
0.35009765625,
0.50830078125,
-0.60888671875,
-0.05352783203125,
-0.74609375,
0.67919921875,
-0.0211181640625,
-0.6025390625,
-0.84228515625,
-0.205322265625,
-0.487060546875,
-0.2117919921875,
0.13916015625,
0.133544921875,
-0.736328125,
0.2032470703125,
-0.1007080078125,
0.62158203125,
-0.470458984375,
-0.2347412109375,
-0.55859375,
0.382568359375,
0.330810546875,
-0.8154296875,
0.490966796875,
-0.95654296875,
0.73291015625,
0.5888671875,
0.032318115234375,
-0.73486328125,
-0.30810546875,
-0.8837890625,
-0.477783203125,
-0.17333984375,
0.57568359375,
-0.07763671875,
0.40869140625,
-0.94091796875,
0.5400390625,
-0.079833984375,
-0.437744140625,
0.2861328125,
0.2420654296875,
0.474365234375,
-0.00684356689453125,
0.366943359375,
-0.12237548828125,
-0.83203125,
0.340087890625,
-0.931640625,
0.8828125,
-0.392333984375,
0.341064453125,
-0.1341552734375,
-0.01702880859375,
0.25390625,
0.2939453125,
-0.265625,
0.09637451171875,
-0.097412109375,
0.51806640625,
-0.81689453125,
-0.76904296875,
0.5478515625,
-0.469482421875,
0.005962371826171875,
0.61328125,
-0.35107421875,
-0.312255859375,
0.29931640625,
0.13037109375,
-0.474609375,
0.12066650390625,
-0.369873046875,
0.69873046875,
-0.14990234375,
-0.71728515625,
-0.2479248046875,
-0.61767578125,
0.75244140625,
-0.11846923828125,
-0.85498046875,
-0.28955078125,
-1.4541015625,
0.0128936767578125,
-0.29931640625,
-0.1842041015625,
0.52294921875,
0.315673828125,
-0.47265625,
-0.20947265625,
-0.1494140625,
-0.348876953125,
-0.407958984375,
-0.67138671875,
-0.10980224609375,
-0.13134765625,
0.2061767578125,
0.9638671875,
-0.27880859375,
-0.32275390625,
0.0007739067077636719,
-0.1280517578125,
0.1409912109375,
-0.451416015625,
-0.47998046875,
-0.456787109375,
-0.3125,
-0.2481689453125,
0.427001953125,
-0.2081298828125,
0.222900390625,
1.0673828125,
0.08013916015625,
0.1446533203125,
0.148193359375,
-0.44970703125,
1.111328125,
0.1214599609375,
-1.111328125,
-0.26171875,
0.7763671875,
-0.12103271484375,
0.5712890625,
-0.11016845703125,
-0.4130859375,
-0.3408203125,
-0.7919921875,
0.319580078125,
-0.5751953125,
0.1229248046875,
-0.59716796875,
-0.265869140625,
-0.2115478515625,
0.401123046875,
-0.1654052734375,
-0.37548828125,
-0.06195068359375,
-0.96728515625,
0.261474609375,
-0.55322265625,
-0.346435546875,
-0.5244140625,
-0.73974609375,
-0.576171875,
0.7265625,
0.2171630859375,
0.489013671875,
0.09588623046875,
-0.451171875,
0.47412109375,
-0.252685546875,
-0.85205078125,
-0.041290283203125,
0.2418212890625,
0.3828125,
-0.1549072265625,
-0.2325439453125,
-0.646484375,
0.94921875,
-0.66943359375,
0.277587890625,
-0.52783203125,
-0.49365234375,
0.0614013671875,
0.01517486572265625,
0.86474609375,
-0.306640625,
0.01039886474609375,
-0.67529296875,
0.456787109375,
0.623046875,
0.13818359375,
-0.4658203125,
-0.78076171875,
-0.33984375,
-1.234375,
0.61181640625,
-0.40087890625,
0.63037109375,
-0.3828125,
-0.1741943359375,
0.6025390625,
-0.533203125,
0.5888671875,
1.1640625,
0.1790771484375,
0.451171875,
-0.46728515625,
0.9365234375,
0.6015625,
-0.54052734375,
-0.38330078125,
0.3818359375,
-0.44873046875,
0.286376953125,
0.0007052421569824219,
-0.9775390625,
-0.230224609375,
0.57470703125,
1.3896484375,
-0.05364990234375,
0.693359375,
-0.1839599609375,
-0.931640625,
-0.7783203125,
0.8447265625,
0.09716796875,
0.5703125,
1.1875,
0.1966552734375,
-0.314453125,
0.45849609375,
0.084716796875,
-0.425048828125,
-0.304931640625,
1.0234375,
-0.11322021484375,
-0.828125,
0.5439453125,
0.74658203125,
-0.96435546875,
-0.88427734375,
-0.303466796875,
-0.233154296875,
-0.385498046875,
-0.413818359375,
0.1832275390625,
-0.04693603515625,
-0.494873046875,
-0.008941650390625,
0.284423828125,
-0.53857421875,
0.396728515625,
-0.1143798828125,
-0.204345703125,
-0.6845703125,
0.360107421875,
0.7431640625,
-0.380615234375,
-0.2027587890625,
-0.7958984375,
-0.10308837890625,
-0.44189453125,
-0.018829345703125,
0.5263671875,
-0.90869140625,
0.099609375,
0.129150390625,
-0.269287109375,
0.6806640625,
-0.560546875,
-0.27099609375,
0.08697509765625,
-0.3203125,
-0.66259765625,
-0.043304443359375,
-0.0767822265625,
-0.16796875,
0.3349609375,
-0.447021484375,
-0.578125,
0.51708984375,
0.01216888427734375,
-0.326904296875,
-0.7919921875,
0.06976318359375,
-1.1962890625,
-0.87890625,
-0.5078125,
-0.61474609375,
-0.0760498046875,
0.1693115234375,
0.0941162109375,
-0.490234375,
-0.0521240234375,
0.58349609375,
-0.5986328125,
0.5185546875,
-0.325439453125,
0.1722412109375,
-0.546875,
-0.251708984375,
-0.468017578125,
-0.2381591796875,
-0.3935546875,
-0.5322265625,
-0.52587890625,
0.456787109375,
-0.28076171875,
0.33251953125,
0.08544921875,
0.2447509765625,
-0.427734375,
-0.7568359375,
0.147705078125,
0.2127685546875,
-0.0134735107421875,
0.53515625,
0.67724609375,
0.040863037109375,
0.70751953125,
-0.27099609375,
-0.615234375,
-0.64453125,
0.59814453125,
0.452880859375,
-0.403564453125,
-0.181640625,
-0.10272216796875,
0.17236328125,
-1.1806640625,
0.172607421875,
-0.317138671875,
0.272216796875,
0.323486328125,
-0.26953125,
0.2349853515625,
0.96142578125,
0.2403564453125,
0.458984375,
0.294677734375,
0.12384033203125,
0.0765380859375,
0.08599853515625,
0.15966796875,
0.72314453125,
-0.203369140625,
-0.317138671875,
0.2479248046875,
0.8271484375,
0.037017822265625,
0.259521484375,
-0.367919921875,
-0.603515625,
-0.5966796875,
0.042327880859375,
-0.2335205078125,
0.49609375,
0.256103515625,
-0.78076171875,
0.0433349609375,
-0.1357421875,
-0.38671875,
0.11041259765625,
-1.287109375,
-0.7646484375,
0.4365234375,
-0.2025146484375,
-0.297607421875,
-0.340576171875,
-0.41162109375,
-0.43603515625,
-0.22119140625,
0.59375,
-0.5830078125,
0.58349609375,
-0.1658935546875,
0.58544921875,
-0.2220458984375,
0.3369140625,
0.07843017578125,
0.59619140625,
-0.5517578125,
-0.6611328125,
0.32421875,
1.1884765625,
0.12255859375,
0.3525390625,
-0.30615234375,
0.285888671875,
-0.08026123046875,
0.07989501953125,
-0.340087890625,
0.298095703125,
-0.45068359375,
0.6787109375,
-0.966796875,
0.207763671875,
0.10546875,
1.0576171875,
0.12939453125,
-0.6884765625,
-0.607421875,
0.947265625,
0.47021484375,
-0.251708984375,
0.405517578125,
0.56201171875,
0.509765625,
-0.386474609375,
-0.2459716796875,
-0.3828125,
0.568359375,
0.7822265625,
0.5576171875,
-0.282958984375,
0.2222900390625,
0.74609375,
0.13134765625,
-0.04095458984375,
0.7001953125,
0.251708984375,
-0.2154541015625,
0.209716796875,
-0.409912109375,
-0.070068359375,
-0.1322021484375,
-0.50634765625,
0.56298828125,
-0.042938232421875,
0.1260986328125,
-0.08697509765625,
-1.0166015625,
0.7626953125,
-0.20263671875,
-0.1717529296875,
0.3076171875,
-0.282958984375,
0.23046875,
0.58447265625,
-0.190673828125,
-0.216064453125,
0.7646484375,
0.82177734375,
0.75244140625,
0.31982421875,
0.86669921875,
0.1407470703125,
-0.6376953125,
0.476318359375,
0.041717529296875,
-0.1497802734375,
-0.52685546875,
-0.343505859375,
-1.16796875,
0.50244140625,
-0.5,
-0.27294921875,
0.403564453125,
-0.30712890625,
0.49951171875,
-0.8642578125,
0.71923828125,
-0.51220703125,
-0.036285400390625,
0.5146484375,
-0.193359375,
-0.947265625,
0.947265625,
-0.72119140625,
0.0584716796875,
0.6240234375,
1.0029296875,
0.3642578125,
1.033203125,
0.328857421875,
-0.275390625,
-0.024871826171875,
0.166259765625,
-0.2169189453125,
-0.5849609375,
-0.328857421875,
-0.442626953125,
0.085693359375,
-0.44775390625,
-0.32568359375,
-0.043609619140625,
0.77197265625,
-0.1075439453125,
-0.7802734375,
-0.1571044921875,
-0.11871337890625,
-0.98974609375,
0.388671875,
0.59521484375,
-0.1339111328125,
0.42724609375,
0.14013671875,
-0.202392578125,
-0.58447265625,
-0.011962890625,
-0.52783203125,
0.4091796875,
-0.7626953125,
-0.52001953125,
-0.84130859375,
-0.470703125,
-0.060516357421875,
-0.161865234375,
-0.326904296875,
-1.189453125,
0.77392578125,
0.54541015625,
0.533203125,
0.1346435546875,
-0.46728515625,
0.154541015625,
1.15234375,
0.80322265625,
0.1339111328125,
0.482666015625,
0.49560546875,
-0.024261474609375,
0.372802734375,
-0.417724609375,
0.6494140625,
-0.2900390625,
0.03387451171875,
-0.58251953125,
-0.1861572265625,
-0.44091796875,
-1.4677734375,
0.2012939453125,
0.418701171875,
0.63427734375,
-0.73486328125,
-1.001953125,
-0.48486328125,
-1.0986328125,
-0.306396484375,
-0.56396484375,
0.88134765625,
-0.16357421875,
-0.08319091796875,
-0.034271240234375,
-1.1357421875,
4.3515625,
0.7861328125,
0.85302734375,
-0.07147216796875,
0.21728515625,
1.068359375,
0.56298828125,
-0.4345703125,
-0.379150390625,
-0.490478515625,
0.38232421875,
-0.265625,
-0.066162109375,
0.779296875,
0.1671142578125,
0.53271484375,
-0.5419921875,
0.32080078125,
-0.1549072265625,
-0.80810546875,
-0.81103515625,
0.2108154296875,
0.2998046875,
0.87109375,
-0.154296875,
0.1883544921875,
-0.06683349609375,
-0.62646484375,
-0.3642578125,
-0.38427734375,
-0.0108489990234375,
-0.2462158203125,
0.85498046875,
-0.125732421875,
-0.1796875,
0.8486328125,
-0.036590576171875,
-0.59912109375,
-0.0126190185546875,
0.2998046875,
0.08465576171875,
-0.30517578125,
0.40380859375,
-0.425537109375,
-0.351806640625,
0.85791015625,
-0.76416015625,
0.1607666015625,
0.465087890625,
-0.8037109375,
0.80712890625,
-0.162353515625,
0.69091796875,
-0.60546875,
-0.498046875,
0.1240234375,
-0.1114501953125,
-0.46044921875,
-0.90185546875,
0.6884765625,
0.46142578125,
0.2447509765625,
0.59765625,
0.422119140625,
-1.064453125,
0.73291015625,
-0.51611328125,
0.49169921875,
-0.97119140625,
0.20556640625,
0.416259765625,
-0.0159149169921875,
0.029144287109375,
-0.6826171875,
0.78515625,
0.23974609375,
-0.2177734375,
0.90283203125,
0.53466796875,
-0.6025390625,
0.4970703125,
-0.0933837890625,
-0.09429931640625,
-0.448486328125,
0.69091796875,
0.94921875,
-0.58056640625,
-0.2890625,
-0.06439208984375,
0.60595703125,
0.4970703125,
0.82275390625,
0.08367919921875,
-0.6201171875,
-0.0411376953125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Tags: implementation, strings
Correct Solution:
```
st = input()
arr = []
for i in range(len(st)):
arr.append(st[i:] + st[:i])
arr = sorted(arr)
cnt = 1
for i in range(1,len(st)):
if(arr[i] != arr[i-1]):
cnt = cnt + 1
print(cnt)
```
| 70,345 | [
0.53662109375,
0.04986572265625,
-0.099609375,
0.44287109375,
-0.431884765625,
-0.517578125,
-0.14208984375,
-0.03759765625,
0.2347412109375,
0.876953125,
1.0986328125,
-0.62451171875,
0.1715087890625,
-0.9169921875,
-0.484619140625,
-0.73779296875,
-0.7265625,
-0.56103515625,
-0.763671875,
0.0092010498046875,
0.211669921875,
-0.363525390625,
-1.2470703125,
-0.51806640625,
-0.7431640625,
1.1806640625,
0.47607421875,
-0.1474609375,
1.1396484375,
1.31640625,
-0.59716796875,
-0.626953125,
0.515625,
-0.8701171875,
-0.350830078125,
-0.60498046875,
0.48779296875,
-0.4931640625,
-0.10113525390625,
-0.7265625,
0.03363037109375,
-0.689453125,
0.48828125,
-0.61572265625,
-1.205078125,
-0.394775390625,
-0.365478515625,
-0.5849609375,
-0.059326171875,
-0.68408203125,
0.123779296875,
-0.1475830078125,
0.6513671875,
-0.35791015625,
0.421875,
0.11346435546875,
-0.44775390625,
-0.334228515625,
-0.58935546875,
0.340087890625,
0.118408203125,
0.01248931884765625,
-0.224853515625,
-0.78173828125,
-0.4287109375,
0.2147216796875,
-0.01110076904296875,
-0.0218658447265625,
0.26953125,
-0.93310546875,
-0.425048828125,
0.12548828125,
-0.169677734375,
-0.4169921875,
-0.396240234375,
-0.39306640625,
0.4208984375,
0.15625,
-0.94775390625,
0.892578125,
-0.059783935546875,
0.88134765625,
0.040191650390625,
0.50927734375,
-0.407958984375,
-0.5302734375,
0.09954833984375,
0.354248046875,
0.08013916015625,
-0.485107421875,
0.08404541015625,
0.4287109375,
-0.724609375,
-0.05755615234375,
0.58544921875,
0.386474609375,
-0.08709716796875,
0.0947265625,
-0.04449462890625,
0.126220703125,
0.84375,
0.966796875,
-0.62451171875,
1.0673828125,
-0.36181640625,
-0.459716796875,
0.060455322265625,
0.266845703125,
-0.2071533203125,
-0.46484375,
-0.42822265625,
-0.172607421875,
0.42822265625,
0.2001953125,
-0.1700439453125,
0.9609375,
0.007625579833984375,
0.5966796875,
-0.5205078125,
0.11517333984375,
0.39013671875,
0.110107421875,
0.269775390625,
-0.1781005859375,
0.50244140625,
-0.0019664764404296875,
-0.7607421875,
1.0361328125,
-0.728515625,
0.1136474609375,
0.34375,
0.09783935546875,
-0.21630859375,
0.487548828125,
0.0633544921875,
1.10546875,
-0.287353515625,
0.8955078125,
0.40283203125,
-0.841796875,
0.93896484375,
-0.1240234375,
0.011962890625,
1.580078125,
0.30615234375,
0.1959228515625,
0.826171875,
0.182861328125,
-0.6376953125,
0.38916015625,
-1.046875,
0.57763671875,
0.381103515625,
0.2998046875,
-0.54638671875,
0.14697265625,
-0.423828125,
0.78662109375,
0.04071044921875,
0.1910400390625,
-0.50244140625,
0.051300048828125,
-0.08990478515625,
1.1220703125,
-0.63525390625,
0.9619140625,
-0.2939453125,
-0.310302734375,
-0.26806640625,
-0.72998046875,
0.10784912109375,
0.1812744140625,
-0.1563720703125,
0.705078125,
0.420166015625,
1.353515625,
1.1083984375,
0.17138671875,
0.265625,
-0.04119873046875,
-0.368896484375,
0.5185546875,
0.130859375,
0.7333984375,
0.662109375,
0.29296875,
-0.397705078125,
-0.08447265625,
-0.2474365234375,
-0.6796875,
-0.185791015625,
0.552734375,
-0.72314453125,
-0.04095458984375,
0.179443359375,
0.2249755859375,
-1.138671875,
-0.578125,
0.2548828125,
-0.94775390625,
-0.1572265625,
0.8232421875,
-0.175537109375,
0.67138671875,
-0.33203125,
-0.416748046875,
0.62548828125,
0.52685546875,
-0.6640625,
0.177490234375,
0.1668701171875,
-0.0172271728515625,
-0.261962890625,
-0.13427734375,
0.6044921875,
-0.1717529296875,
-1.0654296875,
0.587890625,
-0.1473388671875,
-0.474609375,
0.28125,
1.064453125,
0.4306640625,
0.322509765625,
-0.419677734375,
-0.2529296875,
0.392822265625,
1.3046875,
0.09112548828125,
0.849609375,
0.362060546875,
0.82421875,
0.1866455078125,
0.5693359375,
0.260498046875,
0.0160369873046875,
0.2469482421875,
0.87255859375,
0.2034912109375,
0.1151123046875,
0.09478759765625,
0.32080078125,
0.63525390625,
0.50830078125,
0.040283203125,
0.71875,
-0.09912109375,
-0.2261962890625,
-0.36865234375,
0.452880859375,
-0.376708984375,
0.6923828125,
0.352783203125,
0.260009765625,
-0.31494140625,
-0.36181640625,
0.5,
0.73388671875,
-0.27490234375,
-0.54345703125,
-0.08221435546875,
0.2470703125,
0.2269287109375,
0.06793212890625,
0.62353515625,
0.52001953125,
0.5966796875,
0.56640625,
-0.2939453125,
-0.529296875,
-0.75341796875,
-1.0048828125,
-0.859375,
-0.2225341796875,
-0.68115234375,
-0.0224151611328125,
-0.041961669921875,
-0.67138671875,
0.74072265625,
-0.0999755859375,
-0.386474609375,
-0.053131103515625,
-0.90380859375,
0.81787109375,
-0.32958984375,
0.6064453125,
-0.7939453125,
0.31787109375,
-0.25537109375,
0.8447265625,
-0.50634765625,
-0.130615234375,
-0.21142578125,
-0.42431640625,
0.2254638671875,
0.20458984375,
0.420654296875,
-0.10614013671875,
-0.5693359375,
-0.6337890625,
-0.359619140625,
0.029052734375,
-0.38232421875,
0.1280517578125,
-0.364990234375,
0.93408203125,
0.50439453125,
-0.5126953125,
0.9111328125,
1.1357421875,
-1.03125,
0.361328125,
0.20166015625,
0.34033203125,
-0.7802734375,
1.3984375,
0.81396484375,
0.27001953125,
-0.36767578125,
-0.38720703125,
-0.828125,
0.18359375,
0.044647216796875,
-0.369384765625,
-0.71240234375,
0.546875,
0.06927490234375,
-1.166015625,
0.54052734375,
-1.048828125,
-0.994140625,
-0.049957275390625,
-0.185791015625,
0.7548828125,
0.8818359375,
-0.05340576171875,
-0.32275390625,
-0.2188720703125,
-0.449462890625,
0.548828125,
0.35546875,
-0.37841796875,
0.2705078125,
0.689453125,
0.294921875,
-0.03009033203125,
0.3662109375,
-0.52783203125,
-0.30224609375,
0.1727294921875,
0.21923828125,
0.460205078125,
0.2352294921875,
0.482177734375,
0.1885986328125,
0.82666015625,
-0.74267578125,
-0.56298828125,
-0.1800537109375,
0.66748046875,
0.3388671875,
0.325927734375,
-0.0278472900390625,
-0.48193359375,
-0.4775390625,
-0.498046875,
0.55029296875,
0.18701171875,
0.798828125,
-0.560546875,
0.69091796875,
0.271240234375,
-0.6181640625,
0.53369140625,
-0.60546875,
-0.208251953125,
1.01953125,
-0.50341796875,
0.85107421875,
-0.37353515625,
0.307861328125,
-0.034149169921875,
-0.0005030632019042969,
0.6845703125,
0.396240234375,
0.489013671875,
-0.55908203125,
-0.2724609375,
0.033477783203125,
-0.045166015625,
-0.2279052734375,
-0.68701171875,
0.38330078125,
-0.2440185546875,
-0.2279052734375,
-1.154296875,
0.475830078125,
0.8447265625,
0.396484375,
0.03936767578125,
0.72021484375,
0.1068115234375,
0.375732421875,
0.461669921875,
-0.60302734375,
-0.04437255859375,
-0.71484375,
0.65673828125,
-0.01629638671875,
-0.576171875,
-0.791015625,
-0.166748046875,
-0.498291015625,
-0.11669921875,
0.10736083984375,
0.09490966796875,
-0.765625,
0.19921875,
-0.10382080078125,
0.62255859375,
-0.4189453125,
-0.2115478515625,
-0.58056640625,
0.37890625,
0.34228515625,
-0.82861328125,
0.486572265625,
-0.95361328125,
0.7529296875,
0.53515625,
0.032623291015625,
-0.72900390625,
-0.1966552734375,
-0.9130859375,
-0.4609375,
-0.10833740234375,
0.5576171875,
-0.133056640625,
0.3955078125,
-0.89208984375,
0.5029296875,
-0.0256805419921875,
-0.406982421875,
0.291015625,
0.2802734375,
0.455810546875,
-0.01385498046875,
0.339111328125,
-0.05096435546875,
-0.83837890625,
0.41064453125,
-0.88525390625,
0.8740234375,
-0.3701171875,
0.297607421875,
-0.18603515625,
-0.01320648193359375,
0.27392578125,
0.297119140625,
-0.261962890625,
0.064453125,
-0.10394287109375,
0.52294921875,
-0.837890625,
-0.7626953125,
0.52197265625,
-0.47705078125,
0.0240936279296875,
0.5966796875,
-0.2568359375,
-0.302490234375,
0.3134765625,
0.13525390625,
-0.50341796875,
0.14892578125,
-0.3447265625,
0.685546875,
-0.136962890625,
-0.66357421875,
-0.2191162109375,
-0.61279296875,
0.794921875,
-0.132080078125,
-0.8310546875,
-0.325927734375,
-1.37890625,
0.0313720703125,
-0.31982421875,
-0.11859130859375,
0.462646484375,
0.353515625,
-0.428955078125,
-0.263671875,
-0.1466064453125,
-0.339111328125,
-0.36376953125,
-0.68115234375,
-0.0623779296875,
-0.10443115234375,
0.2078857421875,
0.94970703125,
-0.32568359375,
-0.35546875,
0.011444091796875,
-0.12841796875,
0.09063720703125,
-0.44580078125,
-0.48974609375,
-0.447021484375,
-0.369140625,
-0.25439453125,
0.3740234375,
-0.151123046875,
0.169677734375,
1.0712890625,
0.085693359375,
0.0648193359375,
0.1385498046875,
-0.406005859375,
1.1083984375,
0.1409912109375,
-1.0947265625,
-0.27783203125,
0.7490234375,
-0.1566162109375,
0.65625,
-0.07501220703125,
-0.34033203125,
-0.325439453125,
-0.751953125,
0.351806640625,
-0.58740234375,
0.12548828125,
-0.70263671875,
-0.285888671875,
-0.2064208984375,
0.45458984375,
-0.17578125,
-0.357177734375,
-0.09039306640625,
-0.9765625,
0.2127685546875,
-0.53759765625,
-0.369140625,
-0.537109375,
-0.7080078125,
-0.5849609375,
0.79736328125,
0.1473388671875,
0.4638671875,
0.09088134765625,
-0.357421875,
0.477783203125,
-0.1729736328125,
-0.826171875,
0.020355224609375,
0.2373046875,
0.4169921875,
-0.1561279296875,
-0.2274169921875,
-0.625,
0.97998046875,
-0.63525390625,
0.254638671875,
-0.5322265625,
-0.498291015625,
0.09991455078125,
0.03204345703125,
0.8759765625,
-0.310546875,
0.013763427734375,
-0.64892578125,
0.50341796875,
0.63330078125,
0.1326904296875,
-0.414306640625,
-0.7509765625,
-0.317626953125,
-1.2421875,
0.60400390625,
-0.413818359375,
0.66259765625,
-0.40185546875,
-0.1490478515625,
0.50537109375,
-0.525390625,
0.6083984375,
1.1640625,
0.12042236328125,
0.43408203125,
-0.4853515625,
0.94482421875,
0.6064453125,
-0.54345703125,
-0.43017578125,
0.420166015625,
-0.473388671875,
0.294189453125,
-0.0543212890625,
-0.96435546875,
-0.1939697265625,
0.5546875,
1.3583984375,
-0.0160064697265625,
0.724609375,
-0.142822265625,
-0.92578125,
-0.80322265625,
0.83447265625,
0.046844482421875,
0.52734375,
1.21875,
0.2095947265625,
-0.28759765625,
0.41015625,
0.045867919921875,
-0.445556640625,
-0.2919921875,
1,
-0.1636962890625,
-0.7998046875,
0.4482421875,
0.6884765625,
-0.9853515625,
-0.85888671875,
-0.341796875,
-0.1680908203125,
-0.37646484375,
-0.42236328125,
0.226806640625,
-0.037689208984375,
-0.50927734375,
0.0157318115234375,
0.31982421875,
-0.52392578125,
0.422119140625,
-0.103271484375,
-0.21875,
-0.7451171875,
0.29248046875,
0.7265625,
-0.333740234375,
-0.1968994140625,
-0.76953125,
-0.040191650390625,
-0.3974609375,
-0.0084991455078125,
0.5361328125,
-0.86083984375,
0.1302490234375,
0.1343994140625,
-0.220703125,
0.6474609375,
-0.5947265625,
-0.30859375,
0.10626220703125,
-0.310546875,
-0.68017578125,
-0.09716796875,
-0.05523681640625,
-0.186279296875,
0.3759765625,
-0.49169921875,
-0.50927734375,
0.54931640625,
0.0267486572265625,
-0.281494140625,
-0.72265625,
0.0091705322265625,
-1.236328125,
-0.962890625,
-0.4677734375,
-0.6572265625,
-0.073974609375,
0.176025390625,
0.050445556640625,
-0.5029296875,
-0.00572967529296875,
0.59814453125,
-0.65771484375,
0.51953125,
-0.3115234375,
0.1256103515625,
-0.5615234375,
-0.227783203125,
-0.486328125,
-0.272216796875,
-0.39599609375,
-0.474365234375,
-0.472900390625,
0.478271484375,
-0.271728515625,
0.217529296875,
0.08648681640625,
0.175537109375,
-0.40673828125,
-0.7216796875,
0.103759765625,
0.2236328125,
-0.03900146484375,
0.5390625,
0.70166015625,
0.06683349609375,
0.7431640625,
-0.193359375,
-0.5390625,
-0.6923828125,
0.5625,
0.480712890625,
-0.34130859375,
-0.207275390625,
-0.1707763671875,
0.20654296875,
-1.2041015625,
0.2139892578125,
-0.290771484375,
0.351806640625,
0.3251953125,
-0.327880859375,
0.18701171875,
0.9853515625,
0.287841796875,
0.436279296875,
0.3095703125,
0.08782958984375,
0.0246124267578125,
0.0604248046875,
0.1746826171875,
0.66943359375,
-0.1680908203125,
-0.31689453125,
0.251708984375,
0.8134765625,
0.04022216796875,
0.24365234375,
-0.36328125,
-0.5439453125,
-0.63134765625,
0.0921630859375,
-0.1707763671875,
0.45654296875,
0.302978515625,
-0.8271484375,
0.08551025390625,
-0.1590576171875,
-0.40283203125,
0.1131591796875,
-1.2900390625,
-0.76171875,
0.4228515625,
-0.25244140625,
-0.2978515625,
-0.320556640625,
-0.40869140625,
-0.4228515625,
-0.2381591796875,
0.59423828125,
-0.58447265625,
0.58251953125,
-0.1595458984375,
0.5927734375,
-0.189453125,
0.33349609375,
0.06134033203125,
0.57958984375,
-0.59423828125,
-0.6240234375,
0.319580078125,
1.181640625,
0.09722900390625,
0.3388671875,
-0.312255859375,
0.30126953125,
-0.054931640625,
0.099609375,
-0.4228515625,
0.326416015625,
-0.454345703125,
0.72021484375,
-0.91748046875,
0.2056884765625,
0.0626220703125,
1.0224609375,
0.2010498046875,
-0.642578125,
-0.6328125,
0.94580078125,
0.454345703125,
-0.254150390625,
0.414794921875,
0.50537109375,
0.53369140625,
-0.39501953125,
-0.19482421875,
-0.385986328125,
0.54931640625,
0.7158203125,
0.556640625,
-0.259765625,
0.2410888671875,
0.68701171875,
0.059967041015625,
-0.09344482421875,
0.66357421875,
0.239990234375,
-0.26416015625,
0.1611328125,
-0.396240234375,
-0.0355224609375,
-0.1685791015625,
-0.44677734375,
0.55517578125,
-0.086181640625,
0.11297607421875,
-0.09228515625,
-0.9990234375,
0.77978515625,
-0.1640625,
-0.15625,
0.291015625,
-0.273681640625,
0.239013671875,
0.5634765625,
-0.1824951171875,
-0.295654296875,
0.7119140625,
0.85498046875,
0.73291015625,
0.361083984375,
0.8857421875,
0.1962890625,
-0.66455078125,
0.493896484375,
0.046295166015625,
-0.130859375,
-0.5087890625,
-0.295166015625,
-1.1513671875,
0.529296875,
-0.4306640625,
-0.3359375,
0.400390625,
-0.2257080078125,
0.493896484375,
-0.861328125,
0.7509765625,
-0.5322265625,
-0.028045654296875,
0.55908203125,
-0.2369384765625,
-0.93115234375,
0.9208984375,
-0.73291015625,
0.0408935546875,
0.69384765625,
0.98291015625,
0.282470703125,
1.0673828125,
0.343994140625,
-0.311279296875,
-0.03607177734375,
0.1748046875,
-0.283203125,
-0.56640625,
-0.313720703125,
-0.477294921875,
0.053680419921875,
-0.52294921875,
-0.347412109375,
-0.037811279296875,
0.7275390625,
-0.1046142578125,
-0.7001953125,
-0.177490234375,
-0.1318359375,
-0.96728515625,
0.372314453125,
0.58642578125,
-0.12310791015625,
0.43408203125,
0.1590576171875,
-0.1781005859375,
-0.6181640625,
0.0191802978515625,
-0.513671875,
0.421875,
-0.8603515625,
-0.486328125,
-0.88037109375,
-0.426513671875,
-0.060211181640625,
-0.2076416015625,
-0.3623046875,
-1.150390625,
0.75146484375,
0.546875,
0.45849609375,
0.15966796875,
-0.46533203125,
0.193603515625,
1.080078125,
0.79833984375,
0.146728515625,
0.41845703125,
0.513671875,
0.05938720703125,
0.291259765625,
-0.40576171875,
0.6015625,
-0.37744140625,
0.0219879150390625,
-0.58935546875,
-0.0814208984375,
-0.375,
-1.4130859375,
0.264892578125,
0.35693359375,
0.63232421875,
-0.7548828125,
-1.0205078125,
-0.4794921875,
-1.1005859375,
-0.28173828125,
-0.495849609375,
0.86474609375,
-0.18701171875,
-0.11529541015625,
-0.020599365234375,
-1.2021484375,
4.3984375,
0.818359375,
0.8310546875,
-0.045989990234375,
0.18896484375,
1.0517578125,
0.5517578125,
-0.41845703125,
-0.35693359375,
-0.436767578125,
0.378662109375,
-0.25341796875,
-0.06689453125,
0.76318359375,
0.1873779296875,
0.5849609375,
-0.61181640625,
0.278076171875,
-0.1343994140625,
-0.80419921875,
-0.794921875,
0.24072265625,
0.26220703125,
0.8291015625,
-0.16455078125,
0.1971435546875,
-0.06854248046875,
-0.6123046875,
-0.407470703125,
-0.347900390625,
0.01531219482421875,
-0.263671875,
0.8154296875,
-0.1416015625,
-0.1881103515625,
0.884765625,
-0.047149658203125,
-0.5693359375,
0.0088958740234375,
0.282470703125,
0.08453369140625,
-0.298583984375,
0.353271484375,
-0.434326171875,
-0.341796875,
0.80029296875,
-0.73388671875,
0.1651611328125,
0.473388671875,
-0.7978515625,
0.8115234375,
-0.1788330078125,
0.693359375,
-0.576171875,
-0.4931640625,
0.1622314453125,
-0.12371826171875,
-0.468017578125,
-0.849609375,
0.720703125,
0.434814453125,
0.2027587890625,
0.580078125,
0.50341796875,
-1.0224609375,
0.69677734375,
-0.49755859375,
0.426025390625,
-0.990234375,
0.2384033203125,
0.34716796875,
-0.00556182861328125,
0.035919189453125,
-0.6396484375,
0.8017578125,
0.22802734375,
-0.183349609375,
0.8876953125,
0.50244140625,
-0.58984375,
0.430908203125,
-0.12548828125,
-0.10174560546875,
-0.408447265625,
0.71142578125,
1.0087890625,
-0.59033203125,
-0.250732421875,
-0.126953125,
0.62353515625,
0.469970703125,
0.77392578125,
0.10894775390625,
-0.61181640625,
-0.10382080078125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Tags: implementation, strings
Correct Solution:
```
lis = []
s = input()
for i in range(len(s)):
lis.append(s[i:] + s[:i])
print(len(set(lis)))
```
| 70,346 | [
0.5322265625,
-0.0097503662109375,
-0.048004150390625,
0.387939453125,
-0.434814453125,
-0.517578125,
-0.1446533203125,
-0.045684814453125,
0.2156982421875,
0.8720703125,
1.078125,
-0.5703125,
0.2156982421875,
-0.8583984375,
-0.4814453125,
-0.75830078125,
-0.73974609375,
-0.53857421875,
-0.76318359375,
0.015655517578125,
0.2374267578125,
-0.2900390625,
-1.2421875,
-0.53076171875,
-0.71826171875,
1.19140625,
0.488037109375,
-0.147216796875,
1.0732421875,
1.32421875,
-0.66796875,
-0.5888671875,
0.529296875,
-0.865234375,
-0.3671875,
-0.54541015625,
0.441162109375,
-0.47998046875,
-0.1473388671875,
-0.79931640625,
0.0645751953125,
-0.6953125,
0.529296875,
-0.63134765625,
-1.234375,
-0.34814453125,
-0.443359375,
-0.62255859375,
-0.15087890625,
-0.712890625,
0.1737060546875,
-0.2037353515625,
0.66162109375,
-0.3115234375,
0.35791015625,
0.12274169921875,
-0.444091796875,
-0.350830078125,
-0.57666015625,
0.380615234375,
0.12646484375,
0.0179443359375,
-0.2249755859375,
-0.72509765625,
-0.447265625,
0.2220458984375,
-0.0213165283203125,
-0.03204345703125,
0.2252197265625,
-0.89111328125,
-0.355224609375,
0.1614990234375,
-0.11383056640625,
-0.38818359375,
-0.399169921875,
-0.369140625,
0.431396484375,
0.1087646484375,
-0.92578125,
0.9072265625,
-0.112548828125,
0.92578125,
0.04315185546875,
0.473388671875,
-0.40185546875,
-0.56298828125,
0.0791015625,
0.3740234375,
0.196533203125,
-0.445556640625,
0.097412109375,
0.4580078125,
-0.7880859375,
-0.031646728515625,
0.52783203125,
0.44775390625,
-0.07269287109375,
0.09515380859375,
-0.093017578125,
0.1754150390625,
0.8359375,
1.0234375,
-0.57373046875,
1.080078125,
-0.40087890625,
-0.457275390625,
0.097412109375,
0.29931640625,
-0.1923828125,
-0.399169921875,
-0.451416015625,
-0.1988525390625,
0.466064453125,
0.1807861328125,
-0.1436767578125,
0.99755859375,
0.08673095703125,
0.53125,
-0.5234375,
0.150634765625,
0.447998046875,
0.09918212890625,
0.246826171875,
-0.1962890625,
0.521484375,
-0.0145416259765625,
-0.77587890625,
1.0322265625,
-0.7158203125,
0.053802490234375,
0.356201171875,
0.093994140625,
-0.205322265625,
0.45068359375,
0.02362060546875,
1.12890625,
-0.28271484375,
0.919921875,
0.481201171875,
-0.89501953125,
0.9306640625,
-0.1707763671875,
0.00872802734375,
1.5654296875,
0.36328125,
0.2103271484375,
0.857421875,
0.1627197265625,
-0.67529296875,
0.414306640625,
-1.052734375,
0.61279296875,
0.4189453125,
0.2978515625,
-0.5546875,
0.08984375,
-0.397216796875,
0.76904296875,
0.06854248046875,
0.168212890625,
-0.458740234375,
0.07586669921875,
-0.09307861328125,
1.1552734375,
-0.62744140625,
0.96142578125,
-0.321533203125,
-0.37939453125,
-0.277587890625,
-0.7587890625,
0.1505126953125,
0.19677734375,
-0.1524658203125,
0.72119140625,
0.4267578125,
1.3125,
1.09765625,
0.0865478515625,
0.2406005859375,
-0.03173828125,
-0.411865234375,
0.49658203125,
0.185546875,
0.76416015625,
0.70361328125,
0.25927734375,
-0.369873046875,
-0.1331787109375,
-0.289794921875,
-0.69189453125,
-0.20654296875,
0.615234375,
-0.75439453125,
-0.07159423828125,
0.2178955078125,
0.305419921875,
-1.1123046875,
-0.58349609375,
0.2127685546875,
-0.9697265625,
-0.1103515625,
0.8076171875,
-0.2255859375,
0.650390625,
-0.33935546875,
-0.42724609375,
0.56103515625,
0.56640625,
-0.61181640625,
0.1552734375,
0.20361328125,
0.005035400390625,
-0.2900390625,
-0.1455078125,
0.609375,
-0.2216796875,
-1.0283203125,
0.6416015625,
-0.2137451171875,
-0.4140625,
0.266845703125,
1.0458984375,
0.4873046875,
0.338134765625,
-0.412353515625,
-0.2861328125,
0.342529296875,
1.32421875,
0.1307373046875,
0.8544921875,
0.34228515625,
0.86474609375,
0.22265625,
0.55517578125,
0.2900390625,
0.048797607421875,
0.2391357421875,
0.88427734375,
0.2120361328125,
0.1383056640625,
0.1387939453125,
0.338134765625,
0.67578125,
0.57177734375,
0.05267333984375,
0.72607421875,
-0.11834716796875,
-0.242431640625,
-0.37548828125,
0.365234375,
-0.3291015625,
0.6953125,
0.398193359375,
0.314208984375,
-0.30517578125,
-0.328369140625,
0.5068359375,
0.73193359375,
-0.275634765625,
-0.591796875,
-0.1370849609375,
0.2496337890625,
0.227783203125,
0.053009033203125,
0.59033203125,
0.481201171875,
0.58251953125,
0.55908203125,
-0.32470703125,
-0.55029296875,
-0.7861328125,
-1.009765625,
-0.88525390625,
-0.2342529296875,
-0.64892578125,
0.045257568359375,
-0.0160980224609375,
-0.70361328125,
0.78955078125,
-0.1766357421875,
-0.4111328125,
-0.0145416259765625,
-0.8935546875,
0.78857421875,
-0.340576171875,
0.73779296875,
-0.8173828125,
0.29345703125,
-0.1771240234375,
0.91845703125,
-0.52783203125,
-0.1219482421875,
-0.212890625,
-0.44921875,
0.28662109375,
0.2357177734375,
0.45068359375,
-0.0753173828125,
-0.6279296875,
-0.62548828125,
-0.34521484375,
0.00603485107421875,
-0.375244140625,
0.19775390625,
-0.4609375,
1.0166015625,
0.53125,
-0.4970703125,
0.8994140625,
1.1796875,
-1.0419921875,
0.37255859375,
0.1685791015625,
0.363525390625,
-0.80712890625,
1.4453125,
0.74169921875,
0.239501953125,
-0.37939453125,
-0.366455078125,
-0.81640625,
0.144775390625,
0.10675048828125,
-0.37939453125,
-0.67822265625,
0.488037109375,
0.0758056640625,
-1.193359375,
0.60009765625,
-1.0927734375,
-0.9599609375,
-0.0797119140625,
-0.1988525390625,
0.8125,
0.92919921875,
-0.04217529296875,
-0.33203125,
-0.21923828125,
-0.394287109375,
0.6396484375,
0.365234375,
-0.31103515625,
0.29931640625,
0.6865234375,
0.266845703125,
-0.11663818359375,
0.36376953125,
-0.546875,
-0.31298828125,
0.1834716796875,
0.297119140625,
0.492431640625,
0.265625,
0.4970703125,
0.1109619140625,
0.81787109375,
-0.78564453125,
-0.576171875,
-0.193115234375,
0.59619140625,
0.371826171875,
0.427978515625,
-0.02044677734375,
-0.478271484375,
-0.50537109375,
-0.5615234375,
0.57421875,
0.1646728515625,
0.79833984375,
-0.5234375,
0.71044921875,
0.2161865234375,
-0.56884765625,
0.52197265625,
-0.59375,
-0.1856689453125,
1.0537109375,
-0.54443359375,
0.81396484375,
-0.377685546875,
0.30078125,
-0.0252227783203125,
-0.005474090576171875,
0.62255859375,
0.323486328125,
0.5244140625,
-0.54931640625,
-0.3037109375,
0.059051513671875,
-0.11029052734375,
-0.1878662109375,
-0.6923828125,
0.369384765625,
-0.2301025390625,
-0.1678466796875,
-1.1796875,
0.5048828125,
0.84912109375,
0.4267578125,
-0.0233612060546875,
0.71240234375,
0.09588623046875,
0.42529296875,
0.453125,
-0.56005859375,
-0.06378173828125,
-0.724609375,
0.65966796875,
-0.0014553070068359375,
-0.50927734375,
-0.8291015625,
-0.176025390625,
-0.51318359375,
-0.1575927734375,
0.15087890625,
0.076904296875,
-0.7509765625,
0.2115478515625,
-0.0806884765625,
0.65673828125,
-0.42138671875,
-0.258056640625,
-0.53759765625,
0.403564453125,
0.35546875,
-0.84521484375,
0.50439453125,
-0.9140625,
0.7236328125,
0.53857421875,
0.01727294921875,
-0.7041015625,
-0.267822265625,
-0.89208984375,
-0.49560546875,
-0.1104736328125,
0.580078125,
-0.0496826171875,
0.3837890625,
-0.90185546875,
0.529296875,
0.007244110107421875,
-0.43798828125,
0.321044921875,
0.261474609375,
0.466064453125,
0.023529052734375,
0.352783203125,
-0.101318359375,
-0.8544921875,
0.353515625,
-0.8994140625,
0.8525390625,
-0.430908203125,
0.333740234375,
-0.171875,
-0.0184326171875,
0.2138671875,
0.312744140625,
-0.283203125,
0.07452392578125,
-0.06982421875,
0.55322265625,
-0.7705078125,
-0.7294921875,
0.53466796875,
-0.47802734375,
-0.06219482421875,
0.63671875,
-0.3017578125,
-0.315673828125,
0.28955078125,
0.1466064453125,
-0.47216796875,
0.1627197265625,
-0.394287109375,
0.68212890625,
-0.1484375,
-0.68408203125,
-0.253662109375,
-0.56591796875,
0.7607421875,
-0.130126953125,
-0.8740234375,
-0.30029296875,
-1.376953125,
0.01259613037109375,
-0.29150390625,
-0.1453857421875,
0.51416015625,
0.35400390625,
-0.45458984375,
-0.252685546875,
-0.1942138671875,
-0.368896484375,
-0.396728515625,
-0.69140625,
-0.11529541015625,
-0.1094970703125,
0.219482421875,
0.970703125,
-0.324462890625,
-0.338134765625,
0.007137298583984375,
-0.16845703125,
0.1109619140625,
-0.489990234375,
-0.47998046875,
-0.431640625,
-0.343505859375,
-0.240234375,
0.385009765625,
-0.155029296875,
0.2373046875,
1.0927734375,
0.1458740234375,
0.10650634765625,
0.09942626953125,
-0.451416015625,
1.0546875,
0.16259765625,
-1.03515625,
-0.286865234375,
0.77685546875,
-0.13037109375,
0.59423828125,
-0.09320068359375,
-0.400390625,
-0.345458984375,
-0.7958984375,
0.309814453125,
-0.587890625,
0.1744384765625,
-0.658203125,
-0.279296875,
-0.25927734375,
0.404052734375,
-0.1627197265625,
-0.386474609375,
-0.132080078125,
-0.98046875,
0.1939697265625,
-0.54443359375,
-0.310791015625,
-0.623046875,
-0.7783203125,
-0.62109375,
0.7470703125,
0.204833984375,
0.48388671875,
0.09454345703125,
-0.42041015625,
0.51318359375,
-0.217529296875,
-0.83837890625,
-0.044891357421875,
0.2454833984375,
0.361083984375,
-0.1759033203125,
-0.22265625,
-0.63134765625,
0.923828125,
-0.71728515625,
0.268798828125,
-0.509765625,
-0.497314453125,
0.0765380859375,
0.09698486328125,
0.8837890625,
-0.30224609375,
0.04095458984375,
-0.7392578125,
0.48388671875,
0.63330078125,
0.13818359375,
-0.48974609375,
-0.763671875,
-0.3076171875,
-1.2578125,
0.5732421875,
-0.4267578125,
0.6201171875,
-0.40771484375,
-0.201171875,
0.54931640625,
-0.5126953125,
0.603515625,
1.1865234375,
0.1456298828125,
0.43212890625,
-0.452392578125,
0.9443359375,
0.5673828125,
-0.53369140625,
-0.409912109375,
0.401611328125,
-0.47509765625,
0.289794921875,
-0.0194091796875,
-0.9228515625,
-0.22412109375,
0.59521484375,
1.4189453125,
-0.05657958984375,
0.71044921875,
-0.2054443359375,
-0.88623046875,
-0.77685546875,
0.884765625,
0.10418701171875,
0.56201171875,
1.1875,
0.1767578125,
-0.251953125,
0.382568359375,
0.080078125,
-0.450927734375,
-0.28759765625,
1.01171875,
-0.057769775390625,
-0.763671875,
0.51611328125,
0.74072265625,
-0.99560546875,
-0.91455078125,
-0.28125,
-0.17431640625,
-0.38525390625,
-0.445068359375,
0.1962890625,
-0.01332855224609375,
-0.51611328125,
-0.01506805419921875,
0.31494140625,
-0.53466796875,
0.39501953125,
-0.08917236328125,
-0.2374267578125,
-0.68994140625,
0.33203125,
0.74951171875,
-0.351318359375,
-0.2220458984375,
-0.8115234375,
-0.11328125,
-0.439453125,
-0.047088623046875,
0.53759765625,
-0.85595703125,
0.09930419921875,
0.1341552734375,
-0.27197265625,
0.6787109375,
-0.58544921875,
-0.28662109375,
0.10272216796875,
-0.35302734375,
-0.67138671875,
-0.061859130859375,
-0.07525634765625,
-0.154541015625,
0.327392578125,
-0.491943359375,
-0.55224609375,
0.5302734375,
0.0227203369140625,
-0.32763671875,
-0.83984375,
0.042083740234375,
-1.2509765625,
-0.83349609375,
-0.4765625,
-0.6240234375,
-0.09539794921875,
0.17431640625,
0.1021728515625,
-0.525390625,
-0.0438232421875,
0.59912109375,
-0.6142578125,
0.5078125,
-0.314453125,
0.1826171875,
-0.58154296875,
-0.242919921875,
-0.4365234375,
-0.2578125,
-0.407958984375,
-0.4970703125,
-0.496337890625,
0.479736328125,
-0.309326171875,
0.315673828125,
0.0980224609375,
0.205078125,
-0.396728515625,
-0.72314453125,
0.1236572265625,
0.2332763671875,
-0.01206207275390625,
0.513671875,
0.73095703125,
0.03680419921875,
0.73876953125,
-0.275146484375,
-0.6201171875,
-0.7099609375,
0.58935546875,
0.441650390625,
-0.363037109375,
-0.22314453125,
-0.133056640625,
0.2205810546875,
-1.2001953125,
0.2132568359375,
-0.3515625,
0.3486328125,
0.33740234375,
-0.293212890625,
0.20458984375,
0.99267578125,
0.338134765625,
0.470703125,
0.25634765625,
0.1219482421875,
0.0679931640625,
0.05877685546875,
0.1376953125,
0.6650390625,
-0.18798828125,
-0.31201171875,
0.244873046875,
0.8056640625,
0.054290771484375,
0.255859375,
-0.365234375,
-0.5859375,
-0.60107421875,
0.07757568359375,
-0.1778564453125,
0.46875,
0.267578125,
-0.796875,
0.037933349609375,
-0.146484375,
-0.392578125,
0.170654296875,
-1.2548828125,
-0.74853515625,
0.39306640625,
-0.1939697265625,
-0.301025390625,
-0.34716796875,
-0.416015625,
-0.41943359375,
-0.22802734375,
0.60693359375,
-0.63818359375,
0.57861328125,
-0.1798095703125,
0.599609375,
-0.2000732421875,
0.307861328125,
0.101318359375,
0.53564453125,
-0.5771484375,
-0.67578125,
0.34716796875,
1.16796875,
0.1295166015625,
0.323974609375,
-0.31298828125,
0.29345703125,
-0.058013916015625,
0.0848388671875,
-0.38134765625,
0.26318359375,
-0.451171875,
0.677734375,
-0.904296875,
0.1795654296875,
0.0711669921875,
1.0146484375,
0.1351318359375,
-0.68701171875,
-0.63671875,
0.9091796875,
0.460205078125,
-0.248291015625,
0.37109375,
0.50830078125,
0.56494140625,
-0.39111328125,
-0.2208251953125,
-0.39111328125,
0.564453125,
0.75830078125,
0.57568359375,
-0.293212890625,
0.1695556640625,
0.740234375,
0.0821533203125,
-0.08050537109375,
0.6494140625,
0.2381591796875,
-0.211669921875,
0.1444091796875,
-0.398193359375,
-0.0809326171875,
-0.1397705078125,
-0.48583984375,
0.52734375,
-0.09869384765625,
0.096923828125,
-0.0926513671875,
-1.044921875,
0.775390625,
-0.1864013671875,
-0.1444091796875,
0.277099609375,
-0.27099609375,
0.253173828125,
0.560546875,
-0.177978515625,
-0.209716796875,
0.68603515625,
0.857421875,
0.728515625,
0.36181640625,
0.82958984375,
0.1839599609375,
-0.62158203125,
0.480224609375,
0.035980224609375,
-0.12744140625,
-0.54345703125,
-0.34375,
-1.1767578125,
0.4921875,
-0.497802734375,
-0.276611328125,
0.40625,
-0.266357421875,
0.51025390625,
-0.85791015625,
0.7705078125,
-0.5341796875,
-0.040374755859375,
0.52490234375,
-0.2435302734375,
-0.94970703125,
0.92431640625,
-0.716796875,
0.10675048828125,
0.62353515625,
0.9833984375,
0.349609375,
1.048828125,
0.3349609375,
-0.27978515625,
-0.02587890625,
0.1732177734375,
-0.255615234375,
-0.5908203125,
-0.28173828125,
-0.475341796875,
0.107177734375,
-0.51171875,
-0.32470703125,
-0.047027587890625,
0.7744140625,
-0.11224365234375,
-0.73095703125,
-0.162841796875,
-0.045623779296875,
-0.9765625,
0.342529296875,
0.61279296875,
-0.1466064453125,
0.436767578125,
0.1793212890625,
-0.205810546875,
-0.595703125,
0.0147552490234375,
-0.5732421875,
0.400390625,
-0.81787109375,
-0.53271484375,
-0.87841796875,
-0.414306640625,
-0.0836181640625,
-0.1943359375,
-0.344482421875,
-1.1435546875,
0.77392578125,
0.5419921875,
0.525390625,
0.18408203125,
-0.466796875,
0.2220458984375,
1.115234375,
0.81396484375,
0.154296875,
0.50390625,
0.49169921875,
-0.034698486328125,
0.327880859375,
-0.459716796875,
0.63427734375,
-0.327392578125,
0.037567138671875,
-0.5712890625,
-0.1573486328125,
-0.397216796875,
-1.4384765625,
0.2252197265625,
0.386962890625,
0.66650390625,
-0.74755859375,
-0.99072265625,
-0.44091796875,
-1.083984375,
-0.322265625,
-0.5341796875,
0.91357421875,
-0.10943603515625,
-0.11328125,
-0.01904296875,
-1.1787109375,
4.36328125,
0.8251953125,
0.92822265625,
0.0017538070678710938,
0.1912841796875,
1.076171875,
0.5654296875,
-0.39208984375,
-0.401611328125,
-0.48779296875,
0.42431640625,
-0.2724609375,
-0.06494140625,
0.7919921875,
0.16455078125,
0.52978515625,
-0.56982421875,
0.316650390625,
-0.2120361328125,
-0.80126953125,
-0.8173828125,
0.2025146484375,
0.26513671875,
0.8544921875,
-0.1910400390625,
0.1448974609375,
-0.0928955078125,
-0.580078125,
-0.384521484375,
-0.38330078125,
-0.03887939453125,
-0.28759765625,
0.857421875,
-0.109130859375,
-0.18505859375,
0.78955078125,
-0.058563232421875,
-0.580078125,
-0.035125732421875,
0.294921875,
0.047637939453125,
-0.262939453125,
0.413818359375,
-0.406982421875,
-0.364990234375,
0.84619140625,
-0.7275390625,
0.14892578125,
0.427734375,
-0.81298828125,
0.8232421875,
-0.173095703125,
0.7001953125,
-0.5703125,
-0.4921875,
0.1146240234375,
-0.12371826171875,
-0.432373046875,
-0.82861328125,
0.66357421875,
0.4384765625,
0.2108154296875,
0.56201171875,
0.447021484375,
-1.052734375,
0.783203125,
-0.4970703125,
0.462646484375,
-0.98193359375,
0.208251953125,
0.3359375,
-0.01439666748046875,
0.0248565673828125,
-0.68408203125,
0.76318359375,
0.1636962890625,
-0.2001953125,
0.90966796875,
0.51318359375,
-0.57958984375,
0.46923828125,
-0.161865234375,
-0.14453125,
-0.419921875,
0.69189453125,
0.95849609375,
-0.5771484375,
-0.285888671875,
-0.07025146484375,
0.640625,
0.44140625,
0.83203125,
0.1287841796875,
-0.57861328125,
-0.041961669921875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Tags: implementation, strings
Correct Solution:
```
n = input()
l = []
for i in range(len(n)):
l.append(n[i:]+n[:i])
print(len(list(dict.fromkeys(l))))
```
| 70,347 | [
0.537109375,
-0.026947021484375,
-0.087890625,
0.373291015625,
-0.4189453125,
-0.51806640625,
-0.149658203125,
-0.06298828125,
0.2060546875,
0.8974609375,
1.0556640625,
-0.6298828125,
0.1949462890625,
-0.88232421875,
-0.47265625,
-0.73828125,
-0.77880859375,
-0.56884765625,
-0.72998046875,
-0.00897979736328125,
0.2413330078125,
-0.281005859375,
-1.2236328125,
-0.495849609375,
-0.7001953125,
1.2119140625,
0.480224609375,
-0.11773681640625,
1.1142578125,
1.3076171875,
-0.68408203125,
-0.6044921875,
0.578125,
-0.84912109375,
-0.356689453125,
-0.57373046875,
0.429443359375,
-0.474609375,
-0.166015625,
-0.744140625,
0.07733154296875,
-0.71044921875,
0.5234375,
-0.5966796875,
-1.251953125,
-0.353515625,
-0.47705078125,
-0.60302734375,
-0.1424560546875,
-0.75732421875,
0.1741943359375,
-0.18408203125,
0.67822265625,
-0.316650390625,
0.375732421875,
0.1322021484375,
-0.4423828125,
-0.341552734375,
-0.54638671875,
0.364501953125,
0.154296875,
0.0266265869140625,
-0.2012939453125,
-0.75146484375,
-0.472412109375,
0.195068359375,
-0.0340576171875,
-0.06573486328125,
0.18701171875,
-0.89990234375,
-0.326416015625,
0.1290283203125,
-0.11883544921875,
-0.437744140625,
-0.387451171875,
-0.34228515625,
0.4267578125,
0.057769775390625,
-0.92919921875,
0.900390625,
-0.09765625,
0.9345703125,
0.01849365234375,
0.51171875,
-0.421630859375,
-0.5673828125,
0.07574462890625,
0.36474609375,
0.1634521484375,
-0.446533203125,
0.08843994140625,
0.4736328125,
-0.76611328125,
-0.035888671875,
0.55224609375,
0.442138671875,
-0.09588623046875,
0.1329345703125,
-0.0443115234375,
0.193359375,
0.8427734375,
1.00390625,
-0.56982421875,
1.1201171875,
-0.348388671875,
-0.475830078125,
0.08514404296875,
0.269287109375,
-0.2177734375,
-0.40185546875,
-0.430419921875,
-0.2205810546875,
0.459716796875,
0.1611328125,
-0.153564453125,
1.0107421875,
0.07952880859375,
0.5478515625,
-0.52783203125,
0.158935546875,
0.405029296875,
0.11773681640625,
0.27099609375,
-0.2025146484375,
0.5087890625,
-0.004131317138671875,
-0.779296875,
1.0283203125,
-0.701171875,
0.042266845703125,
0.345703125,
0.10162353515625,
-0.2042236328125,
0.4501953125,
0.039764404296875,
1.0712890625,
-0.272216796875,
0.908203125,
0.456787109375,
-0.888671875,
0.939453125,
-0.1131591796875,
0.037841796875,
1.55078125,
0.37158203125,
0.22314453125,
0.89697265625,
0.164306640625,
-0.65966796875,
0.416259765625,
-1.064453125,
0.62939453125,
0.423828125,
0.302490234375,
-0.5380859375,
0.10833740234375,
-0.416015625,
0.7802734375,
0.0787353515625,
0.144775390625,
-0.450439453125,
0.0767822265625,
-0.1131591796875,
1.1728515625,
-0.66845703125,
0.95458984375,
-0.321044921875,
-0.369873046875,
-0.2568359375,
-0.74951171875,
0.135498046875,
0.1790771484375,
-0.13916015625,
0.7177734375,
0.423095703125,
1.3037109375,
1.0810546875,
0.08319091796875,
0.277587890625,
-0.035491943359375,
-0.405517578125,
0.42333984375,
0.1986083984375,
0.81396484375,
0.68603515625,
0.2459716796875,
-0.40576171875,
-0.14208984375,
-0.269287109375,
-0.65087890625,
-0.199951171875,
0.59619140625,
-0.74267578125,
-0.086669921875,
0.2445068359375,
0.303466796875,
-1.1083984375,
-0.587890625,
0.2247314453125,
-0.953125,
-0.07879638671875,
0.8408203125,
-0.22998046875,
0.681640625,
-0.35888671875,
-0.41259765625,
0.59765625,
0.55615234375,
-0.60546875,
0.176025390625,
0.1961669921875,
0.011383056640625,
-0.2403564453125,
-0.1729736328125,
0.61181640625,
-0.205322265625,
-1.04296875,
0.63818359375,
-0.18408203125,
-0.4287109375,
0.26708984375,
1.0546875,
0.48046875,
0.335205078125,
-0.3916015625,
-0.2222900390625,
0.335205078125,
1.349609375,
0.12481689453125,
0.86572265625,
0.371826171875,
0.83740234375,
0.2509765625,
0.529296875,
0.277099609375,
0.038543701171875,
0.2235107421875,
0.88623046875,
0.25830078125,
0.1357421875,
0.09930419921875,
0.333251953125,
0.6787109375,
0.58056640625,
0.06353759765625,
0.74072265625,
-0.1151123046875,
-0.19189453125,
-0.34375,
0.42919921875,
-0.333984375,
0.65673828125,
0.38427734375,
0.299072265625,
-0.317626953125,
-0.312255859375,
0.51611328125,
0.72900390625,
-0.29150390625,
-0.56298828125,
-0.10455322265625,
0.2437744140625,
0.207763671875,
0.046234130859375,
0.61572265625,
0.466796875,
0.57568359375,
0.5390625,
-0.3359375,
-0.5361328125,
-0.78857421875,
-1.021484375,
-0.89306640625,
-0.255859375,
-0.6689453125,
0.02520751953125,
-0.02587890625,
-0.67041015625,
0.75390625,
-0.16943359375,
-0.40283203125,
-0.01409149169921875,
-0.88720703125,
0.7783203125,
-0.33935546875,
0.76318359375,
-0.8173828125,
0.30322265625,
-0.1658935546875,
0.89404296875,
-0.51318359375,
-0.11431884765625,
-0.22412109375,
-0.4912109375,
0.302001953125,
0.2498779296875,
0.449951171875,
-0.10125732421875,
-0.6220703125,
-0.59375,
-0.374267578125,
-0.0043792724609375,
-0.3505859375,
0.1656494140625,
-0.47509765625,
1.017578125,
0.55078125,
-0.49169921875,
0.9150390625,
1.197265625,
-1.0654296875,
0.335205078125,
0.1854248046875,
0.378662109375,
-0.82421875,
1.4560546875,
0.783203125,
0.218994140625,
-0.37939453125,
-0.377197265625,
-0.828125,
0.175537109375,
0.10491943359375,
-0.423583984375,
-0.68310546875,
0.454833984375,
0.07208251953125,
-1.1806640625,
0.58837890625,
-1.0849609375,
-0.96044921875,
-0.1053466796875,
-0.200927734375,
0.83056640625,
0.93310546875,
-0.06805419921875,
-0.313232421875,
-0.24169921875,
-0.3857421875,
0.64013671875,
0.362548828125,
-0.321533203125,
0.294677734375,
0.6708984375,
0.241455078125,
-0.10284423828125,
0.364501953125,
-0.544921875,
-0.304443359375,
0.1993408203125,
0.2744140625,
0.5029296875,
0.27392578125,
0.5107421875,
0.12493896484375,
0.7802734375,
-0.7861328125,
-0.529296875,
-0.1715087890625,
0.62353515625,
0.36181640625,
0.391357421875,
-0.053802490234375,
-0.4765625,
-0.50927734375,
-0.56982421875,
0.5791015625,
0.2042236328125,
0.798828125,
-0.521484375,
0.72509765625,
0.2247314453125,
-0.5849609375,
0.54736328125,
-0.60205078125,
-0.1578369140625,
1.0146484375,
-0.5693359375,
0.83935546875,
-0.384521484375,
0.283203125,
-0.0014085769653320312,
0.043365478515625,
0.6171875,
0.363037109375,
0.5048828125,
-0.53369140625,
-0.284423828125,
0.0235443115234375,
-0.106689453125,
-0.17041015625,
-0.65478515625,
0.373291015625,
-0.2279052734375,
-0.210205078125,
-1.134765625,
0.4970703125,
0.83740234375,
0.42333984375,
-0.0438232421875,
0.67626953125,
0.167236328125,
0.38623046875,
0.50048828125,
-0.5771484375,
-0.07196044921875,
-0.7373046875,
0.65966796875,
-0.044189453125,
-0.55224609375,
-0.84033203125,
-0.2125244140625,
-0.5400390625,
-0.15185546875,
0.115478515625,
0.1370849609375,
-0.7666015625,
0.232177734375,
-0.104736328125,
0.6474609375,
-0.43017578125,
-0.2232666015625,
-0.57080078125,
0.39111328125,
0.328369140625,
-0.8671875,
0.525390625,
-0.95458984375,
0.71826171875,
0.51611328125,
0.050506591796875,
-0.71044921875,
-0.2509765625,
-0.8759765625,
-0.47607421875,
-0.11376953125,
0.57666015625,
-0.08477783203125,
0.40087890625,
-0.8974609375,
0.5263671875,
0.007373809814453125,
-0.462890625,
0.297119140625,
0.2412109375,
0.48974609375,
-0.0187530517578125,
0.394287109375,
-0.10552978515625,
-0.83837890625,
0.374267578125,
-0.87060546875,
0.8505859375,
-0.424072265625,
0.328125,
-0.16748046875,
-0.0213623046875,
0.2470703125,
0.29296875,
-0.2939453125,
0.08819580078125,
-0.08892822265625,
0.54150390625,
-0.81005859375,
-0.765625,
0.5546875,
-0.440673828125,
-0.04071044921875,
0.61083984375,
-0.313720703125,
-0.30517578125,
0.278564453125,
0.0928955078125,
-0.46728515625,
0.133056640625,
-0.414306640625,
0.712890625,
-0.1771240234375,
-0.708984375,
-0.264404296875,
-0.57275390625,
0.81787109375,
-0.0921630859375,
-0.86328125,
-0.283203125,
-1.400390625,
-0.0035228729248046875,
-0.30224609375,
-0.1519775390625,
0.497802734375,
0.35205078125,
-0.47998046875,
-0.2330322265625,
-0.1761474609375,
-0.364013671875,
-0.3984375,
-0.67333984375,
-0.0799560546875,
-0.1165771484375,
0.18896484375,
0.98486328125,
-0.279052734375,
-0.329833984375,
-0.006702423095703125,
-0.143798828125,
0.12744140625,
-0.49560546875,
-0.5263671875,
-0.438232421875,
-0.31103515625,
-0.225830078125,
0.417724609375,
-0.1842041015625,
0.2320556640625,
1.1142578125,
0.12066650390625,
0.1136474609375,
0.1005859375,
-0.467529296875,
1.04296875,
0.1385498046875,
-1.09765625,
-0.29345703125,
0.78173828125,
-0.16357421875,
0.59423828125,
-0.1185302734375,
-0.415283203125,
-0.357177734375,
-0.79443359375,
0.342529296875,
-0.61328125,
0.165283203125,
-0.6435546875,
-0.25,
-0.2197265625,
0.37353515625,
-0.1590576171875,
-0.38671875,
-0.11944580078125,
-0.9619140625,
0.1990966796875,
-0.55712890625,
-0.3212890625,
-0.60986328125,
-0.78759765625,
-0.619140625,
0.72509765625,
0.212890625,
0.4814453125,
0.11224365234375,
-0.45166015625,
0.441650390625,
-0.23486328125,
-0.8349609375,
-0.0648193359375,
0.236083984375,
0.3525390625,
-0.166259765625,
-0.2432861328125,
-0.650390625,
0.955078125,
-0.7001953125,
0.269287109375,
-0.494140625,
-0.471923828125,
0.10137939453125,
0.0657958984375,
0.87646484375,
-0.271240234375,
0.00919342041015625,
-0.73095703125,
0.455322265625,
0.64599609375,
0.1455078125,
-0.50634765625,
-0.76318359375,
-0.322021484375,
-1.326171875,
0.6005859375,
-0.418212890625,
0.625,
-0.375732421875,
-0.20166015625,
0.55712890625,
-0.5244140625,
0.58349609375,
1.14453125,
0.12744140625,
0.449951171875,
-0.41455078125,
0.9462890625,
0.60009765625,
-0.5556640625,
-0.41796875,
0.3984375,
-0.46142578125,
0.2763671875,
-0.0125579833984375,
-0.91015625,
-0.235107421875,
0.58447265625,
1.3935546875,
-0.050445556640625,
0.71044921875,
-0.2196044921875,
-0.92236328125,
-0.7978515625,
0.837890625,
0.09423828125,
0.5439453125,
1.173828125,
0.14990234375,
-0.3154296875,
0.359619140625,
0.07794189453125,
-0.4580078125,
-0.29150390625,
1.01171875,
-0.062744140625,
-0.79248046875,
0.5166015625,
0.72998046875,
-0.9697265625,
-0.88720703125,
-0.25439453125,
-0.1693115234375,
-0.40283203125,
-0.426025390625,
0.2344970703125,
-0.025054931640625,
-0.498046875,
-0.07806396484375,
0.306396484375,
-0.49853515625,
0.411865234375,
-0.08978271484375,
-0.2210693359375,
-0.716796875,
0.350830078125,
0.71044921875,
-0.34130859375,
-0.2298583984375,
-0.81689453125,
-0.07757568359375,
-0.406005859375,
-0.04803466796875,
0.525390625,
-0.89208984375,
0.0953369140625,
0.11529541015625,
-0.2666015625,
0.68994140625,
-0.59326171875,
-0.309814453125,
0.10528564453125,
-0.337890625,
-0.6513671875,
-0.06317138671875,
-0.0858154296875,
-0.173828125,
0.2880859375,
-0.48779296875,
-0.56591796875,
0.5185546875,
-0.0168609619140625,
-0.36767578125,
-0.8310546875,
0.0272979736328125,
-1.2470703125,
-0.82958984375,
-0.50341796875,
-0.60986328125,
-0.07598876953125,
0.2088623046875,
0.1011962890625,
-0.52001953125,
-0.046875,
0.619140625,
-0.623046875,
0.51953125,
-0.337890625,
0.1826171875,
-0.5947265625,
-0.2264404296875,
-0.438232421875,
-0.2568359375,
-0.369384765625,
-0.50732421875,
-0.4990234375,
0.5185546875,
-0.289794921875,
0.31103515625,
0.07733154296875,
0.244140625,
-0.422607421875,
-0.69677734375,
0.11865234375,
0.2281494140625,
-0.037872314453125,
0.54052734375,
0.69677734375,
0.0555419921875,
0.74072265625,
-0.25634765625,
-0.65087890625,
-0.70751953125,
0.59765625,
0.4541015625,
-0.35595703125,
-0.22998046875,
-0.1217041015625,
0.173095703125,
-1.2177734375,
0.210205078125,
-0.3642578125,
0.314697265625,
0.32421875,
-0.32275390625,
0.178955078125,
0.9951171875,
0.29345703125,
0.458251953125,
0.287353515625,
0.1031494140625,
0.06561279296875,
0.06298828125,
0.1748046875,
0.6728515625,
-0.18408203125,
-0.3173828125,
0.24365234375,
0.8203125,
0.035491943359375,
0.2454833984375,
-0.353759765625,
-0.61376953125,
-0.603515625,
0.120361328125,
-0.12420654296875,
0.475341796875,
0.2371826171875,
-0.775390625,
0.034515380859375,
-0.1513671875,
-0.4404296875,
0.143310546875,
-1.201171875,
-0.76171875,
0.414794921875,
-0.2088623046875,
-0.29833984375,
-0.33203125,
-0.419921875,
-0.437744140625,
-0.197998046875,
0.6513671875,
-0.5859375,
0.5859375,
-0.1759033203125,
0.58349609375,
-0.1871337890625,
0.33349609375,
0.084228515625,
0.5634765625,
-0.5625,
-0.6376953125,
0.343017578125,
1.1982421875,
0.1365966796875,
0.36181640625,
-0.32763671875,
0.314697265625,
-0.051116943359375,
0.07147216796875,
-0.37841796875,
0.267822265625,
-0.46826171875,
0.69091796875,
-0.90625,
0.1993408203125,
0.09698486328125,
1.0009765625,
0.157958984375,
-0.64990234375,
-0.66162109375,
0.869140625,
0.450439453125,
-0.2261962890625,
0.344970703125,
0.53857421875,
0.51416015625,
-0.43310546875,
-0.2261962890625,
-0.336669921875,
0.583984375,
0.7666015625,
0.56396484375,
-0.300537109375,
0.1746826171875,
0.77197265625,
0.11083984375,
-0.10205078125,
0.65576171875,
0.2410888671875,
-0.234375,
0.1676025390625,
-0.404296875,
-0.042327880859375,
-0.15087890625,
-0.463623046875,
0.56201171875,
-0.04638671875,
0.0963134765625,
-0.0921630859375,
-0.98681640625,
0.75244140625,
-0.1973876953125,
-0.1490478515625,
0.264404296875,
-0.253173828125,
0.2548828125,
0.54052734375,
-0.1927490234375,
-0.25732421875,
0.71435546875,
0.8330078125,
0.748046875,
0.41015625,
0.82568359375,
0.13232421875,
-0.60595703125,
0.4755859375,
0.060821533203125,
-0.123779296875,
-0.52197265625,
-0.37158203125,
-1.19921875,
0.52099609375,
-0.5244140625,
-0.290771484375,
0.36865234375,
-0.284423828125,
0.54150390625,
-0.87548828125,
0.736328125,
-0.55029296875,
0.004795074462890625,
0.5107421875,
-0.274169921875,
-0.955078125,
0.9140625,
-0.740234375,
0.106689453125,
0.62744140625,
0.9853515625,
0.35009765625,
1.029296875,
0.310302734375,
-0.273193359375,
-0.0238800048828125,
0.160888671875,
-0.259521484375,
-0.5791015625,
-0.289794921875,
-0.446044921875,
0.08685302734375,
-0.465576171875,
-0.32568359375,
-0.0537109375,
0.74755859375,
-0.10003662109375,
-0.76025390625,
-0.1639404296875,
-0.097900390625,
-0.96337890625,
0.389404296875,
0.62158203125,
-0.1318359375,
0.4296875,
0.1795654296875,
-0.1925048828125,
-0.62890625,
0.00925445556640625,
-0.5712890625,
0.401123046875,
-0.78173828125,
-0.55712890625,
-0.83056640625,
-0.47412109375,
-0.038116455078125,
-0.17724609375,
-0.372314453125,
-1.1484375,
0.751953125,
0.56494140625,
0.488037109375,
0.149658203125,
-0.4599609375,
0.1943359375,
1.1376953125,
0.80224609375,
0.1651611328125,
0.484375,
0.496826171875,
-0.0328369140625,
0.374267578125,
-0.439697265625,
0.626953125,
-0.339111328125,
0.037109375,
-0.57861328125,
-0.1824951171875,
-0.404541015625,
-1.4609375,
0.24072265625,
0.3984375,
0.6591796875,
-0.76220703125,
-1.021484375,
-0.460693359375,
-1.076171875,
-0.328125,
-0.50341796875,
0.875,
-0.1312255859375,
-0.11376953125,
0.01181793212890625,
-1.1865234375,
4.36328125,
0.8212890625,
0.89111328125,
-0.037017822265625,
0.206298828125,
1.072265625,
0.56494140625,
-0.369384765625,
-0.4013671875,
-0.471923828125,
0.361572265625,
-0.276611328125,
-0.06878662109375,
0.7822265625,
0.146240234375,
0.4794921875,
-0.53369140625,
0.309814453125,
-0.1883544921875,
-0.787109375,
-0.80419921875,
0.222412109375,
0.270751953125,
0.85107421875,
-0.169189453125,
0.1468505859375,
-0.066650390625,
-0.537109375,
-0.409912109375,
-0.3212890625,
-0.0286712646484375,
-0.230224609375,
0.88720703125,
-0.1187744140625,
-0.181396484375,
0.77294921875,
-0.00959014892578125,
-0.5888671875,
-0.01239013671875,
0.290283203125,
0.094482421875,
-0.2335205078125,
0.439697265625,
-0.443603515625,
-0.35595703125,
0.83837890625,
-0.77099609375,
0.193359375,
0.45166015625,
-0.806640625,
0.79345703125,
-0.151123046875,
0.70947265625,
-0.60498046875,
-0.431396484375,
0.11273193359375,
-0.142822265625,
-0.43896484375,
-0.8525390625,
0.67041015625,
0.468994140625,
0.1912841796875,
0.6044921875,
0.426513671875,
-1.0537109375,
0.73095703125,
-0.475341796875,
0.45556640625,
-0.955078125,
0.2470703125,
0.35302734375,
-0.0204620361328125,
0.059234619140625,
-0.67578125,
0.8056640625,
0.1756591796875,
-0.1749267578125,
0.92041015625,
0.521484375,
-0.578125,
0.4609375,
-0.149169921875,
-0.1263427734375,
-0.426025390625,
0.6982421875,
0.90234375,
-0.58349609375,
-0.272705078125,
-0.069091796875,
0.6484375,
0.4580078125,
0.82177734375,
0.10150146484375,
-0.56884765625,
-0.0268402099609375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Tags: implementation, strings
Correct Solution:
```
s = input()
known = set()
for i in range(len(s)):
p = s[i:]+ s[:i]
known.add(p)
print(len(known))
```
| 70,348 | [
0.5634765625,
-0.00829315185546875,
-0.0775146484375,
0.37890625,
-0.406005859375,
-0.52978515625,
-0.1337890625,
-0.05712890625,
0.20068359375,
0.87939453125,
1.103515625,
-0.61376953125,
0.2021484375,
-0.8671875,
-0.479248046875,
-0.73974609375,
-0.77978515625,
-0.5625,
-0.75,
-0.00876617431640625,
0.223876953125,
-0.27734375,
-1.24609375,
-0.525390625,
-0.68701171875,
1.189453125,
0.47900390625,
-0.146484375,
1.072265625,
1.3154296875,
-0.66943359375,
-0.5576171875,
0.552734375,
-0.86865234375,
-0.3349609375,
-0.5927734375,
0.4384765625,
-0.4638671875,
-0.1646728515625,
-0.75244140625,
0.0870361328125,
-0.69091796875,
0.544921875,
-0.5908203125,
-1.2578125,
-0.34765625,
-0.496826171875,
-0.6318359375,
-0.1405029296875,
-0.71826171875,
0.1837158203125,
-0.1746826171875,
0.689453125,
-0.292724609375,
0.396728515625,
0.12408447265625,
-0.447021484375,
-0.34130859375,
-0.61328125,
0.364013671875,
0.1217041015625,
-0.01297760009765625,
-0.2247314453125,
-0.75830078125,
-0.483642578125,
0.195556640625,
-0.01168060302734375,
-0.050262451171875,
0.21142578125,
-0.9140625,
-0.357177734375,
0.132568359375,
-0.1300048828125,
-0.41015625,
-0.378662109375,
-0.3505859375,
0.432373046875,
0.11480712890625,
-0.9375,
0.89599609375,
-0.11492919921875,
0.9326171875,
0.00826263427734375,
0.456298828125,
-0.413818359375,
-0.58642578125,
0.074462890625,
0.37109375,
0.182373046875,
-0.43359375,
0.09881591796875,
0.478759765625,
-0.775390625,
0.0012426376342773438,
0.54443359375,
0.42041015625,
-0.09844970703125,
0.1234130859375,
-0.04888916015625,
0.1776123046875,
0.87890625,
0.990234375,
-0.60107421875,
1.109375,
-0.352294921875,
-0.46923828125,
0.060028076171875,
0.30419921875,
-0.224365234375,
-0.369384765625,
-0.428466796875,
-0.18701171875,
0.447265625,
0.1505126953125,
-0.1964111328125,
1.001953125,
0.083251953125,
0.54150390625,
-0.52392578125,
0.137451171875,
0.426025390625,
0.1107177734375,
0.273681640625,
-0.149658203125,
0.5126953125,
0.0013780593872070312,
-0.76953125,
1.0263671875,
-0.720703125,
0.050323486328125,
0.345703125,
0.088134765625,
-0.1966552734375,
0.44482421875,
0.03369140625,
1.095703125,
-0.2958984375,
0.89013671875,
0.466064453125,
-0.8974609375,
0.92578125,
-0.15283203125,
-0.00357818603515625,
1.541015625,
0.384033203125,
0.218994140625,
0.88818359375,
0.192626953125,
-0.68798828125,
0.390869140625,
-1.0517578125,
0.61376953125,
0.38623046875,
0.3203125,
-0.541015625,
0.10015869140625,
-0.41552734375,
0.75439453125,
0.0848388671875,
0.165771484375,
-0.458251953125,
0.0792236328125,
-0.0965576171875,
1.1728515625,
-0.6630859375,
0.96630859375,
-0.31103515625,
-0.36181640625,
-0.26611328125,
-0.77099609375,
0.1456298828125,
0.1673583984375,
-0.14599609375,
0.7333984375,
0.476806640625,
1.328125,
1.1171875,
0.06658935546875,
0.2445068359375,
-0.0262451171875,
-0.406005859375,
0.446044921875,
0.1826171875,
0.7822265625,
0.68505859375,
0.29296875,
-0.365966796875,
-0.1307373046875,
-0.32080078125,
-0.6767578125,
-0.211181640625,
0.578125,
-0.76904296875,
-0.052581787109375,
0.250732421875,
0.298095703125,
-1.111328125,
-0.62451171875,
0.2122802734375,
-0.9697265625,
-0.08929443359375,
0.83740234375,
-0.2073974609375,
0.6611328125,
-0.337646484375,
-0.40625,
0.572265625,
0.5673828125,
-0.6240234375,
0.1346435546875,
0.18994140625,
0.02691650390625,
-0.257568359375,
-0.1787109375,
0.6015625,
-0.2208251953125,
-1.021484375,
0.654296875,
-0.1865234375,
-0.400146484375,
0.270263671875,
1.056640625,
0.48388671875,
0.34423828125,
-0.396240234375,
-0.2900390625,
0.328369140625,
1.345703125,
0.12548828125,
0.87158203125,
0.361572265625,
0.85986328125,
0.24072265625,
0.55908203125,
0.298828125,
0.04498291015625,
0.2313232421875,
0.90966796875,
0.2265625,
0.1300048828125,
0.1591796875,
0.321533203125,
0.67041015625,
0.54931640625,
0.0963134765625,
0.75146484375,
-0.12152099609375,
-0.24951171875,
-0.373779296875,
0.37451171875,
-0.323974609375,
0.705078125,
0.384521484375,
0.324462890625,
-0.30224609375,
-0.328369140625,
0.50390625,
0.73193359375,
-0.276611328125,
-0.57666015625,
-0.135498046875,
0.2491455078125,
0.22705078125,
0.0135650634765625,
0.61474609375,
0.49267578125,
0.583984375,
0.51220703125,
-0.328125,
-0.51611328125,
-0.7744140625,
-1.0048828125,
-0.89697265625,
-0.2646484375,
-0.63232421875,
0.030242919921875,
-0.056182861328125,
-0.69189453125,
0.765625,
-0.175537109375,
-0.40625,
0.01580810546875,
-0.90478515625,
0.8154296875,
-0.34423828125,
0.7197265625,
-0.82275390625,
0.3154296875,
-0.147705078125,
0.92724609375,
-0.5205078125,
-0.1368408203125,
-0.1995849609375,
-0.4697265625,
0.29248046875,
0.267822265625,
0.458984375,
-0.09442138671875,
-0.625,
-0.6123046875,
-0.385986328125,
0.018157958984375,
-0.383056640625,
0.195068359375,
-0.44287109375,
1.0234375,
0.55908203125,
-0.50341796875,
0.91455078125,
1.2080078125,
-1.052734375,
0.378173828125,
0.1546630859375,
0.351318359375,
-0.81640625,
1.45703125,
0.7548828125,
0.2252197265625,
-0.364990234375,
-0.37744140625,
-0.79248046875,
0.171875,
0.09967041015625,
-0.438720703125,
-0.6826171875,
0.485595703125,
0.059539794921875,
-1.173828125,
0.58349609375,
-1.1015625,
-0.94091796875,
-0.08770751953125,
-0.22802734375,
0.85498046875,
0.95556640625,
-0.055511474609375,
-0.292724609375,
-0.20849609375,
-0.3955078125,
0.6357421875,
0.3447265625,
-0.328857421875,
0.297119140625,
0.6826171875,
0.2398681640625,
-0.11090087890625,
0.352783203125,
-0.5283203125,
-0.31298828125,
0.1744384765625,
0.30322265625,
0.52001953125,
0.26123046875,
0.5068359375,
0.11834716796875,
0.8017578125,
-0.7763671875,
-0.56982421875,
-0.153076171875,
0.60595703125,
0.386474609375,
0.4013671875,
-0.034454345703125,
-0.49560546875,
-0.53466796875,
-0.5869140625,
0.55859375,
0.189697265625,
0.802734375,
-0.552734375,
0.7158203125,
0.2225341796875,
-0.58984375,
0.513671875,
-0.59912109375,
-0.1763916015625,
1.0458984375,
-0.55712890625,
0.82275390625,
-0.43408203125,
0.297119140625,
0.007904052734375,
-0.017974853515625,
0.6357421875,
0.355224609375,
0.521484375,
-0.55712890625,
-0.2939453125,
0.01259613037109375,
-0.08685302734375,
-0.17724609375,
-0.67626953125,
0.36962890625,
-0.2293701171875,
-0.1732177734375,
-1.16796875,
0.51513671875,
0.85400390625,
0.4130859375,
-0.051910400390625,
0.70068359375,
0.11187744140625,
0.399658203125,
0.4921875,
-0.5654296875,
-0.0762939453125,
-0.74462890625,
0.6435546875,
-0.0206756591796875,
-0.55322265625,
-0.8447265625,
-0.2412109375,
-0.52197265625,
-0.163330078125,
0.15283203125,
0.0760498046875,
-0.71337890625,
0.22705078125,
-0.10589599609375,
0.66845703125,
-0.4443359375,
-0.2427978515625,
-0.5771484375,
0.396240234375,
0.31396484375,
-0.875,
0.5126953125,
-0.958984375,
0.71533203125,
0.5439453125,
0.0299530029296875,
-0.7119140625,
-0.281005859375,
-0.87451171875,
-0.494384765625,
-0.12469482421875,
0.60693359375,
-0.08587646484375,
0.39794921875,
-0.921875,
0.53759765625,
0.02239990234375,
-0.451904296875,
0.30322265625,
0.2705078125,
0.4736328125,
0.003765106201171875,
0.3857421875,
-0.09906005859375,
-0.85107421875,
0.34619140625,
-0.9248046875,
0.86376953125,
-0.429931640625,
0.32470703125,
-0.1922607421875,
-0.026947021484375,
0.1947021484375,
0.31201171875,
-0.2841796875,
0.094970703125,
-0.08209228515625,
0.54931640625,
-0.7802734375,
-0.75830078125,
0.5234375,
-0.46728515625,
-0.06890869140625,
0.65478515625,
-0.2978515625,
-0.307861328125,
0.274169921875,
0.140869140625,
-0.49267578125,
0.16015625,
-0.405029296875,
0.70654296875,
-0.1287841796875,
-0.71533203125,
-0.26513671875,
-0.58837890625,
0.78173828125,
-0.0838623046875,
-0.8896484375,
-0.3056640625,
-1.38671875,
0.00029277801513671875,
-0.30859375,
-0.1436767578125,
0.52880859375,
0.35986328125,
-0.465576171875,
-0.236328125,
-0.173095703125,
-0.3583984375,
-0.379150390625,
-0.6728515625,
-0.1029052734375,
-0.07635498046875,
0.2244873046875,
0.9697265625,
-0.283935546875,
-0.33154296875,
-0.002178192138671875,
-0.166015625,
0.1170654296875,
-0.488037109375,
-0.4814453125,
-0.444580078125,
-0.31689453125,
-0.2218017578125,
0.4033203125,
-0.1583251953125,
0.23828125,
1.109375,
0.1124267578125,
0.1307373046875,
0.11529541015625,
-0.478515625,
1.0732421875,
0.1695556640625,
-1.087890625,
-0.28125,
0.740234375,
-0.138671875,
0.5849609375,
-0.07208251953125,
-0.4111328125,
-0.323974609375,
-0.8115234375,
0.32080078125,
-0.58544921875,
0.17919921875,
-0.6611328125,
-0.269775390625,
-0.234375,
0.40234375,
-0.144775390625,
-0.374267578125,
-0.12432861328125,
-0.962890625,
0.217529296875,
-0.55322265625,
-0.30419921875,
-0.63916015625,
-0.7685546875,
-0.599609375,
0.7294921875,
0.2242431640625,
0.485595703125,
0.1085205078125,
-0.45751953125,
0.481201171875,
-0.220947265625,
-0.8642578125,
-0.06890869140625,
0.22412109375,
0.337890625,
-0.1895751953125,
-0.239501953125,
-0.63916015625,
0.970703125,
-0.71630859375,
0.25,
-0.5185546875,
-0.505859375,
0.0762939453125,
0.05633544921875,
0.912109375,
-0.279541015625,
0.01441192626953125,
-0.720703125,
0.456298828125,
0.64306640625,
0.111572265625,
-0.52490234375,
-0.7890625,
-0.310791015625,
-1.29296875,
0.6025390625,
-0.428955078125,
0.5966796875,
-0.408935546875,
-0.208984375,
0.56689453125,
-0.5146484375,
0.59375,
1.2060546875,
0.169677734375,
0.44775390625,
-0.406005859375,
0.95849609375,
0.58740234375,
-0.5546875,
-0.433349609375,
0.39013671875,
-0.46533203125,
0.2626953125,
-0.0208740234375,
-0.9267578125,
-0.2216796875,
0.57177734375,
1.396484375,
-0.05975341796875,
0.7197265625,
-0.240966796875,
-0.91650390625,
-0.7958984375,
0.86962890625,
0.10260009765625,
0.56640625,
1.197265625,
0.21923828125,
-0.292724609375,
0.348876953125,
0.09234619140625,
-0.435302734375,
-0.318603515625,
1.0107421875,
-0.045318603515625,
-0.78125,
0.5419921875,
0.7607421875,
-1.0087890625,
-0.8935546875,
-0.2509765625,
-0.1783447265625,
-0.41650390625,
-0.455322265625,
0.1973876953125,
-0.004695892333984375,
-0.50927734375,
-0.009368896484375,
0.32958984375,
-0.52490234375,
0.398193359375,
-0.06585693359375,
-0.1947021484375,
-0.68896484375,
0.38818359375,
0.740234375,
-0.341552734375,
-0.218505859375,
-0.8076171875,
-0.098388671875,
-0.4140625,
-0.086669921875,
0.55419921875,
-0.88037109375,
0.08697509765625,
0.12158203125,
-0.2509765625,
0.68798828125,
-0.638671875,
-0.323486328125,
0.135498046875,
-0.353759765625,
-0.650390625,
-0.0423583984375,
-0.08319091796875,
-0.1531982421875,
0.308837890625,
-0.4951171875,
-0.5732421875,
0.51806640625,
0.04095458984375,
-0.372802734375,
-0.8388671875,
0.042755126953125,
-1.267578125,
-0.86376953125,
-0.5009765625,
-0.60693359375,
-0.08935546875,
0.19580078125,
0.1192626953125,
-0.52783203125,
-0.039825439453125,
0.6025390625,
-0.6396484375,
0.5078125,
-0.33251953125,
0.1754150390625,
-0.572265625,
-0.25439453125,
-0.454833984375,
-0.266357421875,
-0.38525390625,
-0.4892578125,
-0.51806640625,
0.5224609375,
-0.31005859375,
0.31787109375,
0.06744384765625,
0.239013671875,
-0.40576171875,
-0.6923828125,
0.1142578125,
0.2359619140625,
-0.043060302734375,
0.517578125,
0.6904296875,
0.055938720703125,
0.7041015625,
-0.275634765625,
-0.6396484375,
-0.69970703125,
0.59521484375,
0.419921875,
-0.350341796875,
-0.2174072265625,
-0.117431640625,
0.2039794921875,
-1.2177734375,
0.1929931640625,
-0.33447265625,
0.311767578125,
0.325439453125,
-0.3095703125,
0.22314453125,
1.0205078125,
0.30517578125,
0.47998046875,
0.288818359375,
0.11328125,
0.0772705078125,
0.09869384765625,
0.178466796875,
0.66015625,
-0.19482421875,
-0.320556640625,
0.235107421875,
0.787109375,
0.0826416015625,
0.263671875,
-0.3388671875,
-0.5810546875,
-0.59619140625,
0.06817626953125,
-0.1622314453125,
0.4677734375,
0.2374267578125,
-0.8037109375,
0.039306640625,
-0.1640625,
-0.39599609375,
0.1668701171875,
-1.248046875,
-0.771484375,
0.413330078125,
-0.1651611328125,
-0.318115234375,
-0.335693359375,
-0.419189453125,
-0.429931640625,
-0.19677734375,
0.64697265625,
-0.5927734375,
0.59619140625,
-0.199462890625,
0.5927734375,
-0.1773681640625,
0.30029296875,
0.08221435546875,
0.58447265625,
-0.58251953125,
-0.6552734375,
0.32275390625,
1.18359375,
0.151611328125,
0.346435546875,
-0.3427734375,
0.31787109375,
-0.04974365234375,
0.0858154296875,
-0.37451171875,
0.2822265625,
-0.48095703125,
0.68798828125,
-0.93701171875,
0.1943359375,
0.08404541015625,
1.017578125,
0.1646728515625,
-0.66259765625,
-0.642578125,
0.916015625,
0.41796875,
-0.2347412109375,
0.397216796875,
0.50146484375,
0.54150390625,
-0.41015625,
-0.1964111328125,
-0.34521484375,
0.58544921875,
0.7470703125,
0.58203125,
-0.3056640625,
0.166748046875,
0.77783203125,
0.0843505859375,
-0.0762939453125,
0.62255859375,
0.236572265625,
-0.21337890625,
0.166748046875,
-0.412353515625,
-0.036956787109375,
-0.148681640625,
-0.490966796875,
0.57177734375,
-0.081298828125,
0.09259033203125,
-0.10174560546875,
-1.037109375,
0.76708984375,
-0.1895751953125,
-0.10205078125,
0.27490234375,
-0.262939453125,
0.26220703125,
0.5439453125,
-0.216064453125,
-0.2509765625,
0.68994140625,
0.83447265625,
0.74462890625,
0.359130859375,
0.810546875,
0.1678466796875,
-0.62158203125,
0.487548828125,
0.05999755859375,
-0.11309814453125,
-0.51416015625,
-0.3935546875,
-1.17578125,
0.51025390625,
-0.492919921875,
-0.288330078125,
0.39990234375,
-0.3046875,
0.50146484375,
-0.84912109375,
0.77197265625,
-0.54541015625,
-0.00592041015625,
0.51318359375,
-0.279296875,
-0.953125,
0.93603515625,
-0.7216796875,
0.1168212890625,
0.6357421875,
0.99072265625,
0.312744140625,
1.05859375,
0.33203125,
-0.25927734375,
-0.025970458984375,
0.1822509765625,
-0.26416015625,
-0.56982421875,
-0.300537109375,
-0.469970703125,
0.10430908203125,
-0.4775390625,
-0.3671875,
-0.06451416015625,
0.7705078125,
-0.08660888671875,
-0.75390625,
-0.1759033203125,
-0.048797607421875,
-0.95361328125,
0.35986328125,
0.60693359375,
-0.1436767578125,
0.42138671875,
0.1937255859375,
-0.213623046875,
-0.630859375,
-0.0011653900146484375,
-0.60546875,
0.38671875,
-0.78955078125,
-0.51513671875,
-0.83251953125,
-0.42333984375,
-0.026214599609375,
-0.2047119140625,
-0.34521484375,
-1.1513671875,
0.74755859375,
0.55712890625,
0.50732421875,
0.1800537109375,
-0.4501953125,
0.22021484375,
1.146484375,
0.798828125,
0.11688232421875,
0.4970703125,
0.471923828125,
-0.037109375,
0.3779296875,
-0.491943359375,
0.6201171875,
-0.3193359375,
0.0399169921875,
-0.57958984375,
-0.17919921875,
-0.425537109375,
-1.431640625,
0.248779296875,
0.38037109375,
0.66064453125,
-0.74609375,
-1.001953125,
-0.45654296875,
-1.064453125,
-0.31689453125,
-0.52978515625,
0.88232421875,
-0.1239013671875,
-0.1253662109375,
-0.0247650146484375,
-1.2109375,
4.34375,
0.82421875,
0.90283203125,
-0.028289794921875,
0.200927734375,
1.07421875,
0.56201171875,
-0.365478515625,
-0.395751953125,
-0.467529296875,
0.4228515625,
-0.2744140625,
-0.0673828125,
0.79052734375,
0.1451416015625,
0.48974609375,
-0.5576171875,
0.34130859375,
-0.1937255859375,
-0.79345703125,
-0.79296875,
0.238037109375,
0.276123046875,
0.83349609375,
-0.18408203125,
0.148193359375,
-0.087158203125,
-0.57470703125,
-0.35986328125,
-0.351318359375,
-0.036224365234375,
-0.26708984375,
0.87255859375,
-0.0887451171875,
-0.1756591796875,
0.80859375,
-0.024169921875,
-0.59814453125,
-0.024200439453125,
0.291015625,
0.060333251953125,
-0.2548828125,
0.409423828125,
-0.412841796875,
-0.396240234375,
0.83984375,
-0.77685546875,
0.1573486328125,
0.424072265625,
-0.82763671875,
0.8193359375,
-0.20751953125,
0.7333984375,
-0.57275390625,
-0.438232421875,
0.127197265625,
-0.1353759765625,
-0.4052734375,
-0.853515625,
0.677734375,
0.48828125,
0.2255859375,
0.57080078125,
0.43359375,
-1.04296875,
0.7587890625,
-0.5263671875,
0.453857421875,
-0.9658203125,
0.2196044921875,
0.347900390625,
-0.006710052490234375,
0.05828857421875,
-0.68408203125,
0.78955078125,
0.1392822265625,
-0.20263671875,
0.9296875,
0.52880859375,
-0.57958984375,
0.477783203125,
-0.141845703125,
-0.11907958984375,
-0.414794921875,
0.68701171875,
0.94775390625,
-0.6015625,
-0.265625,
-0.0771484375,
0.64697265625,
0.44873046875,
0.82568359375,
0.134765625,
-0.5712890625,
-0.03253173828125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Tags: implementation, strings
Correct Solution:
```
s = input()
ss = set()
for i in range(len(s)):
a = s[-1]+s[0:-1]
ss.add(a)
s = a
print(len(ss))
```
| 70,349 | [
0.54443359375,
0.0095977783203125,
-0.08319091796875,
0.392822265625,
-0.414794921875,
-0.51904296875,
-0.127685546875,
-0.05859375,
0.198974609375,
0.88232421875,
1.0908203125,
-0.59375,
0.2071533203125,
-0.89013671875,
-0.4619140625,
-0.74462890625,
-0.76318359375,
-0.5771484375,
-0.7763671875,
-0.0019550323486328125,
0.2183837890625,
-0.294677734375,
-1.236328125,
-0.52294921875,
-0.70361328125,
1.2099609375,
0.4697265625,
-0.1290283203125,
1.0927734375,
1.3134765625,
-0.66162109375,
-0.57861328125,
0.56005859375,
-0.875,
-0.311279296875,
-0.58935546875,
0.42333984375,
-0.460693359375,
-0.160888671875,
-0.7431640625,
0.08697509765625,
-0.68701171875,
0.552734375,
-0.611328125,
-1.2646484375,
-0.35791015625,
-0.48193359375,
-0.6357421875,
-0.13720703125,
-0.708984375,
0.173828125,
-0.18408203125,
0.681640625,
-0.30615234375,
0.3896484375,
0.1533203125,
-0.449951171875,
-0.351806640625,
-0.60986328125,
0.347900390625,
0.133056640625,
0.01503753662109375,
-0.2196044921875,
-0.76220703125,
-0.475341796875,
0.2181396484375,
0.00939178466796875,
-0.05426025390625,
0.2364501953125,
-0.9150390625,
-0.351318359375,
0.129638671875,
-0.12164306640625,
-0.398193359375,
-0.381591796875,
-0.353515625,
0.43603515625,
0.11077880859375,
-0.94189453125,
0.8798828125,
-0.10296630859375,
0.9306640625,
0.02569580078125,
0.4873046875,
-0.4228515625,
-0.57421875,
0.08404541015625,
0.381103515625,
0.1678466796875,
-0.454833984375,
0.107177734375,
0.495361328125,
-0.77978515625,
0.00408935546875,
0.552734375,
0.411376953125,
-0.10626220703125,
0.10528564453125,
-0.0704345703125,
0.17333984375,
0.86376953125,
0.96875,
-0.59765625,
1.1171875,
-0.35693359375,
-0.476806640625,
0.0772705078125,
0.2978515625,
-0.221923828125,
-0.37841796875,
-0.42724609375,
-0.1937255859375,
0.456298828125,
0.162353515625,
-0.1973876953125,
0.9912109375,
0.08966064453125,
0.54248046875,
-0.52978515625,
0.146240234375,
0.432373046875,
0.11895751953125,
0.28662109375,
-0.1617431640625,
0.4970703125,
0.0132293701171875,
-0.7744140625,
1.04296875,
-0.70263671875,
0.0416259765625,
0.334228515625,
0.107177734375,
-0.1978759765625,
0.445068359375,
0.0234832763671875,
1.09765625,
-0.28662109375,
0.8935546875,
0.480224609375,
-0.89111328125,
0.92626953125,
-0.157958984375,
0.0176239013671875,
1.5517578125,
0.364501953125,
0.205322265625,
0.8828125,
0.209716796875,
-0.6650390625,
0.3857421875,
-1.044921875,
0.60400390625,
0.389404296875,
0.310791015625,
-0.5234375,
0.0986328125,
-0.416748046875,
0.74365234375,
0.04949951171875,
0.1617431640625,
-0.47412109375,
0.06341552734375,
-0.1129150390625,
1.171875,
-0.66015625,
0.96484375,
-0.313720703125,
-0.3486328125,
-0.269287109375,
-0.77099609375,
0.1597900390625,
0.171142578125,
-0.14990234375,
0.728515625,
0.443359375,
1.3251953125,
1.1181640625,
0.09417724609375,
0.240966796875,
-0.0240936279296875,
-0.409423828125,
0.4462890625,
0.17529296875,
0.7939453125,
0.68798828125,
0.28955078125,
-0.36279296875,
-0.1326904296875,
-0.31005859375,
-0.68359375,
-0.2247314453125,
0.564453125,
-0.7568359375,
-0.046356201171875,
0.22607421875,
0.29736328125,
-1.1142578125,
-0.61865234375,
0.2003173828125,
-0.94921875,
-0.10687255859375,
0.8095703125,
-0.2003173828125,
0.67431640625,
-0.3505859375,
-0.451171875,
0.5703125,
0.57177734375,
-0.62744140625,
0.14208984375,
0.171875,
0.044647216796875,
-0.26318359375,
-0.156005859375,
0.60400390625,
-0.2274169921875,
-1.01953125,
0.64013671875,
-0.1927490234375,
-0.389892578125,
0.25732421875,
1.0546875,
0.465087890625,
0.35498046875,
-0.394775390625,
-0.2744140625,
0.3271484375,
1.3330078125,
0.12261962890625,
0.85888671875,
0.36376953125,
0.8515625,
0.255126953125,
0.578125,
0.293212890625,
0.04541015625,
0.2322998046875,
0.90625,
0.222412109375,
0.13232421875,
0.131591796875,
0.333251953125,
0.6708984375,
0.5439453125,
0.0777587890625,
0.73583984375,
-0.1326904296875,
-0.23876953125,
-0.3603515625,
0.3876953125,
-0.336669921875,
0.70263671875,
0.388916015625,
0.3251953125,
-0.302734375,
-0.319580078125,
0.497314453125,
0.7314453125,
-0.273193359375,
-0.56494140625,
-0.13134765625,
0.250244140625,
0.24169921875,
0.022216796875,
0.60986328125,
0.477783203125,
0.580078125,
0.5107421875,
-0.304931640625,
-0.53662109375,
-0.77734375,
-1.005859375,
-0.90185546875,
-0.26708984375,
-0.634765625,
0.0438232421875,
-0.038848876953125,
-0.68896484375,
0.77099609375,
-0.1962890625,
-0.400390625,
0.0052642822265625,
-0.896484375,
0.798828125,
-0.349853515625,
0.720703125,
-0.8037109375,
0.287109375,
-0.145263671875,
0.91552734375,
-0.5341796875,
-0.129638671875,
-0.1904296875,
-0.46142578125,
0.272705078125,
0.2452392578125,
0.440185546875,
-0.100341796875,
-0.607421875,
-0.6044921875,
-0.392578125,
0.01340484619140625,
-0.368408203125,
0.171142578125,
-0.427734375,
1.00390625,
0.53466796875,
-0.5087890625,
0.91064453125,
1.197265625,
-1.056640625,
0.36865234375,
0.15625,
0.341552734375,
-0.80859375,
1.4384765625,
0.76416015625,
0.25146484375,
-0.3837890625,
-0.388916015625,
-0.79150390625,
0.167236328125,
0.1041259765625,
-0.395751953125,
-0.689453125,
0.480224609375,
0.04888916015625,
-1.1640625,
0.57373046875,
-1.0869140625,
-0.95166015625,
-0.1036376953125,
-0.234619140625,
0.826171875,
0.9267578125,
-0.048248291015625,
-0.302490234375,
-0.1864013671875,
-0.393310546875,
0.6123046875,
0.357421875,
-0.321533203125,
0.31201171875,
0.6865234375,
0.255615234375,
-0.10137939453125,
0.34716796875,
-0.51513671875,
-0.314208984375,
0.1917724609375,
0.274658203125,
0.50390625,
0.271728515625,
0.50927734375,
0.1390380859375,
0.80078125,
-0.7763671875,
-0.572265625,
-0.17236328125,
0.61962890625,
0.3935546875,
0.396728515625,
-0.0161895751953125,
-0.49169921875,
-0.5341796875,
-0.568359375,
0.5810546875,
0.1708984375,
0.79345703125,
-0.5546875,
0.7001953125,
0.23583984375,
-0.60009765625,
0.5126953125,
-0.60205078125,
-0.17578125,
1.044921875,
-0.5732421875,
0.83203125,
-0.421630859375,
0.32763671875,
-0.01065826416015625,
-0.025177001953125,
0.6376953125,
0.364501953125,
0.51904296875,
-0.56103515625,
-0.2900390625,
0.03076171875,
-0.0933837890625,
-0.1844482421875,
-0.677734375,
0.360595703125,
-0.2281494140625,
-0.1771240234375,
-1.16796875,
0.494384765625,
0.8359375,
0.416748046875,
-0.01348876953125,
0.67822265625,
0.105224609375,
0.386474609375,
0.482421875,
-0.5791015625,
-0.0771484375,
-0.7431640625,
0.654296875,
-0.04144287109375,
-0.54150390625,
-0.83642578125,
-0.2490234375,
-0.51806640625,
-0.151611328125,
0.1602783203125,
0.07623291015625,
-0.7314453125,
0.224853515625,
-0.129638671875,
0.6640625,
-0.437744140625,
-0.2442626953125,
-0.55810546875,
0.4013671875,
0.337646484375,
-0.869140625,
0.4951171875,
-0.9609375,
0.7333984375,
0.5419921875,
0.0219573974609375,
-0.70068359375,
-0.276611328125,
-0.8759765625,
-0.48193359375,
-0.127197265625,
0.59521484375,
-0.0660400390625,
0.388427734375,
-0.92041015625,
0.53173828125,
0.01221466064453125,
-0.445556640625,
0.30517578125,
0.275390625,
0.472900390625,
0.0009512901306152344,
0.387939453125,
-0.09393310546875,
-0.86279296875,
0.3681640625,
-0.9267578125,
0.8564453125,
-0.4169921875,
0.32421875,
-0.1839599609375,
-0.01788330078125,
0.221923828125,
0.308837890625,
-0.29150390625,
0.09075927734375,
-0.08392333984375,
0.55322265625,
-0.77880859375,
-0.7666015625,
0.5322265625,
-0.460205078125,
-0.02520751953125,
0.64794921875,
-0.305419921875,
-0.319091796875,
0.279052734375,
0.1385498046875,
-0.498046875,
0.1517333984375,
-0.4189453125,
0.69873046875,
-0.141845703125,
-0.69921875,
-0.28759765625,
-0.59326171875,
0.7861328125,
-0.10955810546875,
-0.90576171875,
-0.310546875,
-1.3798828125,
0.01087188720703125,
-0.30712890625,
-0.140625,
0.52685546875,
0.34814453125,
-0.467041015625,
-0.232666015625,
-0.1695556640625,
-0.34375,
-0.3837890625,
-0.68505859375,
-0.10736083984375,
-0.10577392578125,
0.221435546875,
0.95458984375,
-0.288818359375,
-0.344970703125,
-0.01015472412109375,
-0.1375732421875,
0.12481689453125,
-0.4814453125,
-0.4951171875,
-0.426513671875,
-0.32080078125,
-0.23046875,
0.418701171875,
-0.2086181640625,
0.2288818359375,
1.087890625,
0.1209716796875,
0.1339111328125,
0.11895751953125,
-0.4794921875,
1.083984375,
0.1754150390625,
-1.0634765625,
-0.28759765625,
0.73974609375,
-0.125,
0.5927734375,
-0.083251953125,
-0.396484375,
-0.316650390625,
-0.7802734375,
0.323486328125,
-0.5869140625,
0.174560546875,
-0.6650390625,
-0.284423828125,
-0.239501953125,
0.393798828125,
-0.137939453125,
-0.373779296875,
-0.12432861328125,
-0.96630859375,
0.2091064453125,
-0.5576171875,
-0.308349609375,
-0.6171875,
-0.77978515625,
-0.578125,
0.7275390625,
0.208251953125,
0.490966796875,
0.1231689453125,
-0.46533203125,
0.474853515625,
-0.2105712890625,
-0.85302734375,
-0.0594482421875,
0.2301025390625,
0.3466796875,
-0.1905517578125,
-0.263916015625,
-0.62109375,
0.96142578125,
-0.70361328125,
0.272705078125,
-0.513671875,
-0.5126953125,
0.07159423828125,
0.0635986328125,
0.90380859375,
-0.29931640625,
0.032928466796875,
-0.73095703125,
0.468017578125,
0.64111328125,
0.1483154296875,
-0.51953125,
-0.7900390625,
-0.31884765625,
-1.2958984375,
0.58740234375,
-0.439697265625,
0.607421875,
-0.414794921875,
-0.1923828125,
0.564453125,
-0.492919921875,
0.58349609375,
1.2119140625,
0.18115234375,
0.466552734375,
-0.43310546875,
0.9541015625,
0.58251953125,
-0.54736328125,
-0.417724609375,
0.374267578125,
-0.46044921875,
0.27978515625,
-0.0158538818359375,
-0.92919921875,
-0.2249755859375,
0.603515625,
1.39453125,
-0.06793212890625,
0.7041015625,
-0.2301025390625,
-0.9169921875,
-0.787109375,
0.86376953125,
0.11785888671875,
0.5546875,
1.193359375,
0.21435546875,
-0.2880859375,
0.367431640625,
0.09326171875,
-0.416259765625,
-0.29443359375,
1.013671875,
-0.0567626953125,
-0.77685546875,
0.546875,
0.748046875,
-0.99951171875,
-0.89990234375,
-0.26220703125,
-0.174560546875,
-0.415771484375,
-0.452880859375,
0.19189453125,
-0.0168609619140625,
-0.50830078125,
0.0027332305908203125,
0.32763671875,
-0.495361328125,
0.384765625,
-0.08984375,
-0.1920166015625,
-0.71142578125,
0.374267578125,
0.72900390625,
-0.356201171875,
-0.2205810546875,
-0.8046875,
-0.0865478515625,
-0.438720703125,
-0.0692138671875,
0.53662109375,
-0.86572265625,
0.1138916015625,
0.11456298828125,
-0.2529296875,
0.67578125,
-0.6337890625,
-0.31396484375,
0.13330078125,
-0.3447265625,
-0.6708984375,
-0.055328369140625,
-0.08544921875,
-0.145263671875,
0.3232421875,
-0.51025390625,
-0.5703125,
0.5087890625,
0.033172607421875,
-0.356201171875,
-0.830078125,
0.048583984375,
-1.2509765625,
-0.85107421875,
-0.5048828125,
-0.62548828125,
-0.09423828125,
0.19775390625,
0.1207275390625,
-0.53515625,
-0.045867919921875,
0.6064453125,
-0.62841796875,
0.499267578125,
-0.339111328125,
0.1500244140625,
-0.56591796875,
-0.262939453125,
-0.456787109375,
-0.23681640625,
-0.374267578125,
-0.496826171875,
-0.51904296875,
0.529296875,
-0.293701171875,
0.31591796875,
0.07000732421875,
0.2357177734375,
-0.397216796875,
-0.69384765625,
0.1407470703125,
0.21923828125,
-0.051422119140625,
0.509765625,
0.68212890625,
0.05780029296875,
0.7060546875,
-0.269287109375,
-0.60009765625,
-0.68408203125,
0.61572265625,
0.427734375,
-0.355224609375,
-0.216552734375,
-0.1181640625,
0.2113037109375,
-1.19921875,
0.20556640625,
-0.360107421875,
0.3046875,
0.32763671875,
-0.304931640625,
0.232666015625,
0.98779296875,
0.318359375,
0.45654296875,
0.28076171875,
0.11395263671875,
0.045196533203125,
0.09014892578125,
0.1680908203125,
0.67431640625,
-0.2080078125,
-0.29736328125,
0.23291015625,
0.81201171875,
0.06488037109375,
0.268310546875,
-0.343017578125,
-0.61328125,
-0.5810546875,
0.059600830078125,
-0.154052734375,
0.47705078125,
0.2401123046875,
-0.8115234375,
0.047943115234375,
-0.1439208984375,
-0.384033203125,
0.160888671875,
-1.255859375,
-0.77685546875,
0.403076171875,
-0.180419921875,
-0.29736328125,
-0.342041015625,
-0.4326171875,
-0.412109375,
-0.20361328125,
0.6201171875,
-0.5966796875,
0.60302734375,
-0.1810302734375,
0.58935546875,
-0.1942138671875,
0.302001953125,
0.10943603515625,
0.56982421875,
-0.59033203125,
-0.6552734375,
0.3427734375,
1.185546875,
0.12353515625,
0.332763671875,
-0.344970703125,
0.312744140625,
-0.03863525390625,
0.10699462890625,
-0.378173828125,
0.289306640625,
-0.4970703125,
0.69091796875,
-0.92529296875,
0.1920166015625,
0.09197998046875,
1.0244140625,
0.1707763671875,
-0.662109375,
-0.642578125,
0.9072265625,
0.444580078125,
-0.240478515625,
0.388427734375,
0.499755859375,
0.53759765625,
-0.413818359375,
-0.2242431640625,
-0.34033203125,
0.58203125,
0.7705078125,
0.58251953125,
-0.28173828125,
0.1793212890625,
0.75634765625,
0.08917236328125,
-0.07177734375,
0.63916015625,
0.2548828125,
-0.2088623046875,
0.1800537109375,
-0.418701171875,
-0.06951904296875,
-0.1351318359375,
-0.493408203125,
0.55078125,
-0.06817626953125,
0.09539794921875,
-0.10003662109375,
-1.0263671875,
0.7724609375,
-0.1854248046875,
-0.114501953125,
0.2802734375,
-0.2578125,
0.26318359375,
0.57080078125,
-0.2117919921875,
-0.2296142578125,
0.68505859375,
0.85400390625,
0.736328125,
0.353271484375,
0.8115234375,
0.168212890625,
-0.61669921875,
0.489013671875,
0.05670166015625,
-0.1385498046875,
-0.5234375,
-0.3603515625,
-1.1982421875,
0.52783203125,
-0.494140625,
-0.297119140625,
0.40771484375,
-0.31884765625,
0.5087890625,
-0.84326171875,
0.7744140625,
-0.5498046875,
-0.02789306640625,
0.498046875,
-0.27587890625,
-0.95654296875,
0.9375,
-0.72119140625,
0.11767578125,
0.61572265625,
0.986328125,
0.318603515625,
1.05859375,
0.3349609375,
-0.271728515625,
-0.01354217529296875,
0.1776123046875,
-0.266357421875,
-0.5517578125,
-0.305908203125,
-0.458740234375,
0.09185791015625,
-0.4970703125,
-0.371337890625,
-0.06842041015625,
0.775390625,
-0.11407470703125,
-0.75634765625,
-0.1690673828125,
-0.05755615234375,
-0.9765625,
0.37158203125,
0.591796875,
-0.128662109375,
0.4091796875,
0.1756591796875,
-0.226318359375,
-0.6279296875,
0.006305694580078125,
-0.57177734375,
0.39453125,
-0.79833984375,
-0.50927734375,
-0.85595703125,
-0.409912109375,
-0.05548095703125,
-0.1912841796875,
-0.338623046875,
-1.15625,
0.74365234375,
0.552734375,
0.4912109375,
0.171142578125,
-0.43896484375,
0.1982421875,
1.1533203125,
0.81494140625,
0.11602783203125,
0.49462890625,
0.47509765625,
-0.029571533203125,
0.358642578125,
-0.474365234375,
0.63720703125,
-0.317626953125,
0.06365966796875,
-0.5771484375,
-0.16650390625,
-0.4208984375,
-1.4287109375,
0.2427978515625,
0.370849609375,
0.64208984375,
-0.73974609375,
-0.99853515625,
-0.4638671875,
-1.0849609375,
-0.305908203125,
-0.54296875,
0.90234375,
-0.148193359375,
-0.117919921875,
-0.029296875,
-1.2021484375,
4.3515625,
0.8388671875,
0.90625,
-0.0260162353515625,
0.2083740234375,
1.08203125,
0.55517578125,
-0.374755859375,
-0.3984375,
-0.457763671875,
0.414306640625,
-0.2919921875,
-0.06494140625,
0.7841796875,
0.146240234375,
0.5166015625,
-0.548828125,
0.314453125,
-0.1666259765625,
-0.8046875,
-0.79833984375,
0.243408203125,
0.263427734375,
0.845703125,
-0.166259765625,
0.151123046875,
-0.10552978515625,
-0.57421875,
-0.356201171875,
-0.36572265625,
-0.018280029296875,
-0.261474609375,
0.8720703125,
-0.08453369140625,
-0.1678466796875,
0.80908203125,
-0.02740478515625,
-0.57373046875,
-0.03375244140625,
0.277587890625,
0.058074951171875,
-0.27294921875,
0.411376953125,
-0.43017578125,
-0.3955078125,
0.83642578125,
-0.77587890625,
0.1558837890625,
0.454833984375,
-0.83447265625,
0.82080078125,
-0.1981201171875,
0.7099609375,
-0.5751953125,
-0.46923828125,
0.1102294921875,
-0.1329345703125,
-0.40478515625,
-0.84228515625,
0.67529296875,
0.493896484375,
0.238525390625,
0.56884765625,
0.443359375,
-1.0595703125,
0.7490234375,
-0.5205078125,
0.470947265625,
-0.98046875,
0.2147216796875,
0.346923828125,
-0.01171875,
0.0634765625,
-0.6689453125,
0.7890625,
0.1756591796875,
-0.2244873046875,
0.91259765625,
0.529296875,
-0.57470703125,
0.46142578125,
-0.134033203125,
-0.1102294921875,
-0.42822265625,
0.70703125,
0.96240234375,
-0.5966796875,
-0.265869140625,
-0.08160400390625,
0.65087890625,
0.451904296875,
0.8408203125,
0.11175537109375,
-0.587890625,
-0.03704833984375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Tags: implementation, strings
Correct Solution:
```
a=input()
r=['']
for i in range(len(a)):
s=a[len(a)-1]+a[:len(a)-1]
a=s
if a not in r:
r.append(a)
print(len(r)-1)
```
| 70,350 | [
0.560546875,
-0.040496826171875,
-0.057220458984375,
0.40576171875,
-0.3916015625,
-0.52099609375,
-0.08135986328125,
-0.06805419921875,
0.174072265625,
0.873046875,
1.111328125,
-0.5947265625,
0.171630859375,
-0.85400390625,
-0.44140625,
-0.7509765625,
-0.7724609375,
-0.5654296875,
-0.76416015625,
0.0350341796875,
0.198974609375,
-0.28759765625,
-1.251953125,
-0.52587890625,
-0.70068359375,
1.2001953125,
0.4560546875,
-0.1505126953125,
1.1220703125,
1.31640625,
-0.67236328125,
-0.62939453125,
0.55712890625,
-0.849609375,
-0.296142578125,
-0.5537109375,
0.42236328125,
-0.45849609375,
-0.150146484375,
-0.70458984375,
0.072998046875,
-0.6767578125,
0.5087890625,
-0.60693359375,
-1.2900390625,
-0.358642578125,
-0.494140625,
-0.60205078125,
-0.1402587890625,
-0.71533203125,
0.17138671875,
-0.16943359375,
0.66259765625,
-0.315673828125,
0.406005859375,
0.128173828125,
-0.470458984375,
-0.3388671875,
-0.6064453125,
0.351318359375,
0.13037109375,
-0.01290130615234375,
-0.21875,
-0.7548828125,
-0.46484375,
0.208740234375,
-0.03826904296875,
-0.0303192138671875,
0.2183837890625,
-0.91162109375,
-0.302978515625,
0.12335205078125,
-0.1378173828125,
-0.416015625,
-0.382568359375,
-0.354248046875,
0.4697265625,
0.08099365234375,
-0.9423828125,
0.9111328125,
-0.1142578125,
0.93212890625,
0.037353515625,
0.521484375,
-0.421630859375,
-0.599609375,
0.10760498046875,
0.38037109375,
0.1373291015625,
-0.4462890625,
0.10186767578125,
0.47265625,
-0.78076171875,
-0.060302734375,
0.5576171875,
0.387451171875,
-0.093017578125,
0.12017822265625,
-0.052490234375,
0.1796875,
0.8837890625,
0.99560546875,
-0.5654296875,
1.0986328125,
-0.366455078125,
-0.458740234375,
0.11260986328125,
0.280029296875,
-0.23291015625,
-0.357177734375,
-0.40673828125,
-0.2083740234375,
0.435546875,
0.14208984375,
-0.1602783203125,
0.98779296875,
0.07183837890625,
0.56787109375,
-0.56591796875,
0.103271484375,
0.410400390625,
0.10736083984375,
0.259521484375,
-0.1944580078125,
0.498046875,
0.01873779296875,
-0.7919921875,
1.0341796875,
-0.69873046875,
0.06280517578125,
0.352294921875,
0.0877685546875,
-0.1929931640625,
0.4384765625,
0.030731201171875,
1.0732421875,
-0.299560546875,
0.89306640625,
0.478759765625,
-0.88671875,
0.931640625,
-0.10076904296875,
0.008941650390625,
1.560546875,
0.36669921875,
0.1859130859375,
0.88720703125,
0.1597900390625,
-0.68408203125,
0.445556640625,
-1.048828125,
0.6181640625,
0.406005859375,
0.298583984375,
-0.54736328125,
0.1385498046875,
-0.390625,
0.71923828125,
0.03472900390625,
0.18359375,
-0.447509765625,
0.056060791015625,
-0.1221923828125,
1.1796875,
-0.66357421875,
0.9736328125,
-0.298583984375,
-0.347412109375,
-0.278564453125,
-0.77734375,
0.169677734375,
0.1943359375,
-0.141845703125,
0.734375,
0.43603515625,
1.3271484375,
1.068359375,
0.119873046875,
0.25341796875,
-0.014190673828125,
-0.37646484375,
0.45947265625,
0.1800537109375,
0.7724609375,
0.66796875,
0.250244140625,
-0.380859375,
-0.1376953125,
-0.292236328125,
-0.6474609375,
-0.2066650390625,
0.53271484375,
-0.703125,
-0.038116455078125,
0.242919921875,
0.28515625,
-1.0888671875,
-0.58837890625,
0.1939697265625,
-0.93408203125,
-0.106201171875,
0.83154296875,
-0.2354736328125,
0.6943359375,
-0.3486328125,
-0.430908203125,
0.58984375,
0.5576171875,
-0.62451171875,
0.1802978515625,
0.166259765625,
0.028900146484375,
-0.30615234375,
-0.1710205078125,
0.6005859375,
-0.2132568359375,
-1.025390625,
0.6240234375,
-0.1627197265625,
-0.448974609375,
0.247802734375,
1.0458984375,
0.45654296875,
0.385009765625,
-0.38330078125,
-0.2919921875,
0.350341796875,
1.3701171875,
0.10589599609375,
0.83203125,
0.387939453125,
0.8818359375,
0.23486328125,
0.56884765625,
0.297119140625,
0.034423828125,
0.25927734375,
0.9052734375,
0.2308349609375,
0.148193359375,
0.11376953125,
0.2919921875,
0.70166015625,
0.55322265625,
0.09112548828125,
0.76318359375,
-0.129150390625,
-0.239501953125,
-0.337646484375,
0.383056640625,
-0.3095703125,
0.654296875,
0.385009765625,
0.33349609375,
-0.348388671875,
-0.351318359375,
0.47900390625,
0.7216796875,
-0.2431640625,
-0.556640625,
-0.133544921875,
0.260498046875,
0.2144775390625,
0.05181884765625,
0.6015625,
0.47998046875,
0.58251953125,
0.51806640625,
-0.31396484375,
-0.5283203125,
-0.7861328125,
-1.0087890625,
-0.91259765625,
-0.2451171875,
-0.66845703125,
0.047149658203125,
-0.048675537109375,
-0.69482421875,
0.75,
-0.2044677734375,
-0.372314453125,
0.005451202392578125,
-0.91552734375,
0.798828125,
-0.306396484375,
0.71875,
-0.7978515625,
0.285400390625,
-0.196533203125,
0.89892578125,
-0.478271484375,
-0.1064453125,
-0.220947265625,
-0.449462890625,
0.251220703125,
0.245361328125,
0.4169921875,
-0.131103515625,
-0.60546875,
-0.5986328125,
-0.342529296875,
0.038909912109375,
-0.40771484375,
0.121826171875,
-0.445068359375,
0.9833984375,
0.5146484375,
-0.493408203125,
0.912109375,
1.1748046875,
-1.0947265625,
0.360107421875,
0.1798095703125,
0.35693359375,
-0.783203125,
1.4052734375,
0.77099609375,
0.26025390625,
-0.375244140625,
-0.4052734375,
-0.82421875,
0.1788330078125,
0.10516357421875,
-0.423095703125,
-0.71142578125,
0.515625,
0.07489013671875,
-1.1875,
0.5791015625,
-1.1025390625,
-0.97509765625,
-0.09246826171875,
-0.23779296875,
0.8359375,
0.95703125,
-0.07403564453125,
-0.30322265625,
-0.1890869140625,
-0.400390625,
0.63134765625,
0.358642578125,
-0.344970703125,
0.308837890625,
0.70654296875,
0.2861328125,
-0.07916259765625,
0.343994140625,
-0.4921875,
-0.303466796875,
0.2183837890625,
0.2763671875,
0.49755859375,
0.2362060546875,
0.541015625,
0.1741943359375,
0.7724609375,
-0.80029296875,
-0.53515625,
-0.189697265625,
0.642578125,
0.3818359375,
0.366455078125,
-0.0361328125,
-0.489013671875,
-0.53125,
-0.55078125,
0.5517578125,
0.16650390625,
0.759765625,
-0.50927734375,
0.736328125,
0.208740234375,
-0.5869140625,
0.52783203125,
-0.60205078125,
-0.162109375,
1.0439453125,
-0.56298828125,
0.84326171875,
-0.411376953125,
0.33056640625,
-0.005802154541015625,
-0.0015344619750976562,
0.6357421875,
0.387451171875,
0.541015625,
-0.5390625,
-0.310791015625,
0.044525146484375,
-0.123046875,
-0.2127685546875,
-0.666015625,
0.373779296875,
-0.2200927734375,
-0.1646728515625,
-1.181640625,
0.5322265625,
0.814453125,
0.452392578125,
0.0162200927734375,
0.69091796875,
0.1072998046875,
0.37841796875,
0.470703125,
-0.5439453125,
-0.08575439453125,
-0.7431640625,
0.6806640625,
-0.06878662109375,
-0.56884765625,
-0.7998046875,
-0.19970703125,
-0.5361328125,
-0.17919921875,
0.1258544921875,
0.08721923828125,
-0.79248046875,
0.2177734375,
-0.155029296875,
0.63720703125,
-0.440185546875,
-0.2303466796875,
-0.54345703125,
0.41650390625,
0.364990234375,
-0.87451171875,
0.470458984375,
-0.9638671875,
0.74609375,
0.541015625,
0.0162353515625,
-0.69921875,
-0.281982421875,
-0.88916015625,
-0.469482421875,
-0.12054443359375,
0.55078125,
-0.05615234375,
0.423583984375,
-0.90283203125,
0.5361328125,
-0.0004184246063232422,
-0.44775390625,
0.321044921875,
0.278564453125,
0.494140625,
-0.0038013458251953125,
0.390869140625,
-0.0762939453125,
-0.87646484375,
0.379150390625,
-0.8974609375,
0.83203125,
-0.4326171875,
0.318115234375,
-0.1781005859375,
-0.03863525390625,
0.261474609375,
0.28759765625,
-0.27880859375,
0.11846923828125,
-0.09527587890625,
0.52978515625,
-0.802734375,
-0.76220703125,
0.5205078125,
-0.41015625,
-0.03021240234375,
0.63720703125,
-0.348388671875,
-0.32666015625,
0.28466796875,
0.166259765625,
-0.441650390625,
0.1405029296875,
-0.42431640625,
0.72705078125,
-0.132568359375,
-0.69677734375,
-0.27880859375,
-0.61328125,
0.7841796875,
-0.1783447265625,
-0.8623046875,
-0.297607421875,
-1.388671875,
-0.01146697998046875,
-0.32470703125,
-0.1533203125,
0.5595703125,
0.340576171875,
-0.485595703125,
-0.266845703125,
-0.17822265625,
-0.34619140625,
-0.370361328125,
-0.662109375,
-0.1248779296875,
-0.15087890625,
0.1951904296875,
0.970703125,
-0.302001953125,
-0.307373046875,
-0.014251708984375,
-0.1343994140625,
0.1201171875,
-0.5029296875,
-0.5087890625,
-0.4052734375,
-0.33349609375,
-0.2144775390625,
0.41162109375,
-0.2509765625,
0.249755859375,
1.0654296875,
0.12396240234375,
0.10687255859375,
0.11187744140625,
-0.456298828125,
1.0634765625,
0.1640625,
-1.0947265625,
-0.31103515625,
0.74853515625,
-0.126220703125,
0.59228515625,
-0.11639404296875,
-0.41259765625,
-0.322998046875,
-0.7685546875,
0.33349609375,
-0.62060546875,
0.1640625,
-0.65966796875,
-0.286865234375,
-0.199951171875,
0.382080078125,
-0.0989990234375,
-0.36083984375,
-0.10540771484375,
-0.9814453125,
0.215087890625,
-0.58935546875,
-0.327880859375,
-0.59814453125,
-0.7626953125,
-0.60791015625,
0.71923828125,
0.1927490234375,
0.476318359375,
0.10784912109375,
-0.436279296875,
0.480712890625,
-0.2110595703125,
-0.80908203125,
-0.07452392578125,
0.2454833984375,
0.3310546875,
-0.2021484375,
-0.216796875,
-0.640625,
0.97607421875,
-0.6640625,
0.295166015625,
-0.49560546875,
-0.52685546875,
0.0626220703125,
0.07647705078125,
0.87646484375,
-0.301513671875,
0.0269317626953125,
-0.697265625,
0.4736328125,
0.63232421875,
0.12396240234375,
-0.50341796875,
-0.7783203125,
-0.320068359375,
-1.330078125,
0.591796875,
-0.428466796875,
0.58447265625,
-0.404052734375,
-0.2203369140625,
0.54296875,
-0.48046875,
0.57861328125,
1.1611328125,
0.174072265625,
0.4775390625,
-0.501953125,
0.99072265625,
0.60498046875,
-0.58154296875,
-0.412109375,
0.38037109375,
-0.44970703125,
0.331298828125,
-0.007350921630859375,
-0.91845703125,
-0.2305908203125,
0.6162109375,
1.3896484375,
-0.0601806640625,
0.72021484375,
-0.2113037109375,
-0.91845703125,
-0.7939453125,
0.8251953125,
0.11328125,
0.5185546875,
1.1943359375,
0.1617431640625,
-0.273681640625,
0.3740234375,
0.074951171875,
-0.446533203125,
-0.2998046875,
1.0400390625,
-0.10760498046875,
-0.80908203125,
0.51953125,
0.720703125,
-0.96533203125,
-0.87744140625,
-0.239501953125,
-0.16259765625,
-0.408447265625,
-0.420166015625,
0.2127685546875,
-0.00844573974609375,
-0.5185546875,
-0.040740966796875,
0.3125,
-0.53515625,
0.37451171875,
-0.095947265625,
-0.211669921875,
-0.70458984375,
0.372802734375,
0.701171875,
-0.345458984375,
-0.215576171875,
-0.76708984375,
-0.0687255859375,
-0.44970703125,
-0.037139892578125,
0.52294921875,
-0.8818359375,
0.10394287109375,
0.1507568359375,
-0.2249755859375,
0.662109375,
-0.6142578125,
-0.3017578125,
0.1297607421875,
-0.30224609375,
-0.70263671875,
-0.07025146484375,
-0.08953857421875,
-0.1302490234375,
0.305908203125,
-0.48681640625,
-0.55712890625,
0.52587890625,
0.005290985107421875,
-0.337158203125,
-0.81884765625,
0.0792236328125,
-1.21875,
-0.87890625,
-0.49560546875,
-0.6455078125,
-0.0653076171875,
0.201171875,
0.07122802734375,
-0.5048828125,
-0.061798095703125,
0.60693359375,
-0.6005859375,
0.525390625,
-0.33349609375,
0.1427001953125,
-0.55419921875,
-0.272216796875,
-0.410400390625,
-0.255126953125,
-0.421142578125,
-0.49853515625,
-0.496826171875,
0.5283203125,
-0.2880859375,
0.292236328125,
0.133544921875,
0.1973876953125,
-0.399169921875,
-0.70703125,
0.10107421875,
0.2310791015625,
-0.042816162109375,
0.5400390625,
0.65869140625,
0.04852294921875,
0.7587890625,
-0.279541015625,
-0.62158203125,
-0.7197265625,
0.62060546875,
0.477294921875,
-0.369140625,
-0.20947265625,
-0.14404296875,
0.167236328125,
-1.212890625,
0.18017578125,
-0.361328125,
0.3125,
0.297119140625,
-0.278564453125,
0.25,
1,
0.282470703125,
0.4560546875,
0.301025390625,
0.0810546875,
0.04278564453125,
0.0740966796875,
0.1607666015625,
0.654296875,
-0.16259765625,
-0.3125,
0.19921875,
0.83056640625,
0.04205322265625,
0.2464599609375,
-0.368408203125,
-0.58984375,
-0.59716796875,
0.06988525390625,
-0.151123046875,
0.478515625,
0.277099609375,
-0.7783203125,
0.039031982421875,
-0.1483154296875,
-0.40087890625,
0.16455078125,
-1.26171875,
-0.74267578125,
0.42431640625,
-0.248291015625,
-0.26611328125,
-0.344970703125,
-0.414794921875,
-0.423583984375,
-0.1766357421875,
0.599609375,
-0.60302734375,
0.5859375,
-0.162109375,
0.6083984375,
-0.1842041015625,
0.318359375,
0.100341796875,
0.58349609375,
-0.6142578125,
-0.63525390625,
0.322998046875,
1.16796875,
0.140869140625,
0.333740234375,
-0.338623046875,
0.31396484375,
-0.09228515625,
0.10284423828125,
-0.359619140625,
0.3330078125,
-0.462646484375,
0.69140625,
-0.92236328125,
0.1695556640625,
0.083984375,
1.0068359375,
0.16357421875,
-0.68017578125,
-0.64208984375,
0.92431640625,
0.456787109375,
-0.24560546875,
0.381591796875,
0.52783203125,
0.5458984375,
-0.412109375,
-0.2493896484375,
-0.339111328125,
0.59326171875,
0.779296875,
0.55419921875,
-0.29541015625,
0.2275390625,
0.71630859375,
0.06982421875,
-0.09912109375,
0.6357421875,
0.293701171875,
-0.22705078125,
0.2191162109375,
-0.397705078125,
-0.043487548828125,
-0.11572265625,
-0.5087890625,
0.5498046875,
-0.041961669921875,
0.084716796875,
-0.08013916015625,
-1.0185546875,
0.77490234375,
-0.1937255859375,
-0.134521484375,
0.30712890625,
-0.25634765625,
0.2213134765625,
0.5517578125,
-0.2099609375,
-0.2200927734375,
0.716796875,
0.83740234375,
0.75341796875,
0.374267578125,
0.8486328125,
0.1400146484375,
-0.6201171875,
0.49609375,
0.0533447265625,
-0.1590576171875,
-0.52734375,
-0.337158203125,
-1.2060546875,
0.52685546875,
-0.5234375,
-0.33935546875,
0.46240234375,
-0.293212890625,
0.495849609375,
-0.841796875,
0.736328125,
-0.55615234375,
-0.0301055908203125,
0.490234375,
-0.2626953125,
-0.95703125,
0.93994140625,
-0.7353515625,
0.08905029296875,
0.66357421875,
0.98974609375,
0.352783203125,
1.0224609375,
0.3330078125,
-0.265869140625,
0.011810302734375,
0.1466064453125,
-0.26318359375,
-0.60205078125,
-0.270751953125,
-0.47802734375,
0.055877685546875,
-0.490234375,
-0.33837890625,
-0.0714111328125,
0.7666015625,
-0.11492919921875,
-0.74755859375,
-0.1341552734375,
-0.099365234375,
-0.984375,
0.370361328125,
0.56396484375,
-0.11614990234375,
0.450927734375,
0.1688232421875,
-0.20703125,
-0.64013671875,
0.044281005859375,
-0.59033203125,
0.419921875,
-0.7861328125,
-0.51220703125,
-0.86328125,
-0.452392578125,
-0.04754638671875,
-0.1920166015625,
-0.3369140625,
-1.12890625,
0.73876953125,
0.5791015625,
0.4560546875,
0.1895751953125,
-0.457275390625,
0.1954345703125,
1.1240234375,
0.82373046875,
0.1328125,
0.50244140625,
0.509765625,
0.037872314453125,
0.3408203125,
-0.44189453125,
0.6328125,
-0.31787109375,
0.0333251953125,
-0.5654296875,
-0.135498046875,
-0.407470703125,
-1.4501953125,
0.23193359375,
0.389404296875,
0.6337890625,
-0.72802734375,
-1.0107421875,
-0.440185546875,
-1.0576171875,
-0.31689453125,
-0.5400390625,
0.87841796875,
-0.147705078125,
-0.08380126953125,
-0.03729248046875,
-1.2138671875,
4.35546875,
0.82421875,
0.89306640625,
-0.0498046875,
0.240478515625,
1.0712890625,
0.57666015625,
-0.4130859375,
-0.416015625,
-0.44482421875,
0.3798828125,
-0.302978515625,
-0.07464599609375,
0.7783203125,
0.1376953125,
0.53759765625,
-0.5322265625,
0.3212890625,
-0.157470703125,
-0.8388671875,
-0.78955078125,
0.225830078125,
0.262451171875,
0.8671875,
-0.16650390625,
0.177001953125,
-0.11834716796875,
-0.56396484375,
-0.3486328125,
-0.3779296875,
-0.0022640228271484375,
-0.277587890625,
0.87451171875,
-0.085205078125,
-0.15966796875,
0.79931640625,
-0.02752685546875,
-0.6279296875,
-0.016571044921875,
0.25390625,
0.0635986328125,
-0.296142578125,
0.432373046875,
-0.42236328125,
-0.358154296875,
0.82958984375,
-0.77490234375,
0.1688232421875,
0.434326171875,
-0.81982421875,
0.78369140625,
-0.1917724609375,
0.71337890625,
-0.55908203125,
-0.4736328125,
0.11810302734375,
-0.1541748046875,
-0.420654296875,
-0.84033203125,
0.68310546875,
0.461669921875,
0.21728515625,
0.57568359375,
0.413818359375,
-1.0439453125,
0.73876953125,
-0.486328125,
0.434326171875,
-0.9580078125,
0.2052001953125,
0.34375,
-0.02044677734375,
0.04718017578125,
-0.6630859375,
0.810546875,
0.22021484375,
-0.2105712890625,
0.90771484375,
0.51708984375,
-0.58349609375,
0.477783203125,
-0.1715087890625,
-0.115478515625,
-0.42626953125,
0.7109375,
0.98876953125,
-0.60400390625,
-0.2509765625,
-0.059600830078125,
0.64794921875,
0.4697265625,
0.8173828125,
0.07666015625,
-0.57275390625,
-0.0379638671875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Tags: implementation, strings
Correct Solution:
```
a=input()
n=len(a)
lis=[]
lis.append(a)
for i in range(1,n):
newstr=a[i:n]+a[:i]
lis.append(newstr)
set_lis=set(lis)
print(len(set_lis))
```
| 70,351 | [
0.5419921875,
-0.026275634765625,
0.0107574462890625,
0.3876953125,
-0.416259765625,
-0.51708984375,
-0.1298828125,
-0.056396484375,
0.2392578125,
0.8447265625,
1.0751953125,
-0.62744140625,
0.187255859375,
-0.845703125,
-0.466064453125,
-0.7744140625,
-0.775390625,
-0.515625,
-0.724609375,
0.046875,
0.25732421875,
-0.270751953125,
-1.251953125,
-0.51171875,
-0.7353515625,
1.2021484375,
0.482666015625,
-0.1429443359375,
1.126953125,
1.314453125,
-0.66015625,
-0.60302734375,
0.5595703125,
-0.87255859375,
-0.366943359375,
-0.52294921875,
0.425537109375,
-0.472900390625,
-0.16162109375,
-0.82177734375,
0.07318115234375,
-0.7080078125,
0.53857421875,
-0.6279296875,
-1.267578125,
-0.3564453125,
-0.416748046875,
-0.6064453125,
-0.1270751953125,
-0.72998046875,
0.1297607421875,
-0.1776123046875,
0.669921875,
-0.32763671875,
0.35009765625,
0.1229248046875,
-0.469970703125,
-0.33740234375,
-0.5634765625,
0.402587890625,
0.130126953125,
-0.0042877197265625,
-0.205810546875,
-0.72705078125,
-0.446044921875,
0.254150390625,
-0.022857666015625,
-0.00197601318359375,
0.255615234375,
-0.8837890625,
-0.32763671875,
0.184326171875,
-0.09033203125,
-0.39501953125,
-0.3740234375,
-0.363525390625,
0.4267578125,
0.1151123046875,
-0.91845703125,
0.9267578125,
-0.135498046875,
0.9453125,
0.0531005859375,
0.48095703125,
-0.416748046875,
-0.544921875,
0.09808349609375,
0.36572265625,
0.173095703125,
-0.435302734375,
0.0889892578125,
0.431884765625,
-0.76123046875,
-0.0538330078125,
0.5419921875,
0.448486328125,
-0.0714111328125,
0.072998046875,
-0.10443115234375,
0.1968994140625,
0.79248046875,
1.021484375,
-0.5634765625,
1.0771484375,
-0.382080078125,
-0.452880859375,
0.1046142578125,
0.285888671875,
-0.2025146484375,
-0.392578125,
-0.43017578125,
-0.181884765625,
0.44677734375,
0.161865234375,
-0.152587890625,
0.97900390625,
0.1036376953125,
0.5478515625,
-0.5185546875,
0.16748046875,
0.458984375,
0.1207275390625,
0.204833984375,
-0.258056640625,
0.50146484375,
0.01194000244140625,
-0.78857421875,
1.04296875,
-0.72265625,
0.02783203125,
0.35107421875,
0.1002197265625,
-0.17822265625,
0.47265625,
0.040313720703125,
1.1162109375,
-0.270751953125,
0.86572265625,
0.50634765625,
-0.93017578125,
0.93505859375,
-0.181396484375,
-0.034942626953125,
1.603515625,
0.34912109375,
0.2435302734375,
0.85107421875,
0.1634521484375,
-0.6875,
0.491943359375,
-1.056640625,
0.625,
0.457763671875,
0.269775390625,
-0.54931640625,
0.102294921875,
-0.35986328125,
0.77001953125,
0.059417724609375,
0.1864013671875,
-0.443115234375,
0.08709716796875,
-0.1092529296875,
1.12890625,
-0.6484375,
0.951171875,
-0.326904296875,
-0.421630859375,
-0.252197265625,
-0.7705078125,
0.158203125,
0.1927490234375,
-0.115234375,
0.7294921875,
0.43994140625,
1.2841796875,
1.080078125,
0.0880126953125,
0.2431640625,
-0.005214691162109375,
-0.41552734375,
0.52197265625,
0.2037353515625,
0.74658203125,
0.6953125,
0.252197265625,
-0.373291015625,
-0.159912109375,
-0.281494140625,
-0.68310546875,
-0.1820068359375,
0.609375,
-0.7373046875,
-0.0256500244140625,
0.23486328125,
0.292724609375,
-1.1142578125,
-0.583984375,
0.2060546875,
-0.95263671875,
-0.1016845703125,
0.80078125,
-0.2314453125,
0.65283203125,
-0.33349609375,
-0.430419921875,
0.56787109375,
0.54638671875,
-0.603515625,
0.1593017578125,
0.218994140625,
0.004024505615234375,
-0.283203125,
-0.1171875,
0.6181640625,
-0.212158203125,
-1.0537109375,
0.619140625,
-0.1810302734375,
-0.442626953125,
0.26171875,
1.048828125,
0.49365234375,
0.341796875,
-0.4326171875,
-0.28466796875,
0.3447265625,
1.3056640625,
0.1282958984375,
0.8525390625,
0.346435546875,
0.83447265625,
0.1689453125,
0.52294921875,
0.265625,
0.04583740234375,
0.2271728515625,
0.88818359375,
0.2061767578125,
0.1231689453125,
0.11676025390625,
0.35888671875,
0.66650390625,
0.58740234375,
0.07220458984375,
0.7197265625,
-0.10992431640625,
-0.26416015625,
-0.376708984375,
0.353271484375,
-0.33056640625,
0.72021484375,
0.40576171875,
0.31884765625,
-0.283935546875,
-0.318603515625,
0.5029296875,
0.72119140625,
-0.2392578125,
-0.6005859375,
-0.1627197265625,
0.256103515625,
0.2275390625,
0.0875244140625,
0.5966796875,
0.473388671875,
0.57177734375,
0.5673828125,
-0.30712890625,
-0.55810546875,
-0.7685546875,
-0.97900390625,
-0.8662109375,
-0.2353515625,
-0.65087890625,
0.06768798828125,
-0.029754638671875,
-0.720703125,
0.7705078125,
-0.1966552734375,
-0.373291015625,
-0.02130126953125,
-0.89111328125,
0.76708984375,
-0.3369140625,
0.76171875,
-0.810546875,
0.258056640625,
-0.1993408203125,
0.912109375,
-0.4990234375,
-0.1075439453125,
-0.2252197265625,
-0.4306640625,
0.27490234375,
0.2352294921875,
0.434814453125,
-0.0706787109375,
-0.64013671875,
-0.646484375,
-0.354736328125,
0.01450347900390625,
-0.3681640625,
0.1961669921875,
-0.464599609375,
1.0322265625,
0.52294921875,
-0.489501953125,
0.90576171875,
1.1669921875,
-1.068359375,
0.3681640625,
0.1903076171875,
0.35400390625,
-0.77880859375,
1.41796875,
0.7373046875,
0.2325439453125,
-0.40234375,
-0.40576171875,
-0.83251953125,
0.142333984375,
0.086181640625,
-0.337158203125,
-0.71142578125,
0.5029296875,
0.06781005859375,
-1.2177734375,
0.6123046875,
-1.111328125,
-0.9599609375,
-0.08538818359375,
-0.189697265625,
0.80810546875,
0.93896484375,
-0.038421630859375,
-0.308837890625,
-0.2064208984375,
-0.410888671875,
0.64794921875,
0.363525390625,
-0.319580078125,
0.299560546875,
0.70458984375,
0.2447509765625,
-0.1175537109375,
0.384033203125,
-0.546875,
-0.3125,
0.19384765625,
0.255615234375,
0.4892578125,
0.25390625,
0.52099609375,
0.11968994140625,
0.79345703125,
-0.81201171875,
-0.5654296875,
-0.19091796875,
0.5771484375,
0.371826171875,
0.441650390625,
-0.0234527587890625,
-0.461181640625,
-0.525390625,
-0.56787109375,
0.5712890625,
0.17431640625,
0.77490234375,
-0.50439453125,
0.7138671875,
0.190673828125,
-0.5595703125,
0.529296875,
-0.59130859375,
-0.1502685546875,
1.037109375,
-0.537109375,
0.84765625,
-0.3720703125,
0.327392578125,
-0.04412841796875,
0.001667022705078125,
0.64208984375,
0.34765625,
0.5419921875,
-0.52294921875,
-0.32861328125,
0.0869140625,
-0.1046142578125,
-0.2059326171875,
-0.7177734375,
0.380615234375,
-0.2354736328125,
-0.159423828125,
-1.166015625,
0.492919921875,
0.8681640625,
0.457763671875,
0.00424957275390625,
0.73388671875,
0.0762939453125,
0.4169921875,
0.462890625,
-0.56103515625,
-0.049407958984375,
-0.72607421875,
0.70703125,
-0.039398193359375,
-0.52587890625,
-0.78759765625,
-0.165771484375,
-0.515625,
-0.166748046875,
0.09619140625,
0.08660888671875,
-0.771484375,
0.19287109375,
-0.12066650390625,
0.63525390625,
-0.421142578125,
-0.251953125,
-0.525390625,
0.40771484375,
0.349853515625,
-0.8310546875,
0.4951171875,
-0.943359375,
0.7158203125,
0.53857421875,
0.020355224609375,
-0.7021484375,
-0.28759765625,
-0.89697265625,
-0.5224609375,
-0.06591796875,
0.55224609375,
-0.07843017578125,
0.377685546875,
-0.8955078125,
0.54931640625,
-0.01213836669921875,
-0.4501953125,
0.347900390625,
0.280029296875,
0.479736328125,
0.03265380859375,
0.33642578125,
-0.058746337890625,
-0.85546875,
0.35107421875,
-0.89599609375,
0.84375,
-0.42626953125,
0.322509765625,
-0.16455078125,
-0.042327880859375,
0.2734375,
0.306396484375,
-0.2330322265625,
0.10687255859375,
-0.0775146484375,
0.5498046875,
-0.7373046875,
-0.73583984375,
0.52001953125,
-0.463623046875,
-0.04119873046875,
0.64892578125,
-0.314697265625,
-0.310546875,
0.303955078125,
0.147216796875,
-0.44775390625,
0.17626953125,
-0.383544921875,
0.70849609375,
-0.12371826171875,
-0.69140625,
-0.2322998046875,
-0.55029296875,
0.744140625,
-0.1737060546875,
-0.85546875,
-0.302490234375,
-1.373046875,
0.005680084228515625,
-0.307861328125,
-0.134521484375,
0.5244140625,
0.34814453125,
-0.482177734375,
-0.28271484375,
-0.206298828125,
-0.36181640625,
-0.395751953125,
-0.70556640625,
-0.164306640625,
-0.138916015625,
0.19091796875,
1.017578125,
-0.3154296875,
-0.32568359375,
-0.016937255859375,
-0.1693115234375,
0.11541748046875,
-0.50634765625,
-0.49169921875,
-0.427490234375,
-0.363525390625,
-0.2208251953125,
0.3564453125,
-0.1754150390625,
0.260986328125,
1.0693359375,
0.14599609375,
0.1116943359375,
0.0965576171875,
-0.4345703125,
1.0625,
0.162109375,
-0.99462890625,
-0.303466796875,
0.80126953125,
-0.14892578125,
0.609375,
-0.1124267578125,
-0.3779296875,
-0.317626953125,
-0.80322265625,
0.326171875,
-0.5791015625,
0.156005859375,
-0.6328125,
-0.322998046875,
-0.250732421875,
0.402587890625,
-0.1756591796875,
-0.36572265625,
-0.1070556640625,
-0.9482421875,
0.1917724609375,
-0.55029296875,
-0.319580078125,
-0.62451171875,
-0.81591796875,
-0.6083984375,
0.75390625,
0.2081298828125,
0.4501953125,
0.07049560546875,
-0.43408203125,
0.50390625,
-0.237060546875,
-0.837890625,
-0.049072265625,
0.2685546875,
0.377685546875,
-0.11700439453125,
-0.203857421875,
-0.6201171875,
0.92041015625,
-0.69775390625,
0.26953125,
-0.4833984375,
-0.49072265625,
0.076171875,
0.1099853515625,
0.8916015625,
-0.313232421875,
0.028472900390625,
-0.7177734375,
0.4765625,
0.619140625,
0.1365966796875,
-0.45654296875,
-0.716796875,
-0.274658203125,
-1.26953125,
0.57177734375,
-0.437255859375,
0.6123046875,
-0.425537109375,
-0.2239990234375,
0.5419921875,
-0.5244140625,
0.58642578125,
1.1513671875,
0.12255859375,
0.4248046875,
-0.474609375,
0.94580078125,
0.5751953125,
-0.552734375,
-0.398681640625,
0.394287109375,
-0.45458984375,
0.341064453125,
-0.0003638267517089844,
-0.880859375,
-0.23828125,
0.61083984375,
1.4365234375,
-0.07305908203125,
0.7197265625,
-0.1961669921875,
-0.87548828125,
-0.75,
0.8662109375,
0.10638427734375,
0.57080078125,
1.1611328125,
0.14599609375,
-0.254150390625,
0.422119140625,
0.06768798828125,
-0.473388671875,
-0.288330078125,
1.009765625,
-0.1005859375,
-0.7783203125,
0.5380859375,
0.74267578125,
-0.982421875,
-0.90673828125,
-0.310546875,
-0.1771240234375,
-0.358154296875,
-0.44775390625,
0.166259765625,
-0.053741455078125,
-0.5556640625,
-0.036346435546875,
0.292724609375,
-0.54052734375,
0.387451171875,
-0.1005859375,
-0.236083984375,
-0.6572265625,
0.328369140625,
0.74658203125,
-0.327880859375,
-0.245849609375,
-0.79833984375,
-0.10675048828125,
-0.47265625,
-0.007205963134765625,
0.5322265625,
-0.84716796875,
0.1322021484375,
0.146240234375,
-0.265869140625,
0.6865234375,
-0.5908203125,
-0.26220703125,
0.1004638671875,
-0.3134765625,
-0.6591796875,
-0.062042236328125,
-0.0770263671875,
-0.1705322265625,
0.3134765625,
-0.51513671875,
-0.56787109375,
0.541015625,
0.01611328125,
-0.255859375,
-0.83740234375,
0.052490234375,
-1.2353515625,
-0.83984375,
-0.469482421875,
-0.6474609375,
-0.0963134765625,
0.18505859375,
0.10919189453125,
-0.529296875,
-0.07269287109375,
0.626953125,
-0.6298828125,
0.490234375,
-0.308837890625,
0.12213134765625,
-0.5537109375,
-0.247802734375,
-0.42236328125,
-0.279052734375,
-0.4423828125,
-0.5595703125,
-0.481201171875,
0.461669921875,
-0.33203125,
0.31298828125,
0.1270751953125,
0.1968994140625,
-0.3857421875,
-0.728515625,
0.101806640625,
0.223876953125,
0.011993408203125,
0.5087890625,
0.74658203125,
0.03704833984375,
0.73095703125,
-0.261962890625,
-0.64111328125,
-0.6875,
0.56689453125,
0.451904296875,
-0.3701171875,
-0.24267578125,
-0.13671875,
0.217529296875,
-1.21484375,
0.223388671875,
-0.36328125,
0.38916015625,
0.3359375,
-0.28515625,
0.1939697265625,
1.021484375,
0.324462890625,
0.461669921875,
0.267578125,
0.1268310546875,
0.0186309814453125,
0.046844482421875,
0.13037109375,
0.6875,
-0.14990234375,
-0.332763671875,
0.232177734375,
0.79541015625,
0.048583984375,
0.2479248046875,
-0.397216796875,
-0.57958984375,
-0.6025390625,
0.08978271484375,
-0.15966796875,
0.491943359375,
0.304443359375,
-0.77001953125,
0.006809234619140625,
-0.15185546875,
-0.42138671875,
0.1824951171875,
-1.2421875,
-0.76171875,
0.404296875,
-0.24755859375,
-0.27490234375,
-0.33935546875,
-0.392822265625,
-0.41162109375,
-0.2093505859375,
0.57861328125,
-0.65185546875,
0.56689453125,
-0.19091796875,
0.5751953125,
-0.2230224609375,
0.287109375,
0.14404296875,
0.5341796875,
-0.56591796875,
-0.677734375,
0.35986328125,
1.1787109375,
0.1695556640625,
0.3203125,
-0.295166015625,
0.261474609375,
-0.08154296875,
0.09423828125,
-0.40966796875,
0.287109375,
-0.44091796875,
0.69091796875,
-0.92578125,
0.1829833984375,
0.0892333984375,
1.01953125,
0.11444091796875,
-0.669921875,
-0.6201171875,
0.87548828125,
0.447509765625,
-0.22998046875,
0.355712890625,
0.50244140625,
0.580078125,
-0.381103515625,
-0.2340087890625,
-0.42919921875,
0.56005859375,
0.79833984375,
0.54052734375,
-0.318115234375,
0.19189453125,
0.74951171875,
0.06036376953125,
-0.103759765625,
0.6376953125,
0.2486572265625,
-0.2374267578125,
0.11383056640625,
-0.413818359375,
-0.0728759765625,
-0.12347412109375,
-0.48828125,
0.493896484375,
-0.063720703125,
0.1025390625,
-0.0943603515625,
-1.07421875,
0.77685546875,
-0.2276611328125,
-0.1805419921875,
0.29931640625,
-0.27099609375,
0.280029296875,
0.5771484375,
-0.1561279296875,
-0.1849365234375,
0.6884765625,
0.81298828125,
0.71337890625,
0.351318359375,
0.84716796875,
0.18505859375,
-0.60498046875,
0.457275390625,
0.0036182403564453125,
-0.1322021484375,
-0.498779296875,
-0.29638671875,
-1.18359375,
0.5,
-0.472900390625,
-0.274658203125,
0.400390625,
-0.27099609375,
0.494140625,
-0.8623046875,
0.76953125,
-0.52001953125,
-0.053009033203125,
0.51953125,
-0.2362060546875,
-0.94482421875,
0.943359375,
-0.7119140625,
0.099609375,
0.6357421875,
0.99560546875,
0.400634765625,
1.0361328125,
0.302001953125,
-0.325927734375,
-0.032379150390625,
0.156494140625,
-0.248291015625,
-0.60498046875,
-0.290771484375,
-0.460693359375,
0.08294677734375,
-0.5107421875,
-0.287353515625,
-0.050933837890625,
0.73974609375,
-0.1292724609375,
-0.720703125,
-0.1141357421875,
-0.09527587890625,
-0.98095703125,
0.35693359375,
0.57373046875,
-0.1533203125,
0.445068359375,
0.1693115234375,
-0.207275390625,
-0.61328125,
0.01245880126953125,
-0.560546875,
0.41845703125,
-0.82421875,
-0.51953125,
-0.9013671875,
-0.380126953125,
-0.08514404296875,
-0.20703125,
-0.3642578125,
-1.111328125,
0.75634765625,
0.568359375,
0.51611328125,
0.1890869140625,
-0.46142578125,
0.2303466796875,
1.1103515625,
0.8095703125,
0.1435546875,
0.5029296875,
0.51513671875,
0.005046844482421875,
0.290283203125,
-0.43359375,
0.64208984375,
-0.326416015625,
0.031768798828125,
-0.5673828125,
-0.1651611328125,
-0.376708984375,
-1.4697265625,
0.22705078125,
0.390625,
0.6484375,
-0.734375,
-1.00390625,
-0.47314453125,
-1.1005859375,
-0.342041015625,
-0.53369140625,
0.89306640625,
-0.0963134765625,
-0.09149169921875,
-0.00563812255859375,
-1.1923828125,
4.37109375,
0.7841796875,
0.91650390625,
-0.0008039474487304688,
0.21484375,
1.0732421875,
0.56494140625,
-0.400634765625,
-0.42333984375,
-0.470703125,
0.427734375,
-0.25830078125,
-0.04888916015625,
0.8232421875,
0.1466064453125,
0.5546875,
-0.55810546875,
0.297119140625,
-0.2086181640625,
-0.81494140625,
-0.85595703125,
0.1898193359375,
0.281982421875,
0.8603515625,
-0.175048828125,
0.1351318359375,
-0.10638427734375,
-0.56591796875,
-0.363037109375,
-0.41015625,
-0.035003662109375,
-0.30078125,
0.81494140625,
-0.1427001953125,
-0.219482421875,
0.79931640625,
-0.06982421875,
-0.5966796875,
-0.017669677734375,
0.277587890625,
0.0229339599609375,
-0.287353515625,
0.388427734375,
-0.394775390625,
-0.367919921875,
0.84228515625,
-0.70849609375,
0.1605224609375,
0.41650390625,
-0.7958984375,
0.79736328125,
-0.1304931640625,
0.6796875,
-0.541015625,
-0.476806640625,
0.1337890625,
-0.1207275390625,
-0.425048828125,
-0.85107421875,
0.67333984375,
0.439453125,
0.1923828125,
0.5693359375,
0.425048828125,
-1.068359375,
0.76123046875,
-0.5263671875,
0.495849609375,
-0.9501953125,
0.1881103515625,
0.340576171875,
0.014190673828125,
0.01319122314453125,
-0.6416015625,
0.7490234375,
0.1484375,
-0.212158203125,
0.85791015625,
0.544921875,
-0.56298828125,
0.47119140625,
-0.170654296875,
-0.14453125,
-0.418212890625,
0.689453125,
0.93017578125,
-0.5830078125,
-0.31982421875,
-0.035980224609375,
0.64990234375,
0.427734375,
0.8076171875,
0.10809326171875,
-0.5673828125,
-0.0240020751953125
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Submitted Solution:
```
str=input();
l=len(str);
m={};
for i in range(1,l+1):
ch=str[l-1:l];
st=str[0:l-1];
ch+=st;
if (not(ch in m)):
m[ch]=1;
#print(ch)
str=ch;
print(len(m));
```
Yes
| 70,352 | [
0.60986328125,
0.046142578125,
-0.08258056640625,
0.369384765625,
-0.467529296875,
-0.43603515625,
-0.14990234375,
0.03521728515625,
0.05657958984375,
0.865234375,
1.021484375,
-0.63427734375,
0.1717529296875,
-0.92529296875,
-0.4228515625,
-0.732421875,
-0.6796875,
-0.5947265625,
-0.69384765625,
-0.033538818359375,
0.2138671875,
-0.38330078125,
-1.205078125,
-0.5400390625,
-0.6787109375,
1.111328125,
0.421142578125,
-0.1395263671875,
1.0576171875,
1.302734375,
-0.6162109375,
-0.53369140625,
0.55712890625,
-0.71826171875,
-0.296142578125,
-0.61474609375,
0.529296875,
-0.49853515625,
-0.1778564453125,
-0.794921875,
-0.04254150390625,
-0.6708984375,
0.5703125,
-0.587890625,
-1.2373046875,
-0.3759765625,
-0.432373046875,
-0.56494140625,
-0.13623046875,
-0.68896484375,
0.281982421875,
-0.255615234375,
0.65673828125,
-0.390625,
0.4462890625,
0.2724609375,
-0.376953125,
-0.332275390625,
-0.64013671875,
0.320068359375,
0.10821533203125,
0.11651611328125,
-0.2222900390625,
-0.78759765625,
-0.488037109375,
0.256103515625,
0.0233917236328125,
0.0100555419921875,
0.279052734375,
-0.724609375,
-0.438232421875,
0.0131378173828125,
-0.18408203125,
-0.287109375,
-0.4013671875,
-0.337890625,
0.444580078125,
0.06787109375,
-1.091796875,
0.896484375,
-0.202392578125,
0.98974609375,
0.214111328125,
0.461181640625,
-0.375244140625,
-0.48974609375,
0.275146484375,
0.27294921875,
0.1783447265625,
-0.447509765625,
0.2093505859375,
0.3486328125,
-0.7568359375,
-0.057769775390625,
0.5966796875,
0.36328125,
-0.09124755859375,
0.1318359375,
-0.10089111328125,
0.083984375,
0.931640625,
0.890625,
-0.556640625,
1.181640625,
-0.331298828125,
-0.4775390625,
0.0867919921875,
0.21044921875,
-0.2249755859375,
-0.36669921875,
-0.36669921875,
-0.1934814453125,
0.44921875,
0.1673583984375,
-0.27685546875,
0.88623046875,
0.0750732421875,
0.58984375,
-0.492431640625,
0.060150146484375,
0.42529296875,
0.06866455078125,
0.319580078125,
-0.1168212890625,
0.6005859375,
-0.06500244140625,
-0.82763671875,
1.0166015625,
-0.71875,
0.00762939453125,
0.31201171875,
0.0517578125,
-0.2998046875,
0.36181640625,
0.01812744140625,
1.0859375,
-0.2427978515625,
0.779296875,
0.45849609375,
-0.810546875,
0.95703125,
-0.033203125,
0.048126220703125,
1.55078125,
0.267822265625,
0.0845947265625,
0.693359375,
0.231201171875,
-0.591796875,
0.440673828125,
-1.0498046875,
0.5947265625,
0.304443359375,
0.18896484375,
-0.611328125,
0.12060546875,
-0.407958984375,
0.68701171875,
0.07012939453125,
0.0897216796875,
-0.48828125,
0.0236358642578125,
-0.1614990234375,
1.1201171875,
-0.6904296875,
0.900390625,
-0.283447265625,
-0.330322265625,
-0.2435302734375,
-0.6796875,
0.07421875,
0.1270751953125,
-0.061737060546875,
0.7666015625,
0.466064453125,
1.384765625,
1.0712890625,
0.141845703125,
0.2308349609375,
0.053070068359375,
-0.4248046875,
0.404541015625,
0.176025390625,
0.7802734375,
0.68701171875,
0.322265625,
-0.348388671875,
-0.08428955078125,
-0.2464599609375,
-0.69482421875,
-0.171630859375,
0.658203125,
-0.75341796875,
-0.013092041015625,
0.11328125,
0.278076171875,
-1.1728515625,
-0.6474609375,
0.25,
-0.98388671875,
-0.197265625,
0.80859375,
-0.12744140625,
0.74658203125,
-0.36376953125,
-0.43603515625,
0.54296875,
0.54736328125,
-0.52880859375,
0.1927490234375,
0.160400390625,
0.08489990234375,
-0.2205810546875,
-0.206787109375,
0.60546875,
-0.1546630859375,
-1.0205078125,
0.4755859375,
-0.1417236328125,
-0.4658203125,
0.2198486328125,
0.96533203125,
0.3310546875,
0.364013671875,
-0.50634765625,
-0.289306640625,
0.30810546875,
1.3740234375,
0.09625244140625,
0.88232421875,
0.361572265625,
0.8935546875,
0.248046875,
0.74658203125,
0.253662109375,
0.0256500244140625,
0.43798828125,
0.92333984375,
0.06256103515625,
0.120849609375,
0.01165008544921875,
0.369384765625,
0.716796875,
0.6240234375,
0.08868408203125,
0.7529296875,
-0.1585693359375,
-0.243896484375,
-0.441650390625,
0.398681640625,
-0.3232421875,
0.70703125,
0.280029296875,
0.434814453125,
-0.257568359375,
-0.308349609375,
0.5458984375,
0.68408203125,
-0.385498046875,
-0.6328125,
-0.07879638671875,
0.1783447265625,
0.244873046875,
0.113525390625,
0.53125,
0.309814453125,
0.52197265625,
0.485595703125,
-0.2440185546875,
-0.472900390625,
-0.69384765625,
-1.0703125,
-0.98095703125,
-0.2352294921875,
-0.7294921875,
-0.041107177734375,
-0.057586669921875,
-0.6513671875,
0.73193359375,
-0.260498046875,
-0.357421875,
-0.0867919921875,
-0.8095703125,
0.86865234375,
-0.3388671875,
0.67431640625,
-0.818359375,
0.1837158203125,
-0.1763916015625,
0.8779296875,
-0.5869140625,
-0.043975830078125,
-0.2744140625,
-0.365966796875,
0.3134765625,
0.1492919921875,
0.5048828125,
-0.07135009765625,
-0.580078125,
-0.62109375,
-0.32421875,
0.034332275390625,
-0.37060546875,
-0.0019330978393554688,
-0.42431640625,
1.0087890625,
0.481201171875,
-0.60107421875,
0.89892578125,
1.1220703125,
-1.033203125,
0.40869140625,
0.193359375,
0.44970703125,
-0.7314453125,
1.3232421875,
0.75537109375,
0.32666015625,
-0.314697265625,
-0.433349609375,
-0.76806640625,
0.2181396484375,
0.04656982421875,
-0.343994140625,
-0.7197265625,
0.486328125,
0.1527099609375,
-1.2001953125,
0.58935546875,
-1.185546875,
-0.95947265625,
-0.159423828125,
-0.345947265625,
0.8408203125,
0.8505859375,
-0.004627227783203125,
-0.1859130859375,
-0.332763671875,
-0.437744140625,
0.587890625,
0.412109375,
-0.430908203125,
0.320556640625,
0.6982421875,
0.3271484375,
0.06549072265625,
0.329345703125,
-0.60693359375,
-0.388671875,
0.1461181640625,
0.2177734375,
0.53955078125,
0.247802734375,
0.62060546875,
0.1268310546875,
0.83251953125,
-0.8544921875,
-0.57080078125,
-0.2371826171875,
0.6484375,
0.314208984375,
0.37353515625,
0.03533935546875,
-0.39794921875,
-0.5419921875,
-0.49853515625,
0.494384765625,
0.134521484375,
0.71337890625,
-0.430908203125,
0.79248046875,
0.123291015625,
-0.65869140625,
0.57275390625,
-0.55029296875,
-0.13330078125,
0.99609375,
-0.457275390625,
0.77490234375,
-0.48974609375,
0.29736328125,
-0.062744140625,
-0.0305633544921875,
0.6708984375,
0.391845703125,
0.62353515625,
-0.544921875,
-0.244873046875,
0.06976318359375,
-0.020294189453125,
-0.2333984375,
-0.68505859375,
0.25341796875,
-0.278076171875,
-0.360595703125,
-1.2177734375,
0.57421875,
0.79736328125,
0.498291015625,
0.048553466796875,
0.61572265625,
0.0350341796875,
0.281982421875,
0.48828125,
-0.52099609375,
-0.039215087890625,
-0.75830078125,
0.73095703125,
-0.02178955078125,
-0.5283203125,
-0.80029296875,
-0.168212890625,
-0.5224609375,
-0.061431884765625,
0.20361328125,
0.1083984375,
-0.80419921875,
0.28759765625,
-0.05767822265625,
0.6396484375,
-0.53173828125,
-0.2261962890625,
-0.537109375,
0.33349609375,
0.429443359375,
-0.86767578125,
0.53564453125,
-0.94384765625,
0.658203125,
0.564453125,
0.09027099609375,
-0.734375,
-0.1485595703125,
-0.98779296875,
-0.6455078125,
-0.1058349609375,
0.58935546875,
-0.0823974609375,
0.34423828125,
-0.96923828125,
0.4560546875,
0.06256103515625,
-0.58349609375,
0.27197265625,
0.25048828125,
0.42138671875,
-0.0172271728515625,
0.377197265625,
-0.1614990234375,
-0.7890625,
0.358642578125,
-0.8369140625,
0.80224609375,
-0.36865234375,
0.341552734375,
-0.11883544921875,
-0.0234832763671875,
0.283447265625,
0.34912109375,
-0.299072265625,
0.185302734375,
-0.1500244140625,
0.49755859375,
-0.95068359375,
-0.77978515625,
0.5107421875,
-0.40185546875,
0.0034427642822265625,
0.669921875,
-0.33154296875,
-0.3876953125,
0.31689453125,
0.046295166015625,
-0.474609375,
0.23486328125,
-0.3349609375,
0.7158203125,
-0.0889892578125,
-0.59814453125,
-0.150146484375,
-0.59326171875,
0.7666015625,
-0.2236328125,
-0.791015625,
-0.35986328125,
-1.37890625,
-0.004619598388671875,
-0.38720703125,
-0.159423828125,
0.477294921875,
0.397216796875,
-0.416259765625,
-0.250244140625,
-0.1607666015625,
-0.410400390625,
-0.363525390625,
-0.65185546875,
-0.1866455078125,
-0.2191162109375,
0.2398681640625,
0.89697265625,
-0.242431640625,
-0.333251953125,
-0.06689453125,
-0.240478515625,
0.1680908203125,
-0.48974609375,
-0.52685546875,
-0.3662109375,
-0.38330078125,
-0.327392578125,
0.568359375,
-0.219970703125,
0.21826171875,
1.044921875,
0.1636962890625,
0.2210693359375,
0.13330078125,
-0.54443359375,
1.13671875,
0.1607666015625,
-1.185546875,
-0.1937255859375,
0.75390625,
-0.0792236328125,
0.681640625,
-0.203369140625,
-0.27978515625,
-0.4013671875,
-0.78759765625,
0.400634765625,
-0.6572265625,
0.07025146484375,
-0.64794921875,
-0.354248046875,
-0.150634765625,
0.383544921875,
-0.1761474609375,
-0.365966796875,
-0.048309326171875,
-1.1123046875,
0.264404296875,
-0.60107421875,
-0.360595703125,
-0.57861328125,
-0.62646484375,
-0.62255859375,
0.826171875,
0.265625,
0.447265625,
0.0268096923828125,
-0.2587890625,
0.4423828125,
-0.1351318359375,
-0.80908203125,
-0.0361328125,
0.250732421875,
0.347412109375,
-0.2440185546875,
-0.1768798828125,
-0.6337890625,
0.9951171875,
-0.5966796875,
0.29931640625,
-0.42529296875,
-0.484375,
0.1787109375,
0.01326751708984375,
0.9013671875,
-0.294921875,
-0.007091522216796875,
-0.77001953125,
0.461181640625,
0.7236328125,
0.145751953125,
-0.38623046875,
-0.68115234375,
-0.315673828125,
-1.41015625,
0.60595703125,
-0.365478515625,
0.66357421875,
-0.3779296875,
-0.2125244140625,
0.56787109375,
-0.60302734375,
0.52294921875,
1.2509765625,
0.1937255859375,
0.477294921875,
-0.49755859375,
0.9658203125,
0.6025390625,
-0.61474609375,
-0.47509765625,
0.29931640625,
-0.525390625,
0.234375,
-0.04046630859375,
-0.97509765625,
-0.27783203125,
0.5751953125,
1.2841796875,
-0.06024169921875,
0.8369140625,
-0.27392578125,
-0.9892578125,
-0.66259765625,
0.73388671875,
0.03399658203125,
0.4970703125,
1.1455078125,
0.1993408203125,
-0.29736328125,
0.451904296875,
0.029266357421875,
-0.44091796875,
-0.2646484375,
1.1357421875,
-0.1346435546875,
-0.80224609375,
0.61962890625,
0.7783203125,
-1.08203125,
-0.880859375,
-0.32861328125,
-0.16455078125,
-0.34423828125,
-0.50439453125,
0.2467041015625,
-0.11248779296875,
-0.424072265625,
0.08447265625,
0.318359375,
-0.56494140625,
0.453857421875,
-0.1611328125,
-0.198486328125,
-0.841796875,
0.2252197265625,
0.76806640625,
-0.348876953125,
-0.309326171875,
-0.81298828125,
-0.007965087890625,
-0.336669921875,
-0.0103759765625,
0.460205078125,
-0.763671875,
0.13134765625,
0.2666015625,
-0.256103515625,
0.76123046875,
-0.6162109375,
-0.201171875,
0.01910400390625,
-0.36376953125,
-0.65576171875,
-0.1837158203125,
-0.0675048828125,
-0.11163330078125,
0.361572265625,
-0.50732421875,
-0.58935546875,
0.468505859375,
-0.01497650146484375,
-0.30126953125,
-0.72509765625,
-0.047698974609375,
-1.2138671875,
-0.90576171875,
-0.4375,
-0.6171875,
-0.01180267333984375,
0.276611328125,
0.2034912109375,
-0.54052734375,
-0.033843994140625,
0.65283203125,
-0.5576171875,
0.467041015625,
-0.367431640625,
0.17724609375,
-0.63623046875,
-0.271728515625,
-0.499755859375,
-0.258544921875,
-0.43359375,
-0.465087890625,
-0.375732421875,
0.51611328125,
-0.372802734375,
0.27001953125,
-0.019622802734375,
0.22412109375,
-0.29150390625,
-0.5888671875,
0.220947265625,
0.2783203125,
-0.1727294921875,
0.640625,
0.61279296875,
0.18408203125,
0.64892578125,
-0.29638671875,
-0.50927734375,
-0.59423828125,
0.69189453125,
0.4052734375,
-0.322265625,
-0.32177734375,
0.03143310546875,
0.07879638671875,
-1.2275390625,
0.2325439453125,
-0.28857421875,
0.321533203125,
0.351318359375,
-0.33837890625,
0.2021484375,
1.001953125,
0.1439208984375,
0.493896484375,
0.259521484375,
0.1884765625,
0.08502197265625,
0.110107421875,
0.1502685546875,
0.76708984375,
-0.199951171875,
-0.311767578125,
0.2822265625,
0.8095703125,
0.12457275390625,
0.28125,
-0.49462890625,
-0.62890625,
-0.75927734375,
0.10357666015625,
-0.251953125,
0.521484375,
0.24072265625,
-0.90478515625,
0.14306640625,
-0.14453125,
-0.424072265625,
0.1680908203125,
-1.341796875,
-0.85009765625,
0.48876953125,
-0.2061767578125,
-0.294921875,
-0.2391357421875,
-0.4365234375,
-0.3193359375,
-0.2034912109375,
0.51220703125,
-0.568359375,
0.3955078125,
-0.1033935546875,
0.58251953125,
-0.18115234375,
0.33740234375,
0.00661468505859375,
0.6318359375,
-0.6484375,
-0.6689453125,
0.246337890625,
1.1376953125,
0.08636474609375,
0.2490234375,
-0.33203125,
0.33642578125,
-0.1610107421875,
-0.00975799560546875,
-0.3173828125,
0.290771484375,
-0.4462890625,
0.7421875,
-0.86767578125,
0.14697265625,
0.087646484375,
0.9736328125,
0.037872314453125,
-0.70458984375,
-0.65673828125,
0.9169921875,
0.57421875,
-0.1859130859375,
0.428466796875,
0.52685546875,
0.64208984375,
-0.432861328125,
-0.2056884765625,
-0.327880859375,
0.5888671875,
0.8251953125,
0.61474609375,
-0.263427734375,
0.26318359375,
0.71875,
0.1893310546875,
-0.0010967254638671875,
0.6044921875,
0.265625,
-0.2080078125,
0.21728515625,
-0.409423828125,
-0.0994873046875,
-0.1683349609375,
-0.43212890625,
0.5380859375,
-0.07025146484375,
0.09136962890625,
-0.154296875,
-1.033203125,
0.8076171875,
-0.16650390625,
-0.08343505859375,
0.249267578125,
-0.264404296875,
0.29296875,
0.5888671875,
-0.188232421875,
-0.1646728515625,
0.71484375,
0.96240234375,
0.8427734375,
0.38330078125,
0.7958984375,
0.1546630859375,
-0.74365234375,
0.42333984375,
0.132568359375,
-0.1390380859375,
-0.471435546875,
-0.397216796875,
-1.2548828125,
0.6337890625,
-0.42822265625,
-0.21923828125,
0.2724609375,
-0.38818359375,
0.52197265625,
-0.841796875,
0.84814453125,
-0.6767578125,
-0.07586669921875,
0.53759765625,
-0.188232421875,
-0.94677734375,
0.98095703125,
-0.61474609375,
0.05059814453125,
0.6328125,
1.0146484375,
0.386962890625,
1.0576171875,
0.419921875,
-0.31298828125,
0.0249481201171875,
0.25390625,
-0.1981201171875,
-0.483154296875,
-0.263916015625,
-0.489501953125,
0.0007615089416503906,
-0.56103515625,
-0.347412109375,
-0.111572265625,
0.72705078125,
-0.04681396484375,
-0.74658203125,
-0.326171875,
-0.1212158203125,
-0.9013671875,
0.430908203125,
0.54052734375,
0.03955078125,
0.48583984375,
0.2359619140625,
-0.282958984375,
-0.55517578125,
0.10052490234375,
-0.39892578125,
0.406494140625,
-0.77880859375,
-0.42333984375,
-0.86767578125,
-0.385986328125,
0.0009622573852539062,
-0.16943359375,
-0.39501953125,
-1.109375,
0.7763671875,
0.59521484375,
0.48388671875,
0.06396484375,
-0.525390625,
0.149169921875,
1.1767578125,
0.74072265625,
0.09478759765625,
0.4609375,
0.497314453125,
0.02923583984375,
0.289306640625,
-0.447509765625,
0.630859375,
-0.285400390625,
-0.0343017578125,
-0.6455078125,
-0.20263671875,
-0.469970703125,
-1.3740234375,
0.125732421875,
0.359375,
0.495361328125,
-0.76318359375,
-1.14453125,
-0.61865234375,
-1.0263671875,
-0.267822265625,
-0.56982421875,
0.9814453125,
-0.11181640625,
-0.1866455078125,
-0.03216552734375,
-1.12109375,
4.33984375,
0.8427734375,
0.72021484375,
-0.1771240234375,
0.287841796875,
1.0478515625,
0.449951171875,
-0.53125,
-0.332275390625,
-0.57421875,
0.39208984375,
-0.333740234375,
-0.041717529296875,
0.7900390625,
0.17822265625,
0.5419921875,
-0.5927734375,
0.1431884765625,
-0.050018310546875,
-0.8984375,
-0.8173828125,
0.283447265625,
0.3134765625,
0.77197265625,
-0.112060546875,
0.241943359375,
0.09149169921875,
-0.625,
-0.5009765625,
-0.373291015625,
0.032684326171875,
-0.246826171875,
0.87548828125,
-0.0300445556640625,
-0.1744384765625,
0.837890625,
0.04962158203125,
-0.65478515625,
-0.056976318359375,
0.291259765625,
-0.0157012939453125,
-0.20751953125,
0.427734375,
-0.3291015625,
-0.39501953125,
0.9501953125,
-0.75830078125,
0.3037109375,
0.505859375,
-0.8515625,
0.80908203125,
-0.053741455078125,
0.7421875,
-0.4521484375,
-0.416259765625,
0.15576171875,
-0.118896484375,
-0.34765625,
-0.771484375,
0.70361328125,
0.371826171875,
0.2861328125,
0.4921875,
0.587890625,
-1.109375,
0.6259765625,
-0.366943359375,
0.434814453125,
-0.92138671875,
0.2459716796875,
0.278564453125,
-0.0672607421875,
0.04156494140625,
-0.7041015625,
0.8408203125,
0.306396484375,
-0.260009765625,
0.81982421875,
0.62939453125,
-0.53125,
0.51318359375,
-0.2215576171875,
-0.0648193359375,
-0.4111328125,
0.62060546875,
0.8935546875,
-0.599609375,
-0.32177734375,
-0.152099609375,
0.71435546875,
0.50048828125,
0.896484375,
0.1519775390625,
-0.64697265625,
-0.1785888671875
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Submitted Solution:
```
def rotate(l, n):
return ' '.join(l[n:] + l[:n])
word = list(input())
set_of_words = set()
for i in range(len(word)):
set_of_words.add(rotate(word, i))
print(len(set_of_words))
```
Yes
| 70,353 | [
0.62451171875,
0.00940704345703125,
-0.08551025390625,
0.36376953125,
-0.44677734375,
-0.45849609375,
-0.1798095703125,
0.028900146484375,
0.03765869140625,
0.8447265625,
1.044921875,
-0.63134765625,
0.226318359375,
-0.904296875,
-0.41650390625,
-0.7412109375,
-0.76171875,
-0.591796875,
-0.69873046875,
-0.007080078125,
0.2359619140625,
-0.343017578125,
-1.23828125,
-0.560546875,
-0.69091796875,
1.1025390625,
0.4033203125,
-0.177978515625,
1.1025390625,
1.30078125,
-0.59521484375,
-0.484130859375,
0.54931640625,
-0.736328125,
-0.257080078125,
-0.60498046875,
0.51025390625,
-0.4755859375,
-0.1939697265625,
-0.8203125,
-0.00003629922866821289,
-0.7099609375,
0.564453125,
-0.53076171875,
-1.19921875,
-0.344482421875,
-0.445068359375,
-0.603515625,
-0.166748046875,
-0.71923828125,
0.309814453125,
-0.240234375,
0.72412109375,
-0.3896484375,
0.422607421875,
0.2335205078125,
-0.440673828125,
-0.2705078125,
-0.59912109375,
0.34814453125,
0.1251220703125,
0.1329345703125,
-0.2529296875,
-0.7421875,
-0.544921875,
0.254150390625,
0.00983428955078125,
0.04290771484375,
0.2861328125,
-0.72314453125,
-0.43310546875,
0.0379638671875,
-0.073974609375,
-0.300537109375,
-0.3896484375,
-0.274658203125,
0.478515625,
0.040496826171875,
-1.083984375,
0.89990234375,
-0.2109375,
0.97998046875,
0.197265625,
0.4306640625,
-0.41064453125,
-0.449462890625,
0.277099609375,
0.2578125,
0.1925048828125,
-0.455078125,
0.16259765625,
0.343505859375,
-0.80419921875,
-0.10076904296875,
0.56494140625,
0.3466796875,
-0.094970703125,
0.151123046875,
-0.1304931640625,
0.142333984375,
0.93310546875,
0.919921875,
-0.54541015625,
1.21484375,
-0.29443359375,
-0.53759765625,
0.1053466796875,
0.21142578125,
-0.192626953125,
-0.347900390625,
-0.382568359375,
-0.154541015625,
0.423828125,
0.18408203125,
-0.2344970703125,
0.865234375,
0.066650390625,
0.58837890625,
-0.517578125,
0.0231170654296875,
0.378173828125,
0.06573486328125,
0.2457275390625,
-0.10772705078125,
0.6328125,
-0.06298828125,
-0.89794921875,
0.98193359375,
-0.71826171875,
-0.0050811767578125,
0.306884765625,
0.08355712890625,
-0.267822265625,
0.362060546875,
0.01800537109375,
1.060546875,
-0.28466796875,
0.7890625,
0.43408203125,
-0.81494140625,
0.98095703125,
-0.04705810546875,
-0.009521484375,
1.5537109375,
0.33154296875,
0.10223388671875,
0.697265625,
0.232666015625,
-0.5888671875,
0.51416015625,
-1.0205078125,
0.5908203125,
0.349365234375,
0.224853515625,
-0.59814453125,
0.07293701171875,
-0.408447265625,
0.71630859375,
0.11871337890625,
0.07293701171875,
-0.479736328125,
-0.03912353515625,
-0.12152099609375,
1.1640625,
-0.68994140625,
0.9130859375,
-0.328857421875,
-0.343017578125,
-0.271240234375,
-0.685546875,
0.07293701171875,
0.11517333984375,
-0.036773681640625,
0.7421875,
0.44189453125,
1.34375,
1.0654296875,
0.09771728515625,
0.2073974609375,
0.06732177734375,
-0.420166015625,
0.357177734375,
0.2132568359375,
0.794921875,
0.66064453125,
0.282470703125,
-0.32861328125,
-0.09393310546875,
-0.2049560546875,
-0.78564453125,
-0.20947265625,
0.6630859375,
-0.796875,
-0.084716796875,
0.046875,
0.2607421875,
-1.177734375,
-0.68896484375,
0.313720703125,
-0.96337890625,
-0.19482421875,
0.84521484375,
-0.1490478515625,
0.7109375,
-0.369384765625,
-0.465576171875,
0.472900390625,
0.51416015625,
-0.5166015625,
0.22412109375,
0.214599609375,
0.1968994140625,
-0.2169189453125,
-0.194091796875,
0.61376953125,
-0.12115478515625,
-1.0107421875,
0.46484375,
-0.1810302734375,
-0.455078125,
0.2392578125,
0.96337890625,
0.374267578125,
0.386474609375,
-0.46044921875,
-0.259521484375,
0.294189453125,
1.451171875,
0.1434326171875,
0.96533203125,
0.33056640625,
0.91650390625,
0.227294921875,
0.72216796875,
0.2330322265625,
0.06341552734375,
0.413818359375,
0.9140625,
0.09722900390625,
0.06939697265625,
0.069580078125,
0.36474609375,
0.77197265625,
0.66357421875,
0.0540771484375,
0.8173828125,
-0.178466796875,
-0.2130126953125,
-0.45166015625,
0.3955078125,
-0.3671875,
0.70068359375,
0.285888671875,
0.426025390625,
-0.26708984375,
-0.293212890625,
0.5947265625,
0.68408203125,
-0.28564453125,
-0.654296875,
-0.07135009765625,
0.183837890625,
0.220703125,
0.151123046875,
0.5693359375,
0.352294921875,
0.4541015625,
0.50830078125,
-0.272705078125,
-0.470458984375,
-0.69287109375,
-1.0927734375,
-1.0107421875,
-0.2705078125,
-0.720703125,
-0.044281005859375,
-0.12548828125,
-0.62060546875,
0.72265625,
-0.28564453125,
-0.370849609375,
-0.12152099609375,
-0.73388671875,
0.87255859375,
-0.388671875,
0.76904296875,
-0.8291015625,
0.1824951171875,
-0.19384765625,
0.9013671875,
-0.5673828125,
-0.040557861328125,
-0.295166015625,
-0.442626953125,
0.3671875,
0.21923828125,
0.51416015625,
-0.07843017578125,
-0.63232421875,
-0.599609375,
-0.3251953125,
0.05072021484375,
-0.388671875,
0.019744873046875,
-0.43603515625,
1.0458984375,
0.465576171875,
-0.54833984375,
0.89111328125,
1.123046875,
-1.072265625,
0.397216796875,
0.2509765625,
0.457763671875,
-0.74853515625,
1.3134765625,
0.7275390625,
0.352783203125,
-0.322509765625,
-0.369384765625,
-0.8046875,
0.229248046875,
0.047698974609375,
-0.328857421875,
-0.65966796875,
0.4326171875,
0.162353515625,
-1.2548828125,
0.5478515625,
-1.1826171875,
-0.984375,
-0.1788330078125,
-0.36669921875,
0.84033203125,
0.87841796875,
0.0200042724609375,
-0.1796875,
-0.317626953125,
-0.422607421875,
0.69091796875,
0.38525390625,
-0.366455078125,
0.349609375,
0.68408203125,
0.310791015625,
0.08447265625,
0.3994140625,
-0.60986328125,
-0.39013671875,
0.1844482421875,
0.22314453125,
0.529296875,
0.262451171875,
0.61669921875,
0.08660888671875,
0.79638671875,
-0.8388671875,
-0.544921875,
-0.198974609375,
0.59814453125,
0.34423828125,
0.408447265625,
0.0601806640625,
-0.436767578125,
-0.56640625,
-0.48583984375,
0.50146484375,
0.1417236328125,
0.70703125,
-0.42333984375,
0.7783203125,
0.168212890625,
-0.66845703125,
0.51318359375,
-0.54052734375,
-0.17626953125,
0.990234375,
-0.4765625,
0.751953125,
-0.5234375,
0.241455078125,
-0.0858154296875,
-0.0245513916015625,
0.5693359375,
0.37158203125,
0.64501953125,
-0.5791015625,
-0.1756591796875,
0.030792236328125,
-0.055633544921875,
-0.2191162109375,
-0.6923828125,
0.326904296875,
-0.253173828125,
-0.355712890625,
-1.1953125,
0.56298828125,
0.81982421875,
0.498291015625,
-0.05078125,
0.6259765625,
0.055267333984375,
0.2032470703125,
0.50537109375,
-0.529296875,
-0.07159423828125,
-0.79052734375,
0.71875,
-0.0015649795532226562,
-0.505859375,
-0.78662109375,
-0.180419921875,
-0.603515625,
-0.030059814453125,
0.190673828125,
0.1729736328125,
-0.78466796875,
0.29833984375,
-0.025482177734375,
0.6259765625,
-0.5361328125,
-0.201171875,
-0.53076171875,
0.309814453125,
0.444091796875,
-0.837890625,
0.556640625,
-0.97607421875,
0.66015625,
0.5498046875,
0.059814453125,
-0.7646484375,
-0.160400390625,
-0.93017578125,
-0.62060546875,
-0.1422119140625,
0.55322265625,
-0.07867431640625,
0.33447265625,
-0.95068359375,
0.47705078125,
0.0654296875,
-0.5703125,
0.255615234375,
0.29345703125,
0.411865234375,
0.01335906982421875,
0.359375,
-0.11285400390625,
-0.7431640625,
0.33251953125,
-0.83642578125,
0.85107421875,
-0.371826171875,
0.39501953125,
-0.1517333984375,
-0.0214080810546875,
0.334228515625,
0.3837890625,
-0.31298828125,
0.1640625,
-0.1409912109375,
0.52734375,
-0.98388671875,
-0.751953125,
0.50537109375,
-0.38427734375,
-0.0016775131225585938,
0.69921875,
-0.302001953125,
-0.36376953125,
0.27099609375,
0.0667724609375,
-0.451416015625,
0.1944580078125,
-0.3896484375,
0.69775390625,
-0.0760498046875,
-0.64990234375,
-0.15576171875,
-0.5537109375,
0.7802734375,
-0.21044921875,
-0.7607421875,
-0.35693359375,
-1.390625,
0.0200653076171875,
-0.392578125,
-0.204345703125,
0.452392578125,
0.4033203125,
-0.4482421875,
-0.30810546875,
-0.21142578125,
-0.43212890625,
-0.364990234375,
-0.669921875,
-0.13720703125,
-0.2110595703125,
0.1876220703125,
0.890625,
-0.283447265625,
-0.365234375,
-0.0810546875,
-0.295166015625,
0.1373291015625,
-0.50732421875,
-0.60986328125,
-0.345703125,
-0.409912109375,
-0.306396484375,
0.5830078125,
-0.256103515625,
0.20166015625,
1.0556640625,
0.1494140625,
0.17822265625,
0.1014404296875,
-0.52490234375,
1.095703125,
0.12744140625,
-1.158203125,
-0.1983642578125,
0.76708984375,
-0.093994140625,
0.6650390625,
-0.2176513671875,
-0.261474609375,
-0.394287109375,
-0.7822265625,
0.40234375,
-0.6943359375,
0.061248779296875,
-0.5966796875,
-0.337158203125,
-0.17431640625,
0.360595703125,
-0.18408203125,
-0.371337890625,
-0.003917694091796875,
-1.140625,
0.2301025390625,
-0.57666015625,
-0.39208984375,
-0.57177734375,
-0.7314453125,
-0.67822265625,
0.828125,
0.29345703125,
0.4658203125,
0.0290374755859375,
-0.29736328125,
0.449951171875,
-0.10284423828125,
-0.7958984375,
-0.0276031494140625,
0.28466796875,
0.334228515625,
-0.2218017578125,
-0.1602783203125,
-0.60595703125,
0.98291015625,
-0.64306640625,
0.353271484375,
-0.452880859375,
-0.54345703125,
0.1636962890625,
0.052947998046875,
0.90478515625,
-0.27294921875,
-0.00905609130859375,
-0.79443359375,
0.452880859375,
0.7392578125,
0.1339111328125,
-0.404296875,
-0.71435546875,
-0.242919921875,
-1.4404296875,
0.61865234375,
-0.385986328125,
0.72607421875,
-0.410400390625,
-0.256103515625,
0.57177734375,
-0.57958984375,
0.50732421875,
1.1982421875,
0.2012939453125,
0.485107421875,
-0.505859375,
0.97900390625,
0.626953125,
-0.64794921875,
-0.55859375,
0.261474609375,
-0.54736328125,
0.319580078125,
-0.01904296875,
-0.947265625,
-0.30029296875,
0.607421875,
1.275390625,
-0.109375,
0.845703125,
-0.306396484375,
-0.92822265625,
-0.67529296875,
0.74951171875,
0.060272216796875,
0.440673828125,
1.107421875,
0.15576171875,
-0.31640625,
0.4228515625,
0.09765625,
-0.447021484375,
-0.2060546875,
1.12109375,
-0.0867919921875,
-0.8427734375,
0.697265625,
0.7900390625,
-1.1005859375,
-0.92236328125,
-0.30859375,
-0.118896484375,
-0.312744140625,
-0.5400390625,
0.305419921875,
-0.051513671875,
-0.431640625,
0.039031982421875,
0.272216796875,
-0.6640625,
0.4443359375,
-0.087890625,
-0.18994140625,
-0.84228515625,
0.214111328125,
0.71533203125,
-0.33740234375,
-0.388916015625,
-0.83203125,
0.0635986328125,
-0.335693359375,
-0.0228271484375,
0.494384765625,
-0.79345703125,
0.1474609375,
0.2305908203125,
-0.20751953125,
0.8115234375,
-0.62255859375,
-0.201171875,
-0.00742340087890625,
-0.371826171875,
-0.63671875,
-0.185546875,
-0.09783935546875,
-0.08746337890625,
0.2802734375,
-0.55615234375,
-0.63671875,
0.473876953125,
0.027557373046875,
-0.371337890625,
-0.74658203125,
-0.0096282958984375,
-1.2080078125,
-0.92431640625,
-0.402099609375,
-0.59619140625,
0.0445556640625,
0.307373046875,
0.2464599609375,
-0.488037109375,
0.0235137939453125,
0.64453125,
-0.52294921875,
0.44580078125,
-0.397705078125,
0.1859130859375,
-0.70947265625,
-0.269775390625,
-0.50439453125,
-0.21630859375,
-0.425048828125,
-0.435791015625,
-0.405029296875,
0.53662109375,
-0.349853515625,
0.291015625,
-0.0068511962890625,
0.238525390625,
-0.298095703125,
-0.59326171875,
0.21142578125,
0.28369140625,
-0.2388916015625,
0.6376953125,
0.60302734375,
0.1650390625,
0.64404296875,
-0.344970703125,
-0.6162109375,
-0.587890625,
0.673828125,
0.4091796875,
-0.333251953125,
-0.32177734375,
-0.028778076171875,
0.061492919921875,
-1.22265625,
0.210205078125,
-0.30908203125,
0.305419921875,
0.2802734375,
-0.31787109375,
0.194091796875,
0.98388671875,
0.166259765625,
0.493408203125,
0.292724609375,
0.180419921875,
0.0294342041015625,
0.118896484375,
0.17822265625,
0.76171875,
-0.1800537109375,
-0.28173828125,
0.25341796875,
0.87548828125,
0.134765625,
0.305908203125,
-0.52294921875,
-0.6416015625,
-0.6689453125,
0.139404296875,
-0.254638671875,
0.54248046875,
0.267333984375,
-0.88037109375,
0.1702880859375,
-0.1588134765625,
-0.484130859375,
0.2041015625,
-1.328125,
-0.83935546875,
0.47607421875,
-0.1676025390625,
-0.272216796875,
-0.274169921875,
-0.49462890625,
-0.3427734375,
-0.175537109375,
0.53125,
-0.58642578125,
0.4140625,
-0.1376953125,
0.5771484375,
-0.2261962890625,
0.384521484375,
0.0753173828125,
0.60009765625,
-0.62158203125,
-0.638671875,
0.288330078125,
1.15625,
0.11090087890625,
0.2607421875,
-0.324951171875,
0.31396484375,
-0.1868896484375,
0.01194000244140625,
-0.326904296875,
0.267578125,
-0.430419921875,
0.7412109375,
-0.88232421875,
0.1431884765625,
0.10302734375,
0.94775390625,
-0.034912109375,
-0.68212890625,
-0.669921875,
0.91552734375,
0.53369140625,
-0.178955078125,
0.380126953125,
0.52099609375,
0.63427734375,
-0.46142578125,
-0.2081298828125,
-0.346435546875,
0.5869140625,
0.81787109375,
0.6259765625,
-0.27392578125,
0.28662109375,
0.7236328125,
0.220947265625,
-0.01479339599609375,
0.5703125,
0.253662109375,
-0.1688232421875,
0.223876953125,
-0.4140625,
-0.061492919921875,
-0.1640625,
-0.369140625,
0.5615234375,
-0.05340576171875,
0.10809326171875,
-0.1357421875,
-1.0380859375,
0.8154296875,
-0.1566162109375,
-0.072265625,
0.27392578125,
-0.2335205078125,
0.31201171875,
0.5283203125,
-0.185791015625,
-0.1080322265625,
0.6708984375,
0.97216796875,
0.791015625,
0.40673828125,
0.80029296875,
0.098388671875,
-0.6884765625,
0.421875,
0.13623046875,
-0.1485595703125,
-0.494384765625,
-0.39208984375,
-1.3232421875,
0.619140625,
-0.476318359375,
-0.26953125,
0.32958984375,
-0.42138671875,
0.51416015625,
-0.8681640625,
0.87890625,
-0.69921875,
-0.0728759765625,
0.493896484375,
-0.24169921875,
-0.90576171875,
0.974609375,
-0.64501953125,
0.11505126953125,
0.6298828125,
1.04296875,
0.442138671875,
1.072265625,
0.44091796875,
-0.310546875,
0.0274810791015625,
0.289306640625,
-0.2076416015625,
-0.46630859375,
-0.2015380859375,
-0.47119140625,
-0.007587432861328125,
-0.55810546875,
-0.357666015625,
-0.1153564453125,
0.71533203125,
-0.09063720703125,
-0.75244140625,
-0.33740234375,
-0.11004638671875,
-0.861328125,
0.421630859375,
0.58740234375,
-0.0035858154296875,
0.49951171875,
0.240234375,
-0.29443359375,
-0.58251953125,
0.09326171875,
-0.417236328125,
0.44140625,
-0.759765625,
-0.4306640625,
-0.900390625,
-0.366943359375,
0.0276031494140625,
-0.15625,
-0.4169921875,
-1.1142578125,
0.7392578125,
0.642578125,
0.478515625,
0.05816650390625,
-0.5439453125,
0.1707763671875,
1.17578125,
0.76123046875,
0.1339111328125,
0.492919921875,
0.49072265625,
0.0289459228515625,
0.303466796875,
-0.419921875,
0.63232421875,
-0.297119140625,
-0.034149169921875,
-0.658203125,
-0.261474609375,
-0.460693359375,
-1.4189453125,
0.11578369140625,
0.351806640625,
0.470703125,
-0.76806640625,
-1.158203125,
-0.5947265625,
-0.99072265625,
-0.296875,
-0.529296875,
0.9384765625,
-0.07574462890625,
-0.2109375,
-0.0297088623046875,
-1.1611328125,
4.31640625,
0.82373046875,
0.71337890625,
-0.199951171875,
0.26611328125,
1.0927734375,
0.4697265625,
-0.49169921875,
-0.302001953125,
-0.61767578125,
0.3642578125,
-0.35107421875,
-0.0186004638671875,
0.76806640625,
0.11199951171875,
0.564453125,
-0.59716796875,
0.165771484375,
-0.06304931640625,
-0.9033203125,
-0.82763671875,
0.29638671875,
0.308349609375,
0.76953125,
-0.10858154296875,
0.277587890625,
0.1019287109375,
-0.66650390625,
-0.46923828125,
-0.3388671875,
0.01392364501953125,
-0.2235107421875,
0.87890625,
-0.0244598388671875,
-0.175048828125,
0.84423828125,
0.07342529296875,
-0.64990234375,
-0.0185546875,
0.255615234375,
-0.0096282958984375,
-0.1602783203125,
0.491943359375,
-0.29833984375,
-0.37646484375,
0.92431640625,
-0.78759765625,
0.2802734375,
0.5126953125,
-0.759765625,
0.8017578125,
-0.062286376953125,
0.75732421875,
-0.47705078125,
-0.3720703125,
0.1182861328125,
-0.17724609375,
-0.3974609375,
-0.76220703125,
0.72021484375,
0.406494140625,
0.252685546875,
0.51171875,
0.576171875,
-1.107421875,
0.59375,
-0.382080078125,
0.422607421875,
-0.927734375,
0.244384765625,
0.33251953125,
-0.0958251953125,
0.038604736328125,
-0.6767578125,
0.802734375,
0.28466796875,
-0.26220703125,
0.828125,
0.64111328125,
-0.54296875,
0.4990234375,
-0.2034912109375,
-0.028900146484375,
-0.33984375,
0.60791015625,
0.91357421875,
-0.5947265625,
-0.312255859375,
-0.133544921875,
0.7353515625,
0.49267578125,
0.88818359375,
0.1373291015625,
-0.576171875,
-0.133056640625
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Submitted Solution:
```
s=input()
l=[s]
for i in range(len(s)-1):
s=s[-1]+s[:len(s)-1]
l.append(s)
print(len(set(l)))
```
Yes
| 70,354 | [
0.63671875,
0.0303955078125,
-0.08416748046875,
0.36083984375,
-0.456787109375,
-0.446533203125,
-0.1717529296875,
0.0306549072265625,
0.0517578125,
0.888671875,
1.0234375,
-0.64111328125,
0.188232421875,
-0.921875,
-0.443603515625,
-0.7412109375,
-0.73095703125,
-0.60498046875,
-0.7099609375,
-0.036834716796875,
0.24609375,
-0.339599609375,
-1.212890625,
-0.56298828125,
-0.69384765625,
1.1279296875,
0.4208984375,
-0.181884765625,
1.046875,
1.279296875,
-0.65625,
-0.5009765625,
0.517578125,
-0.71484375,
-0.23876953125,
-0.58935546875,
0.51611328125,
-0.490234375,
-0.232177734375,
-0.79248046875,
0.0074462890625,
-0.65234375,
0.58447265625,
-0.5517578125,
-1.2607421875,
-0.38427734375,
-0.468994140625,
-0.62646484375,
-0.17333984375,
-0.69189453125,
0.304443359375,
-0.2724609375,
0.67236328125,
-0.386474609375,
0.42529296875,
0.2496337890625,
-0.390869140625,
-0.328369140625,
-0.64892578125,
0.331787109375,
0.1151123046875,
0.10064697265625,
-0.228271484375,
-0.76220703125,
-0.53564453125,
0.2568359375,
0.01221466064453125,
0.01114654541015625,
0.25634765625,
-0.69140625,
-0.432373046875,
0.050750732421875,
-0.1456298828125,
-0.302490234375,
-0.37353515625,
-0.30712890625,
0.477294921875,
0.06451416015625,
-1.115234375,
0.8935546875,
-0.209228515625,
0.99365234375,
0.2109375,
0.454345703125,
-0.38232421875,
-0.495849609375,
0.273193359375,
0.2489013671875,
0.2088623046875,
-0.4267578125,
0.1878662109375,
0.359375,
-0.79248046875,
-0.05535888671875,
0.5576171875,
0.367919921875,
-0.107177734375,
0.1513671875,
-0.1104736328125,
0.11358642578125,
0.95556640625,
0.9052734375,
-0.55517578125,
1.2119140625,
-0.345458984375,
-0.489501953125,
0.11981201171875,
0.21484375,
-0.2423095703125,
-0.329833984375,
-0.382568359375,
-0.1793212890625,
0.463134765625,
0.1732177734375,
-0.300048828125,
0.90234375,
0.09039306640625,
0.57861328125,
-0.50439453125,
0.0303192138671875,
0.414306640625,
0.07049560546875,
0.330078125,
-0.1365966796875,
0.6103515625,
-0.09625244140625,
-0.880859375,
0.98779296875,
-0.74951171875,
-0.01129150390625,
0.279296875,
0.05596923828125,
-0.307373046875,
0.38818359375,
0.0088958740234375,
1.060546875,
-0.252197265625,
0.76953125,
0.4697265625,
-0.81396484375,
0.97509765625,
-0.04449462890625,
0.0049591064453125,
1.560546875,
0.295654296875,
0.100341796875,
0.67822265625,
0.2403564453125,
-0.626953125,
0.480224609375,
-1.0537109375,
0.61279296875,
0.29296875,
0.1898193359375,
-0.61376953125,
0.0782470703125,
-0.429443359375,
0.64453125,
0.11474609375,
0.058807373046875,
-0.495361328125,
-0.01197052001953125,
-0.163330078125,
1.1611328125,
-0.6962890625,
0.9130859375,
-0.32568359375,
-0.3173828125,
-0.237060546875,
-0.6904296875,
0.0882568359375,
0.1123046875,
0.00010180473327636719,
0.7998046875,
0.486572265625,
1.3662109375,
1.083984375,
0.0909423828125,
0.2322998046875,
0.02655029296875,
-0.427490234375,
0.379638671875,
0.1953125,
0.8212890625,
0.6962890625,
0.33251953125,
-0.33544921875,
-0.10308837890625,
-0.244873046875,
-0.7197265625,
-0.211181640625,
0.681640625,
-0.79541015625,
-0.03033447265625,
0.0694580078125,
0.265869140625,
-1.1611328125,
-0.67724609375,
0.2587890625,
-0.98046875,
-0.1788330078125,
0.8359375,
-0.12481689453125,
0.74365234375,
-0.37158203125,
-0.451416015625,
0.4931640625,
0.56982421875,
-0.51025390625,
0.212646484375,
0.1939697265625,
0.1334228515625,
-0.1966552734375,
-0.2139892578125,
0.630859375,
-0.1710205078125,
-0.99853515625,
0.50048828125,
-0.1688232421875,
-0.4189453125,
0.176513671875,
0.93017578125,
0.34912109375,
0.417236328125,
-0.51123046875,
-0.287109375,
0.295166015625,
1.4287109375,
0.08966064453125,
0.91552734375,
0.367431640625,
0.904296875,
0.255126953125,
0.732421875,
0.273193359375,
0.047088623046875,
0.435302734375,
0.90771484375,
0.06024169921875,
0.11639404296875,
0.052703857421875,
0.3779296875,
0.75537109375,
0.60595703125,
0.10430908203125,
0.79541015625,
-0.16796875,
-0.25146484375,
-0.431640625,
0.418212890625,
-0.361083984375,
0.7490234375,
0.30859375,
0.458740234375,
-0.272705078125,
-0.285888671875,
0.56787109375,
0.701171875,
-0.32666015625,
-0.65380859375,
-0.07781982421875,
0.1937255859375,
0.263916015625,
0.114013671875,
0.560546875,
0.348388671875,
0.53759765625,
0.496826171875,
-0.23779296875,
-0.46826171875,
-0.6845703125,
-1.1083984375,
-1.0458984375,
-0.267822265625,
-0.7119140625,
-0.039031982421875,
-0.081298828125,
-0.69140625,
0.7119140625,
-0.299560546875,
-0.36083984375,
-0.0687255859375,
-0.77392578125,
0.85888671875,
-0.35107421875,
0.71142578125,
-0.8525390625,
0.1553955078125,
-0.166259765625,
0.904296875,
-0.56005859375,
-0.034088134765625,
-0.2430419921875,
-0.40478515625,
0.325439453125,
0.1748046875,
0.53466796875,
-0.0274658203125,
-0.5810546875,
-0.61962890625,
-0.323974609375,
0.044219970703125,
-0.385498046875,
-0.02679443359375,
-0.46728515625,
1.0712890625,
0.501953125,
-0.5703125,
0.88818359375,
1.1669921875,
-1.072265625,
0.422607421875,
0.2093505859375,
0.446044921875,
-0.73046875,
1.3466796875,
0.724609375,
0.295166015625,
-0.359619140625,
-0.40625,
-0.779296875,
0.206298828125,
0.078125,
-0.3564453125,
-0.712890625,
0.47265625,
0.1259765625,
-1.240234375,
0.59521484375,
-1.212890625,
-0.9306640625,
-0.1568603515625,
-0.327392578125,
0.86376953125,
0.8642578125,
0.04058837890625,
-0.17626953125,
-0.36083984375,
-0.418701171875,
0.6328125,
0.42041015625,
-0.411376953125,
0.343994140625,
0.716796875,
0.330810546875,
0.06640625,
0.3486328125,
-0.583984375,
-0.38671875,
0.206787109375,
0.217041015625,
0.56640625,
0.265380859375,
0.6162109375,
0.11773681640625,
0.8154296875,
-0.8701171875,
-0.56689453125,
-0.2220458984375,
0.63330078125,
0.350830078125,
0.402587890625,
0.04205322265625,
-0.378662109375,
-0.5390625,
-0.52734375,
0.485595703125,
0.124267578125,
0.6787109375,
-0.467041015625,
0.76611328125,
0.13916015625,
-0.66015625,
0.51806640625,
-0.5234375,
-0.1180419921875,
0.970703125,
-0.50439453125,
0.7646484375,
-0.53369140625,
0.281982421875,
-0.040985107421875,
-0.0684814453125,
0.60791015625,
0.39306640625,
0.6513671875,
-0.50439453125,
-0.2147216796875,
0.051055908203125,
-0.07171630859375,
-0.211181640625,
-0.65380859375,
0.278076171875,
-0.287353515625,
-0.347412109375,
-1.236328125,
0.60888671875,
0.7861328125,
0.5283203125,
0.007389068603515625,
0.61181640625,
0.07122802734375,
0.246337890625,
0.5263671875,
-0.51171875,
-0.08477783203125,
-0.7822265625,
0.74365234375,
-0.00839996337890625,
-0.51904296875,
-0.79833984375,
-0.217041015625,
-0.5439453125,
-0.07452392578125,
0.2017822265625,
0.10736083984375,
-0.82421875,
0.298828125,
-0.08062744140625,
0.66796875,
-0.5029296875,
-0.232421875,
-0.5458984375,
0.33837890625,
0.431396484375,
-0.90869140625,
0.55078125,
-0.96337890625,
0.64794921875,
0.57568359375,
0.062286376953125,
-0.74560546875,
-0.192138671875,
-0.97265625,
-0.65673828125,
-0.1322021484375,
0.61181640625,
-0.0731201171875,
0.328857421875,
-0.9794921875,
0.469482421875,
0.10601806640625,
-0.5859375,
0.301513671875,
0.261962890625,
0.422607421875,
-0.00560760498046875,
0.383056640625,
-0.177734375,
-0.76416015625,
0.358642578125,
-0.86474609375,
0.81396484375,
-0.387939453125,
0.41796875,
-0.12188720703125,
-0.0227813720703125,
0.281005859375,
0.345458984375,
-0.284423828125,
0.1876220703125,
-0.1400146484375,
0.5068359375,
-0.94091796875,
-0.77490234375,
0.541015625,
-0.39404296875,
-0.0283355712890625,
0.708984375,
-0.296630859375,
-0.374755859375,
0.28564453125,
0.05633544921875,
-0.50146484375,
0.2413330078125,
-0.37060546875,
0.716796875,
-0.082763671875,
-0.63427734375,
-0.1669921875,
-0.548828125,
0.77392578125,
-0.2130126953125,
-0.82373046875,
-0.33544921875,
-1.388671875,
-0.0035190582275390625,
-0.385986328125,
-0.2109375,
0.48828125,
0.4150390625,
-0.429931640625,
-0.269287109375,
-0.1422119140625,
-0.420166015625,
-0.385498046875,
-0.6611328125,
-0.1888427734375,
-0.209228515625,
0.20556640625,
0.93701171875,
-0.254150390625,
-0.351806640625,
-0.09271240234375,
-0.27880859375,
0.167724609375,
-0.51171875,
-0.51611328125,
-0.315185546875,
-0.403076171875,
-0.317138671875,
0.6376953125,
-0.254638671875,
0.2327880859375,
1.041015625,
0.18310546875,
0.2037353515625,
0.1361083984375,
-0.55126953125,
1.1181640625,
0.161865234375,
-1.1572265625,
-0.19580078125,
0.7587890625,
-0.07159423828125,
0.6650390625,
-0.192138671875,
-0.307373046875,
-0.378662109375,
-0.7841796875,
0.4189453125,
-0.6669921875,
0.1278076171875,
-0.6162109375,
-0.36767578125,
-0.179931640625,
0.356201171875,
-0.18310546875,
-0.35107421875,
-0.048065185546875,
-1.1318359375,
0.279541015625,
-0.59765625,
-0.35888671875,
-0.5927734375,
-0.6708984375,
-0.6376953125,
0.7900390625,
0.2734375,
0.4560546875,
0.053924560546875,
-0.28955078125,
0.45556640625,
-0.150634765625,
-0.82373046875,
-0.056304931640625,
0.26806640625,
0.31591796875,
-0.255859375,
-0.1878662109375,
-0.64013671875,
0.9892578125,
-0.61376953125,
0.337158203125,
-0.43408203125,
-0.5439453125,
0.1767578125,
0.0286712646484375,
0.91943359375,
-0.295654296875,
0.0076751708984375,
-0.8193359375,
0.416015625,
0.72216796875,
0.1732177734375,
-0.440185546875,
-0.72119140625,
-0.299072265625,
-1.4462890625,
0.599609375,
-0.36083984375,
0.66845703125,
-0.399169921875,
-0.240478515625,
0.583984375,
-0.5703125,
0.5205078125,
1.2216796875,
0.1982421875,
0.5087890625,
-0.49560546875,
0.9736328125,
0.63134765625,
-0.63720703125,
-0.52783203125,
0.27490234375,
-0.53564453125,
0.259765625,
-0.052215576171875,
-0.923828125,
-0.261962890625,
0.6494140625,
1.2841796875,
-0.08489990234375,
0.8525390625,
-0.302978515625,
-0.98046875,
-0.66943359375,
0.74658203125,
0.042144775390625,
0.477783203125,
1.119140625,
0.191650390625,
-0.2900390625,
0.43017578125,
0.046844482421875,
-0.464599609375,
-0.24609375,
1.12890625,
-0.135498046875,
-0.828125,
0.6494140625,
0.765625,
-1.109375,
-0.923828125,
-0.30712890625,
-0.1160888671875,
-0.341064453125,
-0.5048828125,
0.277099609375,
-0.056915283203125,
-0.420654296875,
0.06695556640625,
0.274169921875,
-0.59912109375,
0.45458984375,
-0.135009765625,
-0.1611328125,
-0.83740234375,
0.26611328125,
0.755859375,
-0.351806640625,
-0.3544921875,
-0.8251953125,
0.00916290283203125,
-0.35595703125,
-0.056976318359375,
0.52490234375,
-0.7705078125,
0.147216796875,
0.25927734375,
-0.251708984375,
0.7861328125,
-0.6376953125,
-0.2181396484375,
0.037811279296875,
-0.376708984375,
-0.662109375,
-0.150146484375,
-0.07171630859375,
-0.08465576171875,
0.343994140625,
-0.5166015625,
-0.64208984375,
0.46923828125,
-0.0013322830200195312,
-0.347412109375,
-0.76318359375,
-0.01105499267578125,
-1.224609375,
-0.9169921875,
-0.451416015625,
-0.609375,
0.007228851318359375,
0.32373046875,
0.26025390625,
-0.54150390625,
-0.007076263427734375,
0.6630859375,
-0.54345703125,
0.452880859375,
-0.406005859375,
0.1737060546875,
-0.64697265625,
-0.27099609375,
-0.4755859375,
-0.2125244140625,
-0.416015625,
-0.490234375,
-0.41064453125,
0.5615234375,
-0.388427734375,
0.27392578125,
-0.01708984375,
0.271728515625,
-0.287109375,
-0.58935546875,
0.202880859375,
0.2493896484375,
-0.2279052734375,
0.62890625,
0.60546875,
0.1767578125,
0.6318359375,
-0.32275390625,
-0.55908203125,
-0.58642578125,
0.72412109375,
0.429443359375,
-0.30419921875,
-0.332763671875,
0.01166534423828125,
0.0980224609375,
-1.23046875,
0.2088623046875,
-0.357666015625,
0.293212890625,
0.356201171875,
-0.318359375,
0.194091796875,
0.99365234375,
0.18408203125,
0.5185546875,
0.28515625,
0.16748046875,
0.07080078125,
0.1346435546875,
0.126220703125,
0.75390625,
-0.18408203125,
-0.299560546875,
0.251708984375,
0.84423828125,
0.1416015625,
0.280517578125,
-0.46630859375,
-0.68212890625,
-0.72021484375,
0.12457275390625,
-0.245849609375,
0.5419921875,
0.225341796875,
-0.88525390625,
0.1431884765625,
-0.1309814453125,
-0.462890625,
0.190185546875,
-1.3203125,
-0.83349609375,
0.50048828125,
-0.1707763671875,
-0.306884765625,
-0.244140625,
-0.445556640625,
-0.3154296875,
-0.1768798828125,
0.51611328125,
-0.58154296875,
0.41943359375,
-0.11810302734375,
0.57666015625,
-0.15478515625,
0.320556640625,
0.03173828125,
0.64306640625,
-0.666015625,
-0.6552734375,
0.265380859375,
1.1728515625,
0.1258544921875,
0.2369384765625,
-0.323974609375,
0.296875,
-0.1563720703125,
-0.025146484375,
-0.29150390625,
0.28076171875,
-0.451904296875,
0.71923828125,
-0.88671875,
0.1412353515625,
0.08673095703125,
0.9560546875,
-0.004138946533203125,
-0.69677734375,
-0.69287109375,
0.91943359375,
0.58203125,
-0.1854248046875,
0.4033203125,
0.51025390625,
0.65771484375,
-0.450927734375,
-0.205078125,
-0.3046875,
0.5869140625,
0.8310546875,
0.62890625,
-0.259765625,
0.2476806640625,
0.75244140625,
0.16455078125,
-0.0247039794921875,
0.60595703125,
0.29296875,
-0.1766357421875,
0.2205810546875,
-0.41650390625,
-0.09930419921875,
-0.1942138671875,
-0.427978515625,
0.552734375,
-0.07293701171875,
0.052032470703125,
-0.1314697265625,
-1.03125,
0.8193359375,
-0.1937255859375,
-0.054718017578125,
0.25048828125,
-0.265380859375,
0.31591796875,
0.5888671875,
-0.1932373046875,
-0.139892578125,
0.69970703125,
0.95654296875,
0.85693359375,
0.383544921875,
0.796875,
0.122314453125,
-0.7138671875,
0.443359375,
0.12103271484375,
-0.1798095703125,
-0.4892578125,
-0.405029296875,
-1.3017578125,
0.64453125,
-0.440185546875,
-0.2462158203125,
0.298583984375,
-0.447265625,
0.52734375,
-0.85888671875,
0.8857421875,
-0.69921875,
-0.07086181640625,
0.5068359375,
-0.2415771484375,
-0.93896484375,
0.994140625,
-0.626953125,
0.0771484375,
0.6171875,
1.0263671875,
0.434814453125,
1.0537109375,
0.423828125,
-0.267333984375,
0.0767822265625,
0.2685546875,
-0.1954345703125,
-0.45849609375,
-0.25634765625,
-0.466796875,
0.00982666015625,
-0.55419921875,
-0.357177734375,
-0.12939453125,
0.73583984375,
-0.063232421875,
-0.73828125,
-0.3154296875,
-0.10418701171875,
-0.87841796875,
0.427734375,
0.5673828125,
0.0310211181640625,
0.49267578125,
0.2191162109375,
-0.3076171875,
-0.5712890625,
0.106201171875,
-0.412353515625,
0.415771484375,
-0.76171875,
-0.4287109375,
-0.88623046875,
-0.403564453125,
0.01904296875,
-0.132080078125,
-0.389404296875,
-1.0966796875,
0.75,
0.59375,
0.4619140625,
0.05816650390625,
-0.53271484375,
0.175048828125,
1.1806640625,
0.77734375,
0.07330322265625,
0.496826171875,
0.5009765625,
0.00229644775390625,
0.29248046875,
-0.46142578125,
0.67333984375,
-0.280517578125,
0.01160430908203125,
-0.6630859375,
-0.213623046875,
-0.481201171875,
-1.3720703125,
0.114501953125,
0.34033203125,
0.469482421875,
-0.7626953125,
-1.1171875,
-0.625,
-1.00390625,
-0.270263671875,
-0.55859375,
1.0068359375,
-0.10400390625,
-0.2027587890625,
-0.030029296875,
-1.1279296875,
4.296875,
0.83740234375,
0.75244140625,
-0.19287109375,
0.30029296875,
1.0986328125,
0.463623046875,
-0.5205078125,
-0.322021484375,
-0.57861328125,
0.392578125,
-0.35888671875,
-0.037506103515625,
0.7900390625,
0.1649169921875,
0.5390625,
-0.5625,
0.12939453125,
-0.045928955078125,
-0.92529296875,
-0.845703125,
0.287841796875,
0.33154296875,
0.77685546875,
-0.126220703125,
0.24951171875,
0.084716796875,
-0.6337890625,
-0.42041015625,
-0.38134765625,
0.03399658203125,
-0.2108154296875,
0.89111328125,
-0.01113128662109375,
-0.1693115234375,
0.8212890625,
0.08514404296875,
-0.650390625,
-0.06036376953125,
0.280517578125,
-0.0246734619140625,
-0.2117919921875,
0.466552734375,
-0.34130859375,
-0.413330078125,
0.90673828125,
-0.78857421875,
0.29443359375,
0.5029296875,
-0.8564453125,
0.8115234375,
-0.09124755859375,
0.76025390625,
-0.4677734375,
-0.392578125,
0.12078857421875,
-0.1553955078125,
-0.354248046875,
-0.74267578125,
0.69287109375,
0.42431640625,
0.25634765625,
0.49072265625,
0.56640625,
-1.09375,
0.603515625,
-0.386474609375,
0.416015625,
-0.8955078125,
0.250244140625,
0.30419921875,
-0.06268310546875,
0.0386962890625,
-0.767578125,
0.81298828125,
0.292236328125,
-0.287841796875,
0.8388671875,
0.62841796875,
-0.55859375,
0.5009765625,
-0.2156982421875,
-0.060516357421875,
-0.39794921875,
0.6171875,
0.91845703125,
-0.6064453125,
-0.33056640625,
-0.13720703125,
0.7001953125,
0.47314453125,
0.9287109375,
0.139404296875,
-0.58642578125,
-0.1405029296875
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Submitted Solution:
```
I = lambda: list(map(int, input().split()))
s = input()
for i in range(1, len(s)):
if s[:i]*(len(s)//i)==s:
print(i)
quit()
print(len(s))
```
Yes
| 70,355 | [
0.63671875,
0.0491943359375,
-0.08355712890625,
0.357177734375,
-0.449462890625,
-0.394775390625,
-0.18115234375,
0.041748046875,
0.041656494140625,
0.88720703125,
1.0224609375,
-0.638671875,
0.166748046875,
-0.90771484375,
-0.438232421875,
-0.78076171875,
-0.69921875,
-0.59033203125,
-0.69091796875,
-0.045379638671875,
0.259521484375,
-0.342529296875,
-1.1708984375,
-0.552734375,
-0.6640625,
1.1279296875,
0.393310546875,
-0.177490234375,
1.064453125,
1.26171875,
-0.6328125,
-0.53466796875,
0.53662109375,
-0.7373046875,
-0.2364501953125,
-0.5791015625,
0.525390625,
-0.4970703125,
-0.2144775390625,
-0.80615234375,
-0.0142364501953125,
-0.67138671875,
0.57275390625,
-0.5537109375,
-1.248046875,
-0.367919921875,
-0.427001953125,
-0.58935546875,
-0.152099609375,
-0.689453125,
0.2734375,
-0.2578125,
0.66259765625,
-0.386962890625,
0.405517578125,
0.23193359375,
-0.375244140625,
-0.285888671875,
-0.62158203125,
0.341064453125,
0.12420654296875,
0.126220703125,
-0.2137451171875,
-0.7333984375,
-0.489990234375,
0.27587890625,
0.0251617431640625,
0.0200958251953125,
0.25048828125,
-0.724609375,
-0.45703125,
0.024810791015625,
-0.172607421875,
-0.2919921875,
-0.394287109375,
-0.310302734375,
0.440673828125,
0.07061767578125,
-1.0693359375,
0.9033203125,
-0.188232421875,
1.0185546875,
0.1806640625,
0.447021484375,
-0.389404296875,
-0.4619140625,
0.28662109375,
0.28955078125,
0.2177734375,
-0.40869140625,
0.184814453125,
0.33251953125,
-0.77392578125,
-0.03759765625,
0.55126953125,
0.336669921875,
-0.07098388671875,
0.13427734375,
-0.0816650390625,
0.1414794921875,
0.943359375,
0.9013671875,
-0.55615234375,
1.22265625,
-0.376708984375,
-0.4609375,
0.108154296875,
0.21630859375,
-0.25244140625,
-0.34423828125,
-0.384033203125,
-0.1917724609375,
0.457275390625,
0.1927490234375,
-0.257568359375,
0.84912109375,
0.08367919921875,
0.58642578125,
-0.5078125,
0.0242156982421875,
0.40234375,
0.10125732421875,
0.310546875,
-0.11236572265625,
0.60888671875,
-0.09228515625,
-0.87060546875,
1.009765625,
-0.7626953125,
0.0007090568542480469,
0.29345703125,
0.065673828125,
-0.283935546875,
0.373046875,
0.0192108154296875,
1.0439453125,
-0.25341796875,
0.81689453125,
0.458740234375,
-0.82763671875,
0.96728515625,
-0.04541015625,
0.0236053466796875,
1.5654296875,
0.266357421875,
0.103271484375,
0.68359375,
0.24609375,
-0.60791015625,
0.47705078125,
-1.044921875,
0.61962890625,
0.303955078125,
0.1822509765625,
-0.65966796875,
0.08966064453125,
-0.4140625,
0.66162109375,
0.14013671875,
0.061370849609375,
-0.482421875,
-0.007808685302734375,
-0.15478515625,
1.1591796875,
-0.67529296875,
0.9052734375,
-0.294677734375,
-0.316650390625,
-0.218994140625,
-0.70263671875,
0.07708740234375,
0.0858154296875,
-0.0207672119140625,
0.78515625,
0.505859375,
1.3662109375,
1.0986328125,
0.08770751953125,
0.255859375,
0.044464111328125,
-0.45703125,
0.380126953125,
0.2161865234375,
0.8232421875,
0.67333984375,
0.340087890625,
-0.30419921875,
-0.0850830078125,
-0.2344970703125,
-0.71533203125,
-0.2154541015625,
0.71044921875,
-0.77978515625,
-0.046783447265625,
0.048583984375,
0.27197265625,
-1.16015625,
-0.65576171875,
0.259521484375,
-0.98828125,
-0.1783447265625,
0.814453125,
-0.1661376953125,
0.72998046875,
-0.397216796875,
-0.4609375,
0.5009765625,
0.541015625,
-0.544921875,
0.231689453125,
0.1820068359375,
0.11956787109375,
-0.2249755859375,
-0.247314453125,
0.61962890625,
-0.1314697265625,
-1.0205078125,
0.493896484375,
-0.1710205078125,
-0.475341796875,
0.1953125,
0.974609375,
0.355712890625,
0.376220703125,
-0.50244140625,
-0.27978515625,
0.32666015625,
1.390625,
0.12371826171875,
0.89794921875,
0.400634765625,
0.9091796875,
0.219970703125,
0.703125,
0.29345703125,
0.04132080078125,
0.418701171875,
0.896484375,
0.039794921875,
0.133544921875,
0.06439208984375,
0.38818359375,
0.75390625,
0.63671875,
0.08367919921875,
0.779296875,
-0.174560546875,
-0.260009765625,
-0.4677734375,
0.419677734375,
-0.3525390625,
0.708984375,
0.3173828125,
0.444091796875,
-0.275146484375,
-0.272216796875,
0.5625,
0.68994140625,
-0.33203125,
-0.62890625,
-0.08538818359375,
0.1591796875,
0.2384033203125,
0.09381103515625,
0.5625,
0.360107421875,
0.533203125,
0.50146484375,
-0.274658203125,
-0.455322265625,
-0.6650390625,
-1.06640625,
-1.029296875,
-0.24951171875,
-0.724609375,
-0.0264892578125,
-0.08331298828125,
-0.6923828125,
0.736328125,
-0.311279296875,
-0.398681640625,
-0.0704345703125,
-0.7568359375,
0.8681640625,
-0.32958984375,
0.70947265625,
-0.85791015625,
0.158447265625,
-0.180419921875,
0.90283203125,
-0.5869140625,
-0.041351318359375,
-0.25390625,
-0.367919921875,
0.333984375,
0.1751708984375,
0.54296875,
-0.003536224365234375,
-0.60986328125,
-0.64111328125,
-0.31005859375,
0.09344482421875,
-0.36865234375,
0.025665283203125,
-0.4619140625,
1.0732421875,
0.470703125,
-0.57666015625,
0.92138671875,
1.1767578125,
-1.0546875,
0.411865234375,
0.18017578125,
0.47802734375,
-0.7314453125,
1.35546875,
0.70849609375,
0.322021484375,
-0.34814453125,
-0.3779296875,
-0.7841796875,
0.195556640625,
0.08502197265625,
-0.371337890625,
-0.70947265625,
0.470703125,
0.1588134765625,
-1.2080078125,
0.591796875,
-1.173828125,
-0.9140625,
-0.1295166015625,
-0.34619140625,
0.87841796875,
0.86767578125,
0.035186767578125,
-0.19091796875,
-0.317138671875,
-0.45458984375,
0.60693359375,
0.401611328125,
-0.44677734375,
0.328125,
0.70166015625,
0.3623046875,
0.0635986328125,
0.350341796875,
-0.54931640625,
-0.361572265625,
0.1834716796875,
0.14306640625,
0.55712890625,
0.234130859375,
0.59716796875,
0.10400390625,
0.82470703125,
-0.8583984375,
-0.5556640625,
-0.23388671875,
0.62109375,
0.31884765625,
0.378662109375,
0.029693603515625,
-0.3642578125,
-0.56298828125,
-0.497314453125,
0.46923828125,
0.13671875,
0.68798828125,
-0.466796875,
0.78857421875,
0.13671875,
-0.6767578125,
0.53955078125,
-0.54296875,
-0.08203125,
0.96240234375,
-0.45703125,
0.7451171875,
-0.5166015625,
0.2646484375,
-0.09130859375,
-0.019500732421875,
0.5810546875,
0.39453125,
0.619140625,
-0.533203125,
-0.1954345703125,
0.0145111083984375,
-0.0628662109375,
-0.218994140625,
-0.65185546875,
0.278076171875,
-0.268310546875,
-0.32568359375,
-1.2333984375,
0.576171875,
0.78857421875,
0.55078125,
0.00914764404296875,
0.6357421875,
0.054962158203125,
0.248779296875,
0.556640625,
-0.482421875,
-0.035797119140625,
-0.75390625,
0.71923828125,
-0.0189361572265625,
-0.5380859375,
-0.77392578125,
-0.2161865234375,
-0.5166015625,
-0.0712890625,
0.1505126953125,
0.12103271484375,
-0.80859375,
0.293212890625,
-0.048736572265625,
0.693359375,
-0.51171875,
-0.22900390625,
-0.541015625,
0.313232421875,
0.399658203125,
-0.86279296875,
0.5556640625,
-0.93408203125,
0.62548828125,
0.5390625,
0.04754638671875,
-0.76220703125,
-0.180908203125,
-0.970703125,
-0.67333984375,
-0.1065673828125,
0.6220703125,
-0.09307861328125,
0.296630859375,
-0.9697265625,
0.489501953125,
0.118896484375,
-0.57861328125,
0.260498046875,
0.23193359375,
0.430419921875,
0.000972747802734375,
0.3681640625,
-0.166259765625,
-0.78564453125,
0.339599609375,
-0.833984375,
0.78076171875,
-0.38427734375,
0.396484375,
-0.1324462890625,
-0.03363037109375,
0.255126953125,
0.34716796875,
-0.2822265625,
0.1749267578125,
-0.144775390625,
0.53271484375,
-0.9423828125,
-0.78369140625,
0.50634765625,
-0.390380859375,
0.03778076171875,
0.70458984375,
-0.302734375,
-0.402587890625,
0.282470703125,
0.059295654296875,
-0.482177734375,
0.23486328125,
-0.351318359375,
0.70556640625,
-0.0762939453125,
-0.5947265625,
-0.1568603515625,
-0.576171875,
0.7822265625,
-0.1998291015625,
-0.8017578125,
-0.33056640625,
-1.3701171875,
0.0012598037719726562,
-0.388671875,
-0.2110595703125,
0.46875,
0.389892578125,
-0.423828125,
-0.27587890625,
-0.12164306640625,
-0.41796875,
-0.3837890625,
-0.65185546875,
-0.176513671875,
-0.254150390625,
0.21533203125,
0.92578125,
-0.2607421875,
-0.35107421875,
-0.1083984375,
-0.25927734375,
0.1314697265625,
-0.5107421875,
-0.515625,
-0.358642578125,
-0.43359375,
-0.315185546875,
0.60205078125,
-0.23388671875,
0.2227783203125,
1.068359375,
0.1956787109375,
0.1962890625,
0.1595458984375,
-0.529296875,
1.1064453125,
0.1597900390625,
-1.1728515625,
-0.1578369140625,
0.7724609375,
-0.08538818359375,
0.65771484375,
-0.190673828125,
-0.295654296875,
-0.4013671875,
-0.810546875,
0.415283203125,
-0.66748046875,
0.09600830078125,
-0.6416015625,
-0.35888671875,
-0.1878662109375,
0.358154296875,
-0.1865234375,
-0.36669921875,
-0.0633544921875,
-1.15625,
0.284912109375,
-0.60888671875,
-0.357421875,
-0.60546875,
-0.6513671875,
-0.64111328125,
0.83837890625,
0.26513671875,
0.440185546875,
0.031768798828125,
-0.279052734375,
0.423583984375,
-0.1343994140625,
-0.80126953125,
-0.06243896484375,
0.2315673828125,
0.3017578125,
-0.2181396484375,
-0.1680908203125,
-0.62890625,
0.9638671875,
-0.59912109375,
0.320068359375,
-0.457763671875,
-0.5341796875,
0.18359375,
0.045867919921875,
0.9140625,
-0.293701171875,
0.0032501220703125,
-0.7978515625,
0.435302734375,
0.71044921875,
0.129150390625,
-0.423828125,
-0.716796875,
-0.28955078125,
-1.427734375,
0.623046875,
-0.37060546875,
0.6474609375,
-0.39013671875,
-0.230224609375,
0.5791015625,
-0.5869140625,
0.56640625,
1.2109375,
0.1751708984375,
0.497802734375,
-0.4482421875,
0.9638671875,
0.6201171875,
-0.62255859375,
-0.499755859375,
0.265380859375,
-0.509765625,
0.262451171875,
-0.05548095703125,
-0.931640625,
-0.2454833984375,
0.60888671875,
1.28125,
-0.10430908203125,
0.86328125,
-0.274658203125,
-0.986328125,
-0.685546875,
0.74462890625,
0.07073974609375,
0.470703125,
1.1328125,
0.200927734375,
-0.290771484375,
0.43701171875,
0.06414794921875,
-0.485107421875,
-0.2607421875,
1.119140625,
-0.1754150390625,
-0.8134765625,
0.6337890625,
0.77294921875,
-1.0947265625,
-0.9091796875,
-0.3251953125,
-0.12548828125,
-0.327392578125,
-0.5166015625,
0.273193359375,
-0.06683349609375,
-0.447998046875,
0.061065673828125,
0.262451171875,
-0.59521484375,
0.4404296875,
-0.1103515625,
-0.1522216796875,
-0.8232421875,
0.2236328125,
0.7890625,
-0.363525390625,
-0.361572265625,
-0.826171875,
0.0266876220703125,
-0.345703125,
-0.046661376953125,
0.54296875,
-0.78515625,
0.1416015625,
0.26171875,
-0.2386474609375,
0.7744140625,
-0.638671875,
-0.229248046875,
0.03759765625,
-0.3984375,
-0.63427734375,
-0.1585693359375,
-0.05950927734375,
-0.0623779296875,
0.33935546875,
-0.51708984375,
-0.62451171875,
0.465087890625,
-0.032501220703125,
-0.3427734375,
-0.7646484375,
-0.02569580078125,
-1.212890625,
-0.9111328125,
-0.43017578125,
-0.6162109375,
0.0012445449829101562,
0.290771484375,
0.22900390625,
-0.521484375,
0.004283905029296875,
0.66650390625,
-0.53857421875,
0.493408203125,
-0.42822265625,
0.1378173828125,
-0.6455078125,
-0.25732421875,
-0.50341796875,
-0.2196044921875,
-0.39892578125,
-0.452880859375,
-0.420166015625,
0.54150390625,
-0.35009765625,
0.273681640625,
-0.0250244140625,
0.251953125,
-0.299560546875,
-0.61279296875,
0.1766357421875,
0.2626953125,
-0.1961669921875,
0.6240234375,
0.60205078125,
0.1646728515625,
0.62841796875,
-0.339111328125,
-0.53076171875,
-0.5771484375,
0.71630859375,
0.40283203125,
-0.333984375,
-0.310791015625,
-0.0350341796875,
0.047210693359375,
-1.2197265625,
0.2103271484375,
-0.3017578125,
0.294677734375,
0.319091796875,
-0.302490234375,
0.202880859375,
1.0107421875,
0.11785888671875,
0.5048828125,
0.2479248046875,
0.187744140625,
0.07861328125,
0.1334228515625,
0.1578369140625,
0.73876953125,
-0.1807861328125,
-0.3095703125,
0.26904296875,
0.8115234375,
0.1688232421875,
0.280517578125,
-0.44677734375,
-0.6787109375,
-0.73681640625,
0.10577392578125,
-0.2403564453125,
0.5146484375,
0.22412109375,
-0.89013671875,
0.136474609375,
-0.14794921875,
-0.45556640625,
0.1593017578125,
-1.3388671875,
-0.84619140625,
0.4912109375,
-0.1788330078125,
-0.31689453125,
-0.22998046875,
-0.471923828125,
-0.34033203125,
-0.1768798828125,
0.55908203125,
-0.546875,
0.405517578125,
-0.11846923828125,
0.578125,
-0.1837158203125,
0.301025390625,
0.0193328857421875,
0.6396484375,
-0.6328125,
-0.64404296875,
0.256103515625,
1.1298828125,
0.09649658203125,
0.246337890625,
-0.347900390625,
0.291748046875,
-0.1513671875,
-0.026275634765625,
-0.26904296875,
0.257080078125,
-0.432861328125,
0.7294921875,
-0.85791015625,
0.1533203125,
0.075439453125,
0.92138671875,
0.0089111328125,
-0.6630859375,
-0.70458984375,
0.908203125,
0.5859375,
-0.1529541015625,
0.418212890625,
0.487060546875,
0.64794921875,
-0.43408203125,
-0.23291015625,
-0.323974609375,
0.58544921875,
0.8115234375,
0.6123046875,
-0.23828125,
0.263427734375,
0.744140625,
0.133544921875,
-0.04095458984375,
0.6015625,
0.2459716796875,
-0.1787109375,
0.2061767578125,
-0.404052734375,
-0.09625244140625,
-0.1898193359375,
-0.436279296875,
0.5615234375,
-0.10064697265625,
0.072509765625,
-0.12548828125,
-1.009765625,
0.81884765625,
-0.1912841796875,
-0.0784912109375,
0.2237548828125,
-0.28369140625,
0.31298828125,
0.56103515625,
-0.166748046875,
-0.13916015625,
0.68798828125,
0.96826171875,
0.8623046875,
0.366455078125,
0.8037109375,
0.1378173828125,
-0.76025390625,
0.421630859375,
0.129638671875,
-0.1536865234375,
-0.464111328125,
-0.3828125,
-1.2890625,
0.669921875,
-0.435302734375,
-0.2451171875,
0.271240234375,
-0.40478515625,
0.5068359375,
-0.8623046875,
0.91259765625,
-0.6552734375,
-0.0860595703125,
0.477294921875,
-0.2265625,
-0.91650390625,
0.9306640625,
-0.60986328125,
0.06134033203125,
0.62744140625,
1.02734375,
0.408447265625,
1.03515625,
0.46728515625,
-0.257568359375,
0.058746337890625,
0.24609375,
-0.169677734375,
-0.43017578125,
-0.241943359375,
-0.5146484375,
0.057281494140625,
-0.54736328125,
-0.349609375,
-0.12042236328125,
0.7177734375,
-0.061614990234375,
-0.7099609375,
-0.318359375,
-0.1036376953125,
-0.86767578125,
0.4306640625,
0.57958984375,
0.034576416015625,
0.51123046875,
0.2269287109375,
-0.279052734375,
-0.53857421875,
0.1153564453125,
-0.434814453125,
0.38671875,
-0.7666015625,
-0.45068359375,
-0.88623046875,
-0.401123046875,
0.033111572265625,
-0.17529296875,
-0.367919921875,
-1.0947265625,
0.7099609375,
0.615234375,
0.477783203125,
0.040618896484375,
-0.5478515625,
0.14208984375,
1.15625,
0.75048828125,
0.12890625,
0.47314453125,
0.48193359375,
-0.01373291015625,
0.26513671875,
-0.45849609375,
0.6474609375,
-0.27099609375,
0.00690460205078125,
-0.6279296875,
-0.1920166015625,
-0.50146484375,
-1.376953125,
0.09783935546875,
0.35546875,
0.50341796875,
-0.78125,
-1.1044921875,
-0.650390625,
-0.9794921875,
-0.28662109375,
-0.54248046875,
0.97509765625,
-0.07806396484375,
-0.2147216796875,
-0.010589599609375,
-1.123046875,
4.33203125,
0.80126953125,
0.75927734375,
-0.1622314453125,
0.287109375,
1.080078125,
0.42333984375,
-0.495849609375,
-0.315185546875,
-0.57958984375,
0.388916015625,
-0.33984375,
-0.03533935546875,
0.83251953125,
0.1700439453125,
0.51171875,
-0.57080078125,
0.1695556640625,
-0.05633544921875,
-0.896484375,
-0.85546875,
0.264892578125,
0.292236328125,
0.763671875,
-0.10186767578125,
0.241943359375,
0.0894775390625,
-0.62939453125,
-0.468505859375,
-0.370849609375,
0.050140380859375,
-0.21630859375,
0.87841796875,
-0.02740478515625,
-0.1448974609375,
0.82177734375,
0.07122802734375,
-0.6650390625,
-0.04327392578125,
0.279296875,
-0.00846099853515625,
-0.217041015625,
0.46533203125,
-0.343994140625,
-0.372314453125,
0.9140625,
-0.77587890625,
0.32373046875,
0.484619140625,
-0.82177734375,
0.77001953125,
-0.08447265625,
0.76220703125,
-0.44970703125,
-0.38818359375,
0.1351318359375,
-0.1595458984375,
-0.3486328125,
-0.771484375,
0.72412109375,
0.41162109375,
0.28369140625,
0.48388671875,
0.60595703125,
-1.1015625,
0.60400390625,
-0.3896484375,
0.4052734375,
-0.9423828125,
0.242431640625,
0.277587890625,
-0.08135986328125,
0.078125,
-0.76416015625,
0.796875,
0.283447265625,
-0.271728515625,
0.849609375,
0.60986328125,
-0.54931640625,
0.52294921875,
-0.2169189453125,
-0.07049560546875,
-0.40869140625,
0.6259765625,
0.888671875,
-0.62255859375,
-0.29833984375,
-0.1463623046875,
0.69091796875,
0.50439453125,
0.88623046875,
0.185791015625,
-0.61279296875,
-0.1600341796875
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Submitted Solution:
```
import math
from collections import Counter
from functools import reduce
s = input()
c = Counter(s).most_common()
s1 = [v for k, v in c]
c1 = Counter(s1).most_common()
x = [k for k, v in c1]
gcd = reduce(math.gcd, x)
if gcd < sorted(x)[0] and gcd != 1:
gcd = 1
n = 0
for k, v in c1:
n += (k//gcd)*v
print(n)
```
No
| 70,356 | [
0.60986328125,
-0.0257110595703125,
-0.04498291015625,
0.364013671875,
-0.376953125,
-0.381103515625,
-0.1435546875,
-0.052703857421875,
0.07550048828125,
0.9365234375,
0.98388671875,
-0.72802734375,
0.2196044921875,
-0.98681640625,
-0.44873046875,
-0.7431640625,
-0.75048828125,
-0.59765625,
-0.75537109375,
-0.06781005859375,
0.2568359375,
-0.372802734375,
-1.1943359375,
-0.5634765625,
-0.6708984375,
1.1435546875,
0.43603515625,
-0.202392578125,
1.1025390625,
1.3251953125,
-0.6318359375,
-0.58740234375,
0.4912109375,
-0.77001953125,
-0.30908203125,
-0.60302734375,
0.57568359375,
-0.5078125,
-0.1669921875,
-0.77734375,
-0.01067352294921875,
-0.73876953125,
0.525390625,
-0.560546875,
-1.2294921875,
-0.37158203125,
-0.436279296875,
-0.611328125,
-0.07525634765625,
-0.7138671875,
0.324951171875,
-0.2491455078125,
0.60302734375,
-0.422119140625,
0.486083984375,
0.216064453125,
-0.324951171875,
-0.361572265625,
-0.61669921875,
0.2484130859375,
0.1812744140625,
0.09698486328125,
-0.23779296875,
-0.81201171875,
-0.4892578125,
0.25830078125,
-0.02288818359375,
0.054473876953125,
0.26953125,
-0.7529296875,
-0.466552734375,
0.05859375,
-0.1529541015625,
-0.29150390625,
-0.331787109375,
-0.338134765625,
0.439697265625,
0.05450439453125,
-1.0576171875,
0.9248046875,
-0.23876953125,
0.9677734375,
0.16845703125,
0.4853515625,
-0.38671875,
-0.482421875,
0.2303466796875,
0.254150390625,
0.18505859375,
-0.39990234375,
0.1507568359375,
0.372802734375,
-0.81005859375,
-0.0296630859375,
0.66162109375,
0.375244140625,
-0.0677490234375,
0.1507568359375,
-0.00675201416015625,
0.10968017578125,
0.96240234375,
0.9404296875,
-0.5986328125,
1.2021484375,
-0.35546875,
-0.45849609375,
0.1190185546875,
0.2071533203125,
-0.314453125,
-0.386474609375,
-0.36474609375,
-0.2149658203125,
0.41552734375,
0.1783447265625,
-0.1572265625,
0.89697265625,
-0.0256805419921875,
0.6044921875,
-0.451904296875,
0.00737762451171875,
0.324462890625,
0.084716796875,
0.324462890625,
-0.1571044921875,
0.5517578125,
-0.10284423828125,
-0.83984375,
1.046875,
-0.79248046875,
-0.046112060546875,
0.326416015625,
0.015655517578125,
-0.283203125,
0.391845703125,
0.0438232421875,
1.068359375,
-0.2415771484375,
0.7431640625,
0.51171875,
-0.83203125,
0.9326171875,
-0.08233642578125,
0.030975341796875,
1.6015625,
0.2349853515625,
0.1492919921875,
0.67041015625,
0.2388916015625,
-0.58837890625,
0.468017578125,
-0.95849609375,
0.60302734375,
0.316162109375,
0.1795654296875,
-0.6162109375,
0.0970458984375,
-0.45263671875,
0.64013671875,
0.1693115234375,
0.0792236328125,
-0.494873046875,
0.056243896484375,
-0.10015869140625,
1.109375,
-0.744140625,
0.93896484375,
-0.363525390625,
-0.301025390625,
-0.282470703125,
-0.62158203125,
0.0548095703125,
0.1339111328125,
-0.052886962890625,
0.85205078125,
0.546875,
1.2841796875,
1.0390625,
0.07891845703125,
0.32568359375,
0.07037353515625,
-0.424072265625,
0.302978515625,
0.25146484375,
0.7734375,
0.6083984375,
0.375,
-0.36767578125,
-0.15869140625,
-0.243408203125,
-0.7587890625,
-0.204345703125,
0.68896484375,
-0.82080078125,
-0.10198974609375,
0.1337890625,
0.224365234375,
-1.1455078125,
-0.64892578125,
0.28955078125,
-1.005859375,
-0.1715087890625,
0.93017578125,
-0.12286376953125,
0.71240234375,
-0.389892578125,
-0.44384765625,
0.58935546875,
0.5615234375,
-0.556640625,
0.19677734375,
0.222900390625,
0.0119476318359375,
-0.2005615234375,
-0.2080078125,
0.6396484375,
-0.0792236328125,
-1.0341796875,
0.482421875,
-0.17578125,
-0.52587890625,
0.1739501953125,
0.98388671875,
0.39208984375,
0.333984375,
-0.463134765625,
-0.274658203125,
0.2467041015625,
1.423828125,
0.11480712890625,
0.88818359375,
0.327880859375,
0.857421875,
0.2003173828125,
0.6640625,
0.247314453125,
0.1015625,
0.49072265625,
0.90673828125,
0.025909423828125,
0.1693115234375,
-0.0254974365234375,
0.3671875,
0.744140625,
0.5849609375,
0.0628662109375,
0.80908203125,
-0.1500244140625,
-0.21044921875,
-0.43603515625,
0.4453125,
-0.406005859375,
0.681640625,
0.281494140625,
0.41748046875,
-0.289306640625,
-0.3330078125,
0.50634765625,
0.7314453125,
-0.3125,
-0.61669921875,
-0.09869384765625,
0.1724853515625,
0.23828125,
0.08306884765625,
0.5146484375,
0.45166015625,
0.55712890625,
0.4833984375,
-0.2298583984375,
-0.44580078125,
-0.71630859375,
-1.060546875,
-1.044921875,
-0.254150390625,
-0.6796875,
0.051727294921875,
-0.15771484375,
-0.5947265625,
0.69287109375,
-0.1707763671875,
-0.339111328125,
-0.035369873046875,
-0.7197265625,
0.83203125,
-0.271728515625,
0.7216796875,
-0.84765625,
0.199951171875,
-0.2149658203125,
0.84423828125,
-0.5458984375,
-0.0216827392578125,
-0.1729736328125,
-0.389892578125,
0.40869140625,
0.2169189453125,
0.492919921875,
-0.07373046875,
-0.5458984375,
-0.67431640625,
-0.356689453125,
0.01131439208984375,
-0.277099609375,
-0.02325439453125,
-0.440673828125,
1.0625,
0.395263671875,
-0.6201171875,
0.984375,
1.1533203125,
-1.09765625,
0.400634765625,
0.2119140625,
0.372314453125,
-0.7841796875,
1.3564453125,
0.76318359375,
0.297119140625,
-0.2978515625,
-0.2763671875,
-0.775390625,
0.1468505859375,
-0.02984619140625,
-0.40478515625,
-0.7890625,
0.53564453125,
0.1385498046875,
-1.2373046875,
0.611328125,
-1.166015625,
-1.021484375,
-0.09356689453125,
-0.346435546875,
0.87841796875,
0.8740234375,
-0.0557861328125,
-0.14794921875,
-0.294677734375,
-0.427734375,
0.60986328125,
0.40576171875,
-0.42529296875,
0.338623046875,
0.71826171875,
0.322509765625,
0.027557373046875,
0.29638671875,
-0.56982421875,
-0.394775390625,
0.0985107421875,
0.2021484375,
0.6806640625,
0.269287109375,
0.6572265625,
0.16015625,
0.8330078125,
-0.91650390625,
-0.5615234375,
-0.1717529296875,
0.64208984375,
0.330810546875,
0.31103515625,
0.053009033203125,
-0.410400390625,
-0.46826171875,
-0.50341796875,
0.464599609375,
0.10723876953125,
0.70361328125,
-0.47900390625,
0.74365234375,
0.144287109375,
-0.654296875,
0.59716796875,
-0.56396484375,
-0.05224609375,
0.919921875,
-0.46484375,
0.7314453125,
-0.4853515625,
0.283935546875,
-0.069091796875,
0.0213470458984375,
0.61083984375,
0.390380859375,
0.53466796875,
-0.59326171875,
-0.1351318359375,
-0.06036376953125,
-0.023406982421875,
-0.21337890625,
-0.64111328125,
0.27392578125,
-0.36083984375,
-0.34326171875,
-1.18359375,
0.64599609375,
0.79931640625,
0.467529296875,
-0.017425537109375,
0.61279296875,
0.036102294921875,
0.249267578125,
0.56103515625,
-0.45751953125,
0.0229949951171875,
-0.82763671875,
0.7255859375,
-0.0367431640625,
-0.54638671875,
-0.7763671875,
-0.1903076171875,
-0.56689453125,
-0.04510498046875,
0.2279052734375,
0.2127685546875,
-0.86279296875,
0.33349609375,
-0.12384033203125,
0.69091796875,
-0.50927734375,
-0.2132568359375,
-0.51025390625,
0.380126953125,
0.344970703125,
-0.9130859375,
0.494873046875,
-0.9775390625,
0.529296875,
0.56298828125,
0.046417236328125,
-0.71435546875,
-0.2269287109375,
-0.9189453125,
-0.60107421875,
-0.1072998046875,
0.6630859375,
-0.1143798828125,
0.35595703125,
-1.0009765625,
0.49365234375,
0.1285400390625,
-0.55810546875,
0.1595458984375,
0.343994140625,
0.4580078125,
0.030792236328125,
0.44189453125,
-0.111572265625,
-0.7001953125,
0.30419921875,
-0.9228515625,
0.7607421875,
-0.405517578125,
0.441650390625,
-0.0416259765625,
-0.05670166015625,
0.1988525390625,
0.380859375,
-0.3447265625,
0.14013671875,
-0.185791015625,
0.54736328125,
-0.93994140625,
-0.8095703125,
0.5556640625,
-0.413818359375,
0.018280029296875,
0.7744140625,
-0.25390625,
-0.399658203125,
0.3369140625,
0.030426025390625,
-0.46630859375,
0.28271484375,
-0.291015625,
0.7509765625,
-0.1025390625,
-0.6015625,
-0.196044921875,
-0.60595703125,
0.796875,
-0.2381591796875,
-0.7529296875,
-0.372314453125,
-1.3447265625,
-0.042572021484375,
-0.485107421875,
-0.239013671875,
0.44140625,
0.36181640625,
-0.439208984375,
-0.3291015625,
-0.055633544921875,
-0.449462890625,
-0.385009765625,
-0.626953125,
-0.1658935546875,
-0.2025146484375,
0.266357421875,
0.912109375,
-0.2479248046875,
-0.382080078125,
-0.0648193359375,
-0.171875,
0.171142578125,
-0.52392578125,
-0.46044921875,
-0.3701171875,
-0.431884765625,
-0.291015625,
0.50341796875,
-0.1807861328125,
0.1668701171875,
1.078125,
0.16650390625,
0.15185546875,
0.149169921875,
-0.52880859375,
1.09765625,
0.1258544921875,
-1.1572265625,
-0.1641845703125,
0.76416015625,
-0.079833984375,
0.67529296875,
-0.124755859375,
-0.3017578125,
-0.404541015625,
-0.740234375,
0.36376953125,
-0.67626953125,
0.088623046875,
-0.57861328125,
-0.326171875,
-0.15771484375,
0.411376953125,
-0.1265869140625,
-0.3779296875,
-0.006717681884765625,
-1.0625,
0.267333984375,
-0.6259765625,
-0.388916015625,
-0.6591796875,
-0.62548828125,
-0.7236328125,
0.79150390625,
0.246826171875,
0.4462890625,
0.01495361328125,
-0.224609375,
0.467041015625,
-0.1549072265625,
-0.81396484375,
-0.1087646484375,
0.2242431640625,
0.27587890625,
-0.239990234375,
-0.1304931640625,
-0.6640625,
1.111328125,
-0.6025390625,
0.221435546875,
-0.463623046875,
-0.52734375,
0.1502685546875,
0.0809326171875,
0.91748046875,
-0.243896484375,
0.07635498046875,
-0.72900390625,
0.346435546875,
0.66943359375,
0.1087646484375,
-0.4052734375,
-0.75732421875,
-0.2587890625,
-1.45703125,
0.6103515625,
-0.34814453125,
0.6796875,
-0.404296875,
-0.228515625,
0.5859375,
-0.61181640625,
0.4990234375,
1.2041015625,
0.211181640625,
0.4794921875,
-0.458251953125,
1.0048828125,
0.6416015625,
-0.67236328125,
-0.53271484375,
0.216064453125,
-0.46484375,
0.255615234375,
0.01264190673828125,
-0.958984375,
-0.272705078125,
0.59326171875,
1.30078125,
-0.0076141357421875,
0.85986328125,
-0.265380859375,
-0.99267578125,
-0.68212890625,
0.69189453125,
-0.017669677734375,
0.58154296875,
1.146484375,
0.1669921875,
-0.23583984375,
0.357666015625,
0.1070556640625,
-0.481689453125,
-0.3154296875,
1.060546875,
-0.1815185546875,
-0.83203125,
0.640625,
0.83447265625,
-1.0400390625,
-0.88671875,
-0.286376953125,
-0.12939453125,
-0.34912109375,
-0.4921875,
0.309326171875,
-0.053955078125,
-0.45947265625,
0.056304931640625,
0.270751953125,
-0.57763671875,
0.404541015625,
-0.1295166015625,
-0.11065673828125,
-0.787109375,
0.1934814453125,
0.7373046875,
-0.319580078125,
-0.361572265625,
-0.7744140625,
0.03851318359375,
-0.3310546875,
-0.040252685546875,
0.53173828125,
-0.84228515625,
0.1533203125,
0.321044921875,
-0.1785888671875,
0.70751953125,
-0.61669921875,
-0.227783203125,
0.0009522438049316406,
-0.425048828125,
-0.6611328125,
-0.1715087890625,
-0.11407470703125,
-0.06640625,
0.35498046875,
-0.45703125,
-0.57177734375,
0.53466796875,
-0.0736083984375,
-0.332275390625,
-0.7314453125,
-0.0268707275390625,
-1.2490234375,
-0.9873046875,
-0.45703125,
-0.69677734375,
-0.042816162109375,
0.271240234375,
0.2105712890625,
-0.53857421875,
0.0185089111328125,
0.64306640625,
-0.50537109375,
0.423828125,
-0.4091796875,
0.17822265625,
-0.6923828125,
-0.342529296875,
-0.5224609375,
-0.1976318359375,
-0.346923828125,
-0.385986328125,
-0.5126953125,
0.55029296875,
-0.267333984375,
0.29345703125,
0.041229248046875,
0.257568359375,
-0.3466796875,
-0.58984375,
0.1749267578125,
0.2269287109375,
-0.166748046875,
0.61181640625,
0.51953125,
0.168701171875,
0.732421875,
-0.262939453125,
-0.60205078125,
-0.66552734375,
0.701171875,
0.44921875,
-0.34912109375,
-0.36865234375,
-0.043182373046875,
0.09918212890625,
-1.2255859375,
0.2054443359375,
-0.341064453125,
0.293212890625,
0.317138671875,
-0.321533203125,
0.1746826171875,
0.98779296875,
0.1336669921875,
0.55029296875,
0.3427734375,
0.17919921875,
-0.036712646484375,
0.14501953125,
0.0924072265625,
0.771484375,
-0.1728515625,
-0.322998046875,
0.281005859375,
0.74169921875,
0.127685546875,
0.25537109375,
-0.4609375,
-0.53173828125,
-0.7109375,
0.0987548828125,
-0.25439453125,
0.48876953125,
0.243408203125,
-0.9169921875,
0.0745849609375,
-0.1004638671875,
-0.47412109375,
0.135498046875,
-1.3154296875,
-0.84814453125,
0.52978515625,
-0.1806640625,
-0.281494140625,
-0.2421875,
-0.338134765625,
-0.325927734375,
-0.159423828125,
0.55322265625,
-0.5322265625,
0.456298828125,
-0.0970458984375,
0.654296875,
-0.2022705078125,
0.271484375,
0.01531982421875,
0.708984375,
-0.65673828125,
-0.66015625,
0.205322265625,
1.2138671875,
0.13427734375,
0.324462890625,
-0.2900390625,
0.25830078125,
-0.12109375,
-0.06463623046875,
-0.283447265625,
0.17578125,
-0.53564453125,
0.81201171875,
-0.8857421875,
0.1676025390625,
0.040679931640625,
0.91015625,
-0.0264739990234375,
-0.70654296875,
-0.6806640625,
0.99072265625,
0.60302734375,
-0.231689453125,
0.49072265625,
0.5673828125,
0.67822265625,
-0.469970703125,
-0.190185546875,
-0.310546875,
0.544921875,
0.7060546875,
0.6484375,
-0.2484130859375,
0.2132568359375,
0.78466796875,
0.2374267578125,
0.0457763671875,
0.57470703125,
0.188720703125,
-0.167724609375,
0.1986083984375,
-0.376953125,
-0.04827880859375,
-0.1358642578125,
-0.50146484375,
0.67578125,
-0.124755859375,
0.050537109375,
-0.09918212890625,
-1.015625,
0.7978515625,
-0.263916015625,
-0.042327880859375,
0.2783203125,
-0.30224609375,
0.34033203125,
0.56396484375,
-0.1759033203125,
-0.1365966796875,
0.7607421875,
0.912109375,
0.880859375,
0.35791015625,
0.8076171875,
0.1627197265625,
-0.712890625,
0.356689453125,
0.159423828125,
-0.1929931640625,
-0.436279296875,
-0.388916015625,
-1.2783203125,
0.623046875,
-0.489013671875,
-0.25048828125,
0.27294921875,
-0.372802734375,
0.45947265625,
-0.8564453125,
0.86279296875,
-0.67333984375,
-0.0197906494140625,
0.53466796875,
-0.2359619140625,
-0.91455078125,
0.9775390625,
-0.63134765625,
0.03125,
0.642578125,
0.9677734375,
0.35400390625,
1.0615234375,
0.396484375,
-0.275390625,
-0.004154205322265625,
0.276611328125,
-0.248779296875,
-0.4345703125,
-0.28076171875,
-0.419921875,
0.05084228515625,
-0.5322265625,
-0.409423828125,
-0.07427978515625,
0.67626953125,
-0.09539794921875,
-0.64794921875,
-0.335205078125,
-0.05340576171875,
-0.88232421875,
0.426025390625,
0.62548828125,
0.046478271484375,
0.485107421875,
0.1614990234375,
-0.32373046875,
-0.52099609375,
0.0823974609375,
-0.444091796875,
0.435546875,
-0.76171875,
-0.390380859375,
-0.84716796875,
-0.437255859375,
-0.0031604766845703125,
-0.197265625,
-0.382080078125,
-1.10546875,
0.75048828125,
0.5888671875,
0.447509765625,
0.0557861328125,
-0.52978515625,
0.2425537109375,
1.16796875,
0.72216796875,
0.02618408203125,
0.450927734375,
0.492919921875,
-0.02490234375,
0.2486572265625,
-0.39599609375,
0.61962890625,
-0.34326171875,
-0.0258941650390625,
-0.6181640625,
-0.18359375,
-0.467529296875,
-1.3935546875,
0.1282958984375,
0.419677734375,
0.5380859375,
-0.76171875,
-1.1357421875,
-0.59814453125,
-1.009765625,
-0.259521484375,
-0.5478515625,
0.90576171875,
-0.032989501953125,
-0.1748046875,
-0.0210113525390625,
-1.1220703125,
4.31640625,
0.7666015625,
0.66455078125,
-0.17431640625,
0.288818359375,
1.044921875,
0.465576171875,
-0.529296875,
-0.275390625,
-0.5341796875,
0.37548828125,
-0.3154296875,
0.0014066696166992188,
0.75830078125,
0.1534423828125,
0.5146484375,
-0.55126953125,
0.204833984375,
-0.035003662109375,
-0.9208984375,
-0.8720703125,
0.31298828125,
0.275390625,
0.755859375,
-0.139892578125,
0.2491455078125,
0.174072265625,
-0.640625,
-0.45849609375,
-0.341552734375,
0.0821533203125,
-0.1776123046875,
0.87451171875,
-0.07489013671875,
-0.10089111328125,
0.79541015625,
0.03826904296875,
-0.62744140625,
-0.0175018310546875,
0.29931640625,
0.056182861328125,
-0.156005859375,
0.46630859375,
-0.338623046875,
-0.325439453125,
0.94287109375,
-0.84130859375,
0.2115478515625,
0.47802734375,
-0.7353515625,
0.86376953125,
-0.03985595703125,
0.791015625,
-0.395263671875,
-0.385498046875,
0.0836181640625,
-0.10943603515625,
-0.441650390625,
-0.7392578125,
0.625,
0.41943359375,
0.2198486328125,
0.619140625,
0.59521484375,
-1.12109375,
0.5341796875,
-0.410400390625,
0.3798828125,
-0.93212890625,
0.1865234375,
0.291259765625,
-0.041748046875,
-0.025726318359375,
-0.798828125,
0.82470703125,
0.310791015625,
-0.310546875,
0.87890625,
0.61962890625,
-0.5634765625,
0.51123046875,
-0.18359375,
-0.0243072509765625,
-0.36962890625,
0.658203125,
0.923828125,
-0.71240234375,
-0.319580078125,
-0.14404296875,
0.75146484375,
0.447509765625,
0.90478515625,
0.1575927734375,
-0.5615234375,
-0.157470703125
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Submitted Solution:
```
I = lambda: list(map(int, input().split()))
s = input()
for i in range(1, len(s)):
if s[:i]*(len(s)//i)==s:
print(len(s)//i)
quit()
print(len(s))
```
No
| 70,357 | [
0.63427734375,
0.046295166015625,
-0.07977294921875,
0.360595703125,
-0.449462890625,
-0.398681640625,
-0.1756591796875,
0.035736083984375,
0.03790283203125,
0.8876953125,
1.0341796875,
-0.638671875,
0.1651611328125,
-0.90087890625,
-0.443359375,
-0.7724609375,
-0.70458984375,
-0.5888671875,
-0.703125,
-0.035888671875,
0.265625,
-0.3349609375,
-1.1787109375,
-0.5625,
-0.666015625,
1.13671875,
0.400390625,
-0.1624755859375,
1.0615234375,
1.2685546875,
-0.6240234375,
-0.5322265625,
0.53466796875,
-0.73779296875,
-0.237548828125,
-0.57568359375,
0.52001953125,
-0.499267578125,
-0.20751953125,
-0.8095703125,
-0.006732940673828125,
-0.6767578125,
0.57080078125,
-0.55615234375,
-1.2451171875,
-0.37353515625,
-0.426025390625,
-0.58837890625,
-0.1514892578125,
-0.6884765625,
0.277587890625,
-0.259765625,
0.673828125,
-0.388916015625,
0.40869140625,
0.23388671875,
-0.37158203125,
-0.286865234375,
-0.6259765625,
0.342529296875,
0.1239013671875,
0.125244140625,
-0.216064453125,
-0.732421875,
-0.492431640625,
0.2724609375,
0.025909423828125,
0.0188751220703125,
0.253662109375,
-0.720703125,
-0.455078125,
0.02178955078125,
-0.174560546875,
-0.2890625,
-0.387939453125,
-0.31103515625,
0.43505859375,
0.06597900390625,
-1.08203125,
0.89208984375,
-0.1829833984375,
1.0205078125,
0.18017578125,
0.453857421875,
-0.389892578125,
-0.469970703125,
0.28466796875,
0.29443359375,
0.208251953125,
-0.413818359375,
0.189453125,
0.333251953125,
-0.7822265625,
-0.04254150390625,
0.5595703125,
0.336181640625,
-0.06842041015625,
0.1376953125,
-0.08514404296875,
0.1339111328125,
0.947265625,
0.90185546875,
-0.55517578125,
1.220703125,
-0.376220703125,
-0.455078125,
0.1068115234375,
0.2257080078125,
-0.260498046875,
-0.336181640625,
-0.38330078125,
-0.1923828125,
0.4658203125,
0.185546875,
-0.25341796875,
0.85693359375,
0.0782470703125,
0.58935546875,
-0.509765625,
0.0279083251953125,
0.412353515625,
0.10284423828125,
0.317626953125,
-0.11480712890625,
0.61669921875,
-0.088623046875,
-0.873046875,
1.0146484375,
-0.7578125,
-0.0004887580871582031,
0.301025390625,
0.0648193359375,
-0.277587890625,
0.36279296875,
0.020050048828125,
1.0439453125,
-0.2462158203125,
0.81201171875,
0.452880859375,
-0.8232421875,
0.96435546875,
-0.0340576171875,
0.00928497314453125,
1.5556640625,
0.26416015625,
0.094970703125,
0.68798828125,
0.244140625,
-0.60498046875,
0.468505859375,
-1.0478515625,
0.6142578125,
0.2978515625,
0.17578125,
-0.65771484375,
0.09564208984375,
-0.4130859375,
0.6591796875,
0.1463623046875,
0.06256103515625,
-0.484375,
-0.01169586181640625,
-0.151611328125,
1.1591796875,
-0.6767578125,
0.90234375,
-0.300048828125,
-0.331787109375,
-0.2149658203125,
-0.69287109375,
0.0731201171875,
0.08685302734375,
-0.0269622802734375,
0.78564453125,
0.50439453125,
1.365234375,
1.095703125,
0.08251953125,
0.253173828125,
0.047210693359375,
-0.448486328125,
0.376708984375,
0.2161865234375,
0.8212890625,
0.6748046875,
0.337646484375,
-0.31201171875,
-0.08984375,
-0.244140625,
-0.71923828125,
-0.209716796875,
0.705078125,
-0.7744140625,
-0.043609619140625,
0.05169677734375,
0.263427734375,
-1.166015625,
-0.6513671875,
0.251220703125,
-0.9921875,
-0.1839599609375,
0.81396484375,
-0.166259765625,
0.73388671875,
-0.398193359375,
-0.455322265625,
0.50390625,
0.5478515625,
-0.54248046875,
0.229736328125,
0.1822509765625,
0.1097412109375,
-0.22216796875,
-0.2401123046875,
0.60888671875,
-0.13232421875,
-1.0185546875,
0.50146484375,
-0.1724853515625,
-0.46826171875,
0.1878662109375,
0.982421875,
0.34814453125,
0.37890625,
-0.495361328125,
-0.290771484375,
0.3212890625,
1.388671875,
0.12646484375,
0.90771484375,
0.40234375,
0.9111328125,
0.21875,
0.70263671875,
0.29345703125,
0.033721923828125,
0.423095703125,
0.90625,
0.0452880859375,
0.140625,
0.054901123046875,
0.39306640625,
0.7529296875,
0.62939453125,
0.0889892578125,
0.78271484375,
-0.174560546875,
-0.257080078125,
-0.466064453125,
0.425048828125,
-0.33984375,
0.7099609375,
0.31591796875,
0.439453125,
-0.28369140625,
-0.269287109375,
0.56103515625,
0.689453125,
-0.32958984375,
-0.6259765625,
-0.091552734375,
0.1572265625,
0.2445068359375,
0.0921630859375,
0.55615234375,
0.357666015625,
0.54345703125,
0.50537109375,
-0.267822265625,
-0.447998046875,
-0.677734375,
-1.0751953125,
-1.02734375,
-0.258056640625,
-0.7333984375,
-0.019195556640625,
-0.0865478515625,
-0.69140625,
0.74560546875,
-0.304931640625,
-0.39599609375,
-0.07073974609375,
-0.7646484375,
0.86474609375,
-0.337890625,
0.71435546875,
-0.84228515625,
0.1605224609375,
-0.18310546875,
0.90234375,
-0.591796875,
-0.04681396484375,
-0.256103515625,
-0.37060546875,
0.328857421875,
0.16357421875,
0.54443359375,
-0.01312255859375,
-0.6142578125,
-0.63720703125,
-0.314208984375,
0.0877685546875,
-0.373291015625,
0.0221099853515625,
-0.460693359375,
1.0703125,
0.47021484375,
-0.57568359375,
0.92236328125,
1.173828125,
-1.0576171875,
0.400146484375,
0.1800537109375,
0.478271484375,
-0.72998046875,
1.3515625,
0.70947265625,
0.3193359375,
-0.35205078125,
-0.390869140625,
-0.77685546875,
0.195556640625,
0.08978271484375,
-0.373779296875,
-0.70263671875,
0.473388671875,
0.1497802734375,
-1.2041015625,
0.59375,
-1.17578125,
-0.92041015625,
-0.1370849609375,
-0.347412109375,
0.87939453125,
0.86962890625,
0.03240966796875,
-0.18359375,
-0.315673828125,
-0.454345703125,
0.60986328125,
0.4013671875,
-0.44580078125,
0.32763671875,
0.7021484375,
0.369384765625,
0.0714111328125,
0.345703125,
-0.54638671875,
-0.361328125,
0.177734375,
0.153076171875,
0.56103515625,
0.2388916015625,
0.595703125,
0.10577392578125,
0.822265625,
-0.85693359375,
-0.55712890625,
-0.2347412109375,
0.61962890625,
0.31494140625,
0.384521484375,
0.0257110595703125,
-0.36962890625,
-0.56396484375,
-0.50439453125,
0.479736328125,
0.1300048828125,
0.6826171875,
-0.4677734375,
0.78857421875,
0.13330078125,
-0.673828125,
0.537109375,
-0.53515625,
-0.0806884765625,
0.962890625,
-0.4619140625,
0.74658203125,
-0.51513671875,
0.26708984375,
-0.08795166015625,
-0.0176544189453125,
0.58349609375,
0.39599609375,
0.61962890625,
-0.52734375,
-0.1927490234375,
0.015533447265625,
-0.066650390625,
-0.216796875,
-0.65576171875,
0.28125,
-0.271240234375,
-0.31396484375,
-1.2314453125,
0.5751953125,
0.791015625,
0.53955078125,
0.0111083984375,
0.63623046875,
0.053863525390625,
0.2388916015625,
0.54931640625,
-0.483154296875,
-0.033355712890625,
-0.75830078125,
0.72509765625,
-0.0235595703125,
-0.54248046875,
-0.77880859375,
-0.2183837890625,
-0.51806640625,
-0.07672119140625,
0.16015625,
0.1214599609375,
-0.8056640625,
0.279541015625,
-0.048004150390625,
0.68896484375,
-0.5078125,
-0.2281494140625,
-0.5498046875,
0.31787109375,
0.3916015625,
-0.8603515625,
0.546875,
-0.9326171875,
0.63330078125,
0.541015625,
0.05078125,
-0.76953125,
-0.180908203125,
-0.97119140625,
-0.67333984375,
-0.1025390625,
0.6220703125,
-0.09368896484375,
0.301513671875,
-0.96728515625,
0.486328125,
0.12396240234375,
-0.58251953125,
0.252685546875,
0.2373046875,
0.426513671875,
-0.003986358642578125,
0.365966796875,
-0.1690673828125,
-0.78369140625,
0.341552734375,
-0.83642578125,
0.787109375,
-0.38671875,
0.3876953125,
-0.1346435546875,
-0.03277587890625,
0.2666015625,
0.34619140625,
-0.2841796875,
0.1746826171875,
-0.1427001953125,
0.5185546875,
-0.93798828125,
-0.7822265625,
0.50830078125,
-0.385986328125,
0.034210205078125,
0.703125,
-0.3076171875,
-0.3984375,
0.277587890625,
0.05963134765625,
-0.48095703125,
0.2293701171875,
-0.3505859375,
0.70263671875,
-0.07855224609375,
-0.59423828125,
-0.1651611328125,
-0.58154296875,
0.77734375,
-0.201904296875,
-0.8046875,
-0.329833984375,
-1.3740234375,
-0.005889892578125,
-0.38720703125,
-0.212158203125,
0.476318359375,
0.393310546875,
-0.42578125,
-0.269775390625,
-0.124267578125,
-0.41015625,
-0.380615234375,
-0.6494140625,
-0.177734375,
-0.2454833984375,
0.2178955078125,
0.91748046875,
-0.259765625,
-0.345947265625,
-0.10369873046875,
-0.2529296875,
0.1328125,
-0.515625,
-0.51318359375,
-0.354736328125,
-0.435546875,
-0.31494140625,
0.59765625,
-0.229248046875,
0.206298828125,
1.0546875,
0.204833984375,
0.1966552734375,
0.1602783203125,
-0.5263671875,
1.1064453125,
0.1622314453125,
-1.16796875,
-0.1646728515625,
0.76953125,
-0.08721923828125,
0.65673828125,
-0.19091796875,
-0.28759765625,
-0.406494140625,
-0.80419921875,
0.4150390625,
-0.66748046875,
0.10260009765625,
-0.638671875,
-0.351318359375,
-0.18994140625,
0.359130859375,
-0.187744140625,
-0.36962890625,
-0.0638427734375,
-1.150390625,
0.292724609375,
-0.60107421875,
-0.35498046875,
-0.5986328125,
-0.642578125,
-0.6435546875,
0.837890625,
0.265380859375,
0.4404296875,
0.0382080078125,
-0.277099609375,
0.432373046875,
-0.1312255859375,
-0.80078125,
-0.059600830078125,
0.237060546875,
0.3046875,
-0.21240234375,
-0.1651611328125,
-0.630859375,
0.9697265625,
-0.60009765625,
0.31396484375,
-0.451904296875,
-0.52734375,
0.1842041015625,
0.039947509765625,
0.9208984375,
-0.298583984375,
0.0004565715789794922,
-0.79638671875,
0.4365234375,
0.7177734375,
0.1280517578125,
-0.423583984375,
-0.716796875,
-0.291259765625,
-1.4326171875,
0.6328125,
-0.36572265625,
0.650390625,
-0.398681640625,
-0.2403564453125,
0.58154296875,
-0.58837890625,
0.56494140625,
1.21484375,
0.17919921875,
0.50146484375,
-0.44775390625,
0.96728515625,
0.6171875,
-0.6220703125,
-0.49609375,
0.270263671875,
-0.50927734375,
0.261962890625,
-0.05499267578125,
-0.93212890625,
-0.2484130859375,
0.6103515625,
1.2783203125,
-0.10479736328125,
0.85791015625,
-0.275390625,
-0.99267578125,
-0.6806640625,
0.7373046875,
0.0743408203125,
0.473388671875,
1.1318359375,
0.2021484375,
-0.286865234375,
0.4453125,
0.0687255859375,
-0.477783203125,
-0.261962890625,
1.1201171875,
-0.1807861328125,
-0.81103515625,
0.63818359375,
0.78369140625,
-1.083984375,
-0.89794921875,
-0.331298828125,
-0.1243896484375,
-0.32470703125,
-0.5224609375,
0.27099609375,
-0.07049560546875,
-0.458740234375,
0.0638427734375,
0.25927734375,
-0.59765625,
0.43994140625,
-0.10772705078125,
-0.15625,
-0.82275390625,
0.226318359375,
0.78173828125,
-0.363037109375,
-0.3583984375,
-0.82080078125,
0.0288238525390625,
-0.345458984375,
-0.043853759765625,
0.5517578125,
-0.79052734375,
0.14013671875,
0.25634765625,
-0.240234375,
0.775390625,
-0.6328125,
-0.2333984375,
0.03765869140625,
-0.39013671875,
-0.63671875,
-0.158203125,
-0.0618896484375,
-0.0728759765625,
0.343017578125,
-0.5205078125,
-0.6201171875,
0.4677734375,
-0.03057861328125,
-0.3359375,
-0.7626953125,
-0.03411865234375,
-1.2060546875,
-0.9130859375,
-0.428466796875,
-0.6171875,
0.0028171539306640625,
0.296630859375,
0.22998046875,
-0.50927734375,
0.000762939453125,
0.66552734375,
-0.54296875,
0.5009765625,
-0.43115234375,
0.1424560546875,
-0.65234375,
-0.25634765625,
-0.50341796875,
-0.2177734375,
-0.406494140625,
-0.44921875,
-0.420166015625,
0.54296875,
-0.349853515625,
0.28125,
-0.03411865234375,
0.25146484375,
-0.295654296875,
-0.6123046875,
0.1734619140625,
0.265869140625,
-0.202880859375,
0.6162109375,
0.60107421875,
0.16796875,
0.6240234375,
-0.349365234375,
-0.53564453125,
-0.58544921875,
0.70361328125,
0.404052734375,
-0.34228515625,
-0.318115234375,
-0.03082275390625,
0.05450439453125,
-1.23046875,
0.2081298828125,
-0.30078125,
0.29833984375,
0.321533203125,
-0.305908203125,
0.208740234375,
1.013671875,
0.114013671875,
0.5068359375,
0.2498779296875,
0.1920166015625,
0.07989501953125,
0.1341552734375,
0.1611328125,
0.73974609375,
-0.1767578125,
-0.299560546875,
0.2744140625,
0.8076171875,
0.1634521484375,
0.27685546875,
-0.45556640625,
-0.673828125,
-0.732421875,
0.10345458984375,
-0.2386474609375,
0.5166015625,
0.21875,
-0.892578125,
0.13818359375,
-0.142822265625,
-0.45654296875,
0.15283203125,
-1.3408203125,
-0.84033203125,
0.49267578125,
-0.18310546875,
-0.31103515625,
-0.2391357421875,
-0.4775390625,
-0.338134765625,
-0.17529296875,
0.55517578125,
-0.53759765625,
0.410400390625,
-0.11529541015625,
0.5771484375,
-0.1834716796875,
0.30517578125,
0.0196533203125,
0.6416015625,
-0.62841796875,
-0.640625,
0.256591796875,
1.12890625,
0.10107421875,
0.2548828125,
-0.351806640625,
0.292724609375,
-0.1484375,
-0.0304107666015625,
-0.2626953125,
0.252197265625,
-0.436767578125,
0.73583984375,
-0.87255859375,
0.1436767578125,
0.0784912109375,
0.93310546875,
0.0142822265625,
-0.65771484375,
-0.70556640625,
0.90673828125,
0.5986328125,
-0.15625,
0.412109375,
0.49560546875,
0.642578125,
-0.436767578125,
-0.234130859375,
-0.325439453125,
0.5859375,
0.80859375,
0.61181640625,
-0.236083984375,
0.2578125,
0.7451171875,
0.139892578125,
-0.036102294921875,
0.5986328125,
0.248779296875,
-0.1722412109375,
0.2109375,
-0.40478515625,
-0.098388671875,
-0.188232421875,
-0.438720703125,
0.55810546875,
-0.09954833984375,
0.072509765625,
-0.11810302734375,
-1.00390625,
0.8125,
-0.204345703125,
-0.07073974609375,
0.2266845703125,
-0.284912109375,
0.314697265625,
0.57080078125,
-0.16064453125,
-0.1337890625,
0.693359375,
0.96435546875,
0.85986328125,
0.37255859375,
0.80322265625,
0.139892578125,
-0.76220703125,
0.424560546875,
0.1243896484375,
-0.154541015625,
-0.47119140625,
-0.38916015625,
-1.2880859375,
0.66162109375,
-0.432861328125,
-0.238525390625,
0.27880859375,
-0.403076171875,
0.51220703125,
-0.85546875,
0.90234375,
-0.65380859375,
-0.09033203125,
0.481201171875,
-0.2281494140625,
-0.921875,
0.9306640625,
-0.61083984375,
0.05621337890625,
0.63134765625,
1.025390625,
0.41845703125,
1.03515625,
0.458984375,
-0.25830078125,
0.052642822265625,
0.2410888671875,
-0.1727294921875,
-0.434814453125,
-0.251708984375,
-0.50634765625,
0.05804443359375,
-0.5361328125,
-0.355224609375,
-0.1307373046875,
0.716796875,
-0.0703125,
-0.7109375,
-0.316162109375,
-0.10272216796875,
-0.875,
0.42626953125,
0.576171875,
0.0304718017578125,
0.505859375,
0.2259521484375,
-0.276123046875,
-0.55419921875,
0.11456298828125,
-0.44091796875,
0.39208984375,
-0.7744140625,
-0.4599609375,
-0.88525390625,
-0.39794921875,
0.0264892578125,
-0.169677734375,
-0.371337890625,
-1.1025390625,
0.71728515625,
0.61279296875,
0.47216796875,
0.04345703125,
-0.54443359375,
0.1405029296875,
1.1611328125,
0.74951171875,
0.119873046875,
0.467041015625,
0.47607421875,
-0.00811767578125,
0.269287109375,
-0.461181640625,
0.6484375,
-0.267578125,
0.007354736328125,
-0.62841796875,
-0.1966552734375,
-0.49853515625,
-1.3720703125,
0.10687255859375,
0.355712890625,
0.5087890625,
-0.7841796875,
-1.111328125,
-0.65625,
-0.97998046875,
-0.285888671875,
-0.541015625,
0.9765625,
-0.082275390625,
-0.205322265625,
-0.0143585205078125,
-1.123046875,
4.328125,
0.81640625,
0.74755859375,
-0.1630859375,
0.298583984375,
1.0771484375,
0.421630859375,
-0.50439453125,
-0.314697265625,
-0.583984375,
0.38330078125,
-0.33203125,
-0.03741455078125,
0.83349609375,
0.169677734375,
0.51708984375,
-0.5673828125,
0.177001953125,
-0.05426025390625,
-0.89697265625,
-0.85595703125,
0.26708984375,
0.29541015625,
0.7666015625,
-0.1025390625,
0.240966796875,
0.0914306640625,
-0.6279296875,
-0.464599609375,
-0.3671875,
0.045989990234375,
-0.2197265625,
0.87060546875,
-0.018280029296875,
-0.1427001953125,
0.81689453125,
0.06524658203125,
-0.66015625,
-0.041748046875,
0.276123046875,
-0.0079498291015625,
-0.212158203125,
0.46923828125,
-0.34765625,
-0.371337890625,
0.9169921875,
-0.7734375,
0.322998046875,
0.482177734375,
-0.8203125,
0.771484375,
-0.08135986328125,
0.76318359375,
-0.44873046875,
-0.389892578125,
0.1419677734375,
-0.1588134765625,
-0.347412109375,
-0.77197265625,
0.72216796875,
0.4072265625,
0.276123046875,
0.489013671875,
0.59814453125,
-1.1015625,
0.6171875,
-0.394287109375,
0.413818359375,
-0.93701171875,
0.24267578125,
0.283935546875,
-0.08355712890625,
0.06536865234375,
-0.75341796875,
0.8046875,
0.284912109375,
-0.274658203125,
0.84716796875,
0.61328125,
-0.55419921875,
0.52099609375,
-0.225830078125,
-0.07379150390625,
-0.40673828125,
0.62109375,
0.87939453125,
-0.62109375,
-0.3037109375,
-0.13525390625,
0.6904296875,
0.498779296875,
0.888671875,
0.1846923828125,
-0.62060546875,
-0.1678466796875
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Submitted Solution:
```
def distinct(mystr):
if mystr is None:
return 0
st = set(mystr)
return len(st)
print(distinct(str(input())))
```
No
| 70,358 | [
0.56787109375,
0.021148681640625,
-0.1240234375,
0.36572265625,
-0.470458984375,
-0.405517578125,
-0.2188720703125,
0.029022216796875,
0.08465576171875,
0.84423828125,
1.046875,
-0.646484375,
0.2313232421875,
-0.90380859375,
-0.50927734375,
-0.7724609375,
-0.76220703125,
-0.6044921875,
-0.77880859375,
-0.0239410400390625,
0.2147216796875,
-0.3388671875,
-1.2373046875,
-0.59228515625,
-0.69384765625,
1.123046875,
0.3955078125,
-0.1529541015625,
1.0908203125,
1.3056640625,
-0.5947265625,
-0.53515625,
0.44384765625,
-0.748046875,
-0.2568359375,
-0.57373046875,
0.492431640625,
-0.50537109375,
-0.2476806640625,
-0.77001953125,
-0.037322998046875,
-0.7001953125,
0.60498046875,
-0.52099609375,
-1.296875,
-0.3671875,
-0.44677734375,
-0.61474609375,
-0.1632080078125,
-0.66455078125,
0.310791015625,
-0.28759765625,
0.681640625,
-0.361328125,
0.484375,
0.2071533203125,
-0.43115234375,
-0.281005859375,
-0.607421875,
0.313232421875,
0.0985107421875,
0.12188720703125,
-0.27099609375,
-0.7236328125,
-0.505859375,
0.277099609375,
0.043701171875,
-0.0038394927978515625,
0.259033203125,
-0.69873046875,
-0.425537109375,
0.031463623046875,
-0.1885986328125,
-0.30126953125,
-0.398681640625,
-0.350830078125,
0.51416015625,
0.10809326171875,
-1.10546875,
0.8359375,
-0.1263427734375,
1.0166015625,
0.2254638671875,
0.383056640625,
-0.3515625,
-0.52197265625,
0.203369140625,
0.298583984375,
0.1976318359375,
-0.4130859375,
0.19873046875,
0.3583984375,
-0.82470703125,
-0.07049560546875,
0.61962890625,
0.315673828125,
-0.0723876953125,
0.1959228515625,
-0.11083984375,
0.08697509765625,
0.96240234375,
0.91357421875,
-0.5380859375,
1.1884765625,
-0.322265625,
-0.53173828125,
0.1488037109375,
0.2462158203125,
-0.1947021484375,
-0.373779296875,
-0.3359375,
-0.1888427734375,
0.4873046875,
0.1710205078125,
-0.2490234375,
0.9482421875,
0.0272674560546875,
0.61572265625,
-0.494140625,
0.06256103515625,
0.458740234375,
0.0928955078125,
0.302001953125,
-0.11773681640625,
0.6484375,
-0.0643310546875,
-0.85791015625,
1.001953125,
-0.73046875,
0.10321044921875,
0.3232421875,
0.08795166015625,
-0.30126953125,
0.366455078125,
0.0670166015625,
1.044921875,
-0.2919921875,
0.78076171875,
0.42529296875,
-0.84912109375,
0.9755859375,
0.0099029541015625,
0.0153350830078125,
1.576171875,
0.338134765625,
0.0728759765625,
0.681640625,
0.2169189453125,
-0.5751953125,
0.46630859375,
-1.052734375,
0.6396484375,
0.27734375,
0.1385498046875,
-0.650390625,
0.05950927734375,
-0.405517578125,
0.6865234375,
0.126220703125,
0.1097412109375,
-0.5634765625,
-0.030029296875,
-0.0987548828125,
1.1669921875,
-0.65966796875,
0.94287109375,
-0.304931640625,
-0.2978515625,
-0.20458984375,
-0.69287109375,
0.10748291015625,
0.162841796875,
-0.01444244384765625,
0.77197265625,
0.434814453125,
1.4208984375,
1.0498046875,
0.107666015625,
0.236572265625,
0.0172576904296875,
-0.407470703125,
0.37255859375,
0.22900390625,
0.787109375,
0.67529296875,
0.295654296875,
-0.37158203125,
-0.1268310546875,
-0.279296875,
-0.7314453125,
-0.197021484375,
0.64306640625,
-0.76953125,
-0.097412109375,
0.0263671875,
0.2069091796875,
-1.1435546875,
-0.66552734375,
0.26806640625,
-1.009765625,
-0.196044921875,
0.869140625,
-0.095947265625,
0.794921875,
-0.341064453125,
-0.41796875,
0.5205078125,
0.59619140625,
-0.525390625,
0.185546875,
0.1627197265625,
0.13623046875,
-0.2374267578125,
-0.226806640625,
0.64453125,
-0.169677734375,
-0.96484375,
0.42919921875,
-0.13818359375,
-0.45947265625,
0.2198486328125,
0.95361328125,
0.291259765625,
0.32177734375,
-0.50634765625,
-0.2958984375,
0.355712890625,
1.412109375,
0.09490966796875,
0.9365234375,
0.386962890625,
0.9013671875,
0.3125,
0.71337890625,
0.2236328125,
0.082763671875,
0.402099609375,
0.89501953125,
0.0924072265625,
0.1011962890625,
0.0731201171875,
0.321044921875,
0.71044921875,
0.62255859375,
0.10101318359375,
0.83447265625,
-0.1502685546875,
-0.2386474609375,
-0.470458984375,
0.475830078125,
-0.32470703125,
0.689453125,
0.311279296875,
0.44140625,
-0.2242431640625,
-0.29833984375,
0.57666015625,
0.66943359375,
-0.366943359375,
-0.6064453125,
-0.10589599609375,
0.1390380859375,
0.251220703125,
0.1053466796875,
0.572265625,
0.353515625,
0.5322265625,
0.505859375,
-0.262451171875,
-0.42529296875,
-0.68896484375,
-1.0888671875,
-1.033203125,
-0.292724609375,
-0.75390625,
-0.03289794921875,
-0.08123779296875,
-0.646484375,
0.7607421875,
-0.279052734375,
-0.40576171875,
-0.09075927734375,
-0.82275390625,
0.8095703125,
-0.377685546875,
0.72314453125,
-0.8076171875,
0.142822265625,
-0.1912841796875,
0.92626953125,
-0.5615234375,
-0.037567138671875,
-0.290771484375,
-0.421875,
0.3076171875,
0.1456298828125,
0.53564453125,
-0.102294921875,
-0.56103515625,
-0.5859375,
-0.28564453125,
0.033905029296875,
-0.395263671875,
-0.0206298828125,
-0.4541015625,
1.0205078125,
0.4521484375,
-0.556640625,
0.908203125,
1.1728515625,
-1.0830078125,
0.437744140625,
0.1668701171875,
0.470458984375,
-0.7216796875,
1.396484375,
0.7236328125,
0.3291015625,
-0.344482421875,
-0.404296875,
-0.81005859375,
0.179443359375,
0.061676025390625,
-0.3681640625,
-0.7060546875,
0.447021484375,
0.09765625,
-1.25390625,
0.61279296875,
-1.2158203125,
-0.8876953125,
-0.1561279296875,
-0.3017578125,
0.86767578125,
0.8056640625,
0.0220489501953125,
-0.220947265625,
-0.386962890625,
-0.4521484375,
0.57421875,
0.356689453125,
-0.43359375,
0.320556640625,
0.681640625,
0.322021484375,
0.07763671875,
0.365478515625,
-0.62158203125,
-0.377197265625,
0.1724853515625,
0.2479248046875,
0.5888671875,
0.302490234375,
0.58642578125,
0.10491943359375,
0.7685546875,
-0.87939453125,
-0.56884765625,
-0.191650390625,
0.6611328125,
0.360107421875,
0.42333984375,
0.06719970703125,
-0.360595703125,
-0.54736328125,
-0.55029296875,
0.498046875,
0.08880615234375,
0.6845703125,
-0.450927734375,
0.78515625,
0.176025390625,
-0.67822265625,
0.55126953125,
-0.52392578125,
-0.150146484375,
0.98388671875,
-0.488037109375,
0.7734375,
-0.494873046875,
0.24267578125,
-0.05120849609375,
-0.0203094482421875,
0.63671875,
0.400146484375,
0.63916015625,
-0.54931640625,
-0.251953125,
0.0933837890625,
-0.0350341796875,
-0.18701171875,
-0.72265625,
0.282470703125,
-0.2330322265625,
-0.3291015625,
-1.2421875,
0.5908203125,
0.76123046875,
0.462890625,
-0.0726318359375,
0.66748046875,
0.0584716796875,
0.1845703125,
0.53125,
-0.58154296875,
-0.0181427001953125,
-0.7900390625,
0.7080078125,
-0.0225372314453125,
-0.5263671875,
-0.84326171875,
-0.26123046875,
-0.50048828125,
-0.058929443359375,
0.260498046875,
0.11962890625,
-0.82275390625,
0.29638671875,
-0.029052734375,
0.6328125,
-0.55712890625,
-0.25244140625,
-0.57470703125,
0.3134765625,
0.375244140625,
-0.8896484375,
0.5126953125,
-0.97216796875,
0.6767578125,
0.57861328125,
0.0626220703125,
-0.7529296875,
-0.1497802734375,
-0.91552734375,
-0.62939453125,
-0.1263427734375,
0.63330078125,
-0.09521484375,
0.33837890625,
-0.990234375,
0.49267578125,
0.08001708984375,
-0.5517578125,
0.280517578125,
0.26611328125,
0.4716796875,
-0.043121337890625,
0.369384765625,
-0.1829833984375,
-0.7939453125,
0.366455078125,
-0.84375,
0.8388671875,
-0.4013671875,
0.374755859375,
-0.14111328125,
-0.002696990966796875,
0.271728515625,
0.369140625,
-0.2274169921875,
0.2352294921875,
-0.10723876953125,
0.52880859375,
-0.94140625,
-0.79296875,
0.58056640625,
-0.435791015625,
0.00954437255859375,
0.70947265625,
-0.282470703125,
-0.3818359375,
0.318359375,
0.05682373046875,
-0.5087890625,
0.2298583984375,
-0.3544921875,
0.689453125,
-0.023590087890625,
-0.63427734375,
-0.1690673828125,
-0.62060546875,
0.7802734375,
-0.1959228515625,
-0.82275390625,
-0.42724609375,
-1.4130859375,
-0.07904052734375,
-0.436279296875,
-0.187255859375,
0.46484375,
0.364013671875,
-0.401123046875,
-0.243896484375,
-0.152099609375,
-0.439453125,
-0.3525390625,
-0.6162109375,
-0.193603515625,
-0.22607421875,
0.243408203125,
0.92138671875,
-0.263671875,
-0.38720703125,
-0.059906005859375,
-0.23291015625,
0.11724853515625,
-0.501953125,
-0.58642578125,
-0.306884765625,
-0.423095703125,
-0.308349609375,
0.595703125,
-0.2457275390625,
0.197021484375,
1.0048828125,
0.1553955078125,
0.1895751953125,
0.1455078125,
-0.5419921875,
1.109375,
0.152587890625,
-1.1806640625,
-0.1715087890625,
0.77783203125,
-0.04962158203125,
0.68994140625,
-0.25390625,
-0.30322265625,
-0.35791015625,
-0.75927734375,
0.43896484375,
-0.6845703125,
0.1744384765625,
-0.595703125,
-0.332275390625,
-0.1708984375,
0.38134765625,
-0.1845703125,
-0.288818359375,
-0.036773681640625,
-1.087890625,
0.27734375,
-0.5673828125,
-0.36572265625,
-0.54345703125,
-0.67578125,
-0.703125,
0.85546875,
0.2279052734375,
0.440673828125,
0.0210113525390625,
-0.300048828125,
0.4775390625,
-0.20458984375,
-0.8017578125,
-0.02197265625,
0.2437744140625,
0.30615234375,
-0.2890625,
-0.22607421875,
-0.65234375,
0.9765625,
-0.6298828125,
0.29541015625,
-0.451416015625,
-0.495361328125,
0.1591796875,
0.0225372314453125,
0.87744140625,
-0.277099609375,
-0.0132293701171875,
-0.7890625,
0.46630859375,
0.79541015625,
0.2283935546875,
-0.413818359375,
-0.78271484375,
-0.302490234375,
-1.4287109375,
0.6357421875,
-0.323486328125,
0.74365234375,
-0.390380859375,
-0.205078125,
0.5751953125,
-0.55224609375,
0.51025390625,
1.212890625,
0.1959228515625,
0.458251953125,
-0.467529296875,
0.96875,
0.666015625,
-0.630859375,
-0.556640625,
0.309814453125,
-0.5634765625,
0.290771484375,
-0.06085205078125,
-0.9921875,
-0.2484130859375,
0.59521484375,
1.3076171875,
-0.086181640625,
0.7783203125,
-0.252685546875,
-1.0224609375,
-0.693359375,
0.76416015625,
0.0887451171875,
0.49609375,
1.1357421875,
0.1500244140625,
-0.357421875,
0.432861328125,
0.0394287109375,
-0.398193359375,
-0.2364501953125,
1.1513671875,
-0.1719970703125,
-0.85986328125,
0.64892578125,
0.77099609375,
-1.103515625,
-0.86279296875,
-0.358154296875,
-0.12030029296875,
-0.300048828125,
-0.51171875,
0.2978515625,
-0.03076171875,
-0.447998046875,
0.06610107421875,
0.312744140625,
-0.619140625,
0.45849609375,
-0.1259765625,
-0.2071533203125,
-0.841796875,
0.2880859375,
0.6904296875,
-0.3623046875,
-0.260986328125,
-0.7763671875,
0.056427001953125,
-0.382568359375,
-0.0406494140625,
0.469482421875,
-0.806640625,
0.15087890625,
0.20361328125,
-0.2359619140625,
0.78955078125,
-0.65380859375,
-0.208984375,
0.0445556640625,
-0.385009765625,
-0.6083984375,
-0.1953125,
-0.1273193359375,
-0.072998046875,
0.3447265625,
-0.47802734375,
-0.64111328125,
0.48193359375,
-0.042205810546875,
-0.30810546875,
-0.685546875,
-0.01456451416015625,
-1.1416015625,
-0.880859375,
-0.3837890625,
-0.630859375,
0.029876708984375,
0.317626953125,
0.2396240234375,
-0.45263671875,
0.007541656494140625,
0.611328125,
-0.55224609375,
0.478271484375,
-0.45751953125,
0.2227783203125,
-0.6796875,
-0.2445068359375,
-0.481201171875,
-0.254638671875,
-0.44580078125,
-0.448974609375,
-0.38232421875,
0.58349609375,
-0.33740234375,
0.242919921875,
-0.05242919921875,
0.21923828125,
-0.303955078125,
-0.623046875,
0.2222900390625,
0.29833984375,
-0.21923828125,
0.58837890625,
0.60888671875,
0.2200927734375,
0.65234375,
-0.32666015625,
-0.65380859375,
-0.5986328125,
0.66357421875,
0.45068359375,
-0.227294921875,
-0.3125,
-0.005428314208984375,
0.1297607421875,
-1.197265625,
0.21826171875,
-0.35009765625,
0.2440185546875,
0.366943359375,
-0.310546875,
0.1871337890625,
0.994140625,
0.193115234375,
0.480224609375,
0.301513671875,
0.13232421875,
0.0989990234375,
0.129150390625,
0.1561279296875,
0.75439453125,
-0.232421875,
-0.289306640625,
0.316650390625,
0.93017578125,
0.1435546875,
0.28466796875,
-0.432861328125,
-0.6650390625,
-0.7080078125,
0.10821533203125,
-0.20703125,
0.497802734375,
0.174072265625,
-0.8076171875,
0.152099609375,
-0.1480712890625,
-0.43994140625,
0.1737060546875,
-1.3271484375,
-0.79248046875,
0.498046875,
-0.132080078125,
-0.30078125,
-0.27783203125,
-0.469970703125,
-0.328125,
-0.17822265625,
0.496826171875,
-0.490234375,
0.418701171875,
-0.1416015625,
0.5927734375,
-0.1591796875,
0.367919921875,
0.0278778076171875,
0.61376953125,
-0.68408203125,
-0.6474609375,
0.3935546875,
1.134765625,
0.06396484375,
0.256103515625,
-0.353759765625,
0.317626953125,
-0.146484375,
-0.057464599609375,
-0.28173828125,
0.24365234375,
-0.427490234375,
0.68212890625,
-0.888671875,
0.1363525390625,
0.11529541015625,
1.0205078125,
-0.010223388671875,
-0.6982421875,
-0.70263671875,
0.9208984375,
0.5537109375,
-0.15625,
0.41015625,
0.50634765625,
0.626953125,
-0.4462890625,
-0.20947265625,
-0.328857421875,
0.58349609375,
0.8349609375,
0.59423828125,
-0.2919921875,
0.285888671875,
0.76025390625,
0.146728515625,
-0.01093292236328125,
0.6474609375,
0.28515625,
-0.1585693359375,
0.1829833984375,
-0.351806640625,
-0.09539794921875,
-0.1787109375,
-0.44775390625,
0.55810546875,
-0.053192138671875,
0.083251953125,
-0.12322998046875,
-1.0244140625,
0.81005859375,
-0.17578125,
-0.08685302734375,
0.240234375,
-0.2332763671875,
0.2120361328125,
0.625,
-0.1435546875,
-0.1619873046875,
0.7421875,
0.92724609375,
0.81591796875,
0.447509765625,
0.79443359375,
0.1226806640625,
-0.720703125,
0.459228515625,
0.11541748046875,
-0.1678466796875,
-0.53955078125,
-0.41455078125,
-1.2490234375,
0.607421875,
-0.45361328125,
-0.213134765625,
0.269775390625,
-0.43017578125,
0.5302734375,
-0.87158203125,
0.84912109375,
-0.677734375,
-0.1427001953125,
0.5087890625,
-0.2056884765625,
-0.9580078125,
0.9580078125,
-0.66015625,
0.041473388671875,
0.6435546875,
1.013671875,
0.41650390625,
1.134765625,
0.447998046875,
-0.299072265625,
0.050201416015625,
0.34033203125,
-0.1524658203125,
-0.50537109375,
-0.265869140625,
-0.478271484375,
0.070068359375,
-0.53564453125,
-0.3935546875,
-0.1170654296875,
0.76513671875,
-0.045806884765625,
-0.7138671875,
-0.393798828125,
-0.10235595703125,
-0.853515625,
0.431396484375,
0.5625,
0.043121337890625,
0.49462890625,
0.240966796875,
-0.3193359375,
-0.6083984375,
0.0601806640625,
-0.439697265625,
0.4443359375,
-0.716796875,
-0.468505859375,
-0.83203125,
-0.41357421875,
-0.01132965087890625,
-0.15966796875,
-0.42919921875,
-1.1396484375,
0.7548828125,
0.61767578125,
0.486083984375,
0.0248870849609375,
-0.48681640625,
0.18701171875,
1.1572265625,
0.73095703125,
0.063232421875,
0.460205078125,
0.498291015625,
0.0271453857421875,
0.316650390625,
-0.443359375,
0.6572265625,
-0.305908203125,
-0.03411865234375,
-0.67724609375,
-0.1881103515625,
-0.43603515625,
-1.3974609375,
0.09796142578125,
0.3720703125,
0.5009765625,
-0.7978515625,
-1.0810546875,
-0.56103515625,
-0.9501953125,
-0.30029296875,
-0.5341796875,
0.92236328125,
-0.10540771484375,
-0.1932373046875,
-0.032562255859375,
-1.1689453125,
4.296875,
0.82861328125,
0.681640625,
-0.27294921875,
0.27490234375,
1.1044921875,
0.450927734375,
-0.50048828125,
-0.31787109375,
-0.6181640625,
0.412109375,
-0.3642578125,
-0.0611572265625,
0.78759765625,
0.11376953125,
0.58837890625,
-0.57568359375,
0.1846923828125,
-0.0400390625,
-0.93310546875,
-0.81591796875,
0.302001953125,
0.28564453125,
0.765625,
-0.1552734375,
0.2841796875,
0.08056640625,
-0.6376953125,
-0.423095703125,
-0.352294921875,
0.04693603515625,
-0.190185546875,
0.875,
-0.00797271728515625,
-0.146240234375,
0.83251953125,
0.051177978515625,
-0.658203125,
-0.0887451171875,
0.301025390625,
0.060302734375,
-0.2386474609375,
0.4736328125,
-0.3662109375,
-0.40478515625,
0.912109375,
-0.78369140625,
0.222900390625,
0.53515625,
-0.78662109375,
0.83544921875,
-0.11578369140625,
0.7265625,
-0.48681640625,
-0.428466796875,
0.1737060546875,
-0.1845703125,
-0.45849609375,
-0.7666015625,
0.68798828125,
0.397705078125,
0.218505859375,
0.57666015625,
0.55908203125,
-1.072265625,
0.67236328125,
-0.364990234375,
0.435302734375,
-0.89501953125,
0.23486328125,
0.341064453125,
-0.086181640625,
0.0350341796875,
-0.7197265625,
0.85107421875,
0.32958984375,
-0.24755859375,
0.8662109375,
0.6162109375,
-0.5888671875,
0.481689453125,
-0.2423095703125,
-0.0604248046875,
-0.398681640625,
0.67333984375,
0.88720703125,
-0.583984375,
-0.367431640625,
-0.148681640625,
0.64013671875,
0.471923828125,
0.94677734375,
0.1292724609375,
-0.64306640625,
-0.130859375
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and moves the last character of the word to the beginning of the word. He calls this a cyclic shift. He can apply cyclic shift many times. For example, consecutively applying cyclic shift operation to the word "abracadabra" Hongcow will get words "aabracadabr", "raabracadab" and so on.
Hongcow is now wondering how many distinct words he can generate by doing the cyclic shift arbitrarily many times. The initial string is also counted.
Input
The first line of input will be a single string s (1 ≤ |s| ≤ 50), the word Hongcow initially learns how to spell. The string s consists only of lowercase English letters ('a'–'z').
Output
Output a single integer equal to the number of distinct strings that Hongcow can obtain by applying the cyclic shift arbitrarily many times to the given string.
Examples
Input
abcd
Output
4
Input
bbb
Output
1
Input
yzyz
Output
2
Note
For the first sample, the strings Hongcow can generate are "abcd", "dabc", "cdab", and "bcda".
For the second sample, no matter how many times Hongcow does the cyclic shift, Hongcow can only generate "bbb".
For the third sample, the two strings Hongcow can generate are "yzyz" and "zyzy".
Submitted Solution:
```
def main():
# strin = input()
strin = "ysysysysyys"
new = strin
if len(set(list(strin))) == 1:
print(1)
else:
lis = [strin]
for i in range(0,len(strin)-1):
# print(new)
last = new[len(strin)-1]
new = last+new;
new = new[0:len(new)-1]
# new.replace(new[len(new)-1],'')
lis.append(new)
# print("for loop ended",i)
set_s = set(lis)
print(len(set_s))
main()
```
No
| 70,359 | [
0.6044921875,
0.05633544921875,
-0.06781005859375,
0.3046875,
-0.472900390625,
-0.431884765625,
-0.192626953125,
0.031463623046875,
0.06396484375,
0.89013671875,
1.046875,
-0.6435546875,
0.163818359375,
-0.87890625,
-0.467041015625,
-0.7509765625,
-0.72705078125,
-0.619140625,
-0.72900390625,
-0.0498046875,
0.239501953125,
-0.321533203125,
-1.220703125,
-0.5986328125,
-0.689453125,
1.0927734375,
0.418701171875,
-0.150390625,
1.05859375,
1.271484375,
-0.640625,
-0.537109375,
0.46728515625,
-0.73046875,
-0.266845703125,
-0.5576171875,
0.5361328125,
-0.53076171875,
-0.1959228515625,
-0.81005859375,
-0.01203155517578125,
-0.640625,
0.56396484375,
-0.626953125,
-1.2587890625,
-0.384033203125,
-0.39404296875,
-0.611328125,
-0.1910400390625,
-0.64453125,
0.31787109375,
-0.25927734375,
0.66650390625,
-0.39794921875,
0.425048828125,
0.2169189453125,
-0.39453125,
-0.269775390625,
-0.623046875,
0.341796875,
0.0941162109375,
0.147216796875,
-0.2342529296875,
-0.7685546875,
-0.4775390625,
0.26953125,
0.057891845703125,
0.04010009765625,
0.2470703125,
-0.7265625,
-0.47216796875,
0.06890869140625,
-0.12939453125,
-0.29931640625,
-0.395263671875,
-0.28515625,
0.4833984375,
0.07293701171875,
-1.109375,
0.86376953125,
-0.203857421875,
1.015625,
0.173828125,
0.4423828125,
-0.398193359375,
-0.470458984375,
0.260498046875,
0.264404296875,
0.196533203125,
-0.43359375,
0.1884765625,
0.314453125,
-0.80517578125,
-0.10101318359375,
0.537109375,
0.37890625,
-0.0906982421875,
0.1300048828125,
-0.119873046875,
0.0692138671875,
0.9501953125,
0.93017578125,
-0.55712890625,
1.169921875,
-0.34619140625,
-0.44580078125,
0.1395263671875,
0.2139892578125,
-0.226318359375,
-0.38623046875,
-0.363037109375,
-0.1883544921875,
0.466796875,
0.1927490234375,
-0.2169189453125,
0.90380859375,
0.07940673828125,
0.57568359375,
-0.499267578125,
0.049957275390625,
0.406494140625,
0.04949951171875,
0.3056640625,
-0.1185302734375,
0.6357421875,
-0.0755615234375,
-0.79052734375,
0.9638671875,
-0.72705078125,
0.0195465087890625,
0.35107421875,
0.006870269775390625,
-0.319091796875,
0.37646484375,
0.00652313232421875,
1.080078125,
-0.2529296875,
0.8017578125,
0.498291015625,
-0.83349609375,
0.94384765625,
-0.0697021484375,
-0.00634002685546875,
1.580078125,
0.30810546875,
0.1024169921875,
0.66552734375,
0.2188720703125,
-0.5751953125,
0.474365234375,
-1.0390625,
0.62109375,
0.30322265625,
0.177978515625,
-0.61865234375,
0.0745849609375,
-0.426513671875,
0.658203125,
0.12744140625,
0.044219970703125,
-0.456298828125,
0.0234832763671875,
-0.09808349609375,
1.18359375,
-0.66552734375,
0.888671875,
-0.33203125,
-0.349853515625,
-0.2420654296875,
-0.666015625,
0.071533203125,
0.13525390625,
-0.0063629150390625,
0.76708984375,
0.47802734375,
1.3857421875,
1.0869140625,
0.099609375,
0.193115234375,
0.054443359375,
-0.43798828125,
0.403564453125,
0.2017822265625,
0.8291015625,
0.70947265625,
0.336669921875,
-0.3125,
-0.121826171875,
-0.255126953125,
-0.7001953125,
-0.1531982421875,
0.685546875,
-0.77294921875,
-0.01302337646484375,
0.068115234375,
0.27490234375,
-1.140625,
-0.67431640625,
0.299072265625,
-0.98681640625,
-0.161865234375,
0.80419921875,
-0.1585693359375,
0.72900390625,
-0.3564453125,
-0.4169921875,
0.533203125,
0.5791015625,
-0.509765625,
0.2354736328125,
0.1595458984375,
0.099853515625,
-0.25244140625,
-0.175537109375,
0.60009765625,
-0.1539306640625,
-1.0283203125,
0.49755859375,
-0.11285400390625,
-0.459716796875,
0.231689453125,
0.9658203125,
0.34912109375,
0.36328125,
-0.52783203125,
-0.32958984375,
0.3115234375,
1.3857421875,
0.11505126953125,
0.92236328125,
0.380615234375,
0.92626953125,
0.200927734375,
0.71142578125,
0.239013671875,
0.03228759765625,
0.434814453125,
0.90673828125,
0.01326751708984375,
0.1495361328125,
0.05181884765625,
0.3271484375,
0.76220703125,
0.626953125,
0.044036865234375,
0.755859375,
-0.1575927734375,
-0.25732421875,
-0.458740234375,
0.427978515625,
-0.3271484375,
0.73193359375,
0.31103515625,
0.430908203125,
-0.30224609375,
-0.326171875,
0.57373046875,
0.65283203125,
-0.329345703125,
-0.666015625,
-0.05224609375,
0.1822509765625,
0.2137451171875,
0.11138916015625,
0.54443359375,
0.355712890625,
0.4921875,
0.47314453125,
-0.285888671875,
-0.498291015625,
-0.68310546875,
-1.0908203125,
-1.0625,
-0.250732421875,
-0.72900390625,
-0.068359375,
-0.05511474609375,
-0.70947265625,
0.744140625,
-0.3037109375,
-0.38330078125,
-0.08203125,
-0.7744140625,
0.8564453125,
-0.338623046875,
0.72021484375,
-0.83349609375,
0.15869140625,
-0.1810302734375,
0.92626953125,
-0.546875,
-0.05731201171875,
-0.269775390625,
-0.38525390625,
0.340576171875,
0.149658203125,
0.5869140625,
-0.0189361572265625,
-0.552734375,
-0.6494140625,
-0.291259765625,
0.035888671875,
-0.412841796875,
0.0462646484375,
-0.46484375,
1.0693359375,
0.474853515625,
-0.58642578125,
0.87646484375,
1.1640625,
-1.0595703125,
0.414306640625,
0.192138671875,
0.40673828125,
-0.73193359375,
1.361328125,
0.7080078125,
0.29931640625,
-0.312255859375,
-0.426513671875,
-0.80859375,
0.16552734375,
0.061614990234375,
-0.348876953125,
-0.68896484375,
0.465576171875,
0.1591796875,
-1.2255859375,
0.57666015625,
-1.24609375,
-0.92431640625,
-0.12646484375,
-0.307373046875,
0.84912109375,
0.837890625,
0.01140594482421875,
-0.1949462890625,
-0.352294921875,
-0.41064453125,
0.6630859375,
0.394775390625,
-0.434326171875,
0.34423828125,
0.7236328125,
0.373779296875,
0.0225982666015625,
0.39306640625,
-0.59033203125,
-0.353759765625,
0.166748046875,
0.21044921875,
0.55029296875,
0.2489013671875,
0.6142578125,
0.1129150390625,
0.77734375,
-0.865234375,
-0.56591796875,
-0.2176513671875,
0.60498046875,
0.332275390625,
0.3359375,
0.052520751953125,
-0.373046875,
-0.5390625,
-0.51953125,
0.49267578125,
0.101318359375,
0.70068359375,
-0.39794921875,
0.8095703125,
0.1192626953125,
-0.63818359375,
0.53125,
-0.544921875,
-0.1790771484375,
0.99072265625,
-0.44482421875,
0.7744140625,
-0.51123046875,
0.240234375,
-0.0498046875,
-0.029998779296875,
0.59521484375,
0.335693359375,
0.65234375,
-0.53369140625,
-0.2432861328125,
0.01256561279296875,
-0.07452392578125,
-0.23046875,
-0.71240234375,
0.27685546875,
-0.278564453125,
-0.328125,
-1.2236328125,
0.58544921875,
0.81298828125,
0.5341796875,
-0.01739501953125,
0.64111328125,
0.05157470703125,
0.255126953125,
0.5244140625,
-0.53369140625,
-0.07122802734375,
-0.78466796875,
0.7421875,
0.00667572021484375,
-0.48291015625,
-0.81298828125,
-0.1976318359375,
-0.56298828125,
-0.06951904296875,
0.2100830078125,
0.13916015625,
-0.8251953125,
0.259033203125,
-0.0601806640625,
0.5947265625,
-0.482666015625,
-0.2025146484375,
-0.5556640625,
0.30615234375,
0.42626953125,
-0.8798828125,
0.49853515625,
-0.9970703125,
0.64208984375,
0.55419921875,
0.0438232421875,
-0.7548828125,
-0.1710205078125,
-0.9326171875,
-0.62451171875,
-0.126953125,
0.5986328125,
-0.07696533203125,
0.3271484375,
-0.951171875,
0.432373046875,
0.09490966796875,
-0.58154296875,
0.284423828125,
0.25341796875,
0.420166015625,
-0.0025501251220703125,
0.375732421875,
-0.1627197265625,
-0.75048828125,
0.32568359375,
-0.85693359375,
0.84375,
-0.4248046875,
0.410888671875,
-0.14306640625,
-0.04742431640625,
0.295654296875,
0.3779296875,
-0.28125,
0.1778564453125,
-0.10418701171875,
0.50634765625,
-0.931640625,
-0.82861328125,
0.537109375,
-0.40234375,
0.00080108642578125,
0.6767578125,
-0.294189453125,
-0.43115234375,
0.26416015625,
0.08062744140625,
-0.47705078125,
0.2052001953125,
-0.401123046875,
0.6748046875,
-0.08935546875,
-0.6376953125,
-0.146484375,
-0.55810546875,
0.76025390625,
-0.2125244140625,
-0.80859375,
-0.346923828125,
-1.4072265625,
0.01016998291015625,
-0.400146484375,
-0.169921875,
0.50390625,
0.40625,
-0.4345703125,
-0.317626953125,
-0.2010498046875,
-0.38525390625,
-0.336181640625,
-0.64404296875,
-0.183349609375,
-0.224609375,
0.22119140625,
0.9072265625,
-0.28955078125,
-0.383544921875,
-0.0640869140625,
-0.29296875,
0.15966796875,
-0.46826171875,
-0.53955078125,
-0.366455078125,
-0.441162109375,
-0.322509765625,
0.58447265625,
-0.236083984375,
0.225830078125,
1.083984375,
0.2239990234375,
0.132568359375,
0.1785888671875,
-0.52880859375,
1.09765625,
0.12445068359375,
-1.158203125,
-0.1514892578125,
0.74267578125,
-0.08404541015625,
0.64404296875,
-0.217529296875,
-0.3046875,
-0.421142578125,
-0.7578125,
0.407470703125,
-0.6962890625,
0.1063232421875,
-0.640625,
-0.33447265625,
-0.1990966796875,
0.360595703125,
-0.2279052734375,
-0.449951171875,
-0.050201416015625,
-1.16796875,
0.260498046875,
-0.5703125,
-0.347412109375,
-0.61328125,
-0.69287109375,
-0.6552734375,
0.83203125,
0.252197265625,
0.431884765625,
0.0599365234375,
-0.250244140625,
0.479248046875,
-0.11334228515625,
-0.7998046875,
0.01397705078125,
0.3046875,
0.35498046875,
-0.255615234375,
-0.1710205078125,
-0.6357421875,
0.9560546875,
-0.62158203125,
0.314697265625,
-0.427734375,
-0.51904296875,
0.1759033203125,
0.051422119140625,
0.91259765625,
-0.3271484375,
-0.0234375,
-0.77294921875,
0.487060546875,
0.7734375,
0.1744384765625,
-0.429931640625,
-0.705078125,
-0.272216796875,
-1.3740234375,
0.61376953125,
-0.37158203125,
0.66357421875,
-0.390869140625,
-0.253173828125,
0.58447265625,
-0.60986328125,
0.5146484375,
1.232421875,
0.2110595703125,
0.5,
-0.509765625,
0.96044921875,
0.623046875,
-0.62353515625,
-0.50830078125,
0.28173828125,
-0.5263671875,
0.277587890625,
-0.0556640625,
-0.951171875,
-0.29833984375,
0.59619140625,
1.2998046875,
-0.0955810546875,
0.85986328125,
-0.290283203125,
-0.9697265625,
-0.66162109375,
0.7783203125,
0.07891845703125,
0.47412109375,
1.1474609375,
0.228271484375,
-0.268310546875,
0.431884765625,
0.0298919677734375,
-0.47265625,
-0.24560546875,
1.1513671875,
-0.129638671875,
-0.81494140625,
0.64013671875,
0.79150390625,
-1.1328125,
-0.896484375,
-0.292724609375,
-0.1422119140625,
-0.31591796875,
-0.53759765625,
0.24462890625,
-0.0806884765625,
-0.429931640625,
0.068603515625,
0.31982421875,
-0.5966796875,
0.463134765625,
-0.08966064453125,
-0.18505859375,
-0.85546875,
0.25146484375,
0.75830078125,
-0.349365234375,
-0.308349609375,
-0.82568359375,
0.034271240234375,
-0.347412109375,
-0.041534423828125,
0.51220703125,
-0.7724609375,
0.15625,
0.27294921875,
-0.259765625,
0.8388671875,
-0.654296875,
-0.1890869140625,
0.04095458984375,
-0.35009765625,
-0.68115234375,
-0.2353515625,
-0.0849609375,
-0.088623046875,
0.341796875,
-0.490478515625,
-0.65625,
0.466796875,
-0.00848388671875,
-0.342529296875,
-0.732421875,
-0.05889892578125,
-1.162109375,
-0.91064453125,
-0.406005859375,
-0.60546875,
0.01529693603515625,
0.285400390625,
0.22509765625,
-0.46337890625,
-0.027374267578125,
0.6279296875,
-0.54052734375,
0.4716796875,
-0.3974609375,
0.1824951171875,
-0.66259765625,
-0.258544921875,
-0.51220703125,
-0.2252197265625,
-0.472412109375,
-0.47119140625,
-0.369140625,
0.515625,
-0.3466796875,
0.264404296875,
-0.008087158203125,
0.227783203125,
-0.3017578125,
-0.576171875,
0.2032470703125,
0.298583984375,
-0.2021484375,
0.61669921875,
0.63134765625,
0.1572265625,
0.67724609375,
-0.361083984375,
-0.56689453125,
-0.6142578125,
0.6865234375,
0.4423828125,
-0.322265625,
-0.3037109375,
-0.030029296875,
0.07696533203125,
-1.2216796875,
0.2421875,
-0.341552734375,
0.349365234375,
0.38427734375,
-0.301513671875,
0.1978759765625,
0.9619140625,
0.1842041015625,
0.5,
0.2332763671875,
0.19580078125,
0.060211181640625,
0.10760498046875,
0.10791015625,
0.78466796875,
-0.1591796875,
-0.2939453125,
0.315185546875,
0.8408203125,
0.13232421875,
0.30126953125,
-0.484619140625,
-0.6181640625,
-0.6962890625,
0.135498046875,
-0.2578125,
0.5234375,
0.25927734375,
-0.87890625,
0.140380859375,
-0.12078857421875,
-0.479736328125,
0.2073974609375,
-1.2958984375,
-0.83740234375,
0.46337890625,
-0.186767578125,
-0.285400390625,
-0.25537109375,
-0.45947265625,
-0.30615234375,
-0.2003173828125,
0.51318359375,
-0.55859375,
0.395751953125,
-0.106201171875,
0.61962890625,
-0.2037353515625,
0.362060546875,
0.035003662109375,
0.5986328125,
-0.61767578125,
-0.69775390625,
0.26416015625,
1.115234375,
0.07232666015625,
0.2109375,
-0.326904296875,
0.3466796875,
-0.14404296875,
0.006206512451171875,
-0.237060546875,
0.263916015625,
-0.4638671875,
0.7177734375,
-0.86474609375,
0.13671875,
0.08123779296875,
0.97119140625,
0.00878143310546875,
-0.7197265625,
-0.70361328125,
0.9111328125,
0.5947265625,
-0.1676025390625,
0.40673828125,
0.51025390625,
0.66552734375,
-0.42919921875,
-0.2435302734375,
-0.3505859375,
0.56591796875,
0.8203125,
0.615234375,
-0.2286376953125,
0.2705078125,
0.75341796875,
0.1341552734375,
-0.03997802734375,
0.5703125,
0.25341796875,
-0.1925048828125,
0.2315673828125,
-0.385009765625,
-0.085205078125,
-0.1715087890625,
-0.418212890625,
0.56103515625,
-0.09356689453125,
0.0689697265625,
-0.1788330078125,
-0.9951171875,
0.814453125,
-0.199462890625,
-0.0672607421875,
0.2822265625,
-0.3203125,
0.298583984375,
0.56884765625,
-0.1641845703125,
-0.10711669921875,
0.67724609375,
0.9072265625,
0.853515625,
0.4091796875,
0.81201171875,
0.1793212890625,
-0.6953125,
0.4599609375,
0.08673095703125,
-0.16015625,
-0.498046875,
-0.387451171875,
-1.267578125,
0.611328125,
-0.4521484375,
-0.22998046875,
0.305908203125,
-0.42138671875,
0.54638671875,
-0.87841796875,
0.87255859375,
-0.646484375,
-0.09808349609375,
0.54296875,
-0.2081298828125,
-0.94287109375,
0.9892578125,
-0.62939453125,
0.10345458984375,
0.59814453125,
1.0380859375,
0.457763671875,
1.056640625,
0.46240234375,
-0.27001953125,
0.0767822265625,
0.26220703125,
-0.207763671875,
-0.44775390625,
-0.2149658203125,
-0.448974609375,
0.036773681640625,
-0.54638671875,
-0.356689453125,
-0.1551513671875,
0.70654296875,
-0.09747314453125,
-0.7333984375,
-0.293701171875,
-0.08343505859375,
-0.82470703125,
0.427001953125,
0.57373046875,
0.059722900390625,
0.4755859375,
0.2003173828125,
-0.2783203125,
-0.587890625,
0.097900390625,
-0.420166015625,
0.459716796875,
-0.736328125,
-0.410400390625,
-0.875,
-0.373046875,
-0.01532745361328125,
-0.15869140625,
-0.3935546875,
-1.078125,
0.75,
0.59130859375,
0.53564453125,
0.0518798828125,
-0.53857421875,
0.156494140625,
1.1806640625,
0.78125,
0.1190185546875,
0.474365234375,
0.50830078125,
-0.028717041015625,
0.271484375,
-0.42724609375,
0.62548828125,
-0.3271484375,
-0.037750244140625,
-0.626953125,
-0.2232666015625,
-0.46630859375,
-1.4013671875,
0.0921630859375,
0.381103515625,
0.47021484375,
-0.73046875,
-1.126953125,
-0.5888671875,
-1.015625,
-0.27587890625,
-0.54296875,
0.9375,
-0.05682373046875,
-0.1851806640625,
0.0091705322265625,
-1.111328125,
4.31640625,
0.857421875,
0.7529296875,
-0.1905517578125,
0.27734375,
1.1171875,
0.413330078125,
-0.5048828125,
-0.352294921875,
-0.60888671875,
0.412109375,
-0.353271484375,
-0.046051025390625,
0.771484375,
0.1502685546875,
0.55126953125,
-0.60400390625,
0.1334228515625,
-0.0645751953125,
-0.89501953125,
-0.82763671875,
0.259765625,
0.286376953125,
0.759765625,
-0.1009521484375,
0.26123046875,
0.0867919921875,
-0.67041015625,
-0.4755859375,
-0.3359375,
0.00507354736328125,
-0.205322265625,
0.85107421875,
0.0143585205078125,
-0.174560546875,
0.8271484375,
0.06256103515625,
-0.67529296875,
-0.034210205078125,
0.301025390625,
0.007110595703125,
-0.2139892578125,
0.447265625,
-0.31103515625,
-0.380615234375,
0.951171875,
-0.7216796875,
0.302001953125,
0.49072265625,
-0.787109375,
0.8427734375,
-0.07501220703125,
0.70654296875,
-0.46484375,
-0.39208984375,
0.147216796875,
-0.142333984375,
-0.38671875,
-0.73974609375,
0.6865234375,
0.367919921875,
0.258056640625,
0.48779296875,
0.5732421875,
-1.1025390625,
0.6240234375,
-0.39794921875,
0.428955078125,
-0.9365234375,
0.2420654296875,
0.2958984375,
-0.08099365234375,
0.037353515625,
-0.69677734375,
0.84326171875,
0.29345703125,
-0.279296875,
0.8369140625,
0.62548828125,
-0.57568359375,
0.50927734375,
-0.24609375,
-0.0845947265625,
-0.412841796875,
0.60205078125,
0.90966796875,
-0.5888671875,
-0.304931640625,
-0.1087646484375,
0.69580078125,
0.474609375,
0.9580078125,
0.159912109375,
-0.61767578125,
-0.1546630859375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Tags: greedy
Correct Solution:
```
######################################################
############Created by Devesh Kumar###################
#############devesh1102@gmail.com####################
##########For CodeForces(Devesh1102)#################
#####################2020#############################
######################################################
import sys
input = sys.stdin.readline
# import sys
import heapq
import copy
import math
import decimal
# import sys.stdout.flush as flush
# from decimal import *
#heapq.heapify(li)
#
#heapq.heappush(li,4)
#
#heapq.heappop(li)
#
# & Bitwise AND Operator 10 & 7 = 2
# | Bitwise OR Operator 10 | 7 = 15
# ^ Bitwise XOR Operator 10 ^ 7 = 13
# << Bitwise Left Shift operator 10<<2 = 40
# >> Bitwise Right Shift Operator
# '''############ ---- Input Functions ---- #######Start#####'''
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def insr2():
s = input()
return((s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
############ ---- Input Functions ---- #######End
# #####
def pr_list(a):
print(*a, sep=" ")
def main():
# tests = inp()
tests = 1
mod = 998244353
limit = 10**18
ans = 0
for test in range(tests):
s = insr()
n = len(s)
k = inp()
forbid = [[0 for i in range(26)] for j in range(26)]
for i in range(k):
a = insr()
forbid[ord(a[0]) - ord('a')][ord(a[1]) - ord('a')] = 1
forbid[ord(a[1]) - ord('a')][ord(a[0]) - ord('a')] = 1
dp = [sys.maxsize for i in range(26)]
dp[ord(s[0]) - ord('a')] = 0
for i in range(1,n):
# print(dp)
mini = sys.maxsize
for j in range(26):
if dp[j] != sys.maxsize and forbid[j][ord(s[i]) - ord('a')]!=1:
mini = min(mini,dp[j])
for j in range(26):
if dp[j]!= sys.maxsize:
dp[j] = dp[j] +1
dp[ord(s[i]) - ord('a')] = min(mini,i)
# print(dp)
print(min(dp))
if __name__== "__main__":
main()
```
| 70,993 | [
0.291015625,
-0.05596923828125,
0.1292724609375,
0.284912109375,
-0.5634765625,
-0.67431640625,
0.14208984375,
-0.12200927734375,
-0.189208984375,
0.90283203125,
0.8505859375,
-0.01378631591796875,
-0.3876953125,
-0.91552734375,
-0.935546875,
-0.12841796875,
-0.91455078125,
-0.58349609375,
-0.53955078125,
-0.1390380859375,
0.0859375,
-0.15283203125,
-1.6376953125,
-0.293212890625,
-0.37158203125,
1.2021484375,
0.3583984375,
-0.2958984375,
1.162109375,
0.75048828125,
-0.26318359375,
-0.338623046875,
0.5576171875,
-1.1689453125,
-0.6259765625,
-0.51220703125,
0.9462890625,
-0.467041015625,
0.007476806640625,
-0.064208984375,
0.66064453125,
-0.251953125,
0.473388671875,
-0.5341796875,
-1.2958984375,
-0.35791015625,
-0.126953125,
-0.61376953125,
-0.3544921875,
-0.40869140625,
0.332275390625,
-0.334228515625,
0.62109375,
-0.220947265625,
0.07373046875,
0.156494140625,
0.2384033203125,
0.08428955078125,
-0.693359375,
0.411376953125,
0.134765625,
0.374755859375,
0.1448974609375,
-0.75634765625,
-0.421875,
-0.107666015625,
-0.309814453125,
0.202392578125,
-0.00026702880859375,
-0.61181640625,
-0.241455078125,
0.4931640625,
-0.3916015625,
-0.330078125,
-0.673828125,
0.0330810546875,
0.2467041015625,
0.093994140625,
-0.56689453125,
0.8388671875,
0.36865234375,
1.013671875,
0.77001953125,
-0.10443115234375,
-0.35009765625,
-0.129150390625,
0.00772857666015625,
0.378662109375,
0.423828125,
-0.2183837890625,
-0.1893310546875,
0.541015625,
-1.03515625,
-0.166748046875,
0.5908203125,
0.40576171875,
-0.28515625,
0.283447265625,
0.45751953125,
0.44873046875,
0.89892578125,
0.58349609375,
-0.34912109375,
0.82958984375,
-0.5546875,
0.16162109375,
0.0953369140625,
0.1873779296875,
-0.05413818359375,
0.25927734375,
-0.31201171875,
-0.08892822265625,
0.486083984375,
0.458984375,
-0.6806640625,
0.76953125,
-0.276123046875,
0.3896484375,
-0.8388671875,
0.281494140625,
0.7314453125,
-0.06927490234375,
0.84912109375,
0.044891357421875,
0.1920166015625,
-0.2216796875,
-0.6083984375,
1.0673828125,
-0.433837890625,
-0.021942138671875,
0.49365234375,
0.0227508544921875,
-0.06689453125,
0.2044677734375,
-0.32080078125,
0.8076171875,
-0.287353515625,
0.6162109375,
0.55419921875,
-0.6220703125,
0.492431640625,
-0.2286376953125,
-0.053070068359375,
1.4287109375,
0.708984375,
-0.06097412109375,
0.78515625,
0.42822265625,
-0.92724609375,
0.1619873046875,
-1.3056640625,
0.8525390625,
0.14013671875,
0.117919921875,
-0.53369140625,
-0.1455078125,
-0.2314453125,
0.157958984375,
0.06756591796875,
0.2060546875,
-0.46826171875,
0.1510009765625,
-0.310302734375,
0.62744140625,
-0.2587890625,
1.0556640625,
-0.6728515625,
0.01007080078125,
-0.142333984375,
-0.5966796875,
0.19921875,
-0.040008544921875,
0.11669921875,
1.0732421875,
0.1568603515625,
0.8330078125,
0.56884765625,
-0.344482421875,
0.64306640625,
0.4794921875,
-0.10455322265625,
0.48046875,
0.1812744140625,
0.324462890625,
0.521484375,
0.298583984375,
-0.15625,
-0.415283203125,
-0.84716796875,
-0.375,
-0.0113525390625,
0.65673828125,
-0.37353515625,
0.341064453125,
0.047698974609375,
-0.0391845703125,
-1.0478515625,
-0.32666015625,
0.18408203125,
-1.0986328125,
-0.5546875,
0.90283203125,
0.14599609375,
0.74658203125,
-0.202392578125,
-0.626953125,
0.64892578125,
1.4775390625,
-0.3173828125,
0.278564453125,
0.6513671875,
-0.58935546875,
-0.345947265625,
0.45751953125,
-0.1702880859375,
-0.179931640625,
-0.85400390625,
0.72412109375,
-0.53466796875,
-0.0231475830078125,
-0.2080078125,
0.266357421875,
0.2763671875,
0.66015625,
-0.1806640625,
-0.3349609375,
0.84765625,
1.12890625,
0.0369873046875,
0.50390625,
0.197998046875,
0.7021484375,
0.1204833984375,
0.71240234375,
0.412841796875,
0.1494140625,
0.8486328125,
0.916015625,
0.2119140625,
0.52880859375,
-0.2252197265625,
0.44091796875,
0.1973876953125,
0.580078125,
0.440673828125,
0.29052734375,
-0.316162109375,
-0.038177490234375,
-0.3876953125,
0.09185791015625,
-0.252197265625,
0.32080078125,
0.431884765625,
0.432373046875,
-0.29443359375,
-0.13916015625,
0.2066650390625,
0.685546875,
-1.171875,
-0.45703125,
0.045135498046875,
0.1319580078125,
-0.0281219482421875,
0.00022304058074951172,
0.2379150390625,
0.77880859375,
0.70263671875,
0.328857421875,
-0.52783203125,
-0.52783203125,
-1.1328125,
-1.0107421875,
-0.86376953125,
-0.332275390625,
-0.82568359375,
-0.11688232421875,
0.634765625,
-1.0869140625,
0.482177734375,
-0.2861328125,
-0.5302734375,
0.1619873046875,
-0.578125,
0.6025390625,
-0.2027587890625,
0.80029296875,
-0.755859375,
0.73291015625,
0.034820556640625,
0.90234375,
-0.287841796875,
-0.3671875,
-0.047760009765625,
-0.61767578125,
0.251953125,
-0.0189208984375,
0.3017578125,
0.1771240234375,
-0.6533203125,
-0.7646484375,
0.032501220703125,
-0.308349609375,
-0.57861328125,
0.215087890625,
-0.7529296875,
0.7294921875,
0.93994140625,
-0.66845703125,
0.77392578125,
1.1220703125,
-0.94921875,
0.0287628173828125,
0.1856689453125,
0.2998046875,
-0.615234375,
1.189453125,
0.29052734375,
0.3974609375,
-0.5205078125,
-0.51220703125,
-0.755859375,
0.0966796875,
-0.03570556640625,
-0.354736328125,
-0.09564208984375,
0.75634765625,
-0.267333984375,
-0.994140625,
0.75341796875,
-1.1796875,
-0.10711669921875,
-0.1295166015625,
-0.489501953125,
0.95068359375,
0.342529296875,
0.354736328125,
-0.288330078125,
-0.818359375,
-0.25146484375,
0.82421875,
0.1776123046875,
-0.521484375,
-0.0372314453125,
0.2440185546875,
0.1773681640625,
0.150634765625,
0.12078857421875,
-0.232421875,
-0.3251953125,
0.070068359375,
0.221923828125,
0.92333984375,
0.2998046875,
0.3857421875,
0.365234375,
0.8486328125,
-0.6884765625,
-0.252685546875,
-0.270263671875,
0.720703125,
0.21337890625,
0.39697265625,
0.1611328125,
-0.24755859375,
-0.330078125,
-0.80615234375,
0.483642578125,
-0.295166015625,
0.763671875,
-0.5322265625,
0.6181640625,
0.383056640625,
-0.5263671875,
0.65966796875,
-0.89599609375,
-0.358154296875,
0.90283203125,
-0.6650390625,
0.95068359375,
-0.8916015625,
0.194580078125,
0.06884765625,
0.1278076171875,
0.701171875,
0.642578125,
0.7373046875,
-0.453125,
-0.60302734375,
-0.2890625,
0.278076171875,
-0.06378173828125,
-0.525390625,
0.144775390625,
-0.2440185546875,
-0.41455078125,
-0.89111328125,
0.41357421875,
0.86083984375,
0.57275390625,
0.3359375,
0.4248046875,
0.1689453125,
0.58740234375,
0.9111328125,
-0.0947265625,
-0.002368927001953125,
-0.7587890625,
1.0380859375,
-0.0124053955078125,
-0.480224609375,
-0.34765625,
-0.33544921875,
-0.312255859375,
0.323974609375,
0.018951416015625,
0.04071044921875,
-0.89208984375,
-0.170654296875,
-0.13720703125,
0.361572265625,
-0.73583984375,
-0.3095703125,
-0.189697265625,
0.425048828125,
0.08111572265625,
-1.017578125,
0.390380859375,
-0.6630859375,
0.927734375,
0.99169921875,
0.0635986328125,
-0.51708984375,
-0.149658203125,
-0.53955078125,
-0.86767578125,
-0.1142578125,
0.58154296875,
-0.12353515625,
0.2261962890625,
-1.2578125,
0.57958984375,
0.3349609375,
-0.088134765625,
0.28466796875,
0.193359375,
0.472900390625,
0.142578125,
0.5234375,
-0.6318359375,
-0.66357421875,
0.419189453125,
-1.1201171875,
0.763671875,
-0.611328125,
0.483154296875,
-0.154541015625,
0.1396484375,
0.1552734375,
0.4560546875,
-0.4775390625,
0.41357421875,
-0.0810546875,
0.3984375,
-1.01171875,
-0.65966796875,
0.51806640625,
-0.1829833984375,
-0.724609375,
0.546875,
0.25244140625,
-0.236083984375,
0.013427734375,
0.5927734375,
-0.466064453125,
0.4443359375,
-0.54736328125,
0.62451171875,
-0.116943359375,
-0.77294921875,
-0.2432861328125,
-0.470458984375,
0.68212890625,
-0.186279296875,
-0.7587890625,
0.220703125,
-1.15625,
-0.250732421875,
0.09710693359375,
-0.49755859375,
0.349365234375,
0.1513671875,
0.1280517578125,
0.09881591796875,
-0.49609375,
-0.36279296875,
-0.1741943359375,
-0.53564453125,
-0.51806640625,
0.337646484375,
0.58984375,
0.6943359375,
0.290283203125,
-0.10791015625,
0.1749267578125,
0.015655517578125,
-0.12200927734375,
-0.58447265625,
-0.354736328125,
0.213134765625,
-0.51220703125,
-0.1392822265625,
0.36181640625,
-0.0020809173583984375,
0.39697265625,
0.8720703125,
-0.055877685546875,
0.2276611328125,
0.348388671875,
-0.5146484375,
1.384765625,
-0.188720703125,
-1.0166015625,
-0.38427734375,
0.2420654296875,
0.060333251953125,
0.607421875,
-0.1727294921875,
-0.7978515625,
-0.6845703125,
-1.1015625,
0.08795166015625,
-0.5263671875,
-0.26171875,
-0.94287109375,
-0.1905517578125,
-0.51123046875,
0.7978515625,
-0.37744140625,
-0.2802734375,
0.340576171875,
-1.2001953125,
0.04998779296875,
-0.59619140625,
-0.41845703125,
-0.56201171875,
-0.5673828125,
-0.623046875,
1.09765625,
0.416015625,
0.1422119140625,
0.421142578125,
-0.34521484375,
0.24853515625,
-0.36669921875,
-0.609375,
-0.495849609375,
-0.280517578125,
0.376953125,
-0.355224609375,
-0.42138671875,
-0.625,
0.8857421875,
-0.54052734375,
0.206787109375,
-0.443603515625,
-0.5341796875,
-0.199462890625,
-0.240478515625,
0.7998046875,
-0.65283203125,
0.1392822265625,
-0.50439453125,
0.68212890625,
0.3701171875,
-0.302001953125,
-0.5234375,
-0.83447265625,
-0.6005859375,
-0.8583984375,
0.65087890625,
-0.552734375,
0.58935546875,
-0.69189453125,
-0.2587890625,
0.900390625,
-0.5205078125,
0.317138671875,
1.3330078125,
-0.2313232421875,
0.213623046875,
-0.84814453125,
0.677734375,
-0.0223541259765625,
-0.64453125,
-0.27685546875,
-0.07952880859375,
-0.9150390625,
0.0960693359375,
-0.63427734375,
-0.896484375,
-0.57373046875,
0.71044921875,
1.466796875,
-0.300537109375,
0.95556640625,
0.2305908203125,
-1.17578125,
-0.7919921875,
0.78857421875,
0.381591796875,
0.56640625,
1.1259765625,
-0.82177734375,
-0.1278076171875,
0.40673828125,
-0.07183837890625,
-0.26416015625,
-0.208984375,
1.056640625,
-0.491455078125,
-0.60302734375,
0.52783203125,
0.57568359375,
-1.111328125,
-0.5341796875,
0.07781982421875,
-0.00972747802734375,
-0.1356201171875,
-0.61669921875,
0.09686279296875,
0.63818359375,
-0.479736328125,
-0.10040283203125,
0.0250244140625,
0.04345703125,
0.634765625,
0.300048828125,
0.30419921875,
-0.51904296875,
0.64306640625,
0.80029296875,
-0.783203125,
-0.37890625,
-0.82958984375,
-0.18505859375,
-0.2322998046875,
0.37353515625,
0.81640625,
0.0882568359375,
0.2191162109375,
0.72021484375,
-0.08892822265625,
0.7138671875,
-0.38818359375,
-0.363037109375,
0.25048828125,
-0.492431640625,
-0.25927734375,
-0.01491546630859375,
0.183349609375,
0.1009521484375,
0.2156982421875,
-0.7021484375,
-0.06610107421875,
0.349853515625,
0.334716796875,
-0.08917236328125,
-0.045318603515625,
-0.325927734375,
-0.58935546875,
-0.413330078125,
-0.5380859375,
-0.765625,
-0.12188720703125,
0.429443359375,
0.367919921875,
-0.73876953125,
0.04022216796875,
0.8408203125,
-0.77880859375,
1.2099609375,
-0.7490234375,
0.325927734375,
-0.43994140625,
-0.09228515625,
-0.78466796875,
0.1318359375,
-0.41796875,
-0.27880859375,
-0.403564453125,
0.5419921875,
0.3779296875,
0.52734375,
-0.1343994140625,
0.1981201171875,
-0.173828125,
-0.81103515625,
-0.06646728515625,
0.049224853515625,
0.0947265625,
0.33251953125,
0.72021484375,
0.52099609375,
0.283203125,
-0.050048828125,
-0.61083984375,
-0.48095703125,
0.12432861328125,
0.94384765625,
0.0238494873046875,
-0.05615234375,
-0.412109375,
0.00319671630859375,
-0.6279296875,
0.261962890625,
-0.2861328125,
-0.09136962890625,
0.09783935546875,
-0.74853515625,
0.505859375,
1.26953125,
-0.09161376953125,
0.177978515625,
-0.0291900634765625,
0.2939453125,
0.386962890625,
0.1669921875,
0.341552734375,
0.1629638671875,
0.1240234375,
-0.2159423828125,
-0.158935546875,
0.6015625,
-0.01273345947265625,
0.4287109375,
-0.2010498046875,
-0.76806640625,
-0.7490234375,
-0.100341796875,
-0.27294921875,
0.042572021484375,
0.59619140625,
-0.8369140625,
-0.06622314453125,
0.087890625,
-0.95166015625,
0.1787109375,
-0.7529296875,
-0.84619140625,
0.0838623046875,
-0.133056640625,
-0.7958984375,
-0.493896484375,
-0.58740234375,
0.037139892578125,
0.1595458984375,
0.5478515625,
-0.7412109375,
0.295654296875,
-0.172119140625,
0.44287109375,
-0.215087890625,
-0.1334228515625,
0.1318359375,
0.291748046875,
-0.470703125,
-0.6533203125,
0.0771484375,
1.4853515625,
0.17919921875,
-0.34912109375,
-0.63037109375,
0.10302734375,
-0.42919921875,
0.3271484375,
-0.2034912109375,
-0.18896484375,
0.01824951171875,
0.435791015625,
-1.181640625,
-0.354248046875,
0.084716796875,
0.286376953125,
-0.021026611328125,
-0.3447265625,
-0.2130126953125,
0.68994140625,
0.982421875,
-0.1396484375,
-0.058502197265625,
0.408935546875,
0.79150390625,
-0.26220703125,
-0.127197265625,
-0.251708984375,
0.30224609375,
0.53076171875,
0.27490234375,
-0.2354736328125,
0.69873046875,
0.93798828125,
-0.33203125,
-0.2208251953125,
0.5380859375,
0.03131103515625,
-0.0085906982421875,
-0.241943359375,
-0.2291259765625,
0.040191650390625,
-0.06988525390625,
-0.84619140625,
0.172607421875,
-0.378662109375,
-0.333251953125,
-0.176513671875,
-0.70849609375,
0.98046875,
-1.1953125,
0.4619140625,
-0.26220703125,
-0.12158203125,
0.399169921875,
0.98046875,
0.05169677734375,
-0.056793212890625,
0.50390625,
0.341552734375,
0.58349609375,
0.8076171875,
0.208984375,
0.154541015625,
-0.3916015625,
0.146484375,
-0.0693359375,
0.006015777587890625,
-0.6806640625,
-0.28125,
-1.1416015625,
0.6298828125,
-0.399169921875,
-0.09930419921875,
0.433837890625,
-0.5341796875,
0.1962890625,
-0.284912109375,
0.7646484375,
-0.38037109375,
0.434814453125,
0.5458984375,
-0.57177734375,
-0.447509765625,
0.84423828125,
-0.1993408203125,
0.38232421875,
0.1937255859375,
0.73828125,
0.34814453125,
1.716796875,
0.32080078125,
-0.2578125,
-0.147705078125,
0.057220458984375,
-0.234375,
-0.60400390625,
-0.38916015625,
-0.37158203125,
-0.119140625,
-0.398193359375,
-0.22998046875,
0.0257110595703125,
0.6533203125,
0.0811767578125,
-0.80615234375,
-0.042236328125,
0.08184814453125,
-0.84521484375,
0.7734375,
0.261474609375,
0.02947998046875,
0.07269287109375,
0.08599853515625,
-0.14208984375,
-0.35009765625,
-0.185791015625,
-0.5927734375,
0.2236328125,
-0.5849609375,
-0.5380859375,
-0.609375,
-1.0380859375,
-0.375732421875,
-0.33203125,
-0.476318359375,
-1.0390625,
0.1490478515625,
0.65185546875,
0.40625,
0.5107421875,
-0.51611328125,
0.397705078125,
1.123046875,
0.71630859375,
-0.351806640625,
0.80810546875,
0.36474609375,
-0.525390625,
0.08441162109375,
-0.0052032470703125,
0.6953125,
-0.33837890625,
-0.0105133056640625,
-0.297607421875,
0.5234375,
-0.9794921875,
-1.3837890625,
0.06396484375,
0.6513671875,
0.50341796875,
-0.54345703125,
-0.9306640625,
-0.401123046875,
-0.74755859375,
-0.046600341796875,
-0.78271484375,
0.6123046875,
0.388671875,
-0.09393310546875,
0.0287017822265625,
-1.0283203125,
4.31640625,
1.0087890625,
0.94677734375,
0.07049560546875,
-0.028228759765625,
0.970703125,
-0.0012559890747070312,
-0.31884765625,
0.1610107421875,
-0.3154296875,
0.7646484375,
-0.215576171875,
-0.088134765625,
0.65087890625,
0.1949462890625,
0.453125,
-0.48486328125,
-0.0171356201171875,
-0.247314453125,
-0.990234375,
-0.7939453125,
0.0758056640625,
0.2432861328125,
0.165283203125,
0.08551025390625,
0.093017578125,
0.57080078125,
-0.626953125,
-0.29052734375,
-0.63525390625,
-0.28369140625,
-0.7109375,
0.666015625,
-0.0755615234375,
-0.1834716796875,
0.50732421875,
0.1470947265625,
-0.62744140625,
0.057891845703125,
0.55517578125,
-0.30810546875,
-0.44873046875,
0.86669921875,
-0.8212890625,
0.197998046875,
0.5556640625,
-0.294677734375,
0.279541015625,
0.62841796875,
-0.421142578125,
0.78076171875,
-0.2249755859375,
0.73193359375,
-0.73681640625,
-0.671875,
0.04107666015625,
0.2283935546875,
-0.33349609375,
0.03997802734375,
0.3427734375,
0.2381591796875,
0.1112060546875,
0.050140380859375,
0.38818359375,
-0.68896484375,
0.68212890625,
0.2008056640625,
0.19287109375,
-0.5341796875,
0.09197998046875,
0.018310546875,
-0.137939453125,
-0.4248046875,
-0.50244140625,
0.57275390625,
0.2161865234375,
-0.0219268798828125,
0.30810546875,
0.471435546875,
-0.78955078125,
0.0018644332885742188,
0.0350341796875,
-0.3779296875,
-0.31396484375,
0.5810546875,
1.5830078125,
-0.75439453125,
-0.423828125,
-0.53466796875,
0.6142578125,
0.183349609375,
0.2802734375,
0.60400390625,
-0.91357421875,
-0.25048828125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Tags: greedy
Correct Solution:
```
import sys
from math import gcd,sqrt,ceil,log2
from collections import defaultdict,Counter,deque
from bisect import bisect_left,bisect_right
import math
import heapq
from itertools import permutations
# input=sys.stdin.readline
# def print(x):
# sys.stdout.write(str(x)+"\n")
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# import sys
# import io, os
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
def get_sum(bit,i):
s = 0
i+=1
while i>0:
s+=bit[i]
i-=i&(-i)
return s
def update(bit,n,i,v):
i+=1
while i<=n:
bit[i]+=v
i+=i&(-i)
def modInverse(b,m):
g = math.gcd(b, m)
if (g != 1):
return -1
else:
return pow(b, m - 2, m)
def primeFactors(n):
sa = set()
sa.add(n)
while n % 2 == 0:
sa.add(2)
n = n // 2
for i in range(3,int(math.sqrt(n))+1,2):
while n % i== 0:
sa.add(i)
n = n // i
# sa.add(n)
return sa
def seive(n):
pri = [True]*(n+1)
p = 2
while p*p<=n:
if pri[p] == True:
for i in range(p*p,n+1,p):
pri[i] = False
p+=1
return pri
def check_prim(n):
if n<0:
return False
for i in range(2,int(sqrt(n))+1):
if n%i == 0:
return False
return True
def getZarr(string, z):
n = len(string)
# [L,R] make a window which matches
# with prefix of s
l, r, k = 0, 0, 0
for i in range(1, n):
# if i>R nothing matches so we will calculate.
# Z[i] using naive way.
if i > r:
l, r = i, i
# R-L = 0 in starting, so it will start
# checking from 0'th index. For example,
# for "ababab" and i = 1, the value of R
# remains 0 and Z[i] becomes 0. For string
# "aaaaaa" and i = 1, Z[i] and R become 5
while r < n and string[r - l] == string[r]:
r += 1
z[i] = r - l
r -= 1
else:
# k = i-L so k corresponds to number which
# matches in [L,R] interval.
k = i - l
# if Z[k] is less than remaining interval
# then Z[i] will be equal to Z[k].
# For example, str = "ababab", i = 3, R = 5
# and L = 2
if z[k] < r - i + 1:
z[i] = z[k]
# For example str = "aaaaaa" and i = 2,
# R is 5, L is 0
else:
# else start from R and check manually
l = i
while r < n and string[r - l] == string[r]:
r += 1
z[i] = r - l
r -= 1
def search(text, pattern):
# Create concatenated string "P$T"
concat = pattern + "$" + text
l = len(concat)
z = [0] * l
getZarr(concat, z)
ha = []
for i in range(l):
if z[i] == len(pattern):
ha.append(i - len(pattern) - 1)
return ha
# n,k = map(int,input().split())
# l = list(map(int,input().split()))
#
# n = int(input())
# l = list(map(int,input().split()))
#
# hash = defaultdict(list)
# la = []
#
# for i in range(n):
# la.append([l[i],i+1])
#
# la.sort(key = lambda x: (x[0],-x[1]))
# ans = []
# r = n
# flag = 0
# lo = []
# ha = [i for i in range(n,0,-1)]
# yo = []
# for a,b in la:
#
# if a == 1:
# ans.append([r,b])
# # hash[(1,1)].append([b,r])
# lo.append((r,b))
# ha.pop(0)
# yo.append([r,b])
# r-=1
#
# elif a == 2:
# # print(yo,lo)
# # print(hash[1,1])
# if lo == []:
# flag = 1
# break
# c,d = lo.pop(0)
# yo.pop(0)
# if b>=d:
# flag = 1
# break
# ans.append([c,b])
# yo.append([c,b])
#
#
#
# elif a == 3:
#
# if yo == []:
# flag = 1
# break
# c,d = yo.pop(0)
# if b>=d:
# flag = 1
# break
# if ha == []:
# flag = 1
# break
#
# ka = ha.pop(0)
#
# ans.append([ka,b])
# ans.append([ka,d])
# yo.append([ka,b])
#
# if flag:
# print(-1)
# else:
# print(len(ans))
# for a,b in ans:
# print(a,b)
s = input()
n = len(s)
k = int(input())
l = []
for i in range(k):
z = input()
l.append(z)
l.append(z[::-1])
la = []
i = 0
while i<n:
cnt = 0
z = s[i]
while i<n and s[i] == z:
cnt+=1
i+=1
la.append([z,cnt])
ans = 0
if len(la) == 1:
print(0)
exit()
x,y = la[0][0],la[1][0]
cnt1,cnt2 = la[0][1],0
i = 1
while i<len(la):
if la[i][0]!=x and la[i][0]!=y:
if x+y in l:
ans += min(cnt1,cnt2)
i-=1
x,y = la[i][0],la[i+1][0]
cnt1,cnt2 = la[i][1],0
i+=1
else:
if la[i][0]==x:
# print(x,cnt1)
cnt1+=la[i][1]
else:
cnt2+=la[i][1]
i+=1
if x+y in l:
ans += min(cnt1,cnt2)
print(ans)
```
| 70,994 | [
0.291015625,
-0.05596923828125,
0.1292724609375,
0.284912109375,
-0.5634765625,
-0.67431640625,
0.14208984375,
-0.12200927734375,
-0.189208984375,
0.90283203125,
0.8505859375,
-0.01378631591796875,
-0.3876953125,
-0.91552734375,
-0.935546875,
-0.12841796875,
-0.91455078125,
-0.58349609375,
-0.53955078125,
-0.1390380859375,
0.0859375,
-0.15283203125,
-1.6376953125,
-0.293212890625,
-0.37158203125,
1.2021484375,
0.3583984375,
-0.2958984375,
1.162109375,
0.75048828125,
-0.26318359375,
-0.338623046875,
0.5576171875,
-1.1689453125,
-0.6259765625,
-0.51220703125,
0.9462890625,
-0.467041015625,
0.007476806640625,
-0.064208984375,
0.66064453125,
-0.251953125,
0.473388671875,
-0.5341796875,
-1.2958984375,
-0.35791015625,
-0.126953125,
-0.61376953125,
-0.3544921875,
-0.40869140625,
0.332275390625,
-0.334228515625,
0.62109375,
-0.220947265625,
0.07373046875,
0.156494140625,
0.2384033203125,
0.08428955078125,
-0.693359375,
0.411376953125,
0.134765625,
0.374755859375,
0.1448974609375,
-0.75634765625,
-0.421875,
-0.107666015625,
-0.309814453125,
0.202392578125,
-0.00026702880859375,
-0.61181640625,
-0.241455078125,
0.4931640625,
-0.3916015625,
-0.330078125,
-0.673828125,
0.0330810546875,
0.2467041015625,
0.093994140625,
-0.56689453125,
0.8388671875,
0.36865234375,
1.013671875,
0.77001953125,
-0.10443115234375,
-0.35009765625,
-0.129150390625,
0.00772857666015625,
0.378662109375,
0.423828125,
-0.2183837890625,
-0.1893310546875,
0.541015625,
-1.03515625,
-0.166748046875,
0.5908203125,
0.40576171875,
-0.28515625,
0.283447265625,
0.45751953125,
0.44873046875,
0.89892578125,
0.58349609375,
-0.34912109375,
0.82958984375,
-0.5546875,
0.16162109375,
0.0953369140625,
0.1873779296875,
-0.05413818359375,
0.25927734375,
-0.31201171875,
-0.08892822265625,
0.486083984375,
0.458984375,
-0.6806640625,
0.76953125,
-0.276123046875,
0.3896484375,
-0.8388671875,
0.281494140625,
0.7314453125,
-0.06927490234375,
0.84912109375,
0.044891357421875,
0.1920166015625,
-0.2216796875,
-0.6083984375,
1.0673828125,
-0.433837890625,
-0.021942138671875,
0.49365234375,
0.0227508544921875,
-0.06689453125,
0.2044677734375,
-0.32080078125,
0.8076171875,
-0.287353515625,
0.6162109375,
0.55419921875,
-0.6220703125,
0.492431640625,
-0.2286376953125,
-0.053070068359375,
1.4287109375,
0.708984375,
-0.06097412109375,
0.78515625,
0.42822265625,
-0.92724609375,
0.1619873046875,
-1.3056640625,
0.8525390625,
0.14013671875,
0.117919921875,
-0.53369140625,
-0.1455078125,
-0.2314453125,
0.157958984375,
0.06756591796875,
0.2060546875,
-0.46826171875,
0.1510009765625,
-0.310302734375,
0.62744140625,
-0.2587890625,
1.0556640625,
-0.6728515625,
0.01007080078125,
-0.142333984375,
-0.5966796875,
0.19921875,
-0.040008544921875,
0.11669921875,
1.0732421875,
0.1568603515625,
0.8330078125,
0.56884765625,
-0.344482421875,
0.64306640625,
0.4794921875,
-0.10455322265625,
0.48046875,
0.1812744140625,
0.324462890625,
0.521484375,
0.298583984375,
-0.15625,
-0.415283203125,
-0.84716796875,
-0.375,
-0.0113525390625,
0.65673828125,
-0.37353515625,
0.341064453125,
0.047698974609375,
-0.0391845703125,
-1.0478515625,
-0.32666015625,
0.18408203125,
-1.0986328125,
-0.5546875,
0.90283203125,
0.14599609375,
0.74658203125,
-0.202392578125,
-0.626953125,
0.64892578125,
1.4775390625,
-0.3173828125,
0.278564453125,
0.6513671875,
-0.58935546875,
-0.345947265625,
0.45751953125,
-0.1702880859375,
-0.179931640625,
-0.85400390625,
0.72412109375,
-0.53466796875,
-0.0231475830078125,
-0.2080078125,
0.266357421875,
0.2763671875,
0.66015625,
-0.1806640625,
-0.3349609375,
0.84765625,
1.12890625,
0.0369873046875,
0.50390625,
0.197998046875,
0.7021484375,
0.1204833984375,
0.71240234375,
0.412841796875,
0.1494140625,
0.8486328125,
0.916015625,
0.2119140625,
0.52880859375,
-0.2252197265625,
0.44091796875,
0.1973876953125,
0.580078125,
0.440673828125,
0.29052734375,
-0.316162109375,
-0.038177490234375,
-0.3876953125,
0.09185791015625,
-0.252197265625,
0.32080078125,
0.431884765625,
0.432373046875,
-0.29443359375,
-0.13916015625,
0.2066650390625,
0.685546875,
-1.171875,
-0.45703125,
0.045135498046875,
0.1319580078125,
-0.0281219482421875,
0.00022304058074951172,
0.2379150390625,
0.77880859375,
0.70263671875,
0.328857421875,
-0.52783203125,
-0.52783203125,
-1.1328125,
-1.0107421875,
-0.86376953125,
-0.332275390625,
-0.82568359375,
-0.11688232421875,
0.634765625,
-1.0869140625,
0.482177734375,
-0.2861328125,
-0.5302734375,
0.1619873046875,
-0.578125,
0.6025390625,
-0.2027587890625,
0.80029296875,
-0.755859375,
0.73291015625,
0.034820556640625,
0.90234375,
-0.287841796875,
-0.3671875,
-0.047760009765625,
-0.61767578125,
0.251953125,
-0.0189208984375,
0.3017578125,
0.1771240234375,
-0.6533203125,
-0.7646484375,
0.032501220703125,
-0.308349609375,
-0.57861328125,
0.215087890625,
-0.7529296875,
0.7294921875,
0.93994140625,
-0.66845703125,
0.77392578125,
1.1220703125,
-0.94921875,
0.0287628173828125,
0.1856689453125,
0.2998046875,
-0.615234375,
1.189453125,
0.29052734375,
0.3974609375,
-0.5205078125,
-0.51220703125,
-0.755859375,
0.0966796875,
-0.03570556640625,
-0.354736328125,
-0.09564208984375,
0.75634765625,
-0.267333984375,
-0.994140625,
0.75341796875,
-1.1796875,
-0.10711669921875,
-0.1295166015625,
-0.489501953125,
0.95068359375,
0.342529296875,
0.354736328125,
-0.288330078125,
-0.818359375,
-0.25146484375,
0.82421875,
0.1776123046875,
-0.521484375,
-0.0372314453125,
0.2440185546875,
0.1773681640625,
0.150634765625,
0.12078857421875,
-0.232421875,
-0.3251953125,
0.070068359375,
0.221923828125,
0.92333984375,
0.2998046875,
0.3857421875,
0.365234375,
0.8486328125,
-0.6884765625,
-0.252685546875,
-0.270263671875,
0.720703125,
0.21337890625,
0.39697265625,
0.1611328125,
-0.24755859375,
-0.330078125,
-0.80615234375,
0.483642578125,
-0.295166015625,
0.763671875,
-0.5322265625,
0.6181640625,
0.383056640625,
-0.5263671875,
0.65966796875,
-0.89599609375,
-0.358154296875,
0.90283203125,
-0.6650390625,
0.95068359375,
-0.8916015625,
0.194580078125,
0.06884765625,
0.1278076171875,
0.701171875,
0.642578125,
0.7373046875,
-0.453125,
-0.60302734375,
-0.2890625,
0.278076171875,
-0.06378173828125,
-0.525390625,
0.144775390625,
-0.2440185546875,
-0.41455078125,
-0.89111328125,
0.41357421875,
0.86083984375,
0.57275390625,
0.3359375,
0.4248046875,
0.1689453125,
0.58740234375,
0.9111328125,
-0.0947265625,
-0.002368927001953125,
-0.7587890625,
1.0380859375,
-0.0124053955078125,
-0.480224609375,
-0.34765625,
-0.33544921875,
-0.312255859375,
0.323974609375,
0.018951416015625,
0.04071044921875,
-0.89208984375,
-0.170654296875,
-0.13720703125,
0.361572265625,
-0.73583984375,
-0.3095703125,
-0.189697265625,
0.425048828125,
0.08111572265625,
-1.017578125,
0.390380859375,
-0.6630859375,
0.927734375,
0.99169921875,
0.0635986328125,
-0.51708984375,
-0.149658203125,
-0.53955078125,
-0.86767578125,
-0.1142578125,
0.58154296875,
-0.12353515625,
0.2261962890625,
-1.2578125,
0.57958984375,
0.3349609375,
-0.088134765625,
0.28466796875,
0.193359375,
0.472900390625,
0.142578125,
0.5234375,
-0.6318359375,
-0.66357421875,
0.419189453125,
-1.1201171875,
0.763671875,
-0.611328125,
0.483154296875,
-0.154541015625,
0.1396484375,
0.1552734375,
0.4560546875,
-0.4775390625,
0.41357421875,
-0.0810546875,
0.3984375,
-1.01171875,
-0.65966796875,
0.51806640625,
-0.1829833984375,
-0.724609375,
0.546875,
0.25244140625,
-0.236083984375,
0.013427734375,
0.5927734375,
-0.466064453125,
0.4443359375,
-0.54736328125,
0.62451171875,
-0.116943359375,
-0.77294921875,
-0.2432861328125,
-0.470458984375,
0.68212890625,
-0.186279296875,
-0.7587890625,
0.220703125,
-1.15625,
-0.250732421875,
0.09710693359375,
-0.49755859375,
0.349365234375,
0.1513671875,
0.1280517578125,
0.09881591796875,
-0.49609375,
-0.36279296875,
-0.1741943359375,
-0.53564453125,
-0.51806640625,
0.337646484375,
0.58984375,
0.6943359375,
0.290283203125,
-0.10791015625,
0.1749267578125,
0.015655517578125,
-0.12200927734375,
-0.58447265625,
-0.354736328125,
0.213134765625,
-0.51220703125,
-0.1392822265625,
0.36181640625,
-0.0020809173583984375,
0.39697265625,
0.8720703125,
-0.055877685546875,
0.2276611328125,
0.348388671875,
-0.5146484375,
1.384765625,
-0.188720703125,
-1.0166015625,
-0.38427734375,
0.2420654296875,
0.060333251953125,
0.607421875,
-0.1727294921875,
-0.7978515625,
-0.6845703125,
-1.1015625,
0.08795166015625,
-0.5263671875,
-0.26171875,
-0.94287109375,
-0.1905517578125,
-0.51123046875,
0.7978515625,
-0.37744140625,
-0.2802734375,
0.340576171875,
-1.2001953125,
0.04998779296875,
-0.59619140625,
-0.41845703125,
-0.56201171875,
-0.5673828125,
-0.623046875,
1.09765625,
0.416015625,
0.1422119140625,
0.421142578125,
-0.34521484375,
0.24853515625,
-0.36669921875,
-0.609375,
-0.495849609375,
-0.280517578125,
0.376953125,
-0.355224609375,
-0.42138671875,
-0.625,
0.8857421875,
-0.54052734375,
0.206787109375,
-0.443603515625,
-0.5341796875,
-0.199462890625,
-0.240478515625,
0.7998046875,
-0.65283203125,
0.1392822265625,
-0.50439453125,
0.68212890625,
0.3701171875,
-0.302001953125,
-0.5234375,
-0.83447265625,
-0.6005859375,
-0.8583984375,
0.65087890625,
-0.552734375,
0.58935546875,
-0.69189453125,
-0.2587890625,
0.900390625,
-0.5205078125,
0.317138671875,
1.3330078125,
-0.2313232421875,
0.213623046875,
-0.84814453125,
0.677734375,
-0.0223541259765625,
-0.64453125,
-0.27685546875,
-0.07952880859375,
-0.9150390625,
0.0960693359375,
-0.63427734375,
-0.896484375,
-0.57373046875,
0.71044921875,
1.466796875,
-0.300537109375,
0.95556640625,
0.2305908203125,
-1.17578125,
-0.7919921875,
0.78857421875,
0.381591796875,
0.56640625,
1.1259765625,
-0.82177734375,
-0.1278076171875,
0.40673828125,
-0.07183837890625,
-0.26416015625,
-0.208984375,
1.056640625,
-0.491455078125,
-0.60302734375,
0.52783203125,
0.57568359375,
-1.111328125,
-0.5341796875,
0.07781982421875,
-0.00972747802734375,
-0.1356201171875,
-0.61669921875,
0.09686279296875,
0.63818359375,
-0.479736328125,
-0.10040283203125,
0.0250244140625,
0.04345703125,
0.634765625,
0.300048828125,
0.30419921875,
-0.51904296875,
0.64306640625,
0.80029296875,
-0.783203125,
-0.37890625,
-0.82958984375,
-0.18505859375,
-0.2322998046875,
0.37353515625,
0.81640625,
0.0882568359375,
0.2191162109375,
0.72021484375,
-0.08892822265625,
0.7138671875,
-0.38818359375,
-0.363037109375,
0.25048828125,
-0.492431640625,
-0.25927734375,
-0.01491546630859375,
0.183349609375,
0.1009521484375,
0.2156982421875,
-0.7021484375,
-0.06610107421875,
0.349853515625,
0.334716796875,
-0.08917236328125,
-0.045318603515625,
-0.325927734375,
-0.58935546875,
-0.413330078125,
-0.5380859375,
-0.765625,
-0.12188720703125,
0.429443359375,
0.367919921875,
-0.73876953125,
0.04022216796875,
0.8408203125,
-0.77880859375,
1.2099609375,
-0.7490234375,
0.325927734375,
-0.43994140625,
-0.09228515625,
-0.78466796875,
0.1318359375,
-0.41796875,
-0.27880859375,
-0.403564453125,
0.5419921875,
0.3779296875,
0.52734375,
-0.1343994140625,
0.1981201171875,
-0.173828125,
-0.81103515625,
-0.06646728515625,
0.049224853515625,
0.0947265625,
0.33251953125,
0.72021484375,
0.52099609375,
0.283203125,
-0.050048828125,
-0.61083984375,
-0.48095703125,
0.12432861328125,
0.94384765625,
0.0238494873046875,
-0.05615234375,
-0.412109375,
0.00319671630859375,
-0.6279296875,
0.261962890625,
-0.2861328125,
-0.09136962890625,
0.09783935546875,
-0.74853515625,
0.505859375,
1.26953125,
-0.09161376953125,
0.177978515625,
-0.0291900634765625,
0.2939453125,
0.386962890625,
0.1669921875,
0.341552734375,
0.1629638671875,
0.1240234375,
-0.2159423828125,
-0.158935546875,
0.6015625,
-0.01273345947265625,
0.4287109375,
-0.2010498046875,
-0.76806640625,
-0.7490234375,
-0.100341796875,
-0.27294921875,
0.042572021484375,
0.59619140625,
-0.8369140625,
-0.06622314453125,
0.087890625,
-0.95166015625,
0.1787109375,
-0.7529296875,
-0.84619140625,
0.0838623046875,
-0.133056640625,
-0.7958984375,
-0.493896484375,
-0.58740234375,
0.037139892578125,
0.1595458984375,
0.5478515625,
-0.7412109375,
0.295654296875,
-0.172119140625,
0.44287109375,
-0.215087890625,
-0.1334228515625,
0.1318359375,
0.291748046875,
-0.470703125,
-0.6533203125,
0.0771484375,
1.4853515625,
0.17919921875,
-0.34912109375,
-0.63037109375,
0.10302734375,
-0.42919921875,
0.3271484375,
-0.2034912109375,
-0.18896484375,
0.01824951171875,
0.435791015625,
-1.181640625,
-0.354248046875,
0.084716796875,
0.286376953125,
-0.021026611328125,
-0.3447265625,
-0.2130126953125,
0.68994140625,
0.982421875,
-0.1396484375,
-0.058502197265625,
0.408935546875,
0.79150390625,
-0.26220703125,
-0.127197265625,
-0.251708984375,
0.30224609375,
0.53076171875,
0.27490234375,
-0.2354736328125,
0.69873046875,
0.93798828125,
-0.33203125,
-0.2208251953125,
0.5380859375,
0.03131103515625,
-0.0085906982421875,
-0.241943359375,
-0.2291259765625,
0.040191650390625,
-0.06988525390625,
-0.84619140625,
0.172607421875,
-0.378662109375,
-0.333251953125,
-0.176513671875,
-0.70849609375,
0.98046875,
-1.1953125,
0.4619140625,
-0.26220703125,
-0.12158203125,
0.399169921875,
0.98046875,
0.05169677734375,
-0.056793212890625,
0.50390625,
0.341552734375,
0.58349609375,
0.8076171875,
0.208984375,
0.154541015625,
-0.3916015625,
0.146484375,
-0.0693359375,
0.006015777587890625,
-0.6806640625,
-0.28125,
-1.1416015625,
0.6298828125,
-0.399169921875,
-0.09930419921875,
0.433837890625,
-0.5341796875,
0.1962890625,
-0.284912109375,
0.7646484375,
-0.38037109375,
0.434814453125,
0.5458984375,
-0.57177734375,
-0.447509765625,
0.84423828125,
-0.1993408203125,
0.38232421875,
0.1937255859375,
0.73828125,
0.34814453125,
1.716796875,
0.32080078125,
-0.2578125,
-0.147705078125,
0.057220458984375,
-0.234375,
-0.60400390625,
-0.38916015625,
-0.37158203125,
-0.119140625,
-0.398193359375,
-0.22998046875,
0.0257110595703125,
0.6533203125,
0.0811767578125,
-0.80615234375,
-0.042236328125,
0.08184814453125,
-0.84521484375,
0.7734375,
0.261474609375,
0.02947998046875,
0.07269287109375,
0.08599853515625,
-0.14208984375,
-0.35009765625,
-0.185791015625,
-0.5927734375,
0.2236328125,
-0.5849609375,
-0.5380859375,
-0.609375,
-1.0380859375,
-0.375732421875,
-0.33203125,
-0.476318359375,
-1.0390625,
0.1490478515625,
0.65185546875,
0.40625,
0.5107421875,
-0.51611328125,
0.397705078125,
1.123046875,
0.71630859375,
-0.351806640625,
0.80810546875,
0.36474609375,
-0.525390625,
0.08441162109375,
-0.0052032470703125,
0.6953125,
-0.33837890625,
-0.0105133056640625,
-0.297607421875,
0.5234375,
-0.9794921875,
-1.3837890625,
0.06396484375,
0.6513671875,
0.50341796875,
-0.54345703125,
-0.9306640625,
-0.401123046875,
-0.74755859375,
-0.046600341796875,
-0.78271484375,
0.6123046875,
0.388671875,
-0.09393310546875,
0.0287017822265625,
-1.0283203125,
4.31640625,
1.0087890625,
0.94677734375,
0.07049560546875,
-0.028228759765625,
0.970703125,
-0.0012559890747070312,
-0.31884765625,
0.1610107421875,
-0.3154296875,
0.7646484375,
-0.215576171875,
-0.088134765625,
0.65087890625,
0.1949462890625,
0.453125,
-0.48486328125,
-0.0171356201171875,
-0.247314453125,
-0.990234375,
-0.7939453125,
0.0758056640625,
0.2432861328125,
0.165283203125,
0.08551025390625,
0.093017578125,
0.57080078125,
-0.626953125,
-0.29052734375,
-0.63525390625,
-0.28369140625,
-0.7109375,
0.666015625,
-0.0755615234375,
-0.1834716796875,
0.50732421875,
0.1470947265625,
-0.62744140625,
0.057891845703125,
0.55517578125,
-0.30810546875,
-0.44873046875,
0.86669921875,
-0.8212890625,
0.197998046875,
0.5556640625,
-0.294677734375,
0.279541015625,
0.62841796875,
-0.421142578125,
0.78076171875,
-0.2249755859375,
0.73193359375,
-0.73681640625,
-0.671875,
0.04107666015625,
0.2283935546875,
-0.33349609375,
0.03997802734375,
0.3427734375,
0.2381591796875,
0.1112060546875,
0.050140380859375,
0.38818359375,
-0.68896484375,
0.68212890625,
0.2008056640625,
0.19287109375,
-0.5341796875,
0.09197998046875,
0.018310546875,
-0.137939453125,
-0.4248046875,
-0.50244140625,
0.57275390625,
0.2161865234375,
-0.0219268798828125,
0.30810546875,
0.471435546875,
-0.78955078125,
0.0018644332885742188,
0.0350341796875,
-0.3779296875,
-0.31396484375,
0.5810546875,
1.5830078125,
-0.75439453125,
-0.423828125,
-0.53466796875,
0.6142578125,
0.183349609375,
0.2802734375,
0.60400390625,
-0.91357421875,
-0.25048828125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Tags: greedy
Correct Solution:
```
S = input()
M = int( input() )
banned = set( input() for i in range( M ) )
buff = set()
for s in banned:
if not ( s[ : : -1 ] in banned ):
buff.add( s[ : : -1 ] )
banned.update( buff )
dp = [ [ 1e9 for i in range( 26 ) ] for j in range( len( S ) + 1 ) ]
for i in range( 26 ):
dp[ 0 ][ i ] = 0
for i in range( len( S ) ):
for j in range( 26 ):
if dp[ i ][ j ] == 1e9: continue
if not ( chr( ord( 'a' ) + j ) + S[ i ] in banned ):
dp[ i + 1 ][ ord( S[ i ] ) - ord( 'a' ) ] = min( dp[ i + 1 ][ ord( S[ i ] ) - ord( 'a' ) ], dp[ i ][ j ] )
dp[ i + 1 ][ j ] = min( dp[ i + 1 ][ j ], dp[ i ][ j ] + 1 )
print( min( dp[ len( S ) ] ) )
```
| 70,995 | [
0.291015625,
-0.05596923828125,
0.1292724609375,
0.284912109375,
-0.5634765625,
-0.67431640625,
0.14208984375,
-0.12200927734375,
-0.189208984375,
0.90283203125,
0.8505859375,
-0.01378631591796875,
-0.3876953125,
-0.91552734375,
-0.935546875,
-0.12841796875,
-0.91455078125,
-0.58349609375,
-0.53955078125,
-0.1390380859375,
0.0859375,
-0.15283203125,
-1.6376953125,
-0.293212890625,
-0.37158203125,
1.2021484375,
0.3583984375,
-0.2958984375,
1.162109375,
0.75048828125,
-0.26318359375,
-0.338623046875,
0.5576171875,
-1.1689453125,
-0.6259765625,
-0.51220703125,
0.9462890625,
-0.467041015625,
0.007476806640625,
-0.064208984375,
0.66064453125,
-0.251953125,
0.473388671875,
-0.5341796875,
-1.2958984375,
-0.35791015625,
-0.126953125,
-0.61376953125,
-0.3544921875,
-0.40869140625,
0.332275390625,
-0.334228515625,
0.62109375,
-0.220947265625,
0.07373046875,
0.156494140625,
0.2384033203125,
0.08428955078125,
-0.693359375,
0.411376953125,
0.134765625,
0.374755859375,
0.1448974609375,
-0.75634765625,
-0.421875,
-0.107666015625,
-0.309814453125,
0.202392578125,
-0.00026702880859375,
-0.61181640625,
-0.241455078125,
0.4931640625,
-0.3916015625,
-0.330078125,
-0.673828125,
0.0330810546875,
0.2467041015625,
0.093994140625,
-0.56689453125,
0.8388671875,
0.36865234375,
1.013671875,
0.77001953125,
-0.10443115234375,
-0.35009765625,
-0.129150390625,
0.00772857666015625,
0.378662109375,
0.423828125,
-0.2183837890625,
-0.1893310546875,
0.541015625,
-1.03515625,
-0.166748046875,
0.5908203125,
0.40576171875,
-0.28515625,
0.283447265625,
0.45751953125,
0.44873046875,
0.89892578125,
0.58349609375,
-0.34912109375,
0.82958984375,
-0.5546875,
0.16162109375,
0.0953369140625,
0.1873779296875,
-0.05413818359375,
0.25927734375,
-0.31201171875,
-0.08892822265625,
0.486083984375,
0.458984375,
-0.6806640625,
0.76953125,
-0.276123046875,
0.3896484375,
-0.8388671875,
0.281494140625,
0.7314453125,
-0.06927490234375,
0.84912109375,
0.044891357421875,
0.1920166015625,
-0.2216796875,
-0.6083984375,
1.0673828125,
-0.433837890625,
-0.021942138671875,
0.49365234375,
0.0227508544921875,
-0.06689453125,
0.2044677734375,
-0.32080078125,
0.8076171875,
-0.287353515625,
0.6162109375,
0.55419921875,
-0.6220703125,
0.492431640625,
-0.2286376953125,
-0.053070068359375,
1.4287109375,
0.708984375,
-0.06097412109375,
0.78515625,
0.42822265625,
-0.92724609375,
0.1619873046875,
-1.3056640625,
0.8525390625,
0.14013671875,
0.117919921875,
-0.53369140625,
-0.1455078125,
-0.2314453125,
0.157958984375,
0.06756591796875,
0.2060546875,
-0.46826171875,
0.1510009765625,
-0.310302734375,
0.62744140625,
-0.2587890625,
1.0556640625,
-0.6728515625,
0.01007080078125,
-0.142333984375,
-0.5966796875,
0.19921875,
-0.040008544921875,
0.11669921875,
1.0732421875,
0.1568603515625,
0.8330078125,
0.56884765625,
-0.344482421875,
0.64306640625,
0.4794921875,
-0.10455322265625,
0.48046875,
0.1812744140625,
0.324462890625,
0.521484375,
0.298583984375,
-0.15625,
-0.415283203125,
-0.84716796875,
-0.375,
-0.0113525390625,
0.65673828125,
-0.37353515625,
0.341064453125,
0.047698974609375,
-0.0391845703125,
-1.0478515625,
-0.32666015625,
0.18408203125,
-1.0986328125,
-0.5546875,
0.90283203125,
0.14599609375,
0.74658203125,
-0.202392578125,
-0.626953125,
0.64892578125,
1.4775390625,
-0.3173828125,
0.278564453125,
0.6513671875,
-0.58935546875,
-0.345947265625,
0.45751953125,
-0.1702880859375,
-0.179931640625,
-0.85400390625,
0.72412109375,
-0.53466796875,
-0.0231475830078125,
-0.2080078125,
0.266357421875,
0.2763671875,
0.66015625,
-0.1806640625,
-0.3349609375,
0.84765625,
1.12890625,
0.0369873046875,
0.50390625,
0.197998046875,
0.7021484375,
0.1204833984375,
0.71240234375,
0.412841796875,
0.1494140625,
0.8486328125,
0.916015625,
0.2119140625,
0.52880859375,
-0.2252197265625,
0.44091796875,
0.1973876953125,
0.580078125,
0.440673828125,
0.29052734375,
-0.316162109375,
-0.038177490234375,
-0.3876953125,
0.09185791015625,
-0.252197265625,
0.32080078125,
0.431884765625,
0.432373046875,
-0.29443359375,
-0.13916015625,
0.2066650390625,
0.685546875,
-1.171875,
-0.45703125,
0.045135498046875,
0.1319580078125,
-0.0281219482421875,
0.00022304058074951172,
0.2379150390625,
0.77880859375,
0.70263671875,
0.328857421875,
-0.52783203125,
-0.52783203125,
-1.1328125,
-1.0107421875,
-0.86376953125,
-0.332275390625,
-0.82568359375,
-0.11688232421875,
0.634765625,
-1.0869140625,
0.482177734375,
-0.2861328125,
-0.5302734375,
0.1619873046875,
-0.578125,
0.6025390625,
-0.2027587890625,
0.80029296875,
-0.755859375,
0.73291015625,
0.034820556640625,
0.90234375,
-0.287841796875,
-0.3671875,
-0.047760009765625,
-0.61767578125,
0.251953125,
-0.0189208984375,
0.3017578125,
0.1771240234375,
-0.6533203125,
-0.7646484375,
0.032501220703125,
-0.308349609375,
-0.57861328125,
0.215087890625,
-0.7529296875,
0.7294921875,
0.93994140625,
-0.66845703125,
0.77392578125,
1.1220703125,
-0.94921875,
0.0287628173828125,
0.1856689453125,
0.2998046875,
-0.615234375,
1.189453125,
0.29052734375,
0.3974609375,
-0.5205078125,
-0.51220703125,
-0.755859375,
0.0966796875,
-0.03570556640625,
-0.354736328125,
-0.09564208984375,
0.75634765625,
-0.267333984375,
-0.994140625,
0.75341796875,
-1.1796875,
-0.10711669921875,
-0.1295166015625,
-0.489501953125,
0.95068359375,
0.342529296875,
0.354736328125,
-0.288330078125,
-0.818359375,
-0.25146484375,
0.82421875,
0.1776123046875,
-0.521484375,
-0.0372314453125,
0.2440185546875,
0.1773681640625,
0.150634765625,
0.12078857421875,
-0.232421875,
-0.3251953125,
0.070068359375,
0.221923828125,
0.92333984375,
0.2998046875,
0.3857421875,
0.365234375,
0.8486328125,
-0.6884765625,
-0.252685546875,
-0.270263671875,
0.720703125,
0.21337890625,
0.39697265625,
0.1611328125,
-0.24755859375,
-0.330078125,
-0.80615234375,
0.483642578125,
-0.295166015625,
0.763671875,
-0.5322265625,
0.6181640625,
0.383056640625,
-0.5263671875,
0.65966796875,
-0.89599609375,
-0.358154296875,
0.90283203125,
-0.6650390625,
0.95068359375,
-0.8916015625,
0.194580078125,
0.06884765625,
0.1278076171875,
0.701171875,
0.642578125,
0.7373046875,
-0.453125,
-0.60302734375,
-0.2890625,
0.278076171875,
-0.06378173828125,
-0.525390625,
0.144775390625,
-0.2440185546875,
-0.41455078125,
-0.89111328125,
0.41357421875,
0.86083984375,
0.57275390625,
0.3359375,
0.4248046875,
0.1689453125,
0.58740234375,
0.9111328125,
-0.0947265625,
-0.002368927001953125,
-0.7587890625,
1.0380859375,
-0.0124053955078125,
-0.480224609375,
-0.34765625,
-0.33544921875,
-0.312255859375,
0.323974609375,
0.018951416015625,
0.04071044921875,
-0.89208984375,
-0.170654296875,
-0.13720703125,
0.361572265625,
-0.73583984375,
-0.3095703125,
-0.189697265625,
0.425048828125,
0.08111572265625,
-1.017578125,
0.390380859375,
-0.6630859375,
0.927734375,
0.99169921875,
0.0635986328125,
-0.51708984375,
-0.149658203125,
-0.53955078125,
-0.86767578125,
-0.1142578125,
0.58154296875,
-0.12353515625,
0.2261962890625,
-1.2578125,
0.57958984375,
0.3349609375,
-0.088134765625,
0.28466796875,
0.193359375,
0.472900390625,
0.142578125,
0.5234375,
-0.6318359375,
-0.66357421875,
0.419189453125,
-1.1201171875,
0.763671875,
-0.611328125,
0.483154296875,
-0.154541015625,
0.1396484375,
0.1552734375,
0.4560546875,
-0.4775390625,
0.41357421875,
-0.0810546875,
0.3984375,
-1.01171875,
-0.65966796875,
0.51806640625,
-0.1829833984375,
-0.724609375,
0.546875,
0.25244140625,
-0.236083984375,
0.013427734375,
0.5927734375,
-0.466064453125,
0.4443359375,
-0.54736328125,
0.62451171875,
-0.116943359375,
-0.77294921875,
-0.2432861328125,
-0.470458984375,
0.68212890625,
-0.186279296875,
-0.7587890625,
0.220703125,
-1.15625,
-0.250732421875,
0.09710693359375,
-0.49755859375,
0.349365234375,
0.1513671875,
0.1280517578125,
0.09881591796875,
-0.49609375,
-0.36279296875,
-0.1741943359375,
-0.53564453125,
-0.51806640625,
0.337646484375,
0.58984375,
0.6943359375,
0.290283203125,
-0.10791015625,
0.1749267578125,
0.015655517578125,
-0.12200927734375,
-0.58447265625,
-0.354736328125,
0.213134765625,
-0.51220703125,
-0.1392822265625,
0.36181640625,
-0.0020809173583984375,
0.39697265625,
0.8720703125,
-0.055877685546875,
0.2276611328125,
0.348388671875,
-0.5146484375,
1.384765625,
-0.188720703125,
-1.0166015625,
-0.38427734375,
0.2420654296875,
0.060333251953125,
0.607421875,
-0.1727294921875,
-0.7978515625,
-0.6845703125,
-1.1015625,
0.08795166015625,
-0.5263671875,
-0.26171875,
-0.94287109375,
-0.1905517578125,
-0.51123046875,
0.7978515625,
-0.37744140625,
-0.2802734375,
0.340576171875,
-1.2001953125,
0.04998779296875,
-0.59619140625,
-0.41845703125,
-0.56201171875,
-0.5673828125,
-0.623046875,
1.09765625,
0.416015625,
0.1422119140625,
0.421142578125,
-0.34521484375,
0.24853515625,
-0.36669921875,
-0.609375,
-0.495849609375,
-0.280517578125,
0.376953125,
-0.355224609375,
-0.42138671875,
-0.625,
0.8857421875,
-0.54052734375,
0.206787109375,
-0.443603515625,
-0.5341796875,
-0.199462890625,
-0.240478515625,
0.7998046875,
-0.65283203125,
0.1392822265625,
-0.50439453125,
0.68212890625,
0.3701171875,
-0.302001953125,
-0.5234375,
-0.83447265625,
-0.6005859375,
-0.8583984375,
0.65087890625,
-0.552734375,
0.58935546875,
-0.69189453125,
-0.2587890625,
0.900390625,
-0.5205078125,
0.317138671875,
1.3330078125,
-0.2313232421875,
0.213623046875,
-0.84814453125,
0.677734375,
-0.0223541259765625,
-0.64453125,
-0.27685546875,
-0.07952880859375,
-0.9150390625,
0.0960693359375,
-0.63427734375,
-0.896484375,
-0.57373046875,
0.71044921875,
1.466796875,
-0.300537109375,
0.95556640625,
0.2305908203125,
-1.17578125,
-0.7919921875,
0.78857421875,
0.381591796875,
0.56640625,
1.1259765625,
-0.82177734375,
-0.1278076171875,
0.40673828125,
-0.07183837890625,
-0.26416015625,
-0.208984375,
1.056640625,
-0.491455078125,
-0.60302734375,
0.52783203125,
0.57568359375,
-1.111328125,
-0.5341796875,
0.07781982421875,
-0.00972747802734375,
-0.1356201171875,
-0.61669921875,
0.09686279296875,
0.63818359375,
-0.479736328125,
-0.10040283203125,
0.0250244140625,
0.04345703125,
0.634765625,
0.300048828125,
0.30419921875,
-0.51904296875,
0.64306640625,
0.80029296875,
-0.783203125,
-0.37890625,
-0.82958984375,
-0.18505859375,
-0.2322998046875,
0.37353515625,
0.81640625,
0.0882568359375,
0.2191162109375,
0.72021484375,
-0.08892822265625,
0.7138671875,
-0.38818359375,
-0.363037109375,
0.25048828125,
-0.492431640625,
-0.25927734375,
-0.01491546630859375,
0.183349609375,
0.1009521484375,
0.2156982421875,
-0.7021484375,
-0.06610107421875,
0.349853515625,
0.334716796875,
-0.08917236328125,
-0.045318603515625,
-0.325927734375,
-0.58935546875,
-0.413330078125,
-0.5380859375,
-0.765625,
-0.12188720703125,
0.429443359375,
0.367919921875,
-0.73876953125,
0.04022216796875,
0.8408203125,
-0.77880859375,
1.2099609375,
-0.7490234375,
0.325927734375,
-0.43994140625,
-0.09228515625,
-0.78466796875,
0.1318359375,
-0.41796875,
-0.27880859375,
-0.403564453125,
0.5419921875,
0.3779296875,
0.52734375,
-0.1343994140625,
0.1981201171875,
-0.173828125,
-0.81103515625,
-0.06646728515625,
0.049224853515625,
0.0947265625,
0.33251953125,
0.72021484375,
0.52099609375,
0.283203125,
-0.050048828125,
-0.61083984375,
-0.48095703125,
0.12432861328125,
0.94384765625,
0.0238494873046875,
-0.05615234375,
-0.412109375,
0.00319671630859375,
-0.6279296875,
0.261962890625,
-0.2861328125,
-0.09136962890625,
0.09783935546875,
-0.74853515625,
0.505859375,
1.26953125,
-0.09161376953125,
0.177978515625,
-0.0291900634765625,
0.2939453125,
0.386962890625,
0.1669921875,
0.341552734375,
0.1629638671875,
0.1240234375,
-0.2159423828125,
-0.158935546875,
0.6015625,
-0.01273345947265625,
0.4287109375,
-0.2010498046875,
-0.76806640625,
-0.7490234375,
-0.100341796875,
-0.27294921875,
0.042572021484375,
0.59619140625,
-0.8369140625,
-0.06622314453125,
0.087890625,
-0.95166015625,
0.1787109375,
-0.7529296875,
-0.84619140625,
0.0838623046875,
-0.133056640625,
-0.7958984375,
-0.493896484375,
-0.58740234375,
0.037139892578125,
0.1595458984375,
0.5478515625,
-0.7412109375,
0.295654296875,
-0.172119140625,
0.44287109375,
-0.215087890625,
-0.1334228515625,
0.1318359375,
0.291748046875,
-0.470703125,
-0.6533203125,
0.0771484375,
1.4853515625,
0.17919921875,
-0.34912109375,
-0.63037109375,
0.10302734375,
-0.42919921875,
0.3271484375,
-0.2034912109375,
-0.18896484375,
0.01824951171875,
0.435791015625,
-1.181640625,
-0.354248046875,
0.084716796875,
0.286376953125,
-0.021026611328125,
-0.3447265625,
-0.2130126953125,
0.68994140625,
0.982421875,
-0.1396484375,
-0.058502197265625,
0.408935546875,
0.79150390625,
-0.26220703125,
-0.127197265625,
-0.251708984375,
0.30224609375,
0.53076171875,
0.27490234375,
-0.2354736328125,
0.69873046875,
0.93798828125,
-0.33203125,
-0.2208251953125,
0.5380859375,
0.03131103515625,
-0.0085906982421875,
-0.241943359375,
-0.2291259765625,
0.040191650390625,
-0.06988525390625,
-0.84619140625,
0.172607421875,
-0.378662109375,
-0.333251953125,
-0.176513671875,
-0.70849609375,
0.98046875,
-1.1953125,
0.4619140625,
-0.26220703125,
-0.12158203125,
0.399169921875,
0.98046875,
0.05169677734375,
-0.056793212890625,
0.50390625,
0.341552734375,
0.58349609375,
0.8076171875,
0.208984375,
0.154541015625,
-0.3916015625,
0.146484375,
-0.0693359375,
0.006015777587890625,
-0.6806640625,
-0.28125,
-1.1416015625,
0.6298828125,
-0.399169921875,
-0.09930419921875,
0.433837890625,
-0.5341796875,
0.1962890625,
-0.284912109375,
0.7646484375,
-0.38037109375,
0.434814453125,
0.5458984375,
-0.57177734375,
-0.447509765625,
0.84423828125,
-0.1993408203125,
0.38232421875,
0.1937255859375,
0.73828125,
0.34814453125,
1.716796875,
0.32080078125,
-0.2578125,
-0.147705078125,
0.057220458984375,
-0.234375,
-0.60400390625,
-0.38916015625,
-0.37158203125,
-0.119140625,
-0.398193359375,
-0.22998046875,
0.0257110595703125,
0.6533203125,
0.0811767578125,
-0.80615234375,
-0.042236328125,
0.08184814453125,
-0.84521484375,
0.7734375,
0.261474609375,
0.02947998046875,
0.07269287109375,
0.08599853515625,
-0.14208984375,
-0.35009765625,
-0.185791015625,
-0.5927734375,
0.2236328125,
-0.5849609375,
-0.5380859375,
-0.609375,
-1.0380859375,
-0.375732421875,
-0.33203125,
-0.476318359375,
-1.0390625,
0.1490478515625,
0.65185546875,
0.40625,
0.5107421875,
-0.51611328125,
0.397705078125,
1.123046875,
0.71630859375,
-0.351806640625,
0.80810546875,
0.36474609375,
-0.525390625,
0.08441162109375,
-0.0052032470703125,
0.6953125,
-0.33837890625,
-0.0105133056640625,
-0.297607421875,
0.5234375,
-0.9794921875,
-1.3837890625,
0.06396484375,
0.6513671875,
0.50341796875,
-0.54345703125,
-0.9306640625,
-0.401123046875,
-0.74755859375,
-0.046600341796875,
-0.78271484375,
0.6123046875,
0.388671875,
-0.09393310546875,
0.0287017822265625,
-1.0283203125,
4.31640625,
1.0087890625,
0.94677734375,
0.07049560546875,
-0.028228759765625,
0.970703125,
-0.0012559890747070312,
-0.31884765625,
0.1610107421875,
-0.3154296875,
0.7646484375,
-0.215576171875,
-0.088134765625,
0.65087890625,
0.1949462890625,
0.453125,
-0.48486328125,
-0.0171356201171875,
-0.247314453125,
-0.990234375,
-0.7939453125,
0.0758056640625,
0.2432861328125,
0.165283203125,
0.08551025390625,
0.093017578125,
0.57080078125,
-0.626953125,
-0.29052734375,
-0.63525390625,
-0.28369140625,
-0.7109375,
0.666015625,
-0.0755615234375,
-0.1834716796875,
0.50732421875,
0.1470947265625,
-0.62744140625,
0.057891845703125,
0.55517578125,
-0.30810546875,
-0.44873046875,
0.86669921875,
-0.8212890625,
0.197998046875,
0.5556640625,
-0.294677734375,
0.279541015625,
0.62841796875,
-0.421142578125,
0.78076171875,
-0.2249755859375,
0.73193359375,
-0.73681640625,
-0.671875,
0.04107666015625,
0.2283935546875,
-0.33349609375,
0.03997802734375,
0.3427734375,
0.2381591796875,
0.1112060546875,
0.050140380859375,
0.38818359375,
-0.68896484375,
0.68212890625,
0.2008056640625,
0.19287109375,
-0.5341796875,
0.09197998046875,
0.018310546875,
-0.137939453125,
-0.4248046875,
-0.50244140625,
0.57275390625,
0.2161865234375,
-0.0219268798828125,
0.30810546875,
0.471435546875,
-0.78955078125,
0.0018644332885742188,
0.0350341796875,
-0.3779296875,
-0.31396484375,
0.5810546875,
1.5830078125,
-0.75439453125,
-0.423828125,
-0.53466796875,
0.6142578125,
0.183349609375,
0.2802734375,
0.60400390625,
-0.91357421875,
-0.25048828125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Tags: greedy
Correct Solution:
```
s = input()
k = int(input())
h = 1
d = {}
for i in range(k):
a, b = input()
d[a] = d[b] = h
h += 1
for c in s:
if c not in d:
d[c] = h
h += 1
count = 0
i = 0
ch = ''
c_ch, c_e = 0, 0
val = 0
while True:
if d[s[i]] != val:
count += min(c_ch, c_e)
c_ch, c_e = 0, 0
val = d[s[i]]
ch = s[i]
if s[i] == ch:
c_ch += 1
else:
c_e += 1
i += 1
if i == len(s):
count += min(c_ch, c_e)
break
print(count)
```
| 70,996 | [
0.291015625,
-0.05596923828125,
0.1292724609375,
0.284912109375,
-0.5634765625,
-0.67431640625,
0.14208984375,
-0.12200927734375,
-0.189208984375,
0.90283203125,
0.8505859375,
-0.01378631591796875,
-0.3876953125,
-0.91552734375,
-0.935546875,
-0.12841796875,
-0.91455078125,
-0.58349609375,
-0.53955078125,
-0.1390380859375,
0.0859375,
-0.15283203125,
-1.6376953125,
-0.293212890625,
-0.37158203125,
1.2021484375,
0.3583984375,
-0.2958984375,
1.162109375,
0.75048828125,
-0.26318359375,
-0.338623046875,
0.5576171875,
-1.1689453125,
-0.6259765625,
-0.51220703125,
0.9462890625,
-0.467041015625,
0.007476806640625,
-0.064208984375,
0.66064453125,
-0.251953125,
0.473388671875,
-0.5341796875,
-1.2958984375,
-0.35791015625,
-0.126953125,
-0.61376953125,
-0.3544921875,
-0.40869140625,
0.332275390625,
-0.334228515625,
0.62109375,
-0.220947265625,
0.07373046875,
0.156494140625,
0.2384033203125,
0.08428955078125,
-0.693359375,
0.411376953125,
0.134765625,
0.374755859375,
0.1448974609375,
-0.75634765625,
-0.421875,
-0.107666015625,
-0.309814453125,
0.202392578125,
-0.00026702880859375,
-0.61181640625,
-0.241455078125,
0.4931640625,
-0.3916015625,
-0.330078125,
-0.673828125,
0.0330810546875,
0.2467041015625,
0.093994140625,
-0.56689453125,
0.8388671875,
0.36865234375,
1.013671875,
0.77001953125,
-0.10443115234375,
-0.35009765625,
-0.129150390625,
0.00772857666015625,
0.378662109375,
0.423828125,
-0.2183837890625,
-0.1893310546875,
0.541015625,
-1.03515625,
-0.166748046875,
0.5908203125,
0.40576171875,
-0.28515625,
0.283447265625,
0.45751953125,
0.44873046875,
0.89892578125,
0.58349609375,
-0.34912109375,
0.82958984375,
-0.5546875,
0.16162109375,
0.0953369140625,
0.1873779296875,
-0.05413818359375,
0.25927734375,
-0.31201171875,
-0.08892822265625,
0.486083984375,
0.458984375,
-0.6806640625,
0.76953125,
-0.276123046875,
0.3896484375,
-0.8388671875,
0.281494140625,
0.7314453125,
-0.06927490234375,
0.84912109375,
0.044891357421875,
0.1920166015625,
-0.2216796875,
-0.6083984375,
1.0673828125,
-0.433837890625,
-0.021942138671875,
0.49365234375,
0.0227508544921875,
-0.06689453125,
0.2044677734375,
-0.32080078125,
0.8076171875,
-0.287353515625,
0.6162109375,
0.55419921875,
-0.6220703125,
0.492431640625,
-0.2286376953125,
-0.053070068359375,
1.4287109375,
0.708984375,
-0.06097412109375,
0.78515625,
0.42822265625,
-0.92724609375,
0.1619873046875,
-1.3056640625,
0.8525390625,
0.14013671875,
0.117919921875,
-0.53369140625,
-0.1455078125,
-0.2314453125,
0.157958984375,
0.06756591796875,
0.2060546875,
-0.46826171875,
0.1510009765625,
-0.310302734375,
0.62744140625,
-0.2587890625,
1.0556640625,
-0.6728515625,
0.01007080078125,
-0.142333984375,
-0.5966796875,
0.19921875,
-0.040008544921875,
0.11669921875,
1.0732421875,
0.1568603515625,
0.8330078125,
0.56884765625,
-0.344482421875,
0.64306640625,
0.4794921875,
-0.10455322265625,
0.48046875,
0.1812744140625,
0.324462890625,
0.521484375,
0.298583984375,
-0.15625,
-0.415283203125,
-0.84716796875,
-0.375,
-0.0113525390625,
0.65673828125,
-0.37353515625,
0.341064453125,
0.047698974609375,
-0.0391845703125,
-1.0478515625,
-0.32666015625,
0.18408203125,
-1.0986328125,
-0.5546875,
0.90283203125,
0.14599609375,
0.74658203125,
-0.202392578125,
-0.626953125,
0.64892578125,
1.4775390625,
-0.3173828125,
0.278564453125,
0.6513671875,
-0.58935546875,
-0.345947265625,
0.45751953125,
-0.1702880859375,
-0.179931640625,
-0.85400390625,
0.72412109375,
-0.53466796875,
-0.0231475830078125,
-0.2080078125,
0.266357421875,
0.2763671875,
0.66015625,
-0.1806640625,
-0.3349609375,
0.84765625,
1.12890625,
0.0369873046875,
0.50390625,
0.197998046875,
0.7021484375,
0.1204833984375,
0.71240234375,
0.412841796875,
0.1494140625,
0.8486328125,
0.916015625,
0.2119140625,
0.52880859375,
-0.2252197265625,
0.44091796875,
0.1973876953125,
0.580078125,
0.440673828125,
0.29052734375,
-0.316162109375,
-0.038177490234375,
-0.3876953125,
0.09185791015625,
-0.252197265625,
0.32080078125,
0.431884765625,
0.432373046875,
-0.29443359375,
-0.13916015625,
0.2066650390625,
0.685546875,
-1.171875,
-0.45703125,
0.045135498046875,
0.1319580078125,
-0.0281219482421875,
0.00022304058074951172,
0.2379150390625,
0.77880859375,
0.70263671875,
0.328857421875,
-0.52783203125,
-0.52783203125,
-1.1328125,
-1.0107421875,
-0.86376953125,
-0.332275390625,
-0.82568359375,
-0.11688232421875,
0.634765625,
-1.0869140625,
0.482177734375,
-0.2861328125,
-0.5302734375,
0.1619873046875,
-0.578125,
0.6025390625,
-0.2027587890625,
0.80029296875,
-0.755859375,
0.73291015625,
0.034820556640625,
0.90234375,
-0.287841796875,
-0.3671875,
-0.047760009765625,
-0.61767578125,
0.251953125,
-0.0189208984375,
0.3017578125,
0.1771240234375,
-0.6533203125,
-0.7646484375,
0.032501220703125,
-0.308349609375,
-0.57861328125,
0.215087890625,
-0.7529296875,
0.7294921875,
0.93994140625,
-0.66845703125,
0.77392578125,
1.1220703125,
-0.94921875,
0.0287628173828125,
0.1856689453125,
0.2998046875,
-0.615234375,
1.189453125,
0.29052734375,
0.3974609375,
-0.5205078125,
-0.51220703125,
-0.755859375,
0.0966796875,
-0.03570556640625,
-0.354736328125,
-0.09564208984375,
0.75634765625,
-0.267333984375,
-0.994140625,
0.75341796875,
-1.1796875,
-0.10711669921875,
-0.1295166015625,
-0.489501953125,
0.95068359375,
0.342529296875,
0.354736328125,
-0.288330078125,
-0.818359375,
-0.25146484375,
0.82421875,
0.1776123046875,
-0.521484375,
-0.0372314453125,
0.2440185546875,
0.1773681640625,
0.150634765625,
0.12078857421875,
-0.232421875,
-0.3251953125,
0.070068359375,
0.221923828125,
0.92333984375,
0.2998046875,
0.3857421875,
0.365234375,
0.8486328125,
-0.6884765625,
-0.252685546875,
-0.270263671875,
0.720703125,
0.21337890625,
0.39697265625,
0.1611328125,
-0.24755859375,
-0.330078125,
-0.80615234375,
0.483642578125,
-0.295166015625,
0.763671875,
-0.5322265625,
0.6181640625,
0.383056640625,
-0.5263671875,
0.65966796875,
-0.89599609375,
-0.358154296875,
0.90283203125,
-0.6650390625,
0.95068359375,
-0.8916015625,
0.194580078125,
0.06884765625,
0.1278076171875,
0.701171875,
0.642578125,
0.7373046875,
-0.453125,
-0.60302734375,
-0.2890625,
0.278076171875,
-0.06378173828125,
-0.525390625,
0.144775390625,
-0.2440185546875,
-0.41455078125,
-0.89111328125,
0.41357421875,
0.86083984375,
0.57275390625,
0.3359375,
0.4248046875,
0.1689453125,
0.58740234375,
0.9111328125,
-0.0947265625,
-0.002368927001953125,
-0.7587890625,
1.0380859375,
-0.0124053955078125,
-0.480224609375,
-0.34765625,
-0.33544921875,
-0.312255859375,
0.323974609375,
0.018951416015625,
0.04071044921875,
-0.89208984375,
-0.170654296875,
-0.13720703125,
0.361572265625,
-0.73583984375,
-0.3095703125,
-0.189697265625,
0.425048828125,
0.08111572265625,
-1.017578125,
0.390380859375,
-0.6630859375,
0.927734375,
0.99169921875,
0.0635986328125,
-0.51708984375,
-0.149658203125,
-0.53955078125,
-0.86767578125,
-0.1142578125,
0.58154296875,
-0.12353515625,
0.2261962890625,
-1.2578125,
0.57958984375,
0.3349609375,
-0.088134765625,
0.28466796875,
0.193359375,
0.472900390625,
0.142578125,
0.5234375,
-0.6318359375,
-0.66357421875,
0.419189453125,
-1.1201171875,
0.763671875,
-0.611328125,
0.483154296875,
-0.154541015625,
0.1396484375,
0.1552734375,
0.4560546875,
-0.4775390625,
0.41357421875,
-0.0810546875,
0.3984375,
-1.01171875,
-0.65966796875,
0.51806640625,
-0.1829833984375,
-0.724609375,
0.546875,
0.25244140625,
-0.236083984375,
0.013427734375,
0.5927734375,
-0.466064453125,
0.4443359375,
-0.54736328125,
0.62451171875,
-0.116943359375,
-0.77294921875,
-0.2432861328125,
-0.470458984375,
0.68212890625,
-0.186279296875,
-0.7587890625,
0.220703125,
-1.15625,
-0.250732421875,
0.09710693359375,
-0.49755859375,
0.349365234375,
0.1513671875,
0.1280517578125,
0.09881591796875,
-0.49609375,
-0.36279296875,
-0.1741943359375,
-0.53564453125,
-0.51806640625,
0.337646484375,
0.58984375,
0.6943359375,
0.290283203125,
-0.10791015625,
0.1749267578125,
0.015655517578125,
-0.12200927734375,
-0.58447265625,
-0.354736328125,
0.213134765625,
-0.51220703125,
-0.1392822265625,
0.36181640625,
-0.0020809173583984375,
0.39697265625,
0.8720703125,
-0.055877685546875,
0.2276611328125,
0.348388671875,
-0.5146484375,
1.384765625,
-0.188720703125,
-1.0166015625,
-0.38427734375,
0.2420654296875,
0.060333251953125,
0.607421875,
-0.1727294921875,
-0.7978515625,
-0.6845703125,
-1.1015625,
0.08795166015625,
-0.5263671875,
-0.26171875,
-0.94287109375,
-0.1905517578125,
-0.51123046875,
0.7978515625,
-0.37744140625,
-0.2802734375,
0.340576171875,
-1.2001953125,
0.04998779296875,
-0.59619140625,
-0.41845703125,
-0.56201171875,
-0.5673828125,
-0.623046875,
1.09765625,
0.416015625,
0.1422119140625,
0.421142578125,
-0.34521484375,
0.24853515625,
-0.36669921875,
-0.609375,
-0.495849609375,
-0.280517578125,
0.376953125,
-0.355224609375,
-0.42138671875,
-0.625,
0.8857421875,
-0.54052734375,
0.206787109375,
-0.443603515625,
-0.5341796875,
-0.199462890625,
-0.240478515625,
0.7998046875,
-0.65283203125,
0.1392822265625,
-0.50439453125,
0.68212890625,
0.3701171875,
-0.302001953125,
-0.5234375,
-0.83447265625,
-0.6005859375,
-0.8583984375,
0.65087890625,
-0.552734375,
0.58935546875,
-0.69189453125,
-0.2587890625,
0.900390625,
-0.5205078125,
0.317138671875,
1.3330078125,
-0.2313232421875,
0.213623046875,
-0.84814453125,
0.677734375,
-0.0223541259765625,
-0.64453125,
-0.27685546875,
-0.07952880859375,
-0.9150390625,
0.0960693359375,
-0.63427734375,
-0.896484375,
-0.57373046875,
0.71044921875,
1.466796875,
-0.300537109375,
0.95556640625,
0.2305908203125,
-1.17578125,
-0.7919921875,
0.78857421875,
0.381591796875,
0.56640625,
1.1259765625,
-0.82177734375,
-0.1278076171875,
0.40673828125,
-0.07183837890625,
-0.26416015625,
-0.208984375,
1.056640625,
-0.491455078125,
-0.60302734375,
0.52783203125,
0.57568359375,
-1.111328125,
-0.5341796875,
0.07781982421875,
-0.00972747802734375,
-0.1356201171875,
-0.61669921875,
0.09686279296875,
0.63818359375,
-0.479736328125,
-0.10040283203125,
0.0250244140625,
0.04345703125,
0.634765625,
0.300048828125,
0.30419921875,
-0.51904296875,
0.64306640625,
0.80029296875,
-0.783203125,
-0.37890625,
-0.82958984375,
-0.18505859375,
-0.2322998046875,
0.37353515625,
0.81640625,
0.0882568359375,
0.2191162109375,
0.72021484375,
-0.08892822265625,
0.7138671875,
-0.38818359375,
-0.363037109375,
0.25048828125,
-0.492431640625,
-0.25927734375,
-0.01491546630859375,
0.183349609375,
0.1009521484375,
0.2156982421875,
-0.7021484375,
-0.06610107421875,
0.349853515625,
0.334716796875,
-0.08917236328125,
-0.045318603515625,
-0.325927734375,
-0.58935546875,
-0.413330078125,
-0.5380859375,
-0.765625,
-0.12188720703125,
0.429443359375,
0.367919921875,
-0.73876953125,
0.04022216796875,
0.8408203125,
-0.77880859375,
1.2099609375,
-0.7490234375,
0.325927734375,
-0.43994140625,
-0.09228515625,
-0.78466796875,
0.1318359375,
-0.41796875,
-0.27880859375,
-0.403564453125,
0.5419921875,
0.3779296875,
0.52734375,
-0.1343994140625,
0.1981201171875,
-0.173828125,
-0.81103515625,
-0.06646728515625,
0.049224853515625,
0.0947265625,
0.33251953125,
0.72021484375,
0.52099609375,
0.283203125,
-0.050048828125,
-0.61083984375,
-0.48095703125,
0.12432861328125,
0.94384765625,
0.0238494873046875,
-0.05615234375,
-0.412109375,
0.00319671630859375,
-0.6279296875,
0.261962890625,
-0.2861328125,
-0.09136962890625,
0.09783935546875,
-0.74853515625,
0.505859375,
1.26953125,
-0.09161376953125,
0.177978515625,
-0.0291900634765625,
0.2939453125,
0.386962890625,
0.1669921875,
0.341552734375,
0.1629638671875,
0.1240234375,
-0.2159423828125,
-0.158935546875,
0.6015625,
-0.01273345947265625,
0.4287109375,
-0.2010498046875,
-0.76806640625,
-0.7490234375,
-0.100341796875,
-0.27294921875,
0.042572021484375,
0.59619140625,
-0.8369140625,
-0.06622314453125,
0.087890625,
-0.95166015625,
0.1787109375,
-0.7529296875,
-0.84619140625,
0.0838623046875,
-0.133056640625,
-0.7958984375,
-0.493896484375,
-0.58740234375,
0.037139892578125,
0.1595458984375,
0.5478515625,
-0.7412109375,
0.295654296875,
-0.172119140625,
0.44287109375,
-0.215087890625,
-0.1334228515625,
0.1318359375,
0.291748046875,
-0.470703125,
-0.6533203125,
0.0771484375,
1.4853515625,
0.17919921875,
-0.34912109375,
-0.63037109375,
0.10302734375,
-0.42919921875,
0.3271484375,
-0.2034912109375,
-0.18896484375,
0.01824951171875,
0.435791015625,
-1.181640625,
-0.354248046875,
0.084716796875,
0.286376953125,
-0.021026611328125,
-0.3447265625,
-0.2130126953125,
0.68994140625,
0.982421875,
-0.1396484375,
-0.058502197265625,
0.408935546875,
0.79150390625,
-0.26220703125,
-0.127197265625,
-0.251708984375,
0.30224609375,
0.53076171875,
0.27490234375,
-0.2354736328125,
0.69873046875,
0.93798828125,
-0.33203125,
-0.2208251953125,
0.5380859375,
0.03131103515625,
-0.0085906982421875,
-0.241943359375,
-0.2291259765625,
0.040191650390625,
-0.06988525390625,
-0.84619140625,
0.172607421875,
-0.378662109375,
-0.333251953125,
-0.176513671875,
-0.70849609375,
0.98046875,
-1.1953125,
0.4619140625,
-0.26220703125,
-0.12158203125,
0.399169921875,
0.98046875,
0.05169677734375,
-0.056793212890625,
0.50390625,
0.341552734375,
0.58349609375,
0.8076171875,
0.208984375,
0.154541015625,
-0.3916015625,
0.146484375,
-0.0693359375,
0.006015777587890625,
-0.6806640625,
-0.28125,
-1.1416015625,
0.6298828125,
-0.399169921875,
-0.09930419921875,
0.433837890625,
-0.5341796875,
0.1962890625,
-0.284912109375,
0.7646484375,
-0.38037109375,
0.434814453125,
0.5458984375,
-0.57177734375,
-0.447509765625,
0.84423828125,
-0.1993408203125,
0.38232421875,
0.1937255859375,
0.73828125,
0.34814453125,
1.716796875,
0.32080078125,
-0.2578125,
-0.147705078125,
0.057220458984375,
-0.234375,
-0.60400390625,
-0.38916015625,
-0.37158203125,
-0.119140625,
-0.398193359375,
-0.22998046875,
0.0257110595703125,
0.6533203125,
0.0811767578125,
-0.80615234375,
-0.042236328125,
0.08184814453125,
-0.84521484375,
0.7734375,
0.261474609375,
0.02947998046875,
0.07269287109375,
0.08599853515625,
-0.14208984375,
-0.35009765625,
-0.185791015625,
-0.5927734375,
0.2236328125,
-0.5849609375,
-0.5380859375,
-0.609375,
-1.0380859375,
-0.375732421875,
-0.33203125,
-0.476318359375,
-1.0390625,
0.1490478515625,
0.65185546875,
0.40625,
0.5107421875,
-0.51611328125,
0.397705078125,
1.123046875,
0.71630859375,
-0.351806640625,
0.80810546875,
0.36474609375,
-0.525390625,
0.08441162109375,
-0.0052032470703125,
0.6953125,
-0.33837890625,
-0.0105133056640625,
-0.297607421875,
0.5234375,
-0.9794921875,
-1.3837890625,
0.06396484375,
0.6513671875,
0.50341796875,
-0.54345703125,
-0.9306640625,
-0.401123046875,
-0.74755859375,
-0.046600341796875,
-0.78271484375,
0.6123046875,
0.388671875,
-0.09393310546875,
0.0287017822265625,
-1.0283203125,
4.31640625,
1.0087890625,
0.94677734375,
0.07049560546875,
-0.028228759765625,
0.970703125,
-0.0012559890747070312,
-0.31884765625,
0.1610107421875,
-0.3154296875,
0.7646484375,
-0.215576171875,
-0.088134765625,
0.65087890625,
0.1949462890625,
0.453125,
-0.48486328125,
-0.0171356201171875,
-0.247314453125,
-0.990234375,
-0.7939453125,
0.0758056640625,
0.2432861328125,
0.165283203125,
0.08551025390625,
0.093017578125,
0.57080078125,
-0.626953125,
-0.29052734375,
-0.63525390625,
-0.28369140625,
-0.7109375,
0.666015625,
-0.0755615234375,
-0.1834716796875,
0.50732421875,
0.1470947265625,
-0.62744140625,
0.057891845703125,
0.55517578125,
-0.30810546875,
-0.44873046875,
0.86669921875,
-0.8212890625,
0.197998046875,
0.5556640625,
-0.294677734375,
0.279541015625,
0.62841796875,
-0.421142578125,
0.78076171875,
-0.2249755859375,
0.73193359375,
-0.73681640625,
-0.671875,
0.04107666015625,
0.2283935546875,
-0.33349609375,
0.03997802734375,
0.3427734375,
0.2381591796875,
0.1112060546875,
0.050140380859375,
0.38818359375,
-0.68896484375,
0.68212890625,
0.2008056640625,
0.19287109375,
-0.5341796875,
0.09197998046875,
0.018310546875,
-0.137939453125,
-0.4248046875,
-0.50244140625,
0.57275390625,
0.2161865234375,
-0.0219268798828125,
0.30810546875,
0.471435546875,
-0.78955078125,
0.0018644332885742188,
0.0350341796875,
-0.3779296875,
-0.31396484375,
0.5810546875,
1.5830078125,
-0.75439453125,
-0.423828125,
-0.53466796875,
0.6142578125,
0.183349609375,
0.2802734375,
0.60400390625,
-0.91357421875,
-0.25048828125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Tags: greedy
Correct Solution:
```
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
ALPHA='abcdefghijklmnopqrstuvwxyz'
MOD=1000000007
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]
#-------------------------code---------------------------#
# vsInput()
s=input()
m=Int()
n=len(s)
ans=0
for _ in range(m):
a,b=list(input())
Ca=0
Cb=0
for i in s+'/':
if(i==a): Ca+=1
elif(i==b): Cb+=1
else:
ans+=min(Ca,Cb)
Ca=0
Cb=0
print(ans)
```
| 70,997 | [
0.291015625,
-0.05596923828125,
0.1292724609375,
0.284912109375,
-0.5634765625,
-0.67431640625,
0.14208984375,
-0.12200927734375,
-0.189208984375,
0.90283203125,
0.8505859375,
-0.01378631591796875,
-0.3876953125,
-0.91552734375,
-0.935546875,
-0.12841796875,
-0.91455078125,
-0.58349609375,
-0.53955078125,
-0.1390380859375,
0.0859375,
-0.15283203125,
-1.6376953125,
-0.293212890625,
-0.37158203125,
1.2021484375,
0.3583984375,
-0.2958984375,
1.162109375,
0.75048828125,
-0.26318359375,
-0.338623046875,
0.5576171875,
-1.1689453125,
-0.6259765625,
-0.51220703125,
0.9462890625,
-0.467041015625,
0.007476806640625,
-0.064208984375,
0.66064453125,
-0.251953125,
0.473388671875,
-0.5341796875,
-1.2958984375,
-0.35791015625,
-0.126953125,
-0.61376953125,
-0.3544921875,
-0.40869140625,
0.332275390625,
-0.334228515625,
0.62109375,
-0.220947265625,
0.07373046875,
0.156494140625,
0.2384033203125,
0.08428955078125,
-0.693359375,
0.411376953125,
0.134765625,
0.374755859375,
0.1448974609375,
-0.75634765625,
-0.421875,
-0.107666015625,
-0.309814453125,
0.202392578125,
-0.00026702880859375,
-0.61181640625,
-0.241455078125,
0.4931640625,
-0.3916015625,
-0.330078125,
-0.673828125,
0.0330810546875,
0.2467041015625,
0.093994140625,
-0.56689453125,
0.8388671875,
0.36865234375,
1.013671875,
0.77001953125,
-0.10443115234375,
-0.35009765625,
-0.129150390625,
0.00772857666015625,
0.378662109375,
0.423828125,
-0.2183837890625,
-0.1893310546875,
0.541015625,
-1.03515625,
-0.166748046875,
0.5908203125,
0.40576171875,
-0.28515625,
0.283447265625,
0.45751953125,
0.44873046875,
0.89892578125,
0.58349609375,
-0.34912109375,
0.82958984375,
-0.5546875,
0.16162109375,
0.0953369140625,
0.1873779296875,
-0.05413818359375,
0.25927734375,
-0.31201171875,
-0.08892822265625,
0.486083984375,
0.458984375,
-0.6806640625,
0.76953125,
-0.276123046875,
0.3896484375,
-0.8388671875,
0.281494140625,
0.7314453125,
-0.06927490234375,
0.84912109375,
0.044891357421875,
0.1920166015625,
-0.2216796875,
-0.6083984375,
1.0673828125,
-0.433837890625,
-0.021942138671875,
0.49365234375,
0.0227508544921875,
-0.06689453125,
0.2044677734375,
-0.32080078125,
0.8076171875,
-0.287353515625,
0.6162109375,
0.55419921875,
-0.6220703125,
0.492431640625,
-0.2286376953125,
-0.053070068359375,
1.4287109375,
0.708984375,
-0.06097412109375,
0.78515625,
0.42822265625,
-0.92724609375,
0.1619873046875,
-1.3056640625,
0.8525390625,
0.14013671875,
0.117919921875,
-0.53369140625,
-0.1455078125,
-0.2314453125,
0.157958984375,
0.06756591796875,
0.2060546875,
-0.46826171875,
0.1510009765625,
-0.310302734375,
0.62744140625,
-0.2587890625,
1.0556640625,
-0.6728515625,
0.01007080078125,
-0.142333984375,
-0.5966796875,
0.19921875,
-0.040008544921875,
0.11669921875,
1.0732421875,
0.1568603515625,
0.8330078125,
0.56884765625,
-0.344482421875,
0.64306640625,
0.4794921875,
-0.10455322265625,
0.48046875,
0.1812744140625,
0.324462890625,
0.521484375,
0.298583984375,
-0.15625,
-0.415283203125,
-0.84716796875,
-0.375,
-0.0113525390625,
0.65673828125,
-0.37353515625,
0.341064453125,
0.047698974609375,
-0.0391845703125,
-1.0478515625,
-0.32666015625,
0.18408203125,
-1.0986328125,
-0.5546875,
0.90283203125,
0.14599609375,
0.74658203125,
-0.202392578125,
-0.626953125,
0.64892578125,
1.4775390625,
-0.3173828125,
0.278564453125,
0.6513671875,
-0.58935546875,
-0.345947265625,
0.45751953125,
-0.1702880859375,
-0.179931640625,
-0.85400390625,
0.72412109375,
-0.53466796875,
-0.0231475830078125,
-0.2080078125,
0.266357421875,
0.2763671875,
0.66015625,
-0.1806640625,
-0.3349609375,
0.84765625,
1.12890625,
0.0369873046875,
0.50390625,
0.197998046875,
0.7021484375,
0.1204833984375,
0.71240234375,
0.412841796875,
0.1494140625,
0.8486328125,
0.916015625,
0.2119140625,
0.52880859375,
-0.2252197265625,
0.44091796875,
0.1973876953125,
0.580078125,
0.440673828125,
0.29052734375,
-0.316162109375,
-0.038177490234375,
-0.3876953125,
0.09185791015625,
-0.252197265625,
0.32080078125,
0.431884765625,
0.432373046875,
-0.29443359375,
-0.13916015625,
0.2066650390625,
0.685546875,
-1.171875,
-0.45703125,
0.045135498046875,
0.1319580078125,
-0.0281219482421875,
0.00022304058074951172,
0.2379150390625,
0.77880859375,
0.70263671875,
0.328857421875,
-0.52783203125,
-0.52783203125,
-1.1328125,
-1.0107421875,
-0.86376953125,
-0.332275390625,
-0.82568359375,
-0.11688232421875,
0.634765625,
-1.0869140625,
0.482177734375,
-0.2861328125,
-0.5302734375,
0.1619873046875,
-0.578125,
0.6025390625,
-0.2027587890625,
0.80029296875,
-0.755859375,
0.73291015625,
0.034820556640625,
0.90234375,
-0.287841796875,
-0.3671875,
-0.047760009765625,
-0.61767578125,
0.251953125,
-0.0189208984375,
0.3017578125,
0.1771240234375,
-0.6533203125,
-0.7646484375,
0.032501220703125,
-0.308349609375,
-0.57861328125,
0.215087890625,
-0.7529296875,
0.7294921875,
0.93994140625,
-0.66845703125,
0.77392578125,
1.1220703125,
-0.94921875,
0.0287628173828125,
0.1856689453125,
0.2998046875,
-0.615234375,
1.189453125,
0.29052734375,
0.3974609375,
-0.5205078125,
-0.51220703125,
-0.755859375,
0.0966796875,
-0.03570556640625,
-0.354736328125,
-0.09564208984375,
0.75634765625,
-0.267333984375,
-0.994140625,
0.75341796875,
-1.1796875,
-0.10711669921875,
-0.1295166015625,
-0.489501953125,
0.95068359375,
0.342529296875,
0.354736328125,
-0.288330078125,
-0.818359375,
-0.25146484375,
0.82421875,
0.1776123046875,
-0.521484375,
-0.0372314453125,
0.2440185546875,
0.1773681640625,
0.150634765625,
0.12078857421875,
-0.232421875,
-0.3251953125,
0.070068359375,
0.221923828125,
0.92333984375,
0.2998046875,
0.3857421875,
0.365234375,
0.8486328125,
-0.6884765625,
-0.252685546875,
-0.270263671875,
0.720703125,
0.21337890625,
0.39697265625,
0.1611328125,
-0.24755859375,
-0.330078125,
-0.80615234375,
0.483642578125,
-0.295166015625,
0.763671875,
-0.5322265625,
0.6181640625,
0.383056640625,
-0.5263671875,
0.65966796875,
-0.89599609375,
-0.358154296875,
0.90283203125,
-0.6650390625,
0.95068359375,
-0.8916015625,
0.194580078125,
0.06884765625,
0.1278076171875,
0.701171875,
0.642578125,
0.7373046875,
-0.453125,
-0.60302734375,
-0.2890625,
0.278076171875,
-0.06378173828125,
-0.525390625,
0.144775390625,
-0.2440185546875,
-0.41455078125,
-0.89111328125,
0.41357421875,
0.86083984375,
0.57275390625,
0.3359375,
0.4248046875,
0.1689453125,
0.58740234375,
0.9111328125,
-0.0947265625,
-0.002368927001953125,
-0.7587890625,
1.0380859375,
-0.0124053955078125,
-0.480224609375,
-0.34765625,
-0.33544921875,
-0.312255859375,
0.323974609375,
0.018951416015625,
0.04071044921875,
-0.89208984375,
-0.170654296875,
-0.13720703125,
0.361572265625,
-0.73583984375,
-0.3095703125,
-0.189697265625,
0.425048828125,
0.08111572265625,
-1.017578125,
0.390380859375,
-0.6630859375,
0.927734375,
0.99169921875,
0.0635986328125,
-0.51708984375,
-0.149658203125,
-0.53955078125,
-0.86767578125,
-0.1142578125,
0.58154296875,
-0.12353515625,
0.2261962890625,
-1.2578125,
0.57958984375,
0.3349609375,
-0.088134765625,
0.28466796875,
0.193359375,
0.472900390625,
0.142578125,
0.5234375,
-0.6318359375,
-0.66357421875,
0.419189453125,
-1.1201171875,
0.763671875,
-0.611328125,
0.483154296875,
-0.154541015625,
0.1396484375,
0.1552734375,
0.4560546875,
-0.4775390625,
0.41357421875,
-0.0810546875,
0.3984375,
-1.01171875,
-0.65966796875,
0.51806640625,
-0.1829833984375,
-0.724609375,
0.546875,
0.25244140625,
-0.236083984375,
0.013427734375,
0.5927734375,
-0.466064453125,
0.4443359375,
-0.54736328125,
0.62451171875,
-0.116943359375,
-0.77294921875,
-0.2432861328125,
-0.470458984375,
0.68212890625,
-0.186279296875,
-0.7587890625,
0.220703125,
-1.15625,
-0.250732421875,
0.09710693359375,
-0.49755859375,
0.349365234375,
0.1513671875,
0.1280517578125,
0.09881591796875,
-0.49609375,
-0.36279296875,
-0.1741943359375,
-0.53564453125,
-0.51806640625,
0.337646484375,
0.58984375,
0.6943359375,
0.290283203125,
-0.10791015625,
0.1749267578125,
0.015655517578125,
-0.12200927734375,
-0.58447265625,
-0.354736328125,
0.213134765625,
-0.51220703125,
-0.1392822265625,
0.36181640625,
-0.0020809173583984375,
0.39697265625,
0.8720703125,
-0.055877685546875,
0.2276611328125,
0.348388671875,
-0.5146484375,
1.384765625,
-0.188720703125,
-1.0166015625,
-0.38427734375,
0.2420654296875,
0.060333251953125,
0.607421875,
-0.1727294921875,
-0.7978515625,
-0.6845703125,
-1.1015625,
0.08795166015625,
-0.5263671875,
-0.26171875,
-0.94287109375,
-0.1905517578125,
-0.51123046875,
0.7978515625,
-0.37744140625,
-0.2802734375,
0.340576171875,
-1.2001953125,
0.04998779296875,
-0.59619140625,
-0.41845703125,
-0.56201171875,
-0.5673828125,
-0.623046875,
1.09765625,
0.416015625,
0.1422119140625,
0.421142578125,
-0.34521484375,
0.24853515625,
-0.36669921875,
-0.609375,
-0.495849609375,
-0.280517578125,
0.376953125,
-0.355224609375,
-0.42138671875,
-0.625,
0.8857421875,
-0.54052734375,
0.206787109375,
-0.443603515625,
-0.5341796875,
-0.199462890625,
-0.240478515625,
0.7998046875,
-0.65283203125,
0.1392822265625,
-0.50439453125,
0.68212890625,
0.3701171875,
-0.302001953125,
-0.5234375,
-0.83447265625,
-0.6005859375,
-0.8583984375,
0.65087890625,
-0.552734375,
0.58935546875,
-0.69189453125,
-0.2587890625,
0.900390625,
-0.5205078125,
0.317138671875,
1.3330078125,
-0.2313232421875,
0.213623046875,
-0.84814453125,
0.677734375,
-0.0223541259765625,
-0.64453125,
-0.27685546875,
-0.07952880859375,
-0.9150390625,
0.0960693359375,
-0.63427734375,
-0.896484375,
-0.57373046875,
0.71044921875,
1.466796875,
-0.300537109375,
0.95556640625,
0.2305908203125,
-1.17578125,
-0.7919921875,
0.78857421875,
0.381591796875,
0.56640625,
1.1259765625,
-0.82177734375,
-0.1278076171875,
0.40673828125,
-0.07183837890625,
-0.26416015625,
-0.208984375,
1.056640625,
-0.491455078125,
-0.60302734375,
0.52783203125,
0.57568359375,
-1.111328125,
-0.5341796875,
0.07781982421875,
-0.00972747802734375,
-0.1356201171875,
-0.61669921875,
0.09686279296875,
0.63818359375,
-0.479736328125,
-0.10040283203125,
0.0250244140625,
0.04345703125,
0.634765625,
0.300048828125,
0.30419921875,
-0.51904296875,
0.64306640625,
0.80029296875,
-0.783203125,
-0.37890625,
-0.82958984375,
-0.18505859375,
-0.2322998046875,
0.37353515625,
0.81640625,
0.0882568359375,
0.2191162109375,
0.72021484375,
-0.08892822265625,
0.7138671875,
-0.38818359375,
-0.363037109375,
0.25048828125,
-0.492431640625,
-0.25927734375,
-0.01491546630859375,
0.183349609375,
0.1009521484375,
0.2156982421875,
-0.7021484375,
-0.06610107421875,
0.349853515625,
0.334716796875,
-0.08917236328125,
-0.045318603515625,
-0.325927734375,
-0.58935546875,
-0.413330078125,
-0.5380859375,
-0.765625,
-0.12188720703125,
0.429443359375,
0.367919921875,
-0.73876953125,
0.04022216796875,
0.8408203125,
-0.77880859375,
1.2099609375,
-0.7490234375,
0.325927734375,
-0.43994140625,
-0.09228515625,
-0.78466796875,
0.1318359375,
-0.41796875,
-0.27880859375,
-0.403564453125,
0.5419921875,
0.3779296875,
0.52734375,
-0.1343994140625,
0.1981201171875,
-0.173828125,
-0.81103515625,
-0.06646728515625,
0.049224853515625,
0.0947265625,
0.33251953125,
0.72021484375,
0.52099609375,
0.283203125,
-0.050048828125,
-0.61083984375,
-0.48095703125,
0.12432861328125,
0.94384765625,
0.0238494873046875,
-0.05615234375,
-0.412109375,
0.00319671630859375,
-0.6279296875,
0.261962890625,
-0.2861328125,
-0.09136962890625,
0.09783935546875,
-0.74853515625,
0.505859375,
1.26953125,
-0.09161376953125,
0.177978515625,
-0.0291900634765625,
0.2939453125,
0.386962890625,
0.1669921875,
0.341552734375,
0.1629638671875,
0.1240234375,
-0.2159423828125,
-0.158935546875,
0.6015625,
-0.01273345947265625,
0.4287109375,
-0.2010498046875,
-0.76806640625,
-0.7490234375,
-0.100341796875,
-0.27294921875,
0.042572021484375,
0.59619140625,
-0.8369140625,
-0.06622314453125,
0.087890625,
-0.95166015625,
0.1787109375,
-0.7529296875,
-0.84619140625,
0.0838623046875,
-0.133056640625,
-0.7958984375,
-0.493896484375,
-0.58740234375,
0.037139892578125,
0.1595458984375,
0.5478515625,
-0.7412109375,
0.295654296875,
-0.172119140625,
0.44287109375,
-0.215087890625,
-0.1334228515625,
0.1318359375,
0.291748046875,
-0.470703125,
-0.6533203125,
0.0771484375,
1.4853515625,
0.17919921875,
-0.34912109375,
-0.63037109375,
0.10302734375,
-0.42919921875,
0.3271484375,
-0.2034912109375,
-0.18896484375,
0.01824951171875,
0.435791015625,
-1.181640625,
-0.354248046875,
0.084716796875,
0.286376953125,
-0.021026611328125,
-0.3447265625,
-0.2130126953125,
0.68994140625,
0.982421875,
-0.1396484375,
-0.058502197265625,
0.408935546875,
0.79150390625,
-0.26220703125,
-0.127197265625,
-0.251708984375,
0.30224609375,
0.53076171875,
0.27490234375,
-0.2354736328125,
0.69873046875,
0.93798828125,
-0.33203125,
-0.2208251953125,
0.5380859375,
0.03131103515625,
-0.0085906982421875,
-0.241943359375,
-0.2291259765625,
0.040191650390625,
-0.06988525390625,
-0.84619140625,
0.172607421875,
-0.378662109375,
-0.333251953125,
-0.176513671875,
-0.70849609375,
0.98046875,
-1.1953125,
0.4619140625,
-0.26220703125,
-0.12158203125,
0.399169921875,
0.98046875,
0.05169677734375,
-0.056793212890625,
0.50390625,
0.341552734375,
0.58349609375,
0.8076171875,
0.208984375,
0.154541015625,
-0.3916015625,
0.146484375,
-0.0693359375,
0.006015777587890625,
-0.6806640625,
-0.28125,
-1.1416015625,
0.6298828125,
-0.399169921875,
-0.09930419921875,
0.433837890625,
-0.5341796875,
0.1962890625,
-0.284912109375,
0.7646484375,
-0.38037109375,
0.434814453125,
0.5458984375,
-0.57177734375,
-0.447509765625,
0.84423828125,
-0.1993408203125,
0.38232421875,
0.1937255859375,
0.73828125,
0.34814453125,
1.716796875,
0.32080078125,
-0.2578125,
-0.147705078125,
0.057220458984375,
-0.234375,
-0.60400390625,
-0.38916015625,
-0.37158203125,
-0.119140625,
-0.398193359375,
-0.22998046875,
0.0257110595703125,
0.6533203125,
0.0811767578125,
-0.80615234375,
-0.042236328125,
0.08184814453125,
-0.84521484375,
0.7734375,
0.261474609375,
0.02947998046875,
0.07269287109375,
0.08599853515625,
-0.14208984375,
-0.35009765625,
-0.185791015625,
-0.5927734375,
0.2236328125,
-0.5849609375,
-0.5380859375,
-0.609375,
-1.0380859375,
-0.375732421875,
-0.33203125,
-0.476318359375,
-1.0390625,
0.1490478515625,
0.65185546875,
0.40625,
0.5107421875,
-0.51611328125,
0.397705078125,
1.123046875,
0.71630859375,
-0.351806640625,
0.80810546875,
0.36474609375,
-0.525390625,
0.08441162109375,
-0.0052032470703125,
0.6953125,
-0.33837890625,
-0.0105133056640625,
-0.297607421875,
0.5234375,
-0.9794921875,
-1.3837890625,
0.06396484375,
0.6513671875,
0.50341796875,
-0.54345703125,
-0.9306640625,
-0.401123046875,
-0.74755859375,
-0.046600341796875,
-0.78271484375,
0.6123046875,
0.388671875,
-0.09393310546875,
0.0287017822265625,
-1.0283203125,
4.31640625,
1.0087890625,
0.94677734375,
0.07049560546875,
-0.028228759765625,
0.970703125,
-0.0012559890747070312,
-0.31884765625,
0.1610107421875,
-0.3154296875,
0.7646484375,
-0.215576171875,
-0.088134765625,
0.65087890625,
0.1949462890625,
0.453125,
-0.48486328125,
-0.0171356201171875,
-0.247314453125,
-0.990234375,
-0.7939453125,
0.0758056640625,
0.2432861328125,
0.165283203125,
0.08551025390625,
0.093017578125,
0.57080078125,
-0.626953125,
-0.29052734375,
-0.63525390625,
-0.28369140625,
-0.7109375,
0.666015625,
-0.0755615234375,
-0.1834716796875,
0.50732421875,
0.1470947265625,
-0.62744140625,
0.057891845703125,
0.55517578125,
-0.30810546875,
-0.44873046875,
0.86669921875,
-0.8212890625,
0.197998046875,
0.5556640625,
-0.294677734375,
0.279541015625,
0.62841796875,
-0.421142578125,
0.78076171875,
-0.2249755859375,
0.73193359375,
-0.73681640625,
-0.671875,
0.04107666015625,
0.2283935546875,
-0.33349609375,
0.03997802734375,
0.3427734375,
0.2381591796875,
0.1112060546875,
0.050140380859375,
0.38818359375,
-0.68896484375,
0.68212890625,
0.2008056640625,
0.19287109375,
-0.5341796875,
0.09197998046875,
0.018310546875,
-0.137939453125,
-0.4248046875,
-0.50244140625,
0.57275390625,
0.2161865234375,
-0.0219268798828125,
0.30810546875,
0.471435546875,
-0.78955078125,
0.0018644332885742188,
0.0350341796875,
-0.3779296875,
-0.31396484375,
0.5810546875,
1.5830078125,
-0.75439453125,
-0.423828125,
-0.53466796875,
0.6142578125,
0.183349609375,
0.2802734375,
0.60400390625,
-0.91357421875,
-0.25048828125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Tags: greedy
Correct Solution:
```
s=input()
ans=[]
count=1
for i in range(1,len(s)):
if(s[i]==s[i-1]):
count+=1
else:
ans.append([count,s[i-1]])
count=1
ans.append([count,s[-1]])
total=0
t=int(input())
for m in range(t):
r=input()
i=0
while(i<len(ans)):
if(ans[i][1] in r):
t1=ans[i][0]
t2=0
flag=0
j=i+1
for j in range(i+1,len(ans)):
if(flag==0):
if(ans[j][1]!=ans[i][1] and ans[j][1] in r):
t2+=ans[j][0]
flag=1
continue;
else:
break;
else:
if(ans[i][1]==ans[j][1]):
t1+=ans[j][0]
flag=0
continue;
else:
break;
total+=min(t1,t2)
i=j+1
else:
i+=1
print(total)
```
| 70,998 | [
0.291015625,
-0.05596923828125,
0.1292724609375,
0.284912109375,
-0.5634765625,
-0.67431640625,
0.14208984375,
-0.12200927734375,
-0.189208984375,
0.90283203125,
0.8505859375,
-0.01378631591796875,
-0.3876953125,
-0.91552734375,
-0.935546875,
-0.12841796875,
-0.91455078125,
-0.58349609375,
-0.53955078125,
-0.1390380859375,
0.0859375,
-0.15283203125,
-1.6376953125,
-0.293212890625,
-0.37158203125,
1.2021484375,
0.3583984375,
-0.2958984375,
1.162109375,
0.75048828125,
-0.26318359375,
-0.338623046875,
0.5576171875,
-1.1689453125,
-0.6259765625,
-0.51220703125,
0.9462890625,
-0.467041015625,
0.007476806640625,
-0.064208984375,
0.66064453125,
-0.251953125,
0.473388671875,
-0.5341796875,
-1.2958984375,
-0.35791015625,
-0.126953125,
-0.61376953125,
-0.3544921875,
-0.40869140625,
0.332275390625,
-0.334228515625,
0.62109375,
-0.220947265625,
0.07373046875,
0.156494140625,
0.2384033203125,
0.08428955078125,
-0.693359375,
0.411376953125,
0.134765625,
0.374755859375,
0.1448974609375,
-0.75634765625,
-0.421875,
-0.107666015625,
-0.309814453125,
0.202392578125,
-0.00026702880859375,
-0.61181640625,
-0.241455078125,
0.4931640625,
-0.3916015625,
-0.330078125,
-0.673828125,
0.0330810546875,
0.2467041015625,
0.093994140625,
-0.56689453125,
0.8388671875,
0.36865234375,
1.013671875,
0.77001953125,
-0.10443115234375,
-0.35009765625,
-0.129150390625,
0.00772857666015625,
0.378662109375,
0.423828125,
-0.2183837890625,
-0.1893310546875,
0.541015625,
-1.03515625,
-0.166748046875,
0.5908203125,
0.40576171875,
-0.28515625,
0.283447265625,
0.45751953125,
0.44873046875,
0.89892578125,
0.58349609375,
-0.34912109375,
0.82958984375,
-0.5546875,
0.16162109375,
0.0953369140625,
0.1873779296875,
-0.05413818359375,
0.25927734375,
-0.31201171875,
-0.08892822265625,
0.486083984375,
0.458984375,
-0.6806640625,
0.76953125,
-0.276123046875,
0.3896484375,
-0.8388671875,
0.281494140625,
0.7314453125,
-0.06927490234375,
0.84912109375,
0.044891357421875,
0.1920166015625,
-0.2216796875,
-0.6083984375,
1.0673828125,
-0.433837890625,
-0.021942138671875,
0.49365234375,
0.0227508544921875,
-0.06689453125,
0.2044677734375,
-0.32080078125,
0.8076171875,
-0.287353515625,
0.6162109375,
0.55419921875,
-0.6220703125,
0.492431640625,
-0.2286376953125,
-0.053070068359375,
1.4287109375,
0.708984375,
-0.06097412109375,
0.78515625,
0.42822265625,
-0.92724609375,
0.1619873046875,
-1.3056640625,
0.8525390625,
0.14013671875,
0.117919921875,
-0.53369140625,
-0.1455078125,
-0.2314453125,
0.157958984375,
0.06756591796875,
0.2060546875,
-0.46826171875,
0.1510009765625,
-0.310302734375,
0.62744140625,
-0.2587890625,
1.0556640625,
-0.6728515625,
0.01007080078125,
-0.142333984375,
-0.5966796875,
0.19921875,
-0.040008544921875,
0.11669921875,
1.0732421875,
0.1568603515625,
0.8330078125,
0.56884765625,
-0.344482421875,
0.64306640625,
0.4794921875,
-0.10455322265625,
0.48046875,
0.1812744140625,
0.324462890625,
0.521484375,
0.298583984375,
-0.15625,
-0.415283203125,
-0.84716796875,
-0.375,
-0.0113525390625,
0.65673828125,
-0.37353515625,
0.341064453125,
0.047698974609375,
-0.0391845703125,
-1.0478515625,
-0.32666015625,
0.18408203125,
-1.0986328125,
-0.5546875,
0.90283203125,
0.14599609375,
0.74658203125,
-0.202392578125,
-0.626953125,
0.64892578125,
1.4775390625,
-0.3173828125,
0.278564453125,
0.6513671875,
-0.58935546875,
-0.345947265625,
0.45751953125,
-0.1702880859375,
-0.179931640625,
-0.85400390625,
0.72412109375,
-0.53466796875,
-0.0231475830078125,
-0.2080078125,
0.266357421875,
0.2763671875,
0.66015625,
-0.1806640625,
-0.3349609375,
0.84765625,
1.12890625,
0.0369873046875,
0.50390625,
0.197998046875,
0.7021484375,
0.1204833984375,
0.71240234375,
0.412841796875,
0.1494140625,
0.8486328125,
0.916015625,
0.2119140625,
0.52880859375,
-0.2252197265625,
0.44091796875,
0.1973876953125,
0.580078125,
0.440673828125,
0.29052734375,
-0.316162109375,
-0.038177490234375,
-0.3876953125,
0.09185791015625,
-0.252197265625,
0.32080078125,
0.431884765625,
0.432373046875,
-0.29443359375,
-0.13916015625,
0.2066650390625,
0.685546875,
-1.171875,
-0.45703125,
0.045135498046875,
0.1319580078125,
-0.0281219482421875,
0.00022304058074951172,
0.2379150390625,
0.77880859375,
0.70263671875,
0.328857421875,
-0.52783203125,
-0.52783203125,
-1.1328125,
-1.0107421875,
-0.86376953125,
-0.332275390625,
-0.82568359375,
-0.11688232421875,
0.634765625,
-1.0869140625,
0.482177734375,
-0.2861328125,
-0.5302734375,
0.1619873046875,
-0.578125,
0.6025390625,
-0.2027587890625,
0.80029296875,
-0.755859375,
0.73291015625,
0.034820556640625,
0.90234375,
-0.287841796875,
-0.3671875,
-0.047760009765625,
-0.61767578125,
0.251953125,
-0.0189208984375,
0.3017578125,
0.1771240234375,
-0.6533203125,
-0.7646484375,
0.032501220703125,
-0.308349609375,
-0.57861328125,
0.215087890625,
-0.7529296875,
0.7294921875,
0.93994140625,
-0.66845703125,
0.77392578125,
1.1220703125,
-0.94921875,
0.0287628173828125,
0.1856689453125,
0.2998046875,
-0.615234375,
1.189453125,
0.29052734375,
0.3974609375,
-0.5205078125,
-0.51220703125,
-0.755859375,
0.0966796875,
-0.03570556640625,
-0.354736328125,
-0.09564208984375,
0.75634765625,
-0.267333984375,
-0.994140625,
0.75341796875,
-1.1796875,
-0.10711669921875,
-0.1295166015625,
-0.489501953125,
0.95068359375,
0.342529296875,
0.354736328125,
-0.288330078125,
-0.818359375,
-0.25146484375,
0.82421875,
0.1776123046875,
-0.521484375,
-0.0372314453125,
0.2440185546875,
0.1773681640625,
0.150634765625,
0.12078857421875,
-0.232421875,
-0.3251953125,
0.070068359375,
0.221923828125,
0.92333984375,
0.2998046875,
0.3857421875,
0.365234375,
0.8486328125,
-0.6884765625,
-0.252685546875,
-0.270263671875,
0.720703125,
0.21337890625,
0.39697265625,
0.1611328125,
-0.24755859375,
-0.330078125,
-0.80615234375,
0.483642578125,
-0.295166015625,
0.763671875,
-0.5322265625,
0.6181640625,
0.383056640625,
-0.5263671875,
0.65966796875,
-0.89599609375,
-0.358154296875,
0.90283203125,
-0.6650390625,
0.95068359375,
-0.8916015625,
0.194580078125,
0.06884765625,
0.1278076171875,
0.701171875,
0.642578125,
0.7373046875,
-0.453125,
-0.60302734375,
-0.2890625,
0.278076171875,
-0.06378173828125,
-0.525390625,
0.144775390625,
-0.2440185546875,
-0.41455078125,
-0.89111328125,
0.41357421875,
0.86083984375,
0.57275390625,
0.3359375,
0.4248046875,
0.1689453125,
0.58740234375,
0.9111328125,
-0.0947265625,
-0.002368927001953125,
-0.7587890625,
1.0380859375,
-0.0124053955078125,
-0.480224609375,
-0.34765625,
-0.33544921875,
-0.312255859375,
0.323974609375,
0.018951416015625,
0.04071044921875,
-0.89208984375,
-0.170654296875,
-0.13720703125,
0.361572265625,
-0.73583984375,
-0.3095703125,
-0.189697265625,
0.425048828125,
0.08111572265625,
-1.017578125,
0.390380859375,
-0.6630859375,
0.927734375,
0.99169921875,
0.0635986328125,
-0.51708984375,
-0.149658203125,
-0.53955078125,
-0.86767578125,
-0.1142578125,
0.58154296875,
-0.12353515625,
0.2261962890625,
-1.2578125,
0.57958984375,
0.3349609375,
-0.088134765625,
0.28466796875,
0.193359375,
0.472900390625,
0.142578125,
0.5234375,
-0.6318359375,
-0.66357421875,
0.419189453125,
-1.1201171875,
0.763671875,
-0.611328125,
0.483154296875,
-0.154541015625,
0.1396484375,
0.1552734375,
0.4560546875,
-0.4775390625,
0.41357421875,
-0.0810546875,
0.3984375,
-1.01171875,
-0.65966796875,
0.51806640625,
-0.1829833984375,
-0.724609375,
0.546875,
0.25244140625,
-0.236083984375,
0.013427734375,
0.5927734375,
-0.466064453125,
0.4443359375,
-0.54736328125,
0.62451171875,
-0.116943359375,
-0.77294921875,
-0.2432861328125,
-0.470458984375,
0.68212890625,
-0.186279296875,
-0.7587890625,
0.220703125,
-1.15625,
-0.250732421875,
0.09710693359375,
-0.49755859375,
0.349365234375,
0.1513671875,
0.1280517578125,
0.09881591796875,
-0.49609375,
-0.36279296875,
-0.1741943359375,
-0.53564453125,
-0.51806640625,
0.337646484375,
0.58984375,
0.6943359375,
0.290283203125,
-0.10791015625,
0.1749267578125,
0.015655517578125,
-0.12200927734375,
-0.58447265625,
-0.354736328125,
0.213134765625,
-0.51220703125,
-0.1392822265625,
0.36181640625,
-0.0020809173583984375,
0.39697265625,
0.8720703125,
-0.055877685546875,
0.2276611328125,
0.348388671875,
-0.5146484375,
1.384765625,
-0.188720703125,
-1.0166015625,
-0.38427734375,
0.2420654296875,
0.060333251953125,
0.607421875,
-0.1727294921875,
-0.7978515625,
-0.6845703125,
-1.1015625,
0.08795166015625,
-0.5263671875,
-0.26171875,
-0.94287109375,
-0.1905517578125,
-0.51123046875,
0.7978515625,
-0.37744140625,
-0.2802734375,
0.340576171875,
-1.2001953125,
0.04998779296875,
-0.59619140625,
-0.41845703125,
-0.56201171875,
-0.5673828125,
-0.623046875,
1.09765625,
0.416015625,
0.1422119140625,
0.421142578125,
-0.34521484375,
0.24853515625,
-0.36669921875,
-0.609375,
-0.495849609375,
-0.280517578125,
0.376953125,
-0.355224609375,
-0.42138671875,
-0.625,
0.8857421875,
-0.54052734375,
0.206787109375,
-0.443603515625,
-0.5341796875,
-0.199462890625,
-0.240478515625,
0.7998046875,
-0.65283203125,
0.1392822265625,
-0.50439453125,
0.68212890625,
0.3701171875,
-0.302001953125,
-0.5234375,
-0.83447265625,
-0.6005859375,
-0.8583984375,
0.65087890625,
-0.552734375,
0.58935546875,
-0.69189453125,
-0.2587890625,
0.900390625,
-0.5205078125,
0.317138671875,
1.3330078125,
-0.2313232421875,
0.213623046875,
-0.84814453125,
0.677734375,
-0.0223541259765625,
-0.64453125,
-0.27685546875,
-0.07952880859375,
-0.9150390625,
0.0960693359375,
-0.63427734375,
-0.896484375,
-0.57373046875,
0.71044921875,
1.466796875,
-0.300537109375,
0.95556640625,
0.2305908203125,
-1.17578125,
-0.7919921875,
0.78857421875,
0.381591796875,
0.56640625,
1.1259765625,
-0.82177734375,
-0.1278076171875,
0.40673828125,
-0.07183837890625,
-0.26416015625,
-0.208984375,
1.056640625,
-0.491455078125,
-0.60302734375,
0.52783203125,
0.57568359375,
-1.111328125,
-0.5341796875,
0.07781982421875,
-0.00972747802734375,
-0.1356201171875,
-0.61669921875,
0.09686279296875,
0.63818359375,
-0.479736328125,
-0.10040283203125,
0.0250244140625,
0.04345703125,
0.634765625,
0.300048828125,
0.30419921875,
-0.51904296875,
0.64306640625,
0.80029296875,
-0.783203125,
-0.37890625,
-0.82958984375,
-0.18505859375,
-0.2322998046875,
0.37353515625,
0.81640625,
0.0882568359375,
0.2191162109375,
0.72021484375,
-0.08892822265625,
0.7138671875,
-0.38818359375,
-0.363037109375,
0.25048828125,
-0.492431640625,
-0.25927734375,
-0.01491546630859375,
0.183349609375,
0.1009521484375,
0.2156982421875,
-0.7021484375,
-0.06610107421875,
0.349853515625,
0.334716796875,
-0.08917236328125,
-0.045318603515625,
-0.325927734375,
-0.58935546875,
-0.413330078125,
-0.5380859375,
-0.765625,
-0.12188720703125,
0.429443359375,
0.367919921875,
-0.73876953125,
0.04022216796875,
0.8408203125,
-0.77880859375,
1.2099609375,
-0.7490234375,
0.325927734375,
-0.43994140625,
-0.09228515625,
-0.78466796875,
0.1318359375,
-0.41796875,
-0.27880859375,
-0.403564453125,
0.5419921875,
0.3779296875,
0.52734375,
-0.1343994140625,
0.1981201171875,
-0.173828125,
-0.81103515625,
-0.06646728515625,
0.049224853515625,
0.0947265625,
0.33251953125,
0.72021484375,
0.52099609375,
0.283203125,
-0.050048828125,
-0.61083984375,
-0.48095703125,
0.12432861328125,
0.94384765625,
0.0238494873046875,
-0.05615234375,
-0.412109375,
0.00319671630859375,
-0.6279296875,
0.261962890625,
-0.2861328125,
-0.09136962890625,
0.09783935546875,
-0.74853515625,
0.505859375,
1.26953125,
-0.09161376953125,
0.177978515625,
-0.0291900634765625,
0.2939453125,
0.386962890625,
0.1669921875,
0.341552734375,
0.1629638671875,
0.1240234375,
-0.2159423828125,
-0.158935546875,
0.6015625,
-0.01273345947265625,
0.4287109375,
-0.2010498046875,
-0.76806640625,
-0.7490234375,
-0.100341796875,
-0.27294921875,
0.042572021484375,
0.59619140625,
-0.8369140625,
-0.06622314453125,
0.087890625,
-0.95166015625,
0.1787109375,
-0.7529296875,
-0.84619140625,
0.0838623046875,
-0.133056640625,
-0.7958984375,
-0.493896484375,
-0.58740234375,
0.037139892578125,
0.1595458984375,
0.5478515625,
-0.7412109375,
0.295654296875,
-0.172119140625,
0.44287109375,
-0.215087890625,
-0.1334228515625,
0.1318359375,
0.291748046875,
-0.470703125,
-0.6533203125,
0.0771484375,
1.4853515625,
0.17919921875,
-0.34912109375,
-0.63037109375,
0.10302734375,
-0.42919921875,
0.3271484375,
-0.2034912109375,
-0.18896484375,
0.01824951171875,
0.435791015625,
-1.181640625,
-0.354248046875,
0.084716796875,
0.286376953125,
-0.021026611328125,
-0.3447265625,
-0.2130126953125,
0.68994140625,
0.982421875,
-0.1396484375,
-0.058502197265625,
0.408935546875,
0.79150390625,
-0.26220703125,
-0.127197265625,
-0.251708984375,
0.30224609375,
0.53076171875,
0.27490234375,
-0.2354736328125,
0.69873046875,
0.93798828125,
-0.33203125,
-0.2208251953125,
0.5380859375,
0.03131103515625,
-0.0085906982421875,
-0.241943359375,
-0.2291259765625,
0.040191650390625,
-0.06988525390625,
-0.84619140625,
0.172607421875,
-0.378662109375,
-0.333251953125,
-0.176513671875,
-0.70849609375,
0.98046875,
-1.1953125,
0.4619140625,
-0.26220703125,
-0.12158203125,
0.399169921875,
0.98046875,
0.05169677734375,
-0.056793212890625,
0.50390625,
0.341552734375,
0.58349609375,
0.8076171875,
0.208984375,
0.154541015625,
-0.3916015625,
0.146484375,
-0.0693359375,
0.006015777587890625,
-0.6806640625,
-0.28125,
-1.1416015625,
0.6298828125,
-0.399169921875,
-0.09930419921875,
0.433837890625,
-0.5341796875,
0.1962890625,
-0.284912109375,
0.7646484375,
-0.38037109375,
0.434814453125,
0.5458984375,
-0.57177734375,
-0.447509765625,
0.84423828125,
-0.1993408203125,
0.38232421875,
0.1937255859375,
0.73828125,
0.34814453125,
1.716796875,
0.32080078125,
-0.2578125,
-0.147705078125,
0.057220458984375,
-0.234375,
-0.60400390625,
-0.38916015625,
-0.37158203125,
-0.119140625,
-0.398193359375,
-0.22998046875,
0.0257110595703125,
0.6533203125,
0.0811767578125,
-0.80615234375,
-0.042236328125,
0.08184814453125,
-0.84521484375,
0.7734375,
0.261474609375,
0.02947998046875,
0.07269287109375,
0.08599853515625,
-0.14208984375,
-0.35009765625,
-0.185791015625,
-0.5927734375,
0.2236328125,
-0.5849609375,
-0.5380859375,
-0.609375,
-1.0380859375,
-0.375732421875,
-0.33203125,
-0.476318359375,
-1.0390625,
0.1490478515625,
0.65185546875,
0.40625,
0.5107421875,
-0.51611328125,
0.397705078125,
1.123046875,
0.71630859375,
-0.351806640625,
0.80810546875,
0.36474609375,
-0.525390625,
0.08441162109375,
-0.0052032470703125,
0.6953125,
-0.33837890625,
-0.0105133056640625,
-0.297607421875,
0.5234375,
-0.9794921875,
-1.3837890625,
0.06396484375,
0.6513671875,
0.50341796875,
-0.54345703125,
-0.9306640625,
-0.401123046875,
-0.74755859375,
-0.046600341796875,
-0.78271484375,
0.6123046875,
0.388671875,
-0.09393310546875,
0.0287017822265625,
-1.0283203125,
4.31640625,
1.0087890625,
0.94677734375,
0.07049560546875,
-0.028228759765625,
0.970703125,
-0.0012559890747070312,
-0.31884765625,
0.1610107421875,
-0.3154296875,
0.7646484375,
-0.215576171875,
-0.088134765625,
0.65087890625,
0.1949462890625,
0.453125,
-0.48486328125,
-0.0171356201171875,
-0.247314453125,
-0.990234375,
-0.7939453125,
0.0758056640625,
0.2432861328125,
0.165283203125,
0.08551025390625,
0.093017578125,
0.57080078125,
-0.626953125,
-0.29052734375,
-0.63525390625,
-0.28369140625,
-0.7109375,
0.666015625,
-0.0755615234375,
-0.1834716796875,
0.50732421875,
0.1470947265625,
-0.62744140625,
0.057891845703125,
0.55517578125,
-0.30810546875,
-0.44873046875,
0.86669921875,
-0.8212890625,
0.197998046875,
0.5556640625,
-0.294677734375,
0.279541015625,
0.62841796875,
-0.421142578125,
0.78076171875,
-0.2249755859375,
0.73193359375,
-0.73681640625,
-0.671875,
0.04107666015625,
0.2283935546875,
-0.33349609375,
0.03997802734375,
0.3427734375,
0.2381591796875,
0.1112060546875,
0.050140380859375,
0.38818359375,
-0.68896484375,
0.68212890625,
0.2008056640625,
0.19287109375,
-0.5341796875,
0.09197998046875,
0.018310546875,
-0.137939453125,
-0.4248046875,
-0.50244140625,
0.57275390625,
0.2161865234375,
-0.0219268798828125,
0.30810546875,
0.471435546875,
-0.78955078125,
0.0018644332885742188,
0.0350341796875,
-0.3779296875,
-0.31396484375,
0.5810546875,
1.5830078125,
-0.75439453125,
-0.423828125,
-0.53466796875,
0.6142578125,
0.183349609375,
0.2802734375,
0.60400390625,
-0.91357421875,
-0.25048828125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Tags: greedy
Correct Solution:
```
import sys
input=sys.stdin.readline
s=input().rstrip()
k=int(input())
cannot=[input().rstrip() for i in range(k)]
ans=0
for t in cannot:
a,b=0,0
for i in range(len(s)):
if s[i]==t[0]:
a+=1
elif s[i]==t[1]:
b+=1
else:
ans+=min(a,b)
a=b=0
ans+=min(a,b)
print(ans)
```
| 70,999 | [
0.291015625,
-0.05596923828125,
0.1292724609375,
0.284912109375,
-0.5634765625,
-0.67431640625,
0.14208984375,
-0.12200927734375,
-0.189208984375,
0.90283203125,
0.8505859375,
-0.01378631591796875,
-0.3876953125,
-0.91552734375,
-0.935546875,
-0.12841796875,
-0.91455078125,
-0.58349609375,
-0.53955078125,
-0.1390380859375,
0.0859375,
-0.15283203125,
-1.6376953125,
-0.293212890625,
-0.37158203125,
1.2021484375,
0.3583984375,
-0.2958984375,
1.162109375,
0.75048828125,
-0.26318359375,
-0.338623046875,
0.5576171875,
-1.1689453125,
-0.6259765625,
-0.51220703125,
0.9462890625,
-0.467041015625,
0.007476806640625,
-0.064208984375,
0.66064453125,
-0.251953125,
0.473388671875,
-0.5341796875,
-1.2958984375,
-0.35791015625,
-0.126953125,
-0.61376953125,
-0.3544921875,
-0.40869140625,
0.332275390625,
-0.334228515625,
0.62109375,
-0.220947265625,
0.07373046875,
0.156494140625,
0.2384033203125,
0.08428955078125,
-0.693359375,
0.411376953125,
0.134765625,
0.374755859375,
0.1448974609375,
-0.75634765625,
-0.421875,
-0.107666015625,
-0.309814453125,
0.202392578125,
-0.00026702880859375,
-0.61181640625,
-0.241455078125,
0.4931640625,
-0.3916015625,
-0.330078125,
-0.673828125,
0.0330810546875,
0.2467041015625,
0.093994140625,
-0.56689453125,
0.8388671875,
0.36865234375,
1.013671875,
0.77001953125,
-0.10443115234375,
-0.35009765625,
-0.129150390625,
0.00772857666015625,
0.378662109375,
0.423828125,
-0.2183837890625,
-0.1893310546875,
0.541015625,
-1.03515625,
-0.166748046875,
0.5908203125,
0.40576171875,
-0.28515625,
0.283447265625,
0.45751953125,
0.44873046875,
0.89892578125,
0.58349609375,
-0.34912109375,
0.82958984375,
-0.5546875,
0.16162109375,
0.0953369140625,
0.1873779296875,
-0.05413818359375,
0.25927734375,
-0.31201171875,
-0.08892822265625,
0.486083984375,
0.458984375,
-0.6806640625,
0.76953125,
-0.276123046875,
0.3896484375,
-0.8388671875,
0.281494140625,
0.7314453125,
-0.06927490234375,
0.84912109375,
0.044891357421875,
0.1920166015625,
-0.2216796875,
-0.6083984375,
1.0673828125,
-0.433837890625,
-0.021942138671875,
0.49365234375,
0.0227508544921875,
-0.06689453125,
0.2044677734375,
-0.32080078125,
0.8076171875,
-0.287353515625,
0.6162109375,
0.55419921875,
-0.6220703125,
0.492431640625,
-0.2286376953125,
-0.053070068359375,
1.4287109375,
0.708984375,
-0.06097412109375,
0.78515625,
0.42822265625,
-0.92724609375,
0.1619873046875,
-1.3056640625,
0.8525390625,
0.14013671875,
0.117919921875,
-0.53369140625,
-0.1455078125,
-0.2314453125,
0.157958984375,
0.06756591796875,
0.2060546875,
-0.46826171875,
0.1510009765625,
-0.310302734375,
0.62744140625,
-0.2587890625,
1.0556640625,
-0.6728515625,
0.01007080078125,
-0.142333984375,
-0.5966796875,
0.19921875,
-0.040008544921875,
0.11669921875,
1.0732421875,
0.1568603515625,
0.8330078125,
0.56884765625,
-0.344482421875,
0.64306640625,
0.4794921875,
-0.10455322265625,
0.48046875,
0.1812744140625,
0.324462890625,
0.521484375,
0.298583984375,
-0.15625,
-0.415283203125,
-0.84716796875,
-0.375,
-0.0113525390625,
0.65673828125,
-0.37353515625,
0.341064453125,
0.047698974609375,
-0.0391845703125,
-1.0478515625,
-0.32666015625,
0.18408203125,
-1.0986328125,
-0.5546875,
0.90283203125,
0.14599609375,
0.74658203125,
-0.202392578125,
-0.626953125,
0.64892578125,
1.4775390625,
-0.3173828125,
0.278564453125,
0.6513671875,
-0.58935546875,
-0.345947265625,
0.45751953125,
-0.1702880859375,
-0.179931640625,
-0.85400390625,
0.72412109375,
-0.53466796875,
-0.0231475830078125,
-0.2080078125,
0.266357421875,
0.2763671875,
0.66015625,
-0.1806640625,
-0.3349609375,
0.84765625,
1.12890625,
0.0369873046875,
0.50390625,
0.197998046875,
0.7021484375,
0.1204833984375,
0.71240234375,
0.412841796875,
0.1494140625,
0.8486328125,
0.916015625,
0.2119140625,
0.52880859375,
-0.2252197265625,
0.44091796875,
0.1973876953125,
0.580078125,
0.440673828125,
0.29052734375,
-0.316162109375,
-0.038177490234375,
-0.3876953125,
0.09185791015625,
-0.252197265625,
0.32080078125,
0.431884765625,
0.432373046875,
-0.29443359375,
-0.13916015625,
0.2066650390625,
0.685546875,
-1.171875,
-0.45703125,
0.045135498046875,
0.1319580078125,
-0.0281219482421875,
0.00022304058074951172,
0.2379150390625,
0.77880859375,
0.70263671875,
0.328857421875,
-0.52783203125,
-0.52783203125,
-1.1328125,
-1.0107421875,
-0.86376953125,
-0.332275390625,
-0.82568359375,
-0.11688232421875,
0.634765625,
-1.0869140625,
0.482177734375,
-0.2861328125,
-0.5302734375,
0.1619873046875,
-0.578125,
0.6025390625,
-0.2027587890625,
0.80029296875,
-0.755859375,
0.73291015625,
0.034820556640625,
0.90234375,
-0.287841796875,
-0.3671875,
-0.047760009765625,
-0.61767578125,
0.251953125,
-0.0189208984375,
0.3017578125,
0.1771240234375,
-0.6533203125,
-0.7646484375,
0.032501220703125,
-0.308349609375,
-0.57861328125,
0.215087890625,
-0.7529296875,
0.7294921875,
0.93994140625,
-0.66845703125,
0.77392578125,
1.1220703125,
-0.94921875,
0.0287628173828125,
0.1856689453125,
0.2998046875,
-0.615234375,
1.189453125,
0.29052734375,
0.3974609375,
-0.5205078125,
-0.51220703125,
-0.755859375,
0.0966796875,
-0.03570556640625,
-0.354736328125,
-0.09564208984375,
0.75634765625,
-0.267333984375,
-0.994140625,
0.75341796875,
-1.1796875,
-0.10711669921875,
-0.1295166015625,
-0.489501953125,
0.95068359375,
0.342529296875,
0.354736328125,
-0.288330078125,
-0.818359375,
-0.25146484375,
0.82421875,
0.1776123046875,
-0.521484375,
-0.0372314453125,
0.2440185546875,
0.1773681640625,
0.150634765625,
0.12078857421875,
-0.232421875,
-0.3251953125,
0.070068359375,
0.221923828125,
0.92333984375,
0.2998046875,
0.3857421875,
0.365234375,
0.8486328125,
-0.6884765625,
-0.252685546875,
-0.270263671875,
0.720703125,
0.21337890625,
0.39697265625,
0.1611328125,
-0.24755859375,
-0.330078125,
-0.80615234375,
0.483642578125,
-0.295166015625,
0.763671875,
-0.5322265625,
0.6181640625,
0.383056640625,
-0.5263671875,
0.65966796875,
-0.89599609375,
-0.358154296875,
0.90283203125,
-0.6650390625,
0.95068359375,
-0.8916015625,
0.194580078125,
0.06884765625,
0.1278076171875,
0.701171875,
0.642578125,
0.7373046875,
-0.453125,
-0.60302734375,
-0.2890625,
0.278076171875,
-0.06378173828125,
-0.525390625,
0.144775390625,
-0.2440185546875,
-0.41455078125,
-0.89111328125,
0.41357421875,
0.86083984375,
0.57275390625,
0.3359375,
0.4248046875,
0.1689453125,
0.58740234375,
0.9111328125,
-0.0947265625,
-0.002368927001953125,
-0.7587890625,
1.0380859375,
-0.0124053955078125,
-0.480224609375,
-0.34765625,
-0.33544921875,
-0.312255859375,
0.323974609375,
0.018951416015625,
0.04071044921875,
-0.89208984375,
-0.170654296875,
-0.13720703125,
0.361572265625,
-0.73583984375,
-0.3095703125,
-0.189697265625,
0.425048828125,
0.08111572265625,
-1.017578125,
0.390380859375,
-0.6630859375,
0.927734375,
0.99169921875,
0.0635986328125,
-0.51708984375,
-0.149658203125,
-0.53955078125,
-0.86767578125,
-0.1142578125,
0.58154296875,
-0.12353515625,
0.2261962890625,
-1.2578125,
0.57958984375,
0.3349609375,
-0.088134765625,
0.28466796875,
0.193359375,
0.472900390625,
0.142578125,
0.5234375,
-0.6318359375,
-0.66357421875,
0.419189453125,
-1.1201171875,
0.763671875,
-0.611328125,
0.483154296875,
-0.154541015625,
0.1396484375,
0.1552734375,
0.4560546875,
-0.4775390625,
0.41357421875,
-0.0810546875,
0.3984375,
-1.01171875,
-0.65966796875,
0.51806640625,
-0.1829833984375,
-0.724609375,
0.546875,
0.25244140625,
-0.236083984375,
0.013427734375,
0.5927734375,
-0.466064453125,
0.4443359375,
-0.54736328125,
0.62451171875,
-0.116943359375,
-0.77294921875,
-0.2432861328125,
-0.470458984375,
0.68212890625,
-0.186279296875,
-0.7587890625,
0.220703125,
-1.15625,
-0.250732421875,
0.09710693359375,
-0.49755859375,
0.349365234375,
0.1513671875,
0.1280517578125,
0.09881591796875,
-0.49609375,
-0.36279296875,
-0.1741943359375,
-0.53564453125,
-0.51806640625,
0.337646484375,
0.58984375,
0.6943359375,
0.290283203125,
-0.10791015625,
0.1749267578125,
0.015655517578125,
-0.12200927734375,
-0.58447265625,
-0.354736328125,
0.213134765625,
-0.51220703125,
-0.1392822265625,
0.36181640625,
-0.0020809173583984375,
0.39697265625,
0.8720703125,
-0.055877685546875,
0.2276611328125,
0.348388671875,
-0.5146484375,
1.384765625,
-0.188720703125,
-1.0166015625,
-0.38427734375,
0.2420654296875,
0.060333251953125,
0.607421875,
-0.1727294921875,
-0.7978515625,
-0.6845703125,
-1.1015625,
0.08795166015625,
-0.5263671875,
-0.26171875,
-0.94287109375,
-0.1905517578125,
-0.51123046875,
0.7978515625,
-0.37744140625,
-0.2802734375,
0.340576171875,
-1.2001953125,
0.04998779296875,
-0.59619140625,
-0.41845703125,
-0.56201171875,
-0.5673828125,
-0.623046875,
1.09765625,
0.416015625,
0.1422119140625,
0.421142578125,
-0.34521484375,
0.24853515625,
-0.36669921875,
-0.609375,
-0.495849609375,
-0.280517578125,
0.376953125,
-0.355224609375,
-0.42138671875,
-0.625,
0.8857421875,
-0.54052734375,
0.206787109375,
-0.443603515625,
-0.5341796875,
-0.199462890625,
-0.240478515625,
0.7998046875,
-0.65283203125,
0.1392822265625,
-0.50439453125,
0.68212890625,
0.3701171875,
-0.302001953125,
-0.5234375,
-0.83447265625,
-0.6005859375,
-0.8583984375,
0.65087890625,
-0.552734375,
0.58935546875,
-0.69189453125,
-0.2587890625,
0.900390625,
-0.5205078125,
0.317138671875,
1.3330078125,
-0.2313232421875,
0.213623046875,
-0.84814453125,
0.677734375,
-0.0223541259765625,
-0.64453125,
-0.27685546875,
-0.07952880859375,
-0.9150390625,
0.0960693359375,
-0.63427734375,
-0.896484375,
-0.57373046875,
0.71044921875,
1.466796875,
-0.300537109375,
0.95556640625,
0.2305908203125,
-1.17578125,
-0.7919921875,
0.78857421875,
0.381591796875,
0.56640625,
1.1259765625,
-0.82177734375,
-0.1278076171875,
0.40673828125,
-0.07183837890625,
-0.26416015625,
-0.208984375,
1.056640625,
-0.491455078125,
-0.60302734375,
0.52783203125,
0.57568359375,
-1.111328125,
-0.5341796875,
0.07781982421875,
-0.00972747802734375,
-0.1356201171875,
-0.61669921875,
0.09686279296875,
0.63818359375,
-0.479736328125,
-0.10040283203125,
0.0250244140625,
0.04345703125,
0.634765625,
0.300048828125,
0.30419921875,
-0.51904296875,
0.64306640625,
0.80029296875,
-0.783203125,
-0.37890625,
-0.82958984375,
-0.18505859375,
-0.2322998046875,
0.37353515625,
0.81640625,
0.0882568359375,
0.2191162109375,
0.72021484375,
-0.08892822265625,
0.7138671875,
-0.38818359375,
-0.363037109375,
0.25048828125,
-0.492431640625,
-0.25927734375,
-0.01491546630859375,
0.183349609375,
0.1009521484375,
0.2156982421875,
-0.7021484375,
-0.06610107421875,
0.349853515625,
0.334716796875,
-0.08917236328125,
-0.045318603515625,
-0.325927734375,
-0.58935546875,
-0.413330078125,
-0.5380859375,
-0.765625,
-0.12188720703125,
0.429443359375,
0.367919921875,
-0.73876953125,
0.04022216796875,
0.8408203125,
-0.77880859375,
1.2099609375,
-0.7490234375,
0.325927734375,
-0.43994140625,
-0.09228515625,
-0.78466796875,
0.1318359375,
-0.41796875,
-0.27880859375,
-0.403564453125,
0.5419921875,
0.3779296875,
0.52734375,
-0.1343994140625,
0.1981201171875,
-0.173828125,
-0.81103515625,
-0.06646728515625,
0.049224853515625,
0.0947265625,
0.33251953125,
0.72021484375,
0.52099609375,
0.283203125,
-0.050048828125,
-0.61083984375,
-0.48095703125,
0.12432861328125,
0.94384765625,
0.0238494873046875,
-0.05615234375,
-0.412109375,
0.00319671630859375,
-0.6279296875,
0.261962890625,
-0.2861328125,
-0.09136962890625,
0.09783935546875,
-0.74853515625,
0.505859375,
1.26953125,
-0.09161376953125,
0.177978515625,
-0.0291900634765625,
0.2939453125,
0.386962890625,
0.1669921875,
0.341552734375,
0.1629638671875,
0.1240234375,
-0.2159423828125,
-0.158935546875,
0.6015625,
-0.01273345947265625,
0.4287109375,
-0.2010498046875,
-0.76806640625,
-0.7490234375,
-0.100341796875,
-0.27294921875,
0.042572021484375,
0.59619140625,
-0.8369140625,
-0.06622314453125,
0.087890625,
-0.95166015625,
0.1787109375,
-0.7529296875,
-0.84619140625,
0.0838623046875,
-0.133056640625,
-0.7958984375,
-0.493896484375,
-0.58740234375,
0.037139892578125,
0.1595458984375,
0.5478515625,
-0.7412109375,
0.295654296875,
-0.172119140625,
0.44287109375,
-0.215087890625,
-0.1334228515625,
0.1318359375,
0.291748046875,
-0.470703125,
-0.6533203125,
0.0771484375,
1.4853515625,
0.17919921875,
-0.34912109375,
-0.63037109375,
0.10302734375,
-0.42919921875,
0.3271484375,
-0.2034912109375,
-0.18896484375,
0.01824951171875,
0.435791015625,
-1.181640625,
-0.354248046875,
0.084716796875,
0.286376953125,
-0.021026611328125,
-0.3447265625,
-0.2130126953125,
0.68994140625,
0.982421875,
-0.1396484375,
-0.058502197265625,
0.408935546875,
0.79150390625,
-0.26220703125,
-0.127197265625,
-0.251708984375,
0.30224609375,
0.53076171875,
0.27490234375,
-0.2354736328125,
0.69873046875,
0.93798828125,
-0.33203125,
-0.2208251953125,
0.5380859375,
0.03131103515625,
-0.0085906982421875,
-0.241943359375,
-0.2291259765625,
0.040191650390625,
-0.06988525390625,
-0.84619140625,
0.172607421875,
-0.378662109375,
-0.333251953125,
-0.176513671875,
-0.70849609375,
0.98046875,
-1.1953125,
0.4619140625,
-0.26220703125,
-0.12158203125,
0.399169921875,
0.98046875,
0.05169677734375,
-0.056793212890625,
0.50390625,
0.341552734375,
0.58349609375,
0.8076171875,
0.208984375,
0.154541015625,
-0.3916015625,
0.146484375,
-0.0693359375,
0.006015777587890625,
-0.6806640625,
-0.28125,
-1.1416015625,
0.6298828125,
-0.399169921875,
-0.09930419921875,
0.433837890625,
-0.5341796875,
0.1962890625,
-0.284912109375,
0.7646484375,
-0.38037109375,
0.434814453125,
0.5458984375,
-0.57177734375,
-0.447509765625,
0.84423828125,
-0.1993408203125,
0.38232421875,
0.1937255859375,
0.73828125,
0.34814453125,
1.716796875,
0.32080078125,
-0.2578125,
-0.147705078125,
0.057220458984375,
-0.234375,
-0.60400390625,
-0.38916015625,
-0.37158203125,
-0.119140625,
-0.398193359375,
-0.22998046875,
0.0257110595703125,
0.6533203125,
0.0811767578125,
-0.80615234375,
-0.042236328125,
0.08184814453125,
-0.84521484375,
0.7734375,
0.261474609375,
0.02947998046875,
0.07269287109375,
0.08599853515625,
-0.14208984375,
-0.35009765625,
-0.185791015625,
-0.5927734375,
0.2236328125,
-0.5849609375,
-0.5380859375,
-0.609375,
-1.0380859375,
-0.375732421875,
-0.33203125,
-0.476318359375,
-1.0390625,
0.1490478515625,
0.65185546875,
0.40625,
0.5107421875,
-0.51611328125,
0.397705078125,
1.123046875,
0.71630859375,
-0.351806640625,
0.80810546875,
0.36474609375,
-0.525390625,
0.08441162109375,
-0.0052032470703125,
0.6953125,
-0.33837890625,
-0.0105133056640625,
-0.297607421875,
0.5234375,
-0.9794921875,
-1.3837890625,
0.06396484375,
0.6513671875,
0.50341796875,
-0.54345703125,
-0.9306640625,
-0.401123046875,
-0.74755859375,
-0.046600341796875,
-0.78271484375,
0.6123046875,
0.388671875,
-0.09393310546875,
0.0287017822265625,
-1.0283203125,
4.31640625,
1.0087890625,
0.94677734375,
0.07049560546875,
-0.028228759765625,
0.970703125,
-0.0012559890747070312,
-0.31884765625,
0.1610107421875,
-0.3154296875,
0.7646484375,
-0.215576171875,
-0.088134765625,
0.65087890625,
0.1949462890625,
0.453125,
-0.48486328125,
-0.0171356201171875,
-0.247314453125,
-0.990234375,
-0.7939453125,
0.0758056640625,
0.2432861328125,
0.165283203125,
0.08551025390625,
0.093017578125,
0.57080078125,
-0.626953125,
-0.29052734375,
-0.63525390625,
-0.28369140625,
-0.7109375,
0.666015625,
-0.0755615234375,
-0.1834716796875,
0.50732421875,
0.1470947265625,
-0.62744140625,
0.057891845703125,
0.55517578125,
-0.30810546875,
-0.44873046875,
0.86669921875,
-0.8212890625,
0.197998046875,
0.5556640625,
-0.294677734375,
0.279541015625,
0.62841796875,
-0.421142578125,
0.78076171875,
-0.2249755859375,
0.73193359375,
-0.73681640625,
-0.671875,
0.04107666015625,
0.2283935546875,
-0.33349609375,
0.03997802734375,
0.3427734375,
0.2381591796875,
0.1112060546875,
0.050140380859375,
0.38818359375,
-0.68896484375,
0.68212890625,
0.2008056640625,
0.19287109375,
-0.5341796875,
0.09197998046875,
0.018310546875,
-0.137939453125,
-0.4248046875,
-0.50244140625,
0.57275390625,
0.2161865234375,
-0.0219268798828125,
0.30810546875,
0.471435546875,
-0.78955078125,
0.0018644332885742188,
0.0350341796875,
-0.3779296875,
-0.31396484375,
0.5810546875,
1.5830078125,
-0.75439453125,
-0.423828125,
-0.53466796875,
0.6142578125,
0.183349609375,
0.2802734375,
0.60400390625,
-0.91357421875,
-0.25048828125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Tags: greedy
Correct Solution:
```
p, t = {}, input()
a, n = False, len(t)
x = y = s = 0
q = [input() for i in range(int(input()))]
for a, b in q: p[a], p[b] = b, a
for i in t:
if a:
if i == a: x += 1
elif i == b: y += 1
else:
s += min(x, y)
if i in p:
a, b = i, p[i]
x, y = 1, 0
else: a = False
elif i in p:
a, b = i, p[i]
x, y = 1, 0
if a: s += min(x, y)
print(s)
```
| 71,000 | [
0.291015625,
-0.05596923828125,
0.1292724609375,
0.284912109375,
-0.5634765625,
-0.67431640625,
0.14208984375,
-0.12200927734375,
-0.189208984375,
0.90283203125,
0.8505859375,
-0.01378631591796875,
-0.3876953125,
-0.91552734375,
-0.935546875,
-0.12841796875,
-0.91455078125,
-0.58349609375,
-0.53955078125,
-0.1390380859375,
0.0859375,
-0.15283203125,
-1.6376953125,
-0.293212890625,
-0.37158203125,
1.2021484375,
0.3583984375,
-0.2958984375,
1.162109375,
0.75048828125,
-0.26318359375,
-0.338623046875,
0.5576171875,
-1.1689453125,
-0.6259765625,
-0.51220703125,
0.9462890625,
-0.467041015625,
0.007476806640625,
-0.064208984375,
0.66064453125,
-0.251953125,
0.473388671875,
-0.5341796875,
-1.2958984375,
-0.35791015625,
-0.126953125,
-0.61376953125,
-0.3544921875,
-0.40869140625,
0.332275390625,
-0.334228515625,
0.62109375,
-0.220947265625,
0.07373046875,
0.156494140625,
0.2384033203125,
0.08428955078125,
-0.693359375,
0.411376953125,
0.134765625,
0.374755859375,
0.1448974609375,
-0.75634765625,
-0.421875,
-0.107666015625,
-0.309814453125,
0.202392578125,
-0.00026702880859375,
-0.61181640625,
-0.241455078125,
0.4931640625,
-0.3916015625,
-0.330078125,
-0.673828125,
0.0330810546875,
0.2467041015625,
0.093994140625,
-0.56689453125,
0.8388671875,
0.36865234375,
1.013671875,
0.77001953125,
-0.10443115234375,
-0.35009765625,
-0.129150390625,
0.00772857666015625,
0.378662109375,
0.423828125,
-0.2183837890625,
-0.1893310546875,
0.541015625,
-1.03515625,
-0.166748046875,
0.5908203125,
0.40576171875,
-0.28515625,
0.283447265625,
0.45751953125,
0.44873046875,
0.89892578125,
0.58349609375,
-0.34912109375,
0.82958984375,
-0.5546875,
0.16162109375,
0.0953369140625,
0.1873779296875,
-0.05413818359375,
0.25927734375,
-0.31201171875,
-0.08892822265625,
0.486083984375,
0.458984375,
-0.6806640625,
0.76953125,
-0.276123046875,
0.3896484375,
-0.8388671875,
0.281494140625,
0.7314453125,
-0.06927490234375,
0.84912109375,
0.044891357421875,
0.1920166015625,
-0.2216796875,
-0.6083984375,
1.0673828125,
-0.433837890625,
-0.021942138671875,
0.49365234375,
0.0227508544921875,
-0.06689453125,
0.2044677734375,
-0.32080078125,
0.8076171875,
-0.287353515625,
0.6162109375,
0.55419921875,
-0.6220703125,
0.492431640625,
-0.2286376953125,
-0.053070068359375,
1.4287109375,
0.708984375,
-0.06097412109375,
0.78515625,
0.42822265625,
-0.92724609375,
0.1619873046875,
-1.3056640625,
0.8525390625,
0.14013671875,
0.117919921875,
-0.53369140625,
-0.1455078125,
-0.2314453125,
0.157958984375,
0.06756591796875,
0.2060546875,
-0.46826171875,
0.1510009765625,
-0.310302734375,
0.62744140625,
-0.2587890625,
1.0556640625,
-0.6728515625,
0.01007080078125,
-0.142333984375,
-0.5966796875,
0.19921875,
-0.040008544921875,
0.11669921875,
1.0732421875,
0.1568603515625,
0.8330078125,
0.56884765625,
-0.344482421875,
0.64306640625,
0.4794921875,
-0.10455322265625,
0.48046875,
0.1812744140625,
0.324462890625,
0.521484375,
0.298583984375,
-0.15625,
-0.415283203125,
-0.84716796875,
-0.375,
-0.0113525390625,
0.65673828125,
-0.37353515625,
0.341064453125,
0.047698974609375,
-0.0391845703125,
-1.0478515625,
-0.32666015625,
0.18408203125,
-1.0986328125,
-0.5546875,
0.90283203125,
0.14599609375,
0.74658203125,
-0.202392578125,
-0.626953125,
0.64892578125,
1.4775390625,
-0.3173828125,
0.278564453125,
0.6513671875,
-0.58935546875,
-0.345947265625,
0.45751953125,
-0.1702880859375,
-0.179931640625,
-0.85400390625,
0.72412109375,
-0.53466796875,
-0.0231475830078125,
-0.2080078125,
0.266357421875,
0.2763671875,
0.66015625,
-0.1806640625,
-0.3349609375,
0.84765625,
1.12890625,
0.0369873046875,
0.50390625,
0.197998046875,
0.7021484375,
0.1204833984375,
0.71240234375,
0.412841796875,
0.1494140625,
0.8486328125,
0.916015625,
0.2119140625,
0.52880859375,
-0.2252197265625,
0.44091796875,
0.1973876953125,
0.580078125,
0.440673828125,
0.29052734375,
-0.316162109375,
-0.038177490234375,
-0.3876953125,
0.09185791015625,
-0.252197265625,
0.32080078125,
0.431884765625,
0.432373046875,
-0.29443359375,
-0.13916015625,
0.2066650390625,
0.685546875,
-1.171875,
-0.45703125,
0.045135498046875,
0.1319580078125,
-0.0281219482421875,
0.00022304058074951172,
0.2379150390625,
0.77880859375,
0.70263671875,
0.328857421875,
-0.52783203125,
-0.52783203125,
-1.1328125,
-1.0107421875,
-0.86376953125,
-0.332275390625,
-0.82568359375,
-0.11688232421875,
0.634765625,
-1.0869140625,
0.482177734375,
-0.2861328125,
-0.5302734375,
0.1619873046875,
-0.578125,
0.6025390625,
-0.2027587890625,
0.80029296875,
-0.755859375,
0.73291015625,
0.034820556640625,
0.90234375,
-0.287841796875,
-0.3671875,
-0.047760009765625,
-0.61767578125,
0.251953125,
-0.0189208984375,
0.3017578125,
0.1771240234375,
-0.6533203125,
-0.7646484375,
0.032501220703125,
-0.308349609375,
-0.57861328125,
0.215087890625,
-0.7529296875,
0.7294921875,
0.93994140625,
-0.66845703125,
0.77392578125,
1.1220703125,
-0.94921875,
0.0287628173828125,
0.1856689453125,
0.2998046875,
-0.615234375,
1.189453125,
0.29052734375,
0.3974609375,
-0.5205078125,
-0.51220703125,
-0.755859375,
0.0966796875,
-0.03570556640625,
-0.354736328125,
-0.09564208984375,
0.75634765625,
-0.267333984375,
-0.994140625,
0.75341796875,
-1.1796875,
-0.10711669921875,
-0.1295166015625,
-0.489501953125,
0.95068359375,
0.342529296875,
0.354736328125,
-0.288330078125,
-0.818359375,
-0.25146484375,
0.82421875,
0.1776123046875,
-0.521484375,
-0.0372314453125,
0.2440185546875,
0.1773681640625,
0.150634765625,
0.12078857421875,
-0.232421875,
-0.3251953125,
0.070068359375,
0.221923828125,
0.92333984375,
0.2998046875,
0.3857421875,
0.365234375,
0.8486328125,
-0.6884765625,
-0.252685546875,
-0.270263671875,
0.720703125,
0.21337890625,
0.39697265625,
0.1611328125,
-0.24755859375,
-0.330078125,
-0.80615234375,
0.483642578125,
-0.295166015625,
0.763671875,
-0.5322265625,
0.6181640625,
0.383056640625,
-0.5263671875,
0.65966796875,
-0.89599609375,
-0.358154296875,
0.90283203125,
-0.6650390625,
0.95068359375,
-0.8916015625,
0.194580078125,
0.06884765625,
0.1278076171875,
0.701171875,
0.642578125,
0.7373046875,
-0.453125,
-0.60302734375,
-0.2890625,
0.278076171875,
-0.06378173828125,
-0.525390625,
0.144775390625,
-0.2440185546875,
-0.41455078125,
-0.89111328125,
0.41357421875,
0.86083984375,
0.57275390625,
0.3359375,
0.4248046875,
0.1689453125,
0.58740234375,
0.9111328125,
-0.0947265625,
-0.002368927001953125,
-0.7587890625,
1.0380859375,
-0.0124053955078125,
-0.480224609375,
-0.34765625,
-0.33544921875,
-0.312255859375,
0.323974609375,
0.018951416015625,
0.04071044921875,
-0.89208984375,
-0.170654296875,
-0.13720703125,
0.361572265625,
-0.73583984375,
-0.3095703125,
-0.189697265625,
0.425048828125,
0.08111572265625,
-1.017578125,
0.390380859375,
-0.6630859375,
0.927734375,
0.99169921875,
0.0635986328125,
-0.51708984375,
-0.149658203125,
-0.53955078125,
-0.86767578125,
-0.1142578125,
0.58154296875,
-0.12353515625,
0.2261962890625,
-1.2578125,
0.57958984375,
0.3349609375,
-0.088134765625,
0.28466796875,
0.193359375,
0.472900390625,
0.142578125,
0.5234375,
-0.6318359375,
-0.66357421875,
0.419189453125,
-1.1201171875,
0.763671875,
-0.611328125,
0.483154296875,
-0.154541015625,
0.1396484375,
0.1552734375,
0.4560546875,
-0.4775390625,
0.41357421875,
-0.0810546875,
0.3984375,
-1.01171875,
-0.65966796875,
0.51806640625,
-0.1829833984375,
-0.724609375,
0.546875,
0.25244140625,
-0.236083984375,
0.013427734375,
0.5927734375,
-0.466064453125,
0.4443359375,
-0.54736328125,
0.62451171875,
-0.116943359375,
-0.77294921875,
-0.2432861328125,
-0.470458984375,
0.68212890625,
-0.186279296875,
-0.7587890625,
0.220703125,
-1.15625,
-0.250732421875,
0.09710693359375,
-0.49755859375,
0.349365234375,
0.1513671875,
0.1280517578125,
0.09881591796875,
-0.49609375,
-0.36279296875,
-0.1741943359375,
-0.53564453125,
-0.51806640625,
0.337646484375,
0.58984375,
0.6943359375,
0.290283203125,
-0.10791015625,
0.1749267578125,
0.015655517578125,
-0.12200927734375,
-0.58447265625,
-0.354736328125,
0.213134765625,
-0.51220703125,
-0.1392822265625,
0.36181640625,
-0.0020809173583984375,
0.39697265625,
0.8720703125,
-0.055877685546875,
0.2276611328125,
0.348388671875,
-0.5146484375,
1.384765625,
-0.188720703125,
-1.0166015625,
-0.38427734375,
0.2420654296875,
0.060333251953125,
0.607421875,
-0.1727294921875,
-0.7978515625,
-0.6845703125,
-1.1015625,
0.08795166015625,
-0.5263671875,
-0.26171875,
-0.94287109375,
-0.1905517578125,
-0.51123046875,
0.7978515625,
-0.37744140625,
-0.2802734375,
0.340576171875,
-1.2001953125,
0.04998779296875,
-0.59619140625,
-0.41845703125,
-0.56201171875,
-0.5673828125,
-0.623046875,
1.09765625,
0.416015625,
0.1422119140625,
0.421142578125,
-0.34521484375,
0.24853515625,
-0.36669921875,
-0.609375,
-0.495849609375,
-0.280517578125,
0.376953125,
-0.355224609375,
-0.42138671875,
-0.625,
0.8857421875,
-0.54052734375,
0.206787109375,
-0.443603515625,
-0.5341796875,
-0.199462890625,
-0.240478515625,
0.7998046875,
-0.65283203125,
0.1392822265625,
-0.50439453125,
0.68212890625,
0.3701171875,
-0.302001953125,
-0.5234375,
-0.83447265625,
-0.6005859375,
-0.8583984375,
0.65087890625,
-0.552734375,
0.58935546875,
-0.69189453125,
-0.2587890625,
0.900390625,
-0.5205078125,
0.317138671875,
1.3330078125,
-0.2313232421875,
0.213623046875,
-0.84814453125,
0.677734375,
-0.0223541259765625,
-0.64453125,
-0.27685546875,
-0.07952880859375,
-0.9150390625,
0.0960693359375,
-0.63427734375,
-0.896484375,
-0.57373046875,
0.71044921875,
1.466796875,
-0.300537109375,
0.95556640625,
0.2305908203125,
-1.17578125,
-0.7919921875,
0.78857421875,
0.381591796875,
0.56640625,
1.1259765625,
-0.82177734375,
-0.1278076171875,
0.40673828125,
-0.07183837890625,
-0.26416015625,
-0.208984375,
1.056640625,
-0.491455078125,
-0.60302734375,
0.52783203125,
0.57568359375,
-1.111328125,
-0.5341796875,
0.07781982421875,
-0.00972747802734375,
-0.1356201171875,
-0.61669921875,
0.09686279296875,
0.63818359375,
-0.479736328125,
-0.10040283203125,
0.0250244140625,
0.04345703125,
0.634765625,
0.300048828125,
0.30419921875,
-0.51904296875,
0.64306640625,
0.80029296875,
-0.783203125,
-0.37890625,
-0.82958984375,
-0.18505859375,
-0.2322998046875,
0.37353515625,
0.81640625,
0.0882568359375,
0.2191162109375,
0.72021484375,
-0.08892822265625,
0.7138671875,
-0.38818359375,
-0.363037109375,
0.25048828125,
-0.492431640625,
-0.25927734375,
-0.01491546630859375,
0.183349609375,
0.1009521484375,
0.2156982421875,
-0.7021484375,
-0.06610107421875,
0.349853515625,
0.334716796875,
-0.08917236328125,
-0.045318603515625,
-0.325927734375,
-0.58935546875,
-0.413330078125,
-0.5380859375,
-0.765625,
-0.12188720703125,
0.429443359375,
0.367919921875,
-0.73876953125,
0.04022216796875,
0.8408203125,
-0.77880859375,
1.2099609375,
-0.7490234375,
0.325927734375,
-0.43994140625,
-0.09228515625,
-0.78466796875,
0.1318359375,
-0.41796875,
-0.27880859375,
-0.403564453125,
0.5419921875,
0.3779296875,
0.52734375,
-0.1343994140625,
0.1981201171875,
-0.173828125,
-0.81103515625,
-0.06646728515625,
0.049224853515625,
0.0947265625,
0.33251953125,
0.72021484375,
0.52099609375,
0.283203125,
-0.050048828125,
-0.61083984375,
-0.48095703125,
0.12432861328125,
0.94384765625,
0.0238494873046875,
-0.05615234375,
-0.412109375,
0.00319671630859375,
-0.6279296875,
0.261962890625,
-0.2861328125,
-0.09136962890625,
0.09783935546875,
-0.74853515625,
0.505859375,
1.26953125,
-0.09161376953125,
0.177978515625,
-0.0291900634765625,
0.2939453125,
0.386962890625,
0.1669921875,
0.341552734375,
0.1629638671875,
0.1240234375,
-0.2159423828125,
-0.158935546875,
0.6015625,
-0.01273345947265625,
0.4287109375,
-0.2010498046875,
-0.76806640625,
-0.7490234375,
-0.100341796875,
-0.27294921875,
0.042572021484375,
0.59619140625,
-0.8369140625,
-0.06622314453125,
0.087890625,
-0.95166015625,
0.1787109375,
-0.7529296875,
-0.84619140625,
0.0838623046875,
-0.133056640625,
-0.7958984375,
-0.493896484375,
-0.58740234375,
0.037139892578125,
0.1595458984375,
0.5478515625,
-0.7412109375,
0.295654296875,
-0.172119140625,
0.44287109375,
-0.215087890625,
-0.1334228515625,
0.1318359375,
0.291748046875,
-0.470703125,
-0.6533203125,
0.0771484375,
1.4853515625,
0.17919921875,
-0.34912109375,
-0.63037109375,
0.10302734375,
-0.42919921875,
0.3271484375,
-0.2034912109375,
-0.18896484375,
0.01824951171875,
0.435791015625,
-1.181640625,
-0.354248046875,
0.084716796875,
0.286376953125,
-0.021026611328125,
-0.3447265625,
-0.2130126953125,
0.68994140625,
0.982421875,
-0.1396484375,
-0.058502197265625,
0.408935546875,
0.79150390625,
-0.26220703125,
-0.127197265625,
-0.251708984375,
0.30224609375,
0.53076171875,
0.27490234375,
-0.2354736328125,
0.69873046875,
0.93798828125,
-0.33203125,
-0.2208251953125,
0.5380859375,
0.03131103515625,
-0.0085906982421875,
-0.241943359375,
-0.2291259765625,
0.040191650390625,
-0.06988525390625,
-0.84619140625,
0.172607421875,
-0.378662109375,
-0.333251953125,
-0.176513671875,
-0.70849609375,
0.98046875,
-1.1953125,
0.4619140625,
-0.26220703125,
-0.12158203125,
0.399169921875,
0.98046875,
0.05169677734375,
-0.056793212890625,
0.50390625,
0.341552734375,
0.58349609375,
0.8076171875,
0.208984375,
0.154541015625,
-0.3916015625,
0.146484375,
-0.0693359375,
0.006015777587890625,
-0.6806640625,
-0.28125,
-1.1416015625,
0.6298828125,
-0.399169921875,
-0.09930419921875,
0.433837890625,
-0.5341796875,
0.1962890625,
-0.284912109375,
0.7646484375,
-0.38037109375,
0.434814453125,
0.5458984375,
-0.57177734375,
-0.447509765625,
0.84423828125,
-0.1993408203125,
0.38232421875,
0.1937255859375,
0.73828125,
0.34814453125,
1.716796875,
0.32080078125,
-0.2578125,
-0.147705078125,
0.057220458984375,
-0.234375,
-0.60400390625,
-0.38916015625,
-0.37158203125,
-0.119140625,
-0.398193359375,
-0.22998046875,
0.0257110595703125,
0.6533203125,
0.0811767578125,
-0.80615234375,
-0.042236328125,
0.08184814453125,
-0.84521484375,
0.7734375,
0.261474609375,
0.02947998046875,
0.07269287109375,
0.08599853515625,
-0.14208984375,
-0.35009765625,
-0.185791015625,
-0.5927734375,
0.2236328125,
-0.5849609375,
-0.5380859375,
-0.609375,
-1.0380859375,
-0.375732421875,
-0.33203125,
-0.476318359375,
-1.0390625,
0.1490478515625,
0.65185546875,
0.40625,
0.5107421875,
-0.51611328125,
0.397705078125,
1.123046875,
0.71630859375,
-0.351806640625,
0.80810546875,
0.36474609375,
-0.525390625,
0.08441162109375,
-0.0052032470703125,
0.6953125,
-0.33837890625,
-0.0105133056640625,
-0.297607421875,
0.5234375,
-0.9794921875,
-1.3837890625,
0.06396484375,
0.6513671875,
0.50341796875,
-0.54345703125,
-0.9306640625,
-0.401123046875,
-0.74755859375,
-0.046600341796875,
-0.78271484375,
0.6123046875,
0.388671875,
-0.09393310546875,
0.0287017822265625,
-1.0283203125,
4.31640625,
1.0087890625,
0.94677734375,
0.07049560546875,
-0.028228759765625,
0.970703125,
-0.0012559890747070312,
-0.31884765625,
0.1610107421875,
-0.3154296875,
0.7646484375,
-0.215576171875,
-0.088134765625,
0.65087890625,
0.1949462890625,
0.453125,
-0.48486328125,
-0.0171356201171875,
-0.247314453125,
-0.990234375,
-0.7939453125,
0.0758056640625,
0.2432861328125,
0.165283203125,
0.08551025390625,
0.093017578125,
0.57080078125,
-0.626953125,
-0.29052734375,
-0.63525390625,
-0.28369140625,
-0.7109375,
0.666015625,
-0.0755615234375,
-0.1834716796875,
0.50732421875,
0.1470947265625,
-0.62744140625,
0.057891845703125,
0.55517578125,
-0.30810546875,
-0.44873046875,
0.86669921875,
-0.8212890625,
0.197998046875,
0.5556640625,
-0.294677734375,
0.279541015625,
0.62841796875,
-0.421142578125,
0.78076171875,
-0.2249755859375,
0.73193359375,
-0.73681640625,
-0.671875,
0.04107666015625,
0.2283935546875,
-0.33349609375,
0.03997802734375,
0.3427734375,
0.2381591796875,
0.1112060546875,
0.050140380859375,
0.38818359375,
-0.68896484375,
0.68212890625,
0.2008056640625,
0.19287109375,
-0.5341796875,
0.09197998046875,
0.018310546875,
-0.137939453125,
-0.4248046875,
-0.50244140625,
0.57275390625,
0.2161865234375,
-0.0219268798828125,
0.30810546875,
0.471435546875,
-0.78955078125,
0.0018644332885742188,
0.0350341796875,
-0.3779296875,
-0.31396484375,
0.5810546875,
1.5830078125,
-0.75439453125,
-0.423828125,
-0.53466796875,
0.6142578125,
0.183349609375,
0.2802734375,
0.60400390625,
-0.91357421875,
-0.25048828125
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Submitted Solution:
```
#!/usr/bin/env python
from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from decimal import *
from io import BytesIO, IOBase
from itertools import *
from collections import *
# sys.setrecursionlimit(10**5)
M = 10 ** 9 + 7
# print(math.factorial(5))
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
# sys.setrecursionlimit(10**6)
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
"""Prints the values to a stream, or to sys.stdout by default."""
sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
at_start = True
for x in args:
if not at_start:
file.write(sep)
file.write(str(x))
at_start = False
file.write(kwargs.pop("end", "\n"))
if kwargs.pop("flush", False):
file.flush()
if sys.version_info[0] < 3:
sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def inp(): return sys.stdin.readline().rstrip("\r\n") # for fast input
def out(var): sys.stdout.write(str(var)) # for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def fsep(): return map(float, inp().split())
def inpu(): return int(inp())
# -----------------------------------------------------------------
def regularbracket(t):
p = 0
for i in t:
if i == "(":
p += 1
else:
p -= 1
if p < 0:
return False
else:
if p > 0:
return False
else:
return True
# -------------------------------------------------
def binarySearchCount(arr, n, key):
left = 0
right = n - 1
count = 0
while (left <= right):
mid = int((right + left) / 2)
# Check if middle element is
# less than or equal to key
if (arr[mid] <= key):
count = mid + 1
left = mid + 1
# If key is smaller, ignore right half
else:
right = mid - 1
return count
# ------------------------------reverse string(pallindrome)
def reverse1(string):
pp = ""
for i in string[::-1]:
pp += i
if pp == string:
return True
return False
# --------------------------------reverse list(paindrome)
def reverse2(list1):
l = []
for i in list1[::-1]:
l.append(i)
if l == list1:
return True
return False
def mex(list1):
# list1 = sorted(list1)
p = max(list1) + 1
for i in range(len(list1)):
if list1[i] != i:
p = i
break
return p
def sumofdigits(n):
n = str(n)
s1 = 0
for i in n:
s1 += int(i)
return s1
def perfect_square(n):
s = math.sqrt(n)
if s == int(s):
return True
return False
# -----------------------------roman
def roman_number(x):
if x > 15999:
return
value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
symbol = ["F", "MF", "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]
roman = ""
i = 0
while x > 0:
div = x // value[i]
x = x % value[i]
while div:
roman += symbol[i]
div -= 1
i += 1
return roman
def soretd(s):
for i in range(1, len(s)):
if s[i - 1] > s[i]:
return False
return True
# print(soretd("1"))
# ---------------------------
def countRhombi(h, w):
ct = 0
for i in range(2, h + 1, 2):
for j in range(2, w + 1, 2):
ct += (h - i + 1) * (w - j + 1)
return ct
def countrhombi2(h, w):
return ((h * h) // 4) * ((w * w) // 4)
# ---------------------------------
def binpow(a, b):
if b == 0:
return 1
else:
res = binpow(a, b // 2)
if b % 2 != 0:
return res * res * a
else:
return res * res
# -------------------------------------------------------
def binpowmodulus(a, b, m):
a %= m
res = 1
while (b > 0):
if (b & 1):
res = res * a % m
a = a * a % m
b >>= 1
return res
# -------------------------------------------------------------
def coprime_to_n(n):
result = n
i = 2
while (i * i <= n):
if (n % i == 0):
while (n % i == 0):
n //= i
result -= result // i
i += 1
if (n > 1):
result -= result // n
return result
# -------------------prime
def prime(x):
if x == 1:
return False
else:
for i in range(2, int(math.sqrt(x)) + 1):
# print(x)
if (x % i == 0):
return False
else:
return True
def luckynumwithequalnumberoffourandseven(x,n,a):
if x >= n and str(x).count("4") == str(x).count("7"):
a.append(x)
else:
if x < 1e12:
luckynumwithequalnumberoffourandseven(x * 10 + 4,n,a)
luckynumwithequalnumberoffourandseven(x * 10 + 7,n,a)
return a
#----------------------
def luckynum(x,l,r,a):
if x>=l and x<=r:
a.append(x)
if x>r:
a.append(x)
return a
if x < 1e10:
luckynum(x * 10 + 4, l,r,a)
luckynum(x * 10 + 7, l,r,a)
return a
def luckynuber(x, n, a):
p = set(str(x))
if len(p) <= 2:
a.append(x)
if x < n:
luckynuber(x + 1, n, a)
return a
# ------------------------------------------------------interactive problems
def interact(type, x):
if type == "r":
inp = input()
return inp.strip()
else:
print(x, flush=True)
# ------------------------------------------------------------------zero at end of factorial of a number
def findTrailingZeros(n):
# Initialize result
count = 0
# Keep dividing n by
# 5 & update Count
while (n >= 5):
n //= 5
count += n
return count
# -----------------------------------------------merge sort
# Python program for implementation of MergeSort
def mergeSort(arr):
if len(arr) > 1:
# Finding the mid of the array
mid = len(arr) // 2
# Dividing the array elements
L = arr[:mid]
# into 2 halves
R = arr[mid:]
# Sorting the first half
mergeSort(L)
# Sorting the second half
mergeSort(R)
i = j = k = 0
# Copy data to temp arrays L[] and R[]
while i < len(L) and j < len(R):
if L[i] < R[j]:
arr[k] = L[i]
i += 1
else:
arr[k] = R[j]
j += 1
k += 1
# Checking if any element was left
while i < len(L):
arr[k] = L[i]
i += 1
k += 1
while j < len(R):
arr[k] = R[j]
j += 1
k += 1
# -----------------------------------------------lucky number with two lucky any digits
res = set()
def solven(p, l, a, b, n): # given number
if p > n or l > 10:
return
if p > 0:
res.add(p)
solven(p * 10 + a, l + 1, a, b, n)
solven(p * 10 + b, l + 1, a, b, n)
# problem
"""
n = int(input())
for a in range(0, 10):
for b in range(0, a):
solve(0, 0)
print(len(res))
"""
# Python3 program to find all subsets
# by backtracking.
# In the array A at every step we have two
# choices for each element either we can
# ignore the element or we can include the
# element in our subset
def subsetsUtil(A, subset, index, d):
print(*subset)
s = sum(subset)
d.append(s)
for i in range(index, len(A)):
# include the A[i] in subset.
subset.append(A[i])
# move onto the next element.
subsetsUtil(A, subset, i + 1, d)
# exclude the A[i] from subset and
# triggers backtracking.
subset.pop(-1)
return d
def subsetSums(arr, l, r, d, sum=0):
if l > r:
d.append(sum)
return
subsetSums(arr, l + 1, r, d, sum + arr[l])
# Subset excluding arr[l]
subsetSums(arr, l + 1, r, d, sum)
return d
def print_factors(x):
factors = []
for i in range(1, x + 1):
if x % i == 0:
factors.append(i)
return (factors)
# -----------------------------------------------
def calc(X, d, ans, D):
# print(X,d)
if len(X) == 0:
return
i = X.index(max(X))
ans[D[max(X)]] = d
Y = X[:i]
Z = X[i + 1:]
calc(Y, d + 1, ans, D)
calc(Z, d + 1, ans, D)
# ---------------------------------------
def factorization(n, l):
c = n
if prime(n) == True:
l.append(n)
return l
for i in range(2, c):
if n == 1:
break
while n % i == 0:
l.append(i)
n = n // i
return l
# endregion------------------------------
def good(b):
l = []
i = 0
while (len(b) != 0):
if b[i] < b[len(b) - 1 - i]:
l.append(b[i])
b.remove(b[i])
else:
l.append(b[len(b) - 1 - i])
b.remove(b[len(b) - 1 - i])
if l == sorted(l):
# print(l)
return True
return False
# arr=[]
# print(good(arr))
def generate(st, s):
if len(s) == 0:
return
# If current string is not already present.
if s not in st:
st.add(s)
# Traverse current string, one by one
# remove every character and recur.
for i in range(len(s)):
t = list(s).copy()
t.remove(s[i])
t = ''.join(t)
generate(st, t)
return
#=--------------------------------------------longest increasing subsequence
def largestincreasingsubsequence(A):
l = [1]*len(A)
sub=[]
for i in range(1,len(l)):
for k in range(i):
if A[k]<A[i]:
sub.append(l[k])
l[i]=1+max(sub,default=0)
return max(l,default=0)
#----------------------------------longest palindromic substring
# Python3 program for the
# above approach
# Function to calculate
# Bitwise OR of sums of
# all subsequences
def findOR(nums, N):
# Stores the prefix
# sum of nums[]
prefix_sum = 0
# Stores the bitwise OR of
# sum of each subsequence
result = 0
# Iterate through array nums[]
for i in range(N):
# Bits set in nums[i] are
# also set in result
result |= nums[i]
# Calculate prefix_sum
prefix_sum += nums[i]
# Bits set in prefix_sum
# are also set in result
result |= prefix_sum
# Return the result
return result
#l=[]
def OR(a, n):
ans = a[0]
for i in range(1, n):
ans |= a[i]
#l.append(ans)
return ans
#print(prime(12345678987766))
"""
def main():
q=inpu()
x = q
v1 = 0
v2 = 0
i = 2
while i * i <= q:
while q % i == 0:
if v1!=0:
v2 = i
else:
v1 = i
q //= i
i += 1
if q - 1!=0:
v2 = q
if v1 * v2 - x!=0:
print(1)
print(v1 * v2)
else:
print(2)
if __name__ == '__main__':
main()
"""
"""
def main():
l,r = sep()
a=[]
luckynum(0,l,r,a)
a.sort()
#print(a)
i=0
ans=0
l-=1
#print(a)
while(True):
if r>a[i]:
ans+=(a[i]*(a[i]-l))
l=a[i]
else:
ans+=(a[i]*(r-l))
break
i+=1
print(ans)
if __name__ == '__main__':
main()
"""
"""
def main():
sqrt = {i * i: i for i in range(1, 1000)}
#print(sqrt)
a, b = sep()
for y in range(1, a):
x2 = a * a - y * y
if x2 in sqrt:
x = sqrt[x2]
if b * y % a == 0 and b * x % a == 0 and b * x // a != y:
print('YES')
print(-x, y)
print(0, 0)
print(b * y // a, b * x // a)
exit()
print('NO')
if __name__ == '__main__':
main()
"""
"""
def main():
m=inpu()
q=lis()
n=inpu()
arr=lis()
q=min(q)
arr.sort(reverse=True)
s=0
cnt=0
i=0
while(i<n):
cnt+=1
s+=arr[i]
#print(cnt,q)
if cnt==q:
i+=2
cnt=0
i+=1
print(s)
if __name__ == '__main__':
main()
"""
"""
def main():
n,k = sep()
if k * 2 >= (n - 1) * n:
print('no solution')
else:
for i in range(n):
print(0,i)
if __name__ == '__main__':
main()
"""
"""
def main():
t = inpu()
for _ in range(t):
n,k = sep()
arr = lis()
i=0
j=0
while(k!=0):
if i==n-1:
break
if arr[i]!=0:
arr[i]-=1
arr[n-1]+=1
k-=1
else:
i+=1
print(*arr)
if __name__ == '__main__':
main()
"""
"""
def main():
t = int(input())
for _ in range(t):
n=int(input())
arr = lis()
s = 0
for x in arr:
s ^= x
if s == 0:
print('YES')
else:
c = 0
y=0
for i in range(n):
y ^= arr[i]
if y == s:
c += 1
y=0
if c >= 2:
print("YES")
else:
print("NO")
if __name__ == '__main__':
main()
"""
def main():
s = inp()
ans = 0
k= inpu()
for _ in range(k):
a, b = 0, 0
p = input()
for x in s:
if (x == p[0]):
a += 1
elif (x == p[1]):
b += 1
else:
ans += min(a, b)
a, b = 0, 0
ans += min(a, b)
print(ans)
if __name__ == '__main__':
main()
```
Yes
| 71,001 | [
0.30078125,
-0.062469482421875,
0.03240966796875,
0.20458984375,
-0.54833984375,
-0.6875,
0.06640625,
-0.06231689453125,
-0.203369140625,
0.943359375,
0.7431640625,
0.0479736328125,
-0.375244140625,
-0.91259765625,
-0.916015625,
-0.159423828125,
-0.9326171875,
-0.6044921875,
-0.5048828125,
-0.191162109375,
0.0599365234375,
-0.224365234375,
-1.6044921875,
-0.27880859375,
-0.45654296875,
1.1884765625,
0.309814453125,
-0.326416015625,
1.13671875,
0.72412109375,
-0.2783203125,
-0.2734375,
0.517578125,
-1.05859375,
-0.548828125,
-0.5869140625,
0.95166015625,
-0.46484375,
-0.0654296875,
-0.05462646484375,
0.572265625,
-0.25830078125,
0.467529296875,
-0.56005859375,
-1.3701171875,
-0.415771484375,
-0.09832763671875,
-0.5927734375,
-0.342529296875,
-0.442626953125,
0.3583984375,
-0.35888671875,
0.59765625,
-0.235595703125,
0.060516357421875,
0.28369140625,
0.256103515625,
0.1417236328125,
-0.78515625,
0.298583984375,
0.1729736328125,
0.319091796875,
0.1888427734375,
-0.8173828125,
-0.455810546875,
-0.08856201171875,
-0.2440185546875,
0.237548828125,
-0.00044155120849609375,
-0.461181640625,
-0.28466796875,
0.41259765625,
-0.390869140625,
-0.19189453125,
-0.64306640625,
0.07904052734375,
0.245361328125,
0.152099609375,
-0.65966796875,
0.89990234375,
0.29345703125,
1.1064453125,
0.72509765625,
-0.10723876953125,
-0.302734375,
-0.1356201171875,
0.06878662109375,
0.4150390625,
0.464599609375,
-0.2666015625,
-0.1451416015625,
0.446533203125,
-0.94091796875,
-0.201416015625,
0.6259765625,
0.396728515625,
-0.314697265625,
0.274658203125,
0.49560546875,
0.448974609375,
0.89501953125,
0.52490234375,
-0.287841796875,
0.87890625,
-0.5888671875,
0.11859130859375,
0.1024169921875,
0.1533203125,
0.015350341796875,
0.252685546875,
-0.22607421875,
-0.10162353515625,
0.459716796875,
0.484619140625,
-0.75341796875,
0.72119140625,
-0.2568359375,
0.428955078125,
-0.796875,
0.2294921875,
0.82080078125,
-0.07073974609375,
0.81787109375,
0.1185302734375,
0.2685546875,
-0.2265625,
-0.64697265625,
1.091796875,
-0.383056640625,
-0.02093505859375,
0.53564453125,
0.05596923828125,
-0.121337890625,
0.1397705078125,
-0.374267578125,
0.80517578125,
-0.30517578125,
0.61962890625,
0.55908203125,
-0.64453125,
0.5234375,
-0.1650390625,
0.01244354248046875,
1.5029296875,
0.634765625,
-0.1658935546875,
0.71533203125,
0.49951171875,
-0.92724609375,
0.1776123046875,
-1.3740234375,
0.85791015625,
0.051177978515625,
0.04443359375,
-0.6064453125,
-0.168701171875,
-0.216552734375,
0.06866455078125,
0.09478759765625,
0.1263427734375,
-0.437255859375,
0.18408203125,
-0.283203125,
0.63330078125,
-0.300048828125,
1.0244140625,
-0.6396484375,
0.03680419921875,
-0.1334228515625,
-0.54345703125,
0.2276611328125,
-0.03997802734375,
0.1929931640625,
1.064453125,
0.2119140625,
0.9189453125,
0.60400390625,
-0.313720703125,
0.6337890625,
0.5205078125,
-0.1890869140625,
0.383544921875,
0.17431640625,
0.41650390625,
0.5517578125,
0.419921875,
-0.144287109375,
-0.352294921875,
-0.78076171875,
-0.322509765625,
-0.040802001953125,
0.83544921875,
-0.421142578125,
0.410888671875,
-0.03094482421875,
-0.016510009765625,
-1.03125,
-0.307373046875,
0.1383056640625,
-1.1015625,
-0.5234375,
0.873046875,
0.16162109375,
0.68310546875,
-0.2763671875,
-0.671875,
0.54638671875,
1.462890625,
-0.276611328125,
0.351318359375,
0.7119140625,
-0.50732421875,
-0.29296875,
0.332763671875,
-0.1485595703125,
-0.1900634765625,
-0.85400390625,
0.69677734375,
-0.52685546875,
-0.024566650390625,
-0.2491455078125,
0.2227783203125,
0.247314453125,
0.66357421875,
-0.232666015625,
-0.40673828125,
0.7802734375,
1.1669921875,
-0.007129669189453125,
0.487548828125,
0.255859375,
0.77783203125,
0.1639404296875,
0.8193359375,
0.39404296875,
0.111572265625,
0.8974609375,
0.8515625,
0.08258056640625,
0.496826171875,
-0.1632080078125,
0.484375,
0.25927734375,
0.642578125,
0.432373046875,
0.2491455078125,
-0.310546875,
-0.0787353515625,
-0.31298828125,
0.141845703125,
-0.29736328125,
0.44384765625,
0.375,
0.487548828125,
-0.2041015625,
-0.1114501953125,
0.2425537109375,
0.7158203125,
-1.1689453125,
-0.55859375,
0.038299560546875,
0.1173095703125,
-0.0595703125,
0.0085601806640625,
0.169921875,
0.77197265625,
0.68310546875,
0.378662109375,
-0.56982421875,
-0.51416015625,
-1.1376953125,
-1.1005859375,
-1.0205078125,
-0.262939453125,
-0.8828125,
-0.08135986328125,
0.60595703125,
-1.0361328125,
0.439453125,
-0.365478515625,
-0.52392578125,
0.1236572265625,
-0.5576171875,
0.71240234375,
-0.196044921875,
0.78173828125,
-0.798828125,
0.693359375,
0.14990234375,
0.873046875,
-0.325439453125,
-0.33251953125,
-0.10137939453125,
-0.6357421875,
0.294189453125,
-0.07525634765625,
0.3232421875,
0.2763671875,
-0.6240234375,
-0.79931640625,
0.02734375,
-0.25927734375,
-0.609375,
0.1796875,
-0.77197265625,
0.80126953125,
0.91748046875,
-0.66748046875,
0.75537109375,
1.1669921875,
-0.93994140625,
0.08294677734375,
0.19677734375,
0.3642578125,
-0.5888671875,
1.1884765625,
0.343994140625,
0.3974609375,
-0.437255859375,
-0.52685546875,
-0.76904296875,
0.0267791748046875,
-0.006038665771484375,
-0.37841796875,
-0.0916748046875,
0.74755859375,
-0.255615234375,
-1.00390625,
0.77880859375,
-1.2822265625,
-0.06475830078125,
-0.07562255859375,
-0.62841796875,
1.0205078125,
0.451416015625,
0.355712890625,
-0.27001953125,
-0.845703125,
-0.2451171875,
0.82666015625,
0.1607666015625,
-0.58642578125,
0.0018444061279296875,
0.33740234375,
0.239501953125,
0.216552734375,
0.096435546875,
-0.2344970703125,
-0.3408203125,
0.0699462890625,
0.11981201171875,
0.99853515625,
0.28955078125,
0.4228515625,
0.273681640625,
0.837890625,
-0.6865234375,
-0.2587890625,
-0.27587890625,
0.716796875,
0.2900390625,
0.427001953125,
0.20068359375,
-0.1329345703125,
-0.48291015625,
-0.8369140625,
0.481201171875,
-0.36962890625,
0.79150390625,
-0.432861328125,
0.61669921875,
0.356201171875,
-0.556640625,
0.67578125,
-0.93115234375,
-0.344970703125,
0.8779296875,
-0.65673828125,
0.9697265625,
-0.98095703125,
0.1610107421875,
0.048980712890625,
0.069580078125,
0.68017578125,
0.59326171875,
0.8212890625,
-0.447021484375,
-0.5361328125,
-0.287841796875,
0.35400390625,
-0.1402587890625,
-0.478271484375,
0.11181640625,
-0.300537109375,
-0.513671875,
-0.9775390625,
0.489990234375,
0.78125,
0.64404296875,
0.28466796875,
0.36083984375,
0.1434326171875,
0.541015625,
0.95068359375,
0.017425537109375,
-0.05718994140625,
-0.77978515625,
0.984375,
0.02099609375,
-0.491455078125,
-0.343017578125,
-0.362060546875,
-0.342041015625,
0.2442626953125,
0.036468505859375,
0.06622314453125,
-0.92822265625,
-0.093505859375,
-0.12261962890625,
0.3408203125,
-0.77294921875,
-0.2763671875,
-0.1971435546875,
0.475341796875,
0.0760498046875,
-1.0712890625,
0.459716796875,
-0.720703125,
0.89404296875,
1.0283203125,
-0.00737762451171875,
-0.57958984375,
-0.09716796875,
-0.7021484375,
-0.95166015625,
-0.1475830078125,
0.603515625,
-0.123779296875,
0.2012939453125,
-1.3759765625,
0.5224609375,
0.385009765625,
-0.1368408203125,
0.316162109375,
0.1495361328125,
0.4951171875,
0.130126953125,
0.546875,
-0.62890625,
-0.66943359375,
0.384765625,
-1.142578125,
0.7314453125,
-0.59033203125,
0.58251953125,
-0.21240234375,
0.1688232421875,
0.145751953125,
0.48779296875,
-0.46435546875,
0.38818359375,
-0.0687255859375,
0.44482421875,
-1.0107421875,
-0.66650390625,
0.5283203125,
-0.1451416015625,
-0.71533203125,
0.53076171875,
0.2568359375,
-0.2998046875,
0.01102447509765625,
0.66748046875,
-0.442138671875,
0.49169921875,
-0.505859375,
0.64453125,
-0.08233642578125,
-0.74951171875,
-0.2144775390625,
-0.5263671875,
0.62939453125,
-0.242431640625,
-0.76318359375,
0.27978515625,
-1.1044921875,
-0.216064453125,
0.05621337890625,
-0.576171875,
0.41259765625,
0.290283203125,
0.11212158203125,
0.00106048583984375,
-0.48388671875,
-0.36572265625,
-0.18359375,
-0.51025390625,
-0.52001953125,
0.296875,
0.625,
0.66650390625,
0.25048828125,
-0.13720703125,
0.133056640625,
-0.0206298828125,
-0.1671142578125,
-0.60302734375,
-0.37255859375,
0.32470703125,
-0.58056640625,
-0.12353515625,
0.4013671875,
-0.0198211669921875,
0.39306640625,
0.86376953125,
-0.053314208984375,
0.229248046875,
0.323486328125,
-0.60107421875,
1.4384765625,
-0.142822265625,
-1.078125,
-0.41162109375,
0.2000732421875,
0.11907958984375,
0.66015625,
-0.2191162109375,
-0.74951171875,
-0.7392578125,
-1.1162109375,
0.12127685546875,
-0.56787109375,
-0.334228515625,
-0.91357421875,
-0.255859375,
-0.53271484375,
0.767578125,
-0.331787109375,
-0.357421875,
0.240478515625,
-1.3017578125,
0.206298828125,
-0.60791015625,
-0.335693359375,
-0.603515625,
-0.55859375,
-0.62255859375,
1.1220703125,
0.467041015625,
0.1578369140625,
0.4228515625,
-0.320556640625,
0.2354736328125,
-0.304443359375,
-0.59375,
-0.51513671875,
-0.20947265625,
0.293212890625,
-0.37841796875,
-0.3916015625,
-0.60693359375,
0.955078125,
-0.5078125,
0.2744140625,
-0.39306640625,
-0.52490234375,
-0.1783447265625,
-0.2047119140625,
0.80322265625,
-0.60498046875,
0.1904296875,
-0.59375,
0.56103515625,
0.409423828125,
-0.325927734375,
-0.53955078125,
-0.80908203125,
-0.55419921875,
-0.97021484375,
0.58544921875,
-0.5859375,
0.5986328125,
-0.7509765625,
-0.2418212890625,
0.9130859375,
-0.52197265625,
0.33984375,
1.431640625,
-0.1285400390625,
0.2283935546875,
-0.888671875,
0.63720703125,
-0.0269927978515625,
-0.6796875,
-0.304931640625,
-0.1119384765625,
-0.9345703125,
0.08038330078125,
-0.56494140625,
-0.873046875,
-0.54833984375,
0.73876953125,
1.3740234375,
-0.27099609375,
0.99169921875,
0.25537109375,
-1.201171875,
-0.78759765625,
0.75927734375,
0.39013671875,
0.51806640625,
1.1142578125,
-0.69482421875,
-0.1605224609375,
0.416015625,
-0.039276123046875,
-0.28369140625,
-0.197265625,
1.0185546875,
-0.46142578125,
-0.61279296875,
0.56005859375,
0.55322265625,
-1.1025390625,
-0.6337890625,
0.1180419921875,
-0.0272979736328125,
-0.027618408203125,
-0.6708984375,
0.2020263671875,
0.646484375,
-0.393310546875,
-0.013824462890625,
0.04400634765625,
-0.00948333740234375,
0.67724609375,
0.296875,
0.2890625,
-0.53955078125,
0.67626953125,
0.8642578125,
-0.80615234375,
-0.409912109375,
-0.89013671875,
-0.1422119140625,
-0.2081298828125,
0.296142578125,
0.7890625,
0.11431884765625,
0.2177734375,
0.76611328125,
-0.112060546875,
0.6572265625,
-0.47412109375,
-0.333251953125,
0.1614990234375,
-0.49365234375,
-0.250244140625,
-0.03656005859375,
0.20654296875,
0.1546630859375,
0.260009765625,
-0.6201171875,
-0.06719970703125,
0.494873046875,
0.32861328125,
-0.0484619140625,
-0.064208984375,
-0.350830078125,
-0.57861328125,
-0.4423828125,
-0.48681640625,
-0.8125,
-0.15380859375,
0.428466796875,
0.43115234375,
-0.72265625,
0.0382080078125,
0.8447265625,
-0.7978515625,
1.1630859375,
-0.79931640625,
0.31591796875,
-0.416748046875,
-0.16455078125,
-0.77685546875,
0.10595703125,
-0.486572265625,
-0.279296875,
-0.328369140625,
0.51171875,
0.40185546875,
0.5966796875,
-0.2371826171875,
0.246337890625,
-0.16357421875,
-0.77490234375,
-0.01462554931640625,
0.09051513671875,
0.054473876953125,
0.344970703125,
0.697265625,
0.4560546875,
0.1826171875,
-0.046173095703125,
-0.53662109375,
-0.427001953125,
0.1942138671875,
0.8984375,
0.00626373291015625,
-0.0687255859375,
-0.3115234375,
-0.0723876953125,
-0.60986328125,
0.2252197265625,
-0.26318359375,
-0.1207275390625,
0.08074951171875,
-0.76171875,
0.53515625,
1.2373046875,
-0.161376953125,
0.2152099609375,
-0.03314208984375,
0.369384765625,
0.388916015625,
0.1488037109375,
0.311279296875,
0.20703125,
0.06744384765625,
-0.228515625,
-0.09967041015625,
0.56591796875,
-0.00792694091796875,
0.4091796875,
-0.3388671875,
-0.7685546875,
-0.82080078125,
-0.0269317626953125,
-0.32666015625,
0.0227813720703125,
0.59375,
-0.8349609375,
-0.08984375,
0.135986328125,
-1.029296875,
0.21240234375,
-0.80810546875,
-0.7998046875,
0.1552734375,
-0.138427734375,
-0.79345703125,
-0.40234375,
-0.56103515625,
0.1148681640625,
0.212890625,
0.5009765625,
-0.74267578125,
0.171142578125,
-0.1153564453125,
0.3916015625,
-0.2607421875,
-0.08935546875,
0.096435546875,
0.2181396484375,
-0.53271484375,
-0.64794921875,
0.121337890625,
1.546875,
0.1912841796875,
-0.355712890625,
-0.66064453125,
0.133544921875,
-0.46533203125,
0.2083740234375,
-0.12359619140625,
-0.12432861328125,
-0.0298004150390625,
0.43994140625,
-1.1474609375,
-0.340087890625,
0.10650634765625,
0.337158203125,
-0.1324462890625,
-0.32958984375,
-0.2227783203125,
0.66162109375,
0.9306640625,
-0.1478271484375,
-0.0328369140625,
0.37646484375,
0.87890625,
-0.2890625,
-0.0989990234375,
-0.1290283203125,
0.323974609375,
0.56005859375,
0.365966796875,
-0.282470703125,
0.724609375,
0.9765625,
-0.3037109375,
-0.0789794921875,
0.51025390625,
0.049591064453125,
0.039154052734375,
-0.2274169921875,
-0.2296142578125,
-0.002803802490234375,
-0.034027099609375,
-0.82080078125,
0.2261962890625,
-0.329345703125,
-0.423583984375,
-0.1932373046875,
-0.71630859375,
1.0029296875,
-1.166015625,
0.42626953125,
-0.3193359375,
-0.1859130859375,
0.4609375,
0.95166015625,
0.037689208984375,
-0.0908203125,
0.495849609375,
0.438232421875,
0.64013671875,
0.83251953125,
0.2283935546875,
0.1160888671875,
-0.451904296875,
0.1641845703125,
0.0161285400390625,
0.023162841796875,
-0.5908203125,
-0.30615234375,
-1.2333984375,
0.64990234375,
-0.450927734375,
-0.09906005859375,
0.33984375,
-0.58056640625,
0.19384765625,
-0.303955078125,
0.83935546875,
-0.4794921875,
0.4287109375,
0.52734375,
-0.58740234375,
-0.46435546875,
0.85595703125,
-0.08673095703125,
0.39501953125,
0.209228515625,
0.7783203125,
0.3125,
1.7255859375,
0.2978515625,
-0.1956787109375,
-0.043060302734375,
0.053619384765625,
-0.1959228515625,
-0.59326171875,
-0.309814453125,
-0.311767578125,
-0.1688232421875,
-0.425537109375,
-0.339111328125,
-0.07940673828125,
0.6396484375,
0.059814453125,
-0.82666015625,
-0.08233642578125,
0.06561279296875,
-0.8720703125,
0.8359375,
0.136474609375,
0.1287841796875,
0.106689453125,
0.1329345703125,
-0.1568603515625,
-0.3369140625,
-0.1610107421875,
-0.4453125,
0.2100830078125,
-0.5205078125,
-0.55810546875,
-0.61865234375,
-0.9541015625,
-0.34423828125,
-0.26806640625,
-0.61669921875,
-0.92236328125,
0.185546875,
0.65869140625,
0.5009765625,
0.4609375,
-0.54638671875,
0.416748046875,
1.1513671875,
0.79345703125,
-0.427734375,
0.93798828125,
0.4228515625,
-0.58154296875,
0.01061248779296875,
-0.138916015625,
0.697265625,
-0.29345703125,
-0.061431884765625,
-0.274169921875,
0.415283203125,
-1.015625,
-1.3095703125,
0.0504150390625,
0.72802734375,
0.3671875,
-0.546875,
-1.00390625,
-0.462890625,
-0.81884765625,
-0.045867919921875,
-0.818359375,
0.63232421875,
0.382568359375,
-0.1622314453125,
0.04608154296875,
-1.0244140625,
4.2578125,
0.99658203125,
0.8515625,
0.07489013671875,
0.0121612548828125,
0.93896484375,
0.0192108154296875,
-0.400634765625,
0.196044921875,
-0.3740234375,
0.78466796875,
-0.283203125,
-0.1058349609375,
0.626953125,
0.1607666015625,
0.414794921875,
-0.4892578125,
-0.066650390625,
-0.206298828125,
-1.0107421875,
-0.87939453125,
0.1136474609375,
0.31787109375,
0.13720703125,
0.10650634765625,
0.127685546875,
0.68701171875,
-0.62939453125,
-0.34912109375,
-0.66455078125,
-0.270751953125,
-0.65234375,
0.7890625,
-0.019195556640625,
-0.060760498046875,
0.5166015625,
0.15966796875,
-0.58251953125,
0.041595458984375,
0.5908203125,
-0.34521484375,
-0.41064453125,
0.8740234375,
-0.79931640625,
0.1572265625,
0.60498046875,
-0.365478515625,
0.327880859375,
0.64013671875,
-0.486083984375,
0.712890625,
-0.1710205078125,
0.775390625,
-0.7861328125,
-0.69189453125,
0.059967041015625,
0.23681640625,
-0.26904296875,
0.093505859375,
0.3662109375,
0.161376953125,
0.11669921875,
-0.007656097412109375,
0.469970703125,
-0.76123046875,
0.61962890625,
0.2076416015625,
0.2049560546875,
-0.5634765625,
0.09027099609375,
0.00823211669921875,
-0.08270263671875,
-0.365234375,
-0.57177734375,
0.51708984375,
0.2265625,
-0.05084228515625,
0.33642578125,
0.53662109375,
-0.84130859375,
0.0175323486328125,
-0.037506103515625,
-0.333740234375,
-0.363525390625,
0.55517578125,
1.580078125,
-0.681640625,
-0.394287109375,
-0.53857421875,
0.59521484375,
0.204345703125,
0.34765625,
0.60107421875,
-0.90185546875,
-0.333251953125
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Submitted Solution:
```
s = input()
ans = 0
for i in range(int(input())):
x = input()
a, b = 0, 0
for j in s:
if j == x[0]:
a += 1
elif j == x[1]:
b += 1
else:
ans += min(a, b)
a, b = 0, 0
ans += min(a, b)
print(ans)
```
Yes
| 71,002 | [
0.30078125,
-0.062469482421875,
0.03240966796875,
0.20458984375,
-0.54833984375,
-0.6875,
0.06640625,
-0.06231689453125,
-0.203369140625,
0.943359375,
0.7431640625,
0.0479736328125,
-0.375244140625,
-0.91259765625,
-0.916015625,
-0.159423828125,
-0.9326171875,
-0.6044921875,
-0.5048828125,
-0.191162109375,
0.0599365234375,
-0.224365234375,
-1.6044921875,
-0.27880859375,
-0.45654296875,
1.1884765625,
0.309814453125,
-0.326416015625,
1.13671875,
0.72412109375,
-0.2783203125,
-0.2734375,
0.517578125,
-1.05859375,
-0.548828125,
-0.5869140625,
0.95166015625,
-0.46484375,
-0.0654296875,
-0.05462646484375,
0.572265625,
-0.25830078125,
0.467529296875,
-0.56005859375,
-1.3701171875,
-0.415771484375,
-0.09832763671875,
-0.5927734375,
-0.342529296875,
-0.442626953125,
0.3583984375,
-0.35888671875,
0.59765625,
-0.235595703125,
0.060516357421875,
0.28369140625,
0.256103515625,
0.1417236328125,
-0.78515625,
0.298583984375,
0.1729736328125,
0.319091796875,
0.1888427734375,
-0.8173828125,
-0.455810546875,
-0.08856201171875,
-0.2440185546875,
0.237548828125,
-0.00044155120849609375,
-0.461181640625,
-0.28466796875,
0.41259765625,
-0.390869140625,
-0.19189453125,
-0.64306640625,
0.07904052734375,
0.245361328125,
0.152099609375,
-0.65966796875,
0.89990234375,
0.29345703125,
1.1064453125,
0.72509765625,
-0.10723876953125,
-0.302734375,
-0.1356201171875,
0.06878662109375,
0.4150390625,
0.464599609375,
-0.2666015625,
-0.1451416015625,
0.446533203125,
-0.94091796875,
-0.201416015625,
0.6259765625,
0.396728515625,
-0.314697265625,
0.274658203125,
0.49560546875,
0.448974609375,
0.89501953125,
0.52490234375,
-0.287841796875,
0.87890625,
-0.5888671875,
0.11859130859375,
0.1024169921875,
0.1533203125,
0.015350341796875,
0.252685546875,
-0.22607421875,
-0.10162353515625,
0.459716796875,
0.484619140625,
-0.75341796875,
0.72119140625,
-0.2568359375,
0.428955078125,
-0.796875,
0.2294921875,
0.82080078125,
-0.07073974609375,
0.81787109375,
0.1185302734375,
0.2685546875,
-0.2265625,
-0.64697265625,
1.091796875,
-0.383056640625,
-0.02093505859375,
0.53564453125,
0.05596923828125,
-0.121337890625,
0.1397705078125,
-0.374267578125,
0.80517578125,
-0.30517578125,
0.61962890625,
0.55908203125,
-0.64453125,
0.5234375,
-0.1650390625,
0.01244354248046875,
1.5029296875,
0.634765625,
-0.1658935546875,
0.71533203125,
0.49951171875,
-0.92724609375,
0.1776123046875,
-1.3740234375,
0.85791015625,
0.051177978515625,
0.04443359375,
-0.6064453125,
-0.168701171875,
-0.216552734375,
0.06866455078125,
0.09478759765625,
0.1263427734375,
-0.437255859375,
0.18408203125,
-0.283203125,
0.63330078125,
-0.300048828125,
1.0244140625,
-0.6396484375,
0.03680419921875,
-0.1334228515625,
-0.54345703125,
0.2276611328125,
-0.03997802734375,
0.1929931640625,
1.064453125,
0.2119140625,
0.9189453125,
0.60400390625,
-0.313720703125,
0.6337890625,
0.5205078125,
-0.1890869140625,
0.383544921875,
0.17431640625,
0.41650390625,
0.5517578125,
0.419921875,
-0.144287109375,
-0.352294921875,
-0.78076171875,
-0.322509765625,
-0.040802001953125,
0.83544921875,
-0.421142578125,
0.410888671875,
-0.03094482421875,
-0.016510009765625,
-1.03125,
-0.307373046875,
0.1383056640625,
-1.1015625,
-0.5234375,
0.873046875,
0.16162109375,
0.68310546875,
-0.2763671875,
-0.671875,
0.54638671875,
1.462890625,
-0.276611328125,
0.351318359375,
0.7119140625,
-0.50732421875,
-0.29296875,
0.332763671875,
-0.1485595703125,
-0.1900634765625,
-0.85400390625,
0.69677734375,
-0.52685546875,
-0.024566650390625,
-0.2491455078125,
0.2227783203125,
0.247314453125,
0.66357421875,
-0.232666015625,
-0.40673828125,
0.7802734375,
1.1669921875,
-0.007129669189453125,
0.487548828125,
0.255859375,
0.77783203125,
0.1639404296875,
0.8193359375,
0.39404296875,
0.111572265625,
0.8974609375,
0.8515625,
0.08258056640625,
0.496826171875,
-0.1632080078125,
0.484375,
0.25927734375,
0.642578125,
0.432373046875,
0.2491455078125,
-0.310546875,
-0.0787353515625,
-0.31298828125,
0.141845703125,
-0.29736328125,
0.44384765625,
0.375,
0.487548828125,
-0.2041015625,
-0.1114501953125,
0.2425537109375,
0.7158203125,
-1.1689453125,
-0.55859375,
0.038299560546875,
0.1173095703125,
-0.0595703125,
0.0085601806640625,
0.169921875,
0.77197265625,
0.68310546875,
0.378662109375,
-0.56982421875,
-0.51416015625,
-1.1376953125,
-1.1005859375,
-1.0205078125,
-0.262939453125,
-0.8828125,
-0.08135986328125,
0.60595703125,
-1.0361328125,
0.439453125,
-0.365478515625,
-0.52392578125,
0.1236572265625,
-0.5576171875,
0.71240234375,
-0.196044921875,
0.78173828125,
-0.798828125,
0.693359375,
0.14990234375,
0.873046875,
-0.325439453125,
-0.33251953125,
-0.10137939453125,
-0.6357421875,
0.294189453125,
-0.07525634765625,
0.3232421875,
0.2763671875,
-0.6240234375,
-0.79931640625,
0.02734375,
-0.25927734375,
-0.609375,
0.1796875,
-0.77197265625,
0.80126953125,
0.91748046875,
-0.66748046875,
0.75537109375,
1.1669921875,
-0.93994140625,
0.08294677734375,
0.19677734375,
0.3642578125,
-0.5888671875,
1.1884765625,
0.343994140625,
0.3974609375,
-0.437255859375,
-0.52685546875,
-0.76904296875,
0.0267791748046875,
-0.006038665771484375,
-0.37841796875,
-0.0916748046875,
0.74755859375,
-0.255615234375,
-1.00390625,
0.77880859375,
-1.2822265625,
-0.06475830078125,
-0.07562255859375,
-0.62841796875,
1.0205078125,
0.451416015625,
0.355712890625,
-0.27001953125,
-0.845703125,
-0.2451171875,
0.82666015625,
0.1607666015625,
-0.58642578125,
0.0018444061279296875,
0.33740234375,
0.239501953125,
0.216552734375,
0.096435546875,
-0.2344970703125,
-0.3408203125,
0.0699462890625,
0.11981201171875,
0.99853515625,
0.28955078125,
0.4228515625,
0.273681640625,
0.837890625,
-0.6865234375,
-0.2587890625,
-0.27587890625,
0.716796875,
0.2900390625,
0.427001953125,
0.20068359375,
-0.1329345703125,
-0.48291015625,
-0.8369140625,
0.481201171875,
-0.36962890625,
0.79150390625,
-0.432861328125,
0.61669921875,
0.356201171875,
-0.556640625,
0.67578125,
-0.93115234375,
-0.344970703125,
0.8779296875,
-0.65673828125,
0.9697265625,
-0.98095703125,
0.1610107421875,
0.048980712890625,
0.069580078125,
0.68017578125,
0.59326171875,
0.8212890625,
-0.447021484375,
-0.5361328125,
-0.287841796875,
0.35400390625,
-0.1402587890625,
-0.478271484375,
0.11181640625,
-0.300537109375,
-0.513671875,
-0.9775390625,
0.489990234375,
0.78125,
0.64404296875,
0.28466796875,
0.36083984375,
0.1434326171875,
0.541015625,
0.95068359375,
0.017425537109375,
-0.05718994140625,
-0.77978515625,
0.984375,
0.02099609375,
-0.491455078125,
-0.343017578125,
-0.362060546875,
-0.342041015625,
0.2442626953125,
0.036468505859375,
0.06622314453125,
-0.92822265625,
-0.093505859375,
-0.12261962890625,
0.3408203125,
-0.77294921875,
-0.2763671875,
-0.1971435546875,
0.475341796875,
0.0760498046875,
-1.0712890625,
0.459716796875,
-0.720703125,
0.89404296875,
1.0283203125,
-0.00737762451171875,
-0.57958984375,
-0.09716796875,
-0.7021484375,
-0.95166015625,
-0.1475830078125,
0.603515625,
-0.123779296875,
0.2012939453125,
-1.3759765625,
0.5224609375,
0.385009765625,
-0.1368408203125,
0.316162109375,
0.1495361328125,
0.4951171875,
0.130126953125,
0.546875,
-0.62890625,
-0.66943359375,
0.384765625,
-1.142578125,
0.7314453125,
-0.59033203125,
0.58251953125,
-0.21240234375,
0.1688232421875,
0.145751953125,
0.48779296875,
-0.46435546875,
0.38818359375,
-0.0687255859375,
0.44482421875,
-1.0107421875,
-0.66650390625,
0.5283203125,
-0.1451416015625,
-0.71533203125,
0.53076171875,
0.2568359375,
-0.2998046875,
0.01102447509765625,
0.66748046875,
-0.442138671875,
0.49169921875,
-0.505859375,
0.64453125,
-0.08233642578125,
-0.74951171875,
-0.2144775390625,
-0.5263671875,
0.62939453125,
-0.242431640625,
-0.76318359375,
0.27978515625,
-1.1044921875,
-0.216064453125,
0.05621337890625,
-0.576171875,
0.41259765625,
0.290283203125,
0.11212158203125,
0.00106048583984375,
-0.48388671875,
-0.36572265625,
-0.18359375,
-0.51025390625,
-0.52001953125,
0.296875,
0.625,
0.66650390625,
0.25048828125,
-0.13720703125,
0.133056640625,
-0.0206298828125,
-0.1671142578125,
-0.60302734375,
-0.37255859375,
0.32470703125,
-0.58056640625,
-0.12353515625,
0.4013671875,
-0.0198211669921875,
0.39306640625,
0.86376953125,
-0.053314208984375,
0.229248046875,
0.323486328125,
-0.60107421875,
1.4384765625,
-0.142822265625,
-1.078125,
-0.41162109375,
0.2000732421875,
0.11907958984375,
0.66015625,
-0.2191162109375,
-0.74951171875,
-0.7392578125,
-1.1162109375,
0.12127685546875,
-0.56787109375,
-0.334228515625,
-0.91357421875,
-0.255859375,
-0.53271484375,
0.767578125,
-0.331787109375,
-0.357421875,
0.240478515625,
-1.3017578125,
0.206298828125,
-0.60791015625,
-0.335693359375,
-0.603515625,
-0.55859375,
-0.62255859375,
1.1220703125,
0.467041015625,
0.1578369140625,
0.4228515625,
-0.320556640625,
0.2354736328125,
-0.304443359375,
-0.59375,
-0.51513671875,
-0.20947265625,
0.293212890625,
-0.37841796875,
-0.3916015625,
-0.60693359375,
0.955078125,
-0.5078125,
0.2744140625,
-0.39306640625,
-0.52490234375,
-0.1783447265625,
-0.2047119140625,
0.80322265625,
-0.60498046875,
0.1904296875,
-0.59375,
0.56103515625,
0.409423828125,
-0.325927734375,
-0.53955078125,
-0.80908203125,
-0.55419921875,
-0.97021484375,
0.58544921875,
-0.5859375,
0.5986328125,
-0.7509765625,
-0.2418212890625,
0.9130859375,
-0.52197265625,
0.33984375,
1.431640625,
-0.1285400390625,
0.2283935546875,
-0.888671875,
0.63720703125,
-0.0269927978515625,
-0.6796875,
-0.304931640625,
-0.1119384765625,
-0.9345703125,
0.08038330078125,
-0.56494140625,
-0.873046875,
-0.54833984375,
0.73876953125,
1.3740234375,
-0.27099609375,
0.99169921875,
0.25537109375,
-1.201171875,
-0.78759765625,
0.75927734375,
0.39013671875,
0.51806640625,
1.1142578125,
-0.69482421875,
-0.1605224609375,
0.416015625,
-0.039276123046875,
-0.28369140625,
-0.197265625,
1.0185546875,
-0.46142578125,
-0.61279296875,
0.56005859375,
0.55322265625,
-1.1025390625,
-0.6337890625,
0.1180419921875,
-0.0272979736328125,
-0.027618408203125,
-0.6708984375,
0.2020263671875,
0.646484375,
-0.393310546875,
-0.013824462890625,
0.04400634765625,
-0.00948333740234375,
0.67724609375,
0.296875,
0.2890625,
-0.53955078125,
0.67626953125,
0.8642578125,
-0.80615234375,
-0.409912109375,
-0.89013671875,
-0.1422119140625,
-0.2081298828125,
0.296142578125,
0.7890625,
0.11431884765625,
0.2177734375,
0.76611328125,
-0.112060546875,
0.6572265625,
-0.47412109375,
-0.333251953125,
0.1614990234375,
-0.49365234375,
-0.250244140625,
-0.03656005859375,
0.20654296875,
0.1546630859375,
0.260009765625,
-0.6201171875,
-0.06719970703125,
0.494873046875,
0.32861328125,
-0.0484619140625,
-0.064208984375,
-0.350830078125,
-0.57861328125,
-0.4423828125,
-0.48681640625,
-0.8125,
-0.15380859375,
0.428466796875,
0.43115234375,
-0.72265625,
0.0382080078125,
0.8447265625,
-0.7978515625,
1.1630859375,
-0.79931640625,
0.31591796875,
-0.416748046875,
-0.16455078125,
-0.77685546875,
0.10595703125,
-0.486572265625,
-0.279296875,
-0.328369140625,
0.51171875,
0.40185546875,
0.5966796875,
-0.2371826171875,
0.246337890625,
-0.16357421875,
-0.77490234375,
-0.01462554931640625,
0.09051513671875,
0.054473876953125,
0.344970703125,
0.697265625,
0.4560546875,
0.1826171875,
-0.046173095703125,
-0.53662109375,
-0.427001953125,
0.1942138671875,
0.8984375,
0.00626373291015625,
-0.0687255859375,
-0.3115234375,
-0.0723876953125,
-0.60986328125,
0.2252197265625,
-0.26318359375,
-0.1207275390625,
0.08074951171875,
-0.76171875,
0.53515625,
1.2373046875,
-0.161376953125,
0.2152099609375,
-0.03314208984375,
0.369384765625,
0.388916015625,
0.1488037109375,
0.311279296875,
0.20703125,
0.06744384765625,
-0.228515625,
-0.09967041015625,
0.56591796875,
-0.00792694091796875,
0.4091796875,
-0.3388671875,
-0.7685546875,
-0.82080078125,
-0.0269317626953125,
-0.32666015625,
0.0227813720703125,
0.59375,
-0.8349609375,
-0.08984375,
0.135986328125,
-1.029296875,
0.21240234375,
-0.80810546875,
-0.7998046875,
0.1552734375,
-0.138427734375,
-0.79345703125,
-0.40234375,
-0.56103515625,
0.1148681640625,
0.212890625,
0.5009765625,
-0.74267578125,
0.171142578125,
-0.1153564453125,
0.3916015625,
-0.2607421875,
-0.08935546875,
0.096435546875,
0.2181396484375,
-0.53271484375,
-0.64794921875,
0.121337890625,
1.546875,
0.1912841796875,
-0.355712890625,
-0.66064453125,
0.133544921875,
-0.46533203125,
0.2083740234375,
-0.12359619140625,
-0.12432861328125,
-0.0298004150390625,
0.43994140625,
-1.1474609375,
-0.340087890625,
0.10650634765625,
0.337158203125,
-0.1324462890625,
-0.32958984375,
-0.2227783203125,
0.66162109375,
0.9306640625,
-0.1478271484375,
-0.0328369140625,
0.37646484375,
0.87890625,
-0.2890625,
-0.0989990234375,
-0.1290283203125,
0.323974609375,
0.56005859375,
0.365966796875,
-0.282470703125,
0.724609375,
0.9765625,
-0.3037109375,
-0.0789794921875,
0.51025390625,
0.049591064453125,
0.039154052734375,
-0.2274169921875,
-0.2296142578125,
-0.002803802490234375,
-0.034027099609375,
-0.82080078125,
0.2261962890625,
-0.329345703125,
-0.423583984375,
-0.1932373046875,
-0.71630859375,
1.0029296875,
-1.166015625,
0.42626953125,
-0.3193359375,
-0.1859130859375,
0.4609375,
0.95166015625,
0.037689208984375,
-0.0908203125,
0.495849609375,
0.438232421875,
0.64013671875,
0.83251953125,
0.2283935546875,
0.1160888671875,
-0.451904296875,
0.1641845703125,
0.0161285400390625,
0.023162841796875,
-0.5908203125,
-0.30615234375,
-1.2333984375,
0.64990234375,
-0.450927734375,
-0.09906005859375,
0.33984375,
-0.58056640625,
0.19384765625,
-0.303955078125,
0.83935546875,
-0.4794921875,
0.4287109375,
0.52734375,
-0.58740234375,
-0.46435546875,
0.85595703125,
-0.08673095703125,
0.39501953125,
0.209228515625,
0.7783203125,
0.3125,
1.7255859375,
0.2978515625,
-0.1956787109375,
-0.043060302734375,
0.053619384765625,
-0.1959228515625,
-0.59326171875,
-0.309814453125,
-0.311767578125,
-0.1688232421875,
-0.425537109375,
-0.339111328125,
-0.07940673828125,
0.6396484375,
0.059814453125,
-0.82666015625,
-0.08233642578125,
0.06561279296875,
-0.8720703125,
0.8359375,
0.136474609375,
0.1287841796875,
0.106689453125,
0.1329345703125,
-0.1568603515625,
-0.3369140625,
-0.1610107421875,
-0.4453125,
0.2100830078125,
-0.5205078125,
-0.55810546875,
-0.61865234375,
-0.9541015625,
-0.34423828125,
-0.26806640625,
-0.61669921875,
-0.92236328125,
0.185546875,
0.65869140625,
0.5009765625,
0.4609375,
-0.54638671875,
0.416748046875,
1.1513671875,
0.79345703125,
-0.427734375,
0.93798828125,
0.4228515625,
-0.58154296875,
0.01061248779296875,
-0.138916015625,
0.697265625,
-0.29345703125,
-0.061431884765625,
-0.274169921875,
0.415283203125,
-1.015625,
-1.3095703125,
0.0504150390625,
0.72802734375,
0.3671875,
-0.546875,
-1.00390625,
-0.462890625,
-0.81884765625,
-0.045867919921875,
-0.818359375,
0.63232421875,
0.382568359375,
-0.1622314453125,
0.04608154296875,
-1.0244140625,
4.2578125,
0.99658203125,
0.8515625,
0.07489013671875,
0.0121612548828125,
0.93896484375,
0.0192108154296875,
-0.400634765625,
0.196044921875,
-0.3740234375,
0.78466796875,
-0.283203125,
-0.1058349609375,
0.626953125,
0.1607666015625,
0.414794921875,
-0.4892578125,
-0.066650390625,
-0.206298828125,
-1.0107421875,
-0.87939453125,
0.1136474609375,
0.31787109375,
0.13720703125,
0.10650634765625,
0.127685546875,
0.68701171875,
-0.62939453125,
-0.34912109375,
-0.66455078125,
-0.270751953125,
-0.65234375,
0.7890625,
-0.019195556640625,
-0.060760498046875,
0.5166015625,
0.15966796875,
-0.58251953125,
0.041595458984375,
0.5908203125,
-0.34521484375,
-0.41064453125,
0.8740234375,
-0.79931640625,
0.1572265625,
0.60498046875,
-0.365478515625,
0.327880859375,
0.64013671875,
-0.486083984375,
0.712890625,
-0.1710205078125,
0.775390625,
-0.7861328125,
-0.69189453125,
0.059967041015625,
0.23681640625,
-0.26904296875,
0.093505859375,
0.3662109375,
0.161376953125,
0.11669921875,
-0.007656097412109375,
0.469970703125,
-0.76123046875,
0.61962890625,
0.2076416015625,
0.2049560546875,
-0.5634765625,
0.09027099609375,
0.00823211669921875,
-0.08270263671875,
-0.365234375,
-0.57177734375,
0.51708984375,
0.2265625,
-0.05084228515625,
0.33642578125,
0.53662109375,
-0.84130859375,
0.0175323486328125,
-0.037506103515625,
-0.333740234375,
-0.363525390625,
0.55517578125,
1.580078125,
-0.681640625,
-0.394287109375,
-0.53857421875,
0.59521484375,
0.204345703125,
0.34765625,
0.60107421875,
-0.90185546875,
-0.333251953125
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Submitted Solution:
```
ans = 0
t = []
x = input()
y = int(input())
for i in range(y):
z = input()
t.append(z)
#x = codeforces
#y = 2
#t = [do, cs]
pt = -1
ln = len(x)
for i in t:
a = i[0]
b = i[1]
pt = 0
for j in range(ln):
ded1=0
ded2=0
if j >= pt:
if x[j] in [a,b]:
pt = j
while pt < ln and x[pt] in [a,b]:
if x[pt] == a:
ded1+=1
else:
ded2+=1
pt += 1
ans += min(ded1, ded2)
print(ans)
```
Yes
| 71,003 | [
0.30078125,
-0.062469482421875,
0.03240966796875,
0.20458984375,
-0.54833984375,
-0.6875,
0.06640625,
-0.06231689453125,
-0.203369140625,
0.943359375,
0.7431640625,
0.0479736328125,
-0.375244140625,
-0.91259765625,
-0.916015625,
-0.159423828125,
-0.9326171875,
-0.6044921875,
-0.5048828125,
-0.191162109375,
0.0599365234375,
-0.224365234375,
-1.6044921875,
-0.27880859375,
-0.45654296875,
1.1884765625,
0.309814453125,
-0.326416015625,
1.13671875,
0.72412109375,
-0.2783203125,
-0.2734375,
0.517578125,
-1.05859375,
-0.548828125,
-0.5869140625,
0.95166015625,
-0.46484375,
-0.0654296875,
-0.05462646484375,
0.572265625,
-0.25830078125,
0.467529296875,
-0.56005859375,
-1.3701171875,
-0.415771484375,
-0.09832763671875,
-0.5927734375,
-0.342529296875,
-0.442626953125,
0.3583984375,
-0.35888671875,
0.59765625,
-0.235595703125,
0.060516357421875,
0.28369140625,
0.256103515625,
0.1417236328125,
-0.78515625,
0.298583984375,
0.1729736328125,
0.319091796875,
0.1888427734375,
-0.8173828125,
-0.455810546875,
-0.08856201171875,
-0.2440185546875,
0.237548828125,
-0.00044155120849609375,
-0.461181640625,
-0.28466796875,
0.41259765625,
-0.390869140625,
-0.19189453125,
-0.64306640625,
0.07904052734375,
0.245361328125,
0.152099609375,
-0.65966796875,
0.89990234375,
0.29345703125,
1.1064453125,
0.72509765625,
-0.10723876953125,
-0.302734375,
-0.1356201171875,
0.06878662109375,
0.4150390625,
0.464599609375,
-0.2666015625,
-0.1451416015625,
0.446533203125,
-0.94091796875,
-0.201416015625,
0.6259765625,
0.396728515625,
-0.314697265625,
0.274658203125,
0.49560546875,
0.448974609375,
0.89501953125,
0.52490234375,
-0.287841796875,
0.87890625,
-0.5888671875,
0.11859130859375,
0.1024169921875,
0.1533203125,
0.015350341796875,
0.252685546875,
-0.22607421875,
-0.10162353515625,
0.459716796875,
0.484619140625,
-0.75341796875,
0.72119140625,
-0.2568359375,
0.428955078125,
-0.796875,
0.2294921875,
0.82080078125,
-0.07073974609375,
0.81787109375,
0.1185302734375,
0.2685546875,
-0.2265625,
-0.64697265625,
1.091796875,
-0.383056640625,
-0.02093505859375,
0.53564453125,
0.05596923828125,
-0.121337890625,
0.1397705078125,
-0.374267578125,
0.80517578125,
-0.30517578125,
0.61962890625,
0.55908203125,
-0.64453125,
0.5234375,
-0.1650390625,
0.01244354248046875,
1.5029296875,
0.634765625,
-0.1658935546875,
0.71533203125,
0.49951171875,
-0.92724609375,
0.1776123046875,
-1.3740234375,
0.85791015625,
0.051177978515625,
0.04443359375,
-0.6064453125,
-0.168701171875,
-0.216552734375,
0.06866455078125,
0.09478759765625,
0.1263427734375,
-0.437255859375,
0.18408203125,
-0.283203125,
0.63330078125,
-0.300048828125,
1.0244140625,
-0.6396484375,
0.03680419921875,
-0.1334228515625,
-0.54345703125,
0.2276611328125,
-0.03997802734375,
0.1929931640625,
1.064453125,
0.2119140625,
0.9189453125,
0.60400390625,
-0.313720703125,
0.6337890625,
0.5205078125,
-0.1890869140625,
0.383544921875,
0.17431640625,
0.41650390625,
0.5517578125,
0.419921875,
-0.144287109375,
-0.352294921875,
-0.78076171875,
-0.322509765625,
-0.040802001953125,
0.83544921875,
-0.421142578125,
0.410888671875,
-0.03094482421875,
-0.016510009765625,
-1.03125,
-0.307373046875,
0.1383056640625,
-1.1015625,
-0.5234375,
0.873046875,
0.16162109375,
0.68310546875,
-0.2763671875,
-0.671875,
0.54638671875,
1.462890625,
-0.276611328125,
0.351318359375,
0.7119140625,
-0.50732421875,
-0.29296875,
0.332763671875,
-0.1485595703125,
-0.1900634765625,
-0.85400390625,
0.69677734375,
-0.52685546875,
-0.024566650390625,
-0.2491455078125,
0.2227783203125,
0.247314453125,
0.66357421875,
-0.232666015625,
-0.40673828125,
0.7802734375,
1.1669921875,
-0.007129669189453125,
0.487548828125,
0.255859375,
0.77783203125,
0.1639404296875,
0.8193359375,
0.39404296875,
0.111572265625,
0.8974609375,
0.8515625,
0.08258056640625,
0.496826171875,
-0.1632080078125,
0.484375,
0.25927734375,
0.642578125,
0.432373046875,
0.2491455078125,
-0.310546875,
-0.0787353515625,
-0.31298828125,
0.141845703125,
-0.29736328125,
0.44384765625,
0.375,
0.487548828125,
-0.2041015625,
-0.1114501953125,
0.2425537109375,
0.7158203125,
-1.1689453125,
-0.55859375,
0.038299560546875,
0.1173095703125,
-0.0595703125,
0.0085601806640625,
0.169921875,
0.77197265625,
0.68310546875,
0.378662109375,
-0.56982421875,
-0.51416015625,
-1.1376953125,
-1.1005859375,
-1.0205078125,
-0.262939453125,
-0.8828125,
-0.08135986328125,
0.60595703125,
-1.0361328125,
0.439453125,
-0.365478515625,
-0.52392578125,
0.1236572265625,
-0.5576171875,
0.71240234375,
-0.196044921875,
0.78173828125,
-0.798828125,
0.693359375,
0.14990234375,
0.873046875,
-0.325439453125,
-0.33251953125,
-0.10137939453125,
-0.6357421875,
0.294189453125,
-0.07525634765625,
0.3232421875,
0.2763671875,
-0.6240234375,
-0.79931640625,
0.02734375,
-0.25927734375,
-0.609375,
0.1796875,
-0.77197265625,
0.80126953125,
0.91748046875,
-0.66748046875,
0.75537109375,
1.1669921875,
-0.93994140625,
0.08294677734375,
0.19677734375,
0.3642578125,
-0.5888671875,
1.1884765625,
0.343994140625,
0.3974609375,
-0.437255859375,
-0.52685546875,
-0.76904296875,
0.0267791748046875,
-0.006038665771484375,
-0.37841796875,
-0.0916748046875,
0.74755859375,
-0.255615234375,
-1.00390625,
0.77880859375,
-1.2822265625,
-0.06475830078125,
-0.07562255859375,
-0.62841796875,
1.0205078125,
0.451416015625,
0.355712890625,
-0.27001953125,
-0.845703125,
-0.2451171875,
0.82666015625,
0.1607666015625,
-0.58642578125,
0.0018444061279296875,
0.33740234375,
0.239501953125,
0.216552734375,
0.096435546875,
-0.2344970703125,
-0.3408203125,
0.0699462890625,
0.11981201171875,
0.99853515625,
0.28955078125,
0.4228515625,
0.273681640625,
0.837890625,
-0.6865234375,
-0.2587890625,
-0.27587890625,
0.716796875,
0.2900390625,
0.427001953125,
0.20068359375,
-0.1329345703125,
-0.48291015625,
-0.8369140625,
0.481201171875,
-0.36962890625,
0.79150390625,
-0.432861328125,
0.61669921875,
0.356201171875,
-0.556640625,
0.67578125,
-0.93115234375,
-0.344970703125,
0.8779296875,
-0.65673828125,
0.9697265625,
-0.98095703125,
0.1610107421875,
0.048980712890625,
0.069580078125,
0.68017578125,
0.59326171875,
0.8212890625,
-0.447021484375,
-0.5361328125,
-0.287841796875,
0.35400390625,
-0.1402587890625,
-0.478271484375,
0.11181640625,
-0.300537109375,
-0.513671875,
-0.9775390625,
0.489990234375,
0.78125,
0.64404296875,
0.28466796875,
0.36083984375,
0.1434326171875,
0.541015625,
0.95068359375,
0.017425537109375,
-0.05718994140625,
-0.77978515625,
0.984375,
0.02099609375,
-0.491455078125,
-0.343017578125,
-0.362060546875,
-0.342041015625,
0.2442626953125,
0.036468505859375,
0.06622314453125,
-0.92822265625,
-0.093505859375,
-0.12261962890625,
0.3408203125,
-0.77294921875,
-0.2763671875,
-0.1971435546875,
0.475341796875,
0.0760498046875,
-1.0712890625,
0.459716796875,
-0.720703125,
0.89404296875,
1.0283203125,
-0.00737762451171875,
-0.57958984375,
-0.09716796875,
-0.7021484375,
-0.95166015625,
-0.1475830078125,
0.603515625,
-0.123779296875,
0.2012939453125,
-1.3759765625,
0.5224609375,
0.385009765625,
-0.1368408203125,
0.316162109375,
0.1495361328125,
0.4951171875,
0.130126953125,
0.546875,
-0.62890625,
-0.66943359375,
0.384765625,
-1.142578125,
0.7314453125,
-0.59033203125,
0.58251953125,
-0.21240234375,
0.1688232421875,
0.145751953125,
0.48779296875,
-0.46435546875,
0.38818359375,
-0.0687255859375,
0.44482421875,
-1.0107421875,
-0.66650390625,
0.5283203125,
-0.1451416015625,
-0.71533203125,
0.53076171875,
0.2568359375,
-0.2998046875,
0.01102447509765625,
0.66748046875,
-0.442138671875,
0.49169921875,
-0.505859375,
0.64453125,
-0.08233642578125,
-0.74951171875,
-0.2144775390625,
-0.5263671875,
0.62939453125,
-0.242431640625,
-0.76318359375,
0.27978515625,
-1.1044921875,
-0.216064453125,
0.05621337890625,
-0.576171875,
0.41259765625,
0.290283203125,
0.11212158203125,
0.00106048583984375,
-0.48388671875,
-0.36572265625,
-0.18359375,
-0.51025390625,
-0.52001953125,
0.296875,
0.625,
0.66650390625,
0.25048828125,
-0.13720703125,
0.133056640625,
-0.0206298828125,
-0.1671142578125,
-0.60302734375,
-0.37255859375,
0.32470703125,
-0.58056640625,
-0.12353515625,
0.4013671875,
-0.0198211669921875,
0.39306640625,
0.86376953125,
-0.053314208984375,
0.229248046875,
0.323486328125,
-0.60107421875,
1.4384765625,
-0.142822265625,
-1.078125,
-0.41162109375,
0.2000732421875,
0.11907958984375,
0.66015625,
-0.2191162109375,
-0.74951171875,
-0.7392578125,
-1.1162109375,
0.12127685546875,
-0.56787109375,
-0.334228515625,
-0.91357421875,
-0.255859375,
-0.53271484375,
0.767578125,
-0.331787109375,
-0.357421875,
0.240478515625,
-1.3017578125,
0.206298828125,
-0.60791015625,
-0.335693359375,
-0.603515625,
-0.55859375,
-0.62255859375,
1.1220703125,
0.467041015625,
0.1578369140625,
0.4228515625,
-0.320556640625,
0.2354736328125,
-0.304443359375,
-0.59375,
-0.51513671875,
-0.20947265625,
0.293212890625,
-0.37841796875,
-0.3916015625,
-0.60693359375,
0.955078125,
-0.5078125,
0.2744140625,
-0.39306640625,
-0.52490234375,
-0.1783447265625,
-0.2047119140625,
0.80322265625,
-0.60498046875,
0.1904296875,
-0.59375,
0.56103515625,
0.409423828125,
-0.325927734375,
-0.53955078125,
-0.80908203125,
-0.55419921875,
-0.97021484375,
0.58544921875,
-0.5859375,
0.5986328125,
-0.7509765625,
-0.2418212890625,
0.9130859375,
-0.52197265625,
0.33984375,
1.431640625,
-0.1285400390625,
0.2283935546875,
-0.888671875,
0.63720703125,
-0.0269927978515625,
-0.6796875,
-0.304931640625,
-0.1119384765625,
-0.9345703125,
0.08038330078125,
-0.56494140625,
-0.873046875,
-0.54833984375,
0.73876953125,
1.3740234375,
-0.27099609375,
0.99169921875,
0.25537109375,
-1.201171875,
-0.78759765625,
0.75927734375,
0.39013671875,
0.51806640625,
1.1142578125,
-0.69482421875,
-0.1605224609375,
0.416015625,
-0.039276123046875,
-0.28369140625,
-0.197265625,
1.0185546875,
-0.46142578125,
-0.61279296875,
0.56005859375,
0.55322265625,
-1.1025390625,
-0.6337890625,
0.1180419921875,
-0.0272979736328125,
-0.027618408203125,
-0.6708984375,
0.2020263671875,
0.646484375,
-0.393310546875,
-0.013824462890625,
0.04400634765625,
-0.00948333740234375,
0.67724609375,
0.296875,
0.2890625,
-0.53955078125,
0.67626953125,
0.8642578125,
-0.80615234375,
-0.409912109375,
-0.89013671875,
-0.1422119140625,
-0.2081298828125,
0.296142578125,
0.7890625,
0.11431884765625,
0.2177734375,
0.76611328125,
-0.112060546875,
0.6572265625,
-0.47412109375,
-0.333251953125,
0.1614990234375,
-0.49365234375,
-0.250244140625,
-0.03656005859375,
0.20654296875,
0.1546630859375,
0.260009765625,
-0.6201171875,
-0.06719970703125,
0.494873046875,
0.32861328125,
-0.0484619140625,
-0.064208984375,
-0.350830078125,
-0.57861328125,
-0.4423828125,
-0.48681640625,
-0.8125,
-0.15380859375,
0.428466796875,
0.43115234375,
-0.72265625,
0.0382080078125,
0.8447265625,
-0.7978515625,
1.1630859375,
-0.79931640625,
0.31591796875,
-0.416748046875,
-0.16455078125,
-0.77685546875,
0.10595703125,
-0.486572265625,
-0.279296875,
-0.328369140625,
0.51171875,
0.40185546875,
0.5966796875,
-0.2371826171875,
0.246337890625,
-0.16357421875,
-0.77490234375,
-0.01462554931640625,
0.09051513671875,
0.054473876953125,
0.344970703125,
0.697265625,
0.4560546875,
0.1826171875,
-0.046173095703125,
-0.53662109375,
-0.427001953125,
0.1942138671875,
0.8984375,
0.00626373291015625,
-0.0687255859375,
-0.3115234375,
-0.0723876953125,
-0.60986328125,
0.2252197265625,
-0.26318359375,
-0.1207275390625,
0.08074951171875,
-0.76171875,
0.53515625,
1.2373046875,
-0.161376953125,
0.2152099609375,
-0.03314208984375,
0.369384765625,
0.388916015625,
0.1488037109375,
0.311279296875,
0.20703125,
0.06744384765625,
-0.228515625,
-0.09967041015625,
0.56591796875,
-0.00792694091796875,
0.4091796875,
-0.3388671875,
-0.7685546875,
-0.82080078125,
-0.0269317626953125,
-0.32666015625,
0.0227813720703125,
0.59375,
-0.8349609375,
-0.08984375,
0.135986328125,
-1.029296875,
0.21240234375,
-0.80810546875,
-0.7998046875,
0.1552734375,
-0.138427734375,
-0.79345703125,
-0.40234375,
-0.56103515625,
0.1148681640625,
0.212890625,
0.5009765625,
-0.74267578125,
0.171142578125,
-0.1153564453125,
0.3916015625,
-0.2607421875,
-0.08935546875,
0.096435546875,
0.2181396484375,
-0.53271484375,
-0.64794921875,
0.121337890625,
1.546875,
0.1912841796875,
-0.355712890625,
-0.66064453125,
0.133544921875,
-0.46533203125,
0.2083740234375,
-0.12359619140625,
-0.12432861328125,
-0.0298004150390625,
0.43994140625,
-1.1474609375,
-0.340087890625,
0.10650634765625,
0.337158203125,
-0.1324462890625,
-0.32958984375,
-0.2227783203125,
0.66162109375,
0.9306640625,
-0.1478271484375,
-0.0328369140625,
0.37646484375,
0.87890625,
-0.2890625,
-0.0989990234375,
-0.1290283203125,
0.323974609375,
0.56005859375,
0.365966796875,
-0.282470703125,
0.724609375,
0.9765625,
-0.3037109375,
-0.0789794921875,
0.51025390625,
0.049591064453125,
0.039154052734375,
-0.2274169921875,
-0.2296142578125,
-0.002803802490234375,
-0.034027099609375,
-0.82080078125,
0.2261962890625,
-0.329345703125,
-0.423583984375,
-0.1932373046875,
-0.71630859375,
1.0029296875,
-1.166015625,
0.42626953125,
-0.3193359375,
-0.1859130859375,
0.4609375,
0.95166015625,
0.037689208984375,
-0.0908203125,
0.495849609375,
0.438232421875,
0.64013671875,
0.83251953125,
0.2283935546875,
0.1160888671875,
-0.451904296875,
0.1641845703125,
0.0161285400390625,
0.023162841796875,
-0.5908203125,
-0.30615234375,
-1.2333984375,
0.64990234375,
-0.450927734375,
-0.09906005859375,
0.33984375,
-0.58056640625,
0.19384765625,
-0.303955078125,
0.83935546875,
-0.4794921875,
0.4287109375,
0.52734375,
-0.58740234375,
-0.46435546875,
0.85595703125,
-0.08673095703125,
0.39501953125,
0.209228515625,
0.7783203125,
0.3125,
1.7255859375,
0.2978515625,
-0.1956787109375,
-0.043060302734375,
0.053619384765625,
-0.1959228515625,
-0.59326171875,
-0.309814453125,
-0.311767578125,
-0.1688232421875,
-0.425537109375,
-0.339111328125,
-0.07940673828125,
0.6396484375,
0.059814453125,
-0.82666015625,
-0.08233642578125,
0.06561279296875,
-0.8720703125,
0.8359375,
0.136474609375,
0.1287841796875,
0.106689453125,
0.1329345703125,
-0.1568603515625,
-0.3369140625,
-0.1610107421875,
-0.4453125,
0.2100830078125,
-0.5205078125,
-0.55810546875,
-0.61865234375,
-0.9541015625,
-0.34423828125,
-0.26806640625,
-0.61669921875,
-0.92236328125,
0.185546875,
0.65869140625,
0.5009765625,
0.4609375,
-0.54638671875,
0.416748046875,
1.1513671875,
0.79345703125,
-0.427734375,
0.93798828125,
0.4228515625,
-0.58154296875,
0.01061248779296875,
-0.138916015625,
0.697265625,
-0.29345703125,
-0.061431884765625,
-0.274169921875,
0.415283203125,
-1.015625,
-1.3095703125,
0.0504150390625,
0.72802734375,
0.3671875,
-0.546875,
-1.00390625,
-0.462890625,
-0.81884765625,
-0.045867919921875,
-0.818359375,
0.63232421875,
0.382568359375,
-0.1622314453125,
0.04608154296875,
-1.0244140625,
4.2578125,
0.99658203125,
0.8515625,
0.07489013671875,
0.0121612548828125,
0.93896484375,
0.0192108154296875,
-0.400634765625,
0.196044921875,
-0.3740234375,
0.78466796875,
-0.283203125,
-0.1058349609375,
0.626953125,
0.1607666015625,
0.414794921875,
-0.4892578125,
-0.066650390625,
-0.206298828125,
-1.0107421875,
-0.87939453125,
0.1136474609375,
0.31787109375,
0.13720703125,
0.10650634765625,
0.127685546875,
0.68701171875,
-0.62939453125,
-0.34912109375,
-0.66455078125,
-0.270751953125,
-0.65234375,
0.7890625,
-0.019195556640625,
-0.060760498046875,
0.5166015625,
0.15966796875,
-0.58251953125,
0.041595458984375,
0.5908203125,
-0.34521484375,
-0.41064453125,
0.8740234375,
-0.79931640625,
0.1572265625,
0.60498046875,
-0.365478515625,
0.327880859375,
0.64013671875,
-0.486083984375,
0.712890625,
-0.1710205078125,
0.775390625,
-0.7861328125,
-0.69189453125,
0.059967041015625,
0.23681640625,
-0.26904296875,
0.093505859375,
0.3662109375,
0.161376953125,
0.11669921875,
-0.007656097412109375,
0.469970703125,
-0.76123046875,
0.61962890625,
0.2076416015625,
0.2049560546875,
-0.5634765625,
0.09027099609375,
0.00823211669921875,
-0.08270263671875,
-0.365234375,
-0.57177734375,
0.51708984375,
0.2265625,
-0.05084228515625,
0.33642578125,
0.53662109375,
-0.84130859375,
0.0175323486328125,
-0.037506103515625,
-0.333740234375,
-0.363525390625,
0.55517578125,
1.580078125,
-0.681640625,
-0.394287109375,
-0.53857421875,
0.59521484375,
0.204345703125,
0.34765625,
0.60107421875,
-0.90185546875,
-0.333251953125
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Submitted Solution:
```
a=input()
b=[input() for i in range(int(input()))]
e=0
for i in b:
x=y=0
for j in a:
if j==i[0]:
x+=1
elif j==i[1]:
y+=1
else:
e+=min(x,y)
x=y=0
e+=min(x,y)
print(e)
```
Yes
| 71,004 | [
0.30078125,
-0.062469482421875,
0.03240966796875,
0.20458984375,
-0.54833984375,
-0.6875,
0.06640625,
-0.06231689453125,
-0.203369140625,
0.943359375,
0.7431640625,
0.0479736328125,
-0.375244140625,
-0.91259765625,
-0.916015625,
-0.159423828125,
-0.9326171875,
-0.6044921875,
-0.5048828125,
-0.191162109375,
0.0599365234375,
-0.224365234375,
-1.6044921875,
-0.27880859375,
-0.45654296875,
1.1884765625,
0.309814453125,
-0.326416015625,
1.13671875,
0.72412109375,
-0.2783203125,
-0.2734375,
0.517578125,
-1.05859375,
-0.548828125,
-0.5869140625,
0.95166015625,
-0.46484375,
-0.0654296875,
-0.05462646484375,
0.572265625,
-0.25830078125,
0.467529296875,
-0.56005859375,
-1.3701171875,
-0.415771484375,
-0.09832763671875,
-0.5927734375,
-0.342529296875,
-0.442626953125,
0.3583984375,
-0.35888671875,
0.59765625,
-0.235595703125,
0.060516357421875,
0.28369140625,
0.256103515625,
0.1417236328125,
-0.78515625,
0.298583984375,
0.1729736328125,
0.319091796875,
0.1888427734375,
-0.8173828125,
-0.455810546875,
-0.08856201171875,
-0.2440185546875,
0.237548828125,
-0.00044155120849609375,
-0.461181640625,
-0.28466796875,
0.41259765625,
-0.390869140625,
-0.19189453125,
-0.64306640625,
0.07904052734375,
0.245361328125,
0.152099609375,
-0.65966796875,
0.89990234375,
0.29345703125,
1.1064453125,
0.72509765625,
-0.10723876953125,
-0.302734375,
-0.1356201171875,
0.06878662109375,
0.4150390625,
0.464599609375,
-0.2666015625,
-0.1451416015625,
0.446533203125,
-0.94091796875,
-0.201416015625,
0.6259765625,
0.396728515625,
-0.314697265625,
0.274658203125,
0.49560546875,
0.448974609375,
0.89501953125,
0.52490234375,
-0.287841796875,
0.87890625,
-0.5888671875,
0.11859130859375,
0.1024169921875,
0.1533203125,
0.015350341796875,
0.252685546875,
-0.22607421875,
-0.10162353515625,
0.459716796875,
0.484619140625,
-0.75341796875,
0.72119140625,
-0.2568359375,
0.428955078125,
-0.796875,
0.2294921875,
0.82080078125,
-0.07073974609375,
0.81787109375,
0.1185302734375,
0.2685546875,
-0.2265625,
-0.64697265625,
1.091796875,
-0.383056640625,
-0.02093505859375,
0.53564453125,
0.05596923828125,
-0.121337890625,
0.1397705078125,
-0.374267578125,
0.80517578125,
-0.30517578125,
0.61962890625,
0.55908203125,
-0.64453125,
0.5234375,
-0.1650390625,
0.01244354248046875,
1.5029296875,
0.634765625,
-0.1658935546875,
0.71533203125,
0.49951171875,
-0.92724609375,
0.1776123046875,
-1.3740234375,
0.85791015625,
0.051177978515625,
0.04443359375,
-0.6064453125,
-0.168701171875,
-0.216552734375,
0.06866455078125,
0.09478759765625,
0.1263427734375,
-0.437255859375,
0.18408203125,
-0.283203125,
0.63330078125,
-0.300048828125,
1.0244140625,
-0.6396484375,
0.03680419921875,
-0.1334228515625,
-0.54345703125,
0.2276611328125,
-0.03997802734375,
0.1929931640625,
1.064453125,
0.2119140625,
0.9189453125,
0.60400390625,
-0.313720703125,
0.6337890625,
0.5205078125,
-0.1890869140625,
0.383544921875,
0.17431640625,
0.41650390625,
0.5517578125,
0.419921875,
-0.144287109375,
-0.352294921875,
-0.78076171875,
-0.322509765625,
-0.040802001953125,
0.83544921875,
-0.421142578125,
0.410888671875,
-0.03094482421875,
-0.016510009765625,
-1.03125,
-0.307373046875,
0.1383056640625,
-1.1015625,
-0.5234375,
0.873046875,
0.16162109375,
0.68310546875,
-0.2763671875,
-0.671875,
0.54638671875,
1.462890625,
-0.276611328125,
0.351318359375,
0.7119140625,
-0.50732421875,
-0.29296875,
0.332763671875,
-0.1485595703125,
-0.1900634765625,
-0.85400390625,
0.69677734375,
-0.52685546875,
-0.024566650390625,
-0.2491455078125,
0.2227783203125,
0.247314453125,
0.66357421875,
-0.232666015625,
-0.40673828125,
0.7802734375,
1.1669921875,
-0.007129669189453125,
0.487548828125,
0.255859375,
0.77783203125,
0.1639404296875,
0.8193359375,
0.39404296875,
0.111572265625,
0.8974609375,
0.8515625,
0.08258056640625,
0.496826171875,
-0.1632080078125,
0.484375,
0.25927734375,
0.642578125,
0.432373046875,
0.2491455078125,
-0.310546875,
-0.0787353515625,
-0.31298828125,
0.141845703125,
-0.29736328125,
0.44384765625,
0.375,
0.487548828125,
-0.2041015625,
-0.1114501953125,
0.2425537109375,
0.7158203125,
-1.1689453125,
-0.55859375,
0.038299560546875,
0.1173095703125,
-0.0595703125,
0.0085601806640625,
0.169921875,
0.77197265625,
0.68310546875,
0.378662109375,
-0.56982421875,
-0.51416015625,
-1.1376953125,
-1.1005859375,
-1.0205078125,
-0.262939453125,
-0.8828125,
-0.08135986328125,
0.60595703125,
-1.0361328125,
0.439453125,
-0.365478515625,
-0.52392578125,
0.1236572265625,
-0.5576171875,
0.71240234375,
-0.196044921875,
0.78173828125,
-0.798828125,
0.693359375,
0.14990234375,
0.873046875,
-0.325439453125,
-0.33251953125,
-0.10137939453125,
-0.6357421875,
0.294189453125,
-0.07525634765625,
0.3232421875,
0.2763671875,
-0.6240234375,
-0.79931640625,
0.02734375,
-0.25927734375,
-0.609375,
0.1796875,
-0.77197265625,
0.80126953125,
0.91748046875,
-0.66748046875,
0.75537109375,
1.1669921875,
-0.93994140625,
0.08294677734375,
0.19677734375,
0.3642578125,
-0.5888671875,
1.1884765625,
0.343994140625,
0.3974609375,
-0.437255859375,
-0.52685546875,
-0.76904296875,
0.0267791748046875,
-0.006038665771484375,
-0.37841796875,
-0.0916748046875,
0.74755859375,
-0.255615234375,
-1.00390625,
0.77880859375,
-1.2822265625,
-0.06475830078125,
-0.07562255859375,
-0.62841796875,
1.0205078125,
0.451416015625,
0.355712890625,
-0.27001953125,
-0.845703125,
-0.2451171875,
0.82666015625,
0.1607666015625,
-0.58642578125,
0.0018444061279296875,
0.33740234375,
0.239501953125,
0.216552734375,
0.096435546875,
-0.2344970703125,
-0.3408203125,
0.0699462890625,
0.11981201171875,
0.99853515625,
0.28955078125,
0.4228515625,
0.273681640625,
0.837890625,
-0.6865234375,
-0.2587890625,
-0.27587890625,
0.716796875,
0.2900390625,
0.427001953125,
0.20068359375,
-0.1329345703125,
-0.48291015625,
-0.8369140625,
0.481201171875,
-0.36962890625,
0.79150390625,
-0.432861328125,
0.61669921875,
0.356201171875,
-0.556640625,
0.67578125,
-0.93115234375,
-0.344970703125,
0.8779296875,
-0.65673828125,
0.9697265625,
-0.98095703125,
0.1610107421875,
0.048980712890625,
0.069580078125,
0.68017578125,
0.59326171875,
0.8212890625,
-0.447021484375,
-0.5361328125,
-0.287841796875,
0.35400390625,
-0.1402587890625,
-0.478271484375,
0.11181640625,
-0.300537109375,
-0.513671875,
-0.9775390625,
0.489990234375,
0.78125,
0.64404296875,
0.28466796875,
0.36083984375,
0.1434326171875,
0.541015625,
0.95068359375,
0.017425537109375,
-0.05718994140625,
-0.77978515625,
0.984375,
0.02099609375,
-0.491455078125,
-0.343017578125,
-0.362060546875,
-0.342041015625,
0.2442626953125,
0.036468505859375,
0.06622314453125,
-0.92822265625,
-0.093505859375,
-0.12261962890625,
0.3408203125,
-0.77294921875,
-0.2763671875,
-0.1971435546875,
0.475341796875,
0.0760498046875,
-1.0712890625,
0.459716796875,
-0.720703125,
0.89404296875,
1.0283203125,
-0.00737762451171875,
-0.57958984375,
-0.09716796875,
-0.7021484375,
-0.95166015625,
-0.1475830078125,
0.603515625,
-0.123779296875,
0.2012939453125,
-1.3759765625,
0.5224609375,
0.385009765625,
-0.1368408203125,
0.316162109375,
0.1495361328125,
0.4951171875,
0.130126953125,
0.546875,
-0.62890625,
-0.66943359375,
0.384765625,
-1.142578125,
0.7314453125,
-0.59033203125,
0.58251953125,
-0.21240234375,
0.1688232421875,
0.145751953125,
0.48779296875,
-0.46435546875,
0.38818359375,
-0.0687255859375,
0.44482421875,
-1.0107421875,
-0.66650390625,
0.5283203125,
-0.1451416015625,
-0.71533203125,
0.53076171875,
0.2568359375,
-0.2998046875,
0.01102447509765625,
0.66748046875,
-0.442138671875,
0.49169921875,
-0.505859375,
0.64453125,
-0.08233642578125,
-0.74951171875,
-0.2144775390625,
-0.5263671875,
0.62939453125,
-0.242431640625,
-0.76318359375,
0.27978515625,
-1.1044921875,
-0.216064453125,
0.05621337890625,
-0.576171875,
0.41259765625,
0.290283203125,
0.11212158203125,
0.00106048583984375,
-0.48388671875,
-0.36572265625,
-0.18359375,
-0.51025390625,
-0.52001953125,
0.296875,
0.625,
0.66650390625,
0.25048828125,
-0.13720703125,
0.133056640625,
-0.0206298828125,
-0.1671142578125,
-0.60302734375,
-0.37255859375,
0.32470703125,
-0.58056640625,
-0.12353515625,
0.4013671875,
-0.0198211669921875,
0.39306640625,
0.86376953125,
-0.053314208984375,
0.229248046875,
0.323486328125,
-0.60107421875,
1.4384765625,
-0.142822265625,
-1.078125,
-0.41162109375,
0.2000732421875,
0.11907958984375,
0.66015625,
-0.2191162109375,
-0.74951171875,
-0.7392578125,
-1.1162109375,
0.12127685546875,
-0.56787109375,
-0.334228515625,
-0.91357421875,
-0.255859375,
-0.53271484375,
0.767578125,
-0.331787109375,
-0.357421875,
0.240478515625,
-1.3017578125,
0.206298828125,
-0.60791015625,
-0.335693359375,
-0.603515625,
-0.55859375,
-0.62255859375,
1.1220703125,
0.467041015625,
0.1578369140625,
0.4228515625,
-0.320556640625,
0.2354736328125,
-0.304443359375,
-0.59375,
-0.51513671875,
-0.20947265625,
0.293212890625,
-0.37841796875,
-0.3916015625,
-0.60693359375,
0.955078125,
-0.5078125,
0.2744140625,
-0.39306640625,
-0.52490234375,
-0.1783447265625,
-0.2047119140625,
0.80322265625,
-0.60498046875,
0.1904296875,
-0.59375,
0.56103515625,
0.409423828125,
-0.325927734375,
-0.53955078125,
-0.80908203125,
-0.55419921875,
-0.97021484375,
0.58544921875,
-0.5859375,
0.5986328125,
-0.7509765625,
-0.2418212890625,
0.9130859375,
-0.52197265625,
0.33984375,
1.431640625,
-0.1285400390625,
0.2283935546875,
-0.888671875,
0.63720703125,
-0.0269927978515625,
-0.6796875,
-0.304931640625,
-0.1119384765625,
-0.9345703125,
0.08038330078125,
-0.56494140625,
-0.873046875,
-0.54833984375,
0.73876953125,
1.3740234375,
-0.27099609375,
0.99169921875,
0.25537109375,
-1.201171875,
-0.78759765625,
0.75927734375,
0.39013671875,
0.51806640625,
1.1142578125,
-0.69482421875,
-0.1605224609375,
0.416015625,
-0.039276123046875,
-0.28369140625,
-0.197265625,
1.0185546875,
-0.46142578125,
-0.61279296875,
0.56005859375,
0.55322265625,
-1.1025390625,
-0.6337890625,
0.1180419921875,
-0.0272979736328125,
-0.027618408203125,
-0.6708984375,
0.2020263671875,
0.646484375,
-0.393310546875,
-0.013824462890625,
0.04400634765625,
-0.00948333740234375,
0.67724609375,
0.296875,
0.2890625,
-0.53955078125,
0.67626953125,
0.8642578125,
-0.80615234375,
-0.409912109375,
-0.89013671875,
-0.1422119140625,
-0.2081298828125,
0.296142578125,
0.7890625,
0.11431884765625,
0.2177734375,
0.76611328125,
-0.112060546875,
0.6572265625,
-0.47412109375,
-0.333251953125,
0.1614990234375,
-0.49365234375,
-0.250244140625,
-0.03656005859375,
0.20654296875,
0.1546630859375,
0.260009765625,
-0.6201171875,
-0.06719970703125,
0.494873046875,
0.32861328125,
-0.0484619140625,
-0.064208984375,
-0.350830078125,
-0.57861328125,
-0.4423828125,
-0.48681640625,
-0.8125,
-0.15380859375,
0.428466796875,
0.43115234375,
-0.72265625,
0.0382080078125,
0.8447265625,
-0.7978515625,
1.1630859375,
-0.79931640625,
0.31591796875,
-0.416748046875,
-0.16455078125,
-0.77685546875,
0.10595703125,
-0.486572265625,
-0.279296875,
-0.328369140625,
0.51171875,
0.40185546875,
0.5966796875,
-0.2371826171875,
0.246337890625,
-0.16357421875,
-0.77490234375,
-0.01462554931640625,
0.09051513671875,
0.054473876953125,
0.344970703125,
0.697265625,
0.4560546875,
0.1826171875,
-0.046173095703125,
-0.53662109375,
-0.427001953125,
0.1942138671875,
0.8984375,
0.00626373291015625,
-0.0687255859375,
-0.3115234375,
-0.0723876953125,
-0.60986328125,
0.2252197265625,
-0.26318359375,
-0.1207275390625,
0.08074951171875,
-0.76171875,
0.53515625,
1.2373046875,
-0.161376953125,
0.2152099609375,
-0.03314208984375,
0.369384765625,
0.388916015625,
0.1488037109375,
0.311279296875,
0.20703125,
0.06744384765625,
-0.228515625,
-0.09967041015625,
0.56591796875,
-0.00792694091796875,
0.4091796875,
-0.3388671875,
-0.7685546875,
-0.82080078125,
-0.0269317626953125,
-0.32666015625,
0.0227813720703125,
0.59375,
-0.8349609375,
-0.08984375,
0.135986328125,
-1.029296875,
0.21240234375,
-0.80810546875,
-0.7998046875,
0.1552734375,
-0.138427734375,
-0.79345703125,
-0.40234375,
-0.56103515625,
0.1148681640625,
0.212890625,
0.5009765625,
-0.74267578125,
0.171142578125,
-0.1153564453125,
0.3916015625,
-0.2607421875,
-0.08935546875,
0.096435546875,
0.2181396484375,
-0.53271484375,
-0.64794921875,
0.121337890625,
1.546875,
0.1912841796875,
-0.355712890625,
-0.66064453125,
0.133544921875,
-0.46533203125,
0.2083740234375,
-0.12359619140625,
-0.12432861328125,
-0.0298004150390625,
0.43994140625,
-1.1474609375,
-0.340087890625,
0.10650634765625,
0.337158203125,
-0.1324462890625,
-0.32958984375,
-0.2227783203125,
0.66162109375,
0.9306640625,
-0.1478271484375,
-0.0328369140625,
0.37646484375,
0.87890625,
-0.2890625,
-0.0989990234375,
-0.1290283203125,
0.323974609375,
0.56005859375,
0.365966796875,
-0.282470703125,
0.724609375,
0.9765625,
-0.3037109375,
-0.0789794921875,
0.51025390625,
0.049591064453125,
0.039154052734375,
-0.2274169921875,
-0.2296142578125,
-0.002803802490234375,
-0.034027099609375,
-0.82080078125,
0.2261962890625,
-0.329345703125,
-0.423583984375,
-0.1932373046875,
-0.71630859375,
1.0029296875,
-1.166015625,
0.42626953125,
-0.3193359375,
-0.1859130859375,
0.4609375,
0.95166015625,
0.037689208984375,
-0.0908203125,
0.495849609375,
0.438232421875,
0.64013671875,
0.83251953125,
0.2283935546875,
0.1160888671875,
-0.451904296875,
0.1641845703125,
0.0161285400390625,
0.023162841796875,
-0.5908203125,
-0.30615234375,
-1.2333984375,
0.64990234375,
-0.450927734375,
-0.09906005859375,
0.33984375,
-0.58056640625,
0.19384765625,
-0.303955078125,
0.83935546875,
-0.4794921875,
0.4287109375,
0.52734375,
-0.58740234375,
-0.46435546875,
0.85595703125,
-0.08673095703125,
0.39501953125,
0.209228515625,
0.7783203125,
0.3125,
1.7255859375,
0.2978515625,
-0.1956787109375,
-0.043060302734375,
0.053619384765625,
-0.1959228515625,
-0.59326171875,
-0.309814453125,
-0.311767578125,
-0.1688232421875,
-0.425537109375,
-0.339111328125,
-0.07940673828125,
0.6396484375,
0.059814453125,
-0.82666015625,
-0.08233642578125,
0.06561279296875,
-0.8720703125,
0.8359375,
0.136474609375,
0.1287841796875,
0.106689453125,
0.1329345703125,
-0.1568603515625,
-0.3369140625,
-0.1610107421875,
-0.4453125,
0.2100830078125,
-0.5205078125,
-0.55810546875,
-0.61865234375,
-0.9541015625,
-0.34423828125,
-0.26806640625,
-0.61669921875,
-0.92236328125,
0.185546875,
0.65869140625,
0.5009765625,
0.4609375,
-0.54638671875,
0.416748046875,
1.1513671875,
0.79345703125,
-0.427734375,
0.93798828125,
0.4228515625,
-0.58154296875,
0.01061248779296875,
-0.138916015625,
0.697265625,
-0.29345703125,
-0.061431884765625,
-0.274169921875,
0.415283203125,
-1.015625,
-1.3095703125,
0.0504150390625,
0.72802734375,
0.3671875,
-0.546875,
-1.00390625,
-0.462890625,
-0.81884765625,
-0.045867919921875,
-0.818359375,
0.63232421875,
0.382568359375,
-0.1622314453125,
0.04608154296875,
-1.0244140625,
4.2578125,
0.99658203125,
0.8515625,
0.07489013671875,
0.0121612548828125,
0.93896484375,
0.0192108154296875,
-0.400634765625,
0.196044921875,
-0.3740234375,
0.78466796875,
-0.283203125,
-0.1058349609375,
0.626953125,
0.1607666015625,
0.414794921875,
-0.4892578125,
-0.066650390625,
-0.206298828125,
-1.0107421875,
-0.87939453125,
0.1136474609375,
0.31787109375,
0.13720703125,
0.10650634765625,
0.127685546875,
0.68701171875,
-0.62939453125,
-0.34912109375,
-0.66455078125,
-0.270751953125,
-0.65234375,
0.7890625,
-0.019195556640625,
-0.060760498046875,
0.5166015625,
0.15966796875,
-0.58251953125,
0.041595458984375,
0.5908203125,
-0.34521484375,
-0.41064453125,
0.8740234375,
-0.79931640625,
0.1572265625,
0.60498046875,
-0.365478515625,
0.327880859375,
0.64013671875,
-0.486083984375,
0.712890625,
-0.1710205078125,
0.775390625,
-0.7861328125,
-0.69189453125,
0.059967041015625,
0.23681640625,
-0.26904296875,
0.093505859375,
0.3662109375,
0.161376953125,
0.11669921875,
-0.007656097412109375,
0.469970703125,
-0.76123046875,
0.61962890625,
0.2076416015625,
0.2049560546875,
-0.5634765625,
0.09027099609375,
0.00823211669921875,
-0.08270263671875,
-0.365234375,
-0.57177734375,
0.51708984375,
0.2265625,
-0.05084228515625,
0.33642578125,
0.53662109375,
-0.84130859375,
0.0175323486328125,
-0.037506103515625,
-0.333740234375,
-0.363525390625,
0.55517578125,
1.580078125,
-0.681640625,
-0.394287109375,
-0.53857421875,
0.59521484375,
0.204345703125,
0.34765625,
0.60107421875,
-0.90185546875,
-0.333251953125
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Submitted Solution:
```
ans = 0
t = []
x = input()
y = int(input())
for i in range(y):
z = input()
t.append(z)
#x = codeforces
#y = 2
#t = [do, cs]
pt = -1
ln = len(x)
for i in t:
a = i[0]
b = i[1]
for j in range(ln):
ded1=0
ded2=0
if j >= pt:
if x[j] in [a,b]:
pt = j
while pt < ln and x[pt] in [a,b]:
if x[pt] == a:
ded1+=1
else:
ded2+=1
pt += 1
ans += min(ded1, ded2)
print(ans)
```
No
| 71,005 | [
0.30078125,
-0.062469482421875,
0.03240966796875,
0.20458984375,
-0.54833984375,
-0.6875,
0.06640625,
-0.06231689453125,
-0.203369140625,
0.943359375,
0.7431640625,
0.0479736328125,
-0.375244140625,
-0.91259765625,
-0.916015625,
-0.159423828125,
-0.9326171875,
-0.6044921875,
-0.5048828125,
-0.191162109375,
0.0599365234375,
-0.224365234375,
-1.6044921875,
-0.27880859375,
-0.45654296875,
1.1884765625,
0.309814453125,
-0.326416015625,
1.13671875,
0.72412109375,
-0.2783203125,
-0.2734375,
0.517578125,
-1.05859375,
-0.548828125,
-0.5869140625,
0.95166015625,
-0.46484375,
-0.0654296875,
-0.05462646484375,
0.572265625,
-0.25830078125,
0.467529296875,
-0.56005859375,
-1.3701171875,
-0.415771484375,
-0.09832763671875,
-0.5927734375,
-0.342529296875,
-0.442626953125,
0.3583984375,
-0.35888671875,
0.59765625,
-0.235595703125,
0.060516357421875,
0.28369140625,
0.256103515625,
0.1417236328125,
-0.78515625,
0.298583984375,
0.1729736328125,
0.319091796875,
0.1888427734375,
-0.8173828125,
-0.455810546875,
-0.08856201171875,
-0.2440185546875,
0.237548828125,
-0.00044155120849609375,
-0.461181640625,
-0.28466796875,
0.41259765625,
-0.390869140625,
-0.19189453125,
-0.64306640625,
0.07904052734375,
0.245361328125,
0.152099609375,
-0.65966796875,
0.89990234375,
0.29345703125,
1.1064453125,
0.72509765625,
-0.10723876953125,
-0.302734375,
-0.1356201171875,
0.06878662109375,
0.4150390625,
0.464599609375,
-0.2666015625,
-0.1451416015625,
0.446533203125,
-0.94091796875,
-0.201416015625,
0.6259765625,
0.396728515625,
-0.314697265625,
0.274658203125,
0.49560546875,
0.448974609375,
0.89501953125,
0.52490234375,
-0.287841796875,
0.87890625,
-0.5888671875,
0.11859130859375,
0.1024169921875,
0.1533203125,
0.015350341796875,
0.252685546875,
-0.22607421875,
-0.10162353515625,
0.459716796875,
0.484619140625,
-0.75341796875,
0.72119140625,
-0.2568359375,
0.428955078125,
-0.796875,
0.2294921875,
0.82080078125,
-0.07073974609375,
0.81787109375,
0.1185302734375,
0.2685546875,
-0.2265625,
-0.64697265625,
1.091796875,
-0.383056640625,
-0.02093505859375,
0.53564453125,
0.05596923828125,
-0.121337890625,
0.1397705078125,
-0.374267578125,
0.80517578125,
-0.30517578125,
0.61962890625,
0.55908203125,
-0.64453125,
0.5234375,
-0.1650390625,
0.01244354248046875,
1.5029296875,
0.634765625,
-0.1658935546875,
0.71533203125,
0.49951171875,
-0.92724609375,
0.1776123046875,
-1.3740234375,
0.85791015625,
0.051177978515625,
0.04443359375,
-0.6064453125,
-0.168701171875,
-0.216552734375,
0.06866455078125,
0.09478759765625,
0.1263427734375,
-0.437255859375,
0.18408203125,
-0.283203125,
0.63330078125,
-0.300048828125,
1.0244140625,
-0.6396484375,
0.03680419921875,
-0.1334228515625,
-0.54345703125,
0.2276611328125,
-0.03997802734375,
0.1929931640625,
1.064453125,
0.2119140625,
0.9189453125,
0.60400390625,
-0.313720703125,
0.6337890625,
0.5205078125,
-0.1890869140625,
0.383544921875,
0.17431640625,
0.41650390625,
0.5517578125,
0.419921875,
-0.144287109375,
-0.352294921875,
-0.78076171875,
-0.322509765625,
-0.040802001953125,
0.83544921875,
-0.421142578125,
0.410888671875,
-0.03094482421875,
-0.016510009765625,
-1.03125,
-0.307373046875,
0.1383056640625,
-1.1015625,
-0.5234375,
0.873046875,
0.16162109375,
0.68310546875,
-0.2763671875,
-0.671875,
0.54638671875,
1.462890625,
-0.276611328125,
0.351318359375,
0.7119140625,
-0.50732421875,
-0.29296875,
0.332763671875,
-0.1485595703125,
-0.1900634765625,
-0.85400390625,
0.69677734375,
-0.52685546875,
-0.024566650390625,
-0.2491455078125,
0.2227783203125,
0.247314453125,
0.66357421875,
-0.232666015625,
-0.40673828125,
0.7802734375,
1.1669921875,
-0.007129669189453125,
0.487548828125,
0.255859375,
0.77783203125,
0.1639404296875,
0.8193359375,
0.39404296875,
0.111572265625,
0.8974609375,
0.8515625,
0.08258056640625,
0.496826171875,
-0.1632080078125,
0.484375,
0.25927734375,
0.642578125,
0.432373046875,
0.2491455078125,
-0.310546875,
-0.0787353515625,
-0.31298828125,
0.141845703125,
-0.29736328125,
0.44384765625,
0.375,
0.487548828125,
-0.2041015625,
-0.1114501953125,
0.2425537109375,
0.7158203125,
-1.1689453125,
-0.55859375,
0.038299560546875,
0.1173095703125,
-0.0595703125,
0.0085601806640625,
0.169921875,
0.77197265625,
0.68310546875,
0.378662109375,
-0.56982421875,
-0.51416015625,
-1.1376953125,
-1.1005859375,
-1.0205078125,
-0.262939453125,
-0.8828125,
-0.08135986328125,
0.60595703125,
-1.0361328125,
0.439453125,
-0.365478515625,
-0.52392578125,
0.1236572265625,
-0.5576171875,
0.71240234375,
-0.196044921875,
0.78173828125,
-0.798828125,
0.693359375,
0.14990234375,
0.873046875,
-0.325439453125,
-0.33251953125,
-0.10137939453125,
-0.6357421875,
0.294189453125,
-0.07525634765625,
0.3232421875,
0.2763671875,
-0.6240234375,
-0.79931640625,
0.02734375,
-0.25927734375,
-0.609375,
0.1796875,
-0.77197265625,
0.80126953125,
0.91748046875,
-0.66748046875,
0.75537109375,
1.1669921875,
-0.93994140625,
0.08294677734375,
0.19677734375,
0.3642578125,
-0.5888671875,
1.1884765625,
0.343994140625,
0.3974609375,
-0.437255859375,
-0.52685546875,
-0.76904296875,
0.0267791748046875,
-0.006038665771484375,
-0.37841796875,
-0.0916748046875,
0.74755859375,
-0.255615234375,
-1.00390625,
0.77880859375,
-1.2822265625,
-0.06475830078125,
-0.07562255859375,
-0.62841796875,
1.0205078125,
0.451416015625,
0.355712890625,
-0.27001953125,
-0.845703125,
-0.2451171875,
0.82666015625,
0.1607666015625,
-0.58642578125,
0.0018444061279296875,
0.33740234375,
0.239501953125,
0.216552734375,
0.096435546875,
-0.2344970703125,
-0.3408203125,
0.0699462890625,
0.11981201171875,
0.99853515625,
0.28955078125,
0.4228515625,
0.273681640625,
0.837890625,
-0.6865234375,
-0.2587890625,
-0.27587890625,
0.716796875,
0.2900390625,
0.427001953125,
0.20068359375,
-0.1329345703125,
-0.48291015625,
-0.8369140625,
0.481201171875,
-0.36962890625,
0.79150390625,
-0.432861328125,
0.61669921875,
0.356201171875,
-0.556640625,
0.67578125,
-0.93115234375,
-0.344970703125,
0.8779296875,
-0.65673828125,
0.9697265625,
-0.98095703125,
0.1610107421875,
0.048980712890625,
0.069580078125,
0.68017578125,
0.59326171875,
0.8212890625,
-0.447021484375,
-0.5361328125,
-0.287841796875,
0.35400390625,
-0.1402587890625,
-0.478271484375,
0.11181640625,
-0.300537109375,
-0.513671875,
-0.9775390625,
0.489990234375,
0.78125,
0.64404296875,
0.28466796875,
0.36083984375,
0.1434326171875,
0.541015625,
0.95068359375,
0.017425537109375,
-0.05718994140625,
-0.77978515625,
0.984375,
0.02099609375,
-0.491455078125,
-0.343017578125,
-0.362060546875,
-0.342041015625,
0.2442626953125,
0.036468505859375,
0.06622314453125,
-0.92822265625,
-0.093505859375,
-0.12261962890625,
0.3408203125,
-0.77294921875,
-0.2763671875,
-0.1971435546875,
0.475341796875,
0.0760498046875,
-1.0712890625,
0.459716796875,
-0.720703125,
0.89404296875,
1.0283203125,
-0.00737762451171875,
-0.57958984375,
-0.09716796875,
-0.7021484375,
-0.95166015625,
-0.1475830078125,
0.603515625,
-0.123779296875,
0.2012939453125,
-1.3759765625,
0.5224609375,
0.385009765625,
-0.1368408203125,
0.316162109375,
0.1495361328125,
0.4951171875,
0.130126953125,
0.546875,
-0.62890625,
-0.66943359375,
0.384765625,
-1.142578125,
0.7314453125,
-0.59033203125,
0.58251953125,
-0.21240234375,
0.1688232421875,
0.145751953125,
0.48779296875,
-0.46435546875,
0.38818359375,
-0.0687255859375,
0.44482421875,
-1.0107421875,
-0.66650390625,
0.5283203125,
-0.1451416015625,
-0.71533203125,
0.53076171875,
0.2568359375,
-0.2998046875,
0.01102447509765625,
0.66748046875,
-0.442138671875,
0.49169921875,
-0.505859375,
0.64453125,
-0.08233642578125,
-0.74951171875,
-0.2144775390625,
-0.5263671875,
0.62939453125,
-0.242431640625,
-0.76318359375,
0.27978515625,
-1.1044921875,
-0.216064453125,
0.05621337890625,
-0.576171875,
0.41259765625,
0.290283203125,
0.11212158203125,
0.00106048583984375,
-0.48388671875,
-0.36572265625,
-0.18359375,
-0.51025390625,
-0.52001953125,
0.296875,
0.625,
0.66650390625,
0.25048828125,
-0.13720703125,
0.133056640625,
-0.0206298828125,
-0.1671142578125,
-0.60302734375,
-0.37255859375,
0.32470703125,
-0.58056640625,
-0.12353515625,
0.4013671875,
-0.0198211669921875,
0.39306640625,
0.86376953125,
-0.053314208984375,
0.229248046875,
0.323486328125,
-0.60107421875,
1.4384765625,
-0.142822265625,
-1.078125,
-0.41162109375,
0.2000732421875,
0.11907958984375,
0.66015625,
-0.2191162109375,
-0.74951171875,
-0.7392578125,
-1.1162109375,
0.12127685546875,
-0.56787109375,
-0.334228515625,
-0.91357421875,
-0.255859375,
-0.53271484375,
0.767578125,
-0.331787109375,
-0.357421875,
0.240478515625,
-1.3017578125,
0.206298828125,
-0.60791015625,
-0.335693359375,
-0.603515625,
-0.55859375,
-0.62255859375,
1.1220703125,
0.467041015625,
0.1578369140625,
0.4228515625,
-0.320556640625,
0.2354736328125,
-0.304443359375,
-0.59375,
-0.51513671875,
-0.20947265625,
0.293212890625,
-0.37841796875,
-0.3916015625,
-0.60693359375,
0.955078125,
-0.5078125,
0.2744140625,
-0.39306640625,
-0.52490234375,
-0.1783447265625,
-0.2047119140625,
0.80322265625,
-0.60498046875,
0.1904296875,
-0.59375,
0.56103515625,
0.409423828125,
-0.325927734375,
-0.53955078125,
-0.80908203125,
-0.55419921875,
-0.97021484375,
0.58544921875,
-0.5859375,
0.5986328125,
-0.7509765625,
-0.2418212890625,
0.9130859375,
-0.52197265625,
0.33984375,
1.431640625,
-0.1285400390625,
0.2283935546875,
-0.888671875,
0.63720703125,
-0.0269927978515625,
-0.6796875,
-0.304931640625,
-0.1119384765625,
-0.9345703125,
0.08038330078125,
-0.56494140625,
-0.873046875,
-0.54833984375,
0.73876953125,
1.3740234375,
-0.27099609375,
0.99169921875,
0.25537109375,
-1.201171875,
-0.78759765625,
0.75927734375,
0.39013671875,
0.51806640625,
1.1142578125,
-0.69482421875,
-0.1605224609375,
0.416015625,
-0.039276123046875,
-0.28369140625,
-0.197265625,
1.0185546875,
-0.46142578125,
-0.61279296875,
0.56005859375,
0.55322265625,
-1.1025390625,
-0.6337890625,
0.1180419921875,
-0.0272979736328125,
-0.027618408203125,
-0.6708984375,
0.2020263671875,
0.646484375,
-0.393310546875,
-0.013824462890625,
0.04400634765625,
-0.00948333740234375,
0.67724609375,
0.296875,
0.2890625,
-0.53955078125,
0.67626953125,
0.8642578125,
-0.80615234375,
-0.409912109375,
-0.89013671875,
-0.1422119140625,
-0.2081298828125,
0.296142578125,
0.7890625,
0.11431884765625,
0.2177734375,
0.76611328125,
-0.112060546875,
0.6572265625,
-0.47412109375,
-0.333251953125,
0.1614990234375,
-0.49365234375,
-0.250244140625,
-0.03656005859375,
0.20654296875,
0.1546630859375,
0.260009765625,
-0.6201171875,
-0.06719970703125,
0.494873046875,
0.32861328125,
-0.0484619140625,
-0.064208984375,
-0.350830078125,
-0.57861328125,
-0.4423828125,
-0.48681640625,
-0.8125,
-0.15380859375,
0.428466796875,
0.43115234375,
-0.72265625,
0.0382080078125,
0.8447265625,
-0.7978515625,
1.1630859375,
-0.79931640625,
0.31591796875,
-0.416748046875,
-0.16455078125,
-0.77685546875,
0.10595703125,
-0.486572265625,
-0.279296875,
-0.328369140625,
0.51171875,
0.40185546875,
0.5966796875,
-0.2371826171875,
0.246337890625,
-0.16357421875,
-0.77490234375,
-0.01462554931640625,
0.09051513671875,
0.054473876953125,
0.344970703125,
0.697265625,
0.4560546875,
0.1826171875,
-0.046173095703125,
-0.53662109375,
-0.427001953125,
0.1942138671875,
0.8984375,
0.00626373291015625,
-0.0687255859375,
-0.3115234375,
-0.0723876953125,
-0.60986328125,
0.2252197265625,
-0.26318359375,
-0.1207275390625,
0.08074951171875,
-0.76171875,
0.53515625,
1.2373046875,
-0.161376953125,
0.2152099609375,
-0.03314208984375,
0.369384765625,
0.388916015625,
0.1488037109375,
0.311279296875,
0.20703125,
0.06744384765625,
-0.228515625,
-0.09967041015625,
0.56591796875,
-0.00792694091796875,
0.4091796875,
-0.3388671875,
-0.7685546875,
-0.82080078125,
-0.0269317626953125,
-0.32666015625,
0.0227813720703125,
0.59375,
-0.8349609375,
-0.08984375,
0.135986328125,
-1.029296875,
0.21240234375,
-0.80810546875,
-0.7998046875,
0.1552734375,
-0.138427734375,
-0.79345703125,
-0.40234375,
-0.56103515625,
0.1148681640625,
0.212890625,
0.5009765625,
-0.74267578125,
0.171142578125,
-0.1153564453125,
0.3916015625,
-0.2607421875,
-0.08935546875,
0.096435546875,
0.2181396484375,
-0.53271484375,
-0.64794921875,
0.121337890625,
1.546875,
0.1912841796875,
-0.355712890625,
-0.66064453125,
0.133544921875,
-0.46533203125,
0.2083740234375,
-0.12359619140625,
-0.12432861328125,
-0.0298004150390625,
0.43994140625,
-1.1474609375,
-0.340087890625,
0.10650634765625,
0.337158203125,
-0.1324462890625,
-0.32958984375,
-0.2227783203125,
0.66162109375,
0.9306640625,
-0.1478271484375,
-0.0328369140625,
0.37646484375,
0.87890625,
-0.2890625,
-0.0989990234375,
-0.1290283203125,
0.323974609375,
0.56005859375,
0.365966796875,
-0.282470703125,
0.724609375,
0.9765625,
-0.3037109375,
-0.0789794921875,
0.51025390625,
0.049591064453125,
0.039154052734375,
-0.2274169921875,
-0.2296142578125,
-0.002803802490234375,
-0.034027099609375,
-0.82080078125,
0.2261962890625,
-0.329345703125,
-0.423583984375,
-0.1932373046875,
-0.71630859375,
1.0029296875,
-1.166015625,
0.42626953125,
-0.3193359375,
-0.1859130859375,
0.4609375,
0.95166015625,
0.037689208984375,
-0.0908203125,
0.495849609375,
0.438232421875,
0.64013671875,
0.83251953125,
0.2283935546875,
0.1160888671875,
-0.451904296875,
0.1641845703125,
0.0161285400390625,
0.023162841796875,
-0.5908203125,
-0.30615234375,
-1.2333984375,
0.64990234375,
-0.450927734375,
-0.09906005859375,
0.33984375,
-0.58056640625,
0.19384765625,
-0.303955078125,
0.83935546875,
-0.4794921875,
0.4287109375,
0.52734375,
-0.58740234375,
-0.46435546875,
0.85595703125,
-0.08673095703125,
0.39501953125,
0.209228515625,
0.7783203125,
0.3125,
1.7255859375,
0.2978515625,
-0.1956787109375,
-0.043060302734375,
0.053619384765625,
-0.1959228515625,
-0.59326171875,
-0.309814453125,
-0.311767578125,
-0.1688232421875,
-0.425537109375,
-0.339111328125,
-0.07940673828125,
0.6396484375,
0.059814453125,
-0.82666015625,
-0.08233642578125,
0.06561279296875,
-0.8720703125,
0.8359375,
0.136474609375,
0.1287841796875,
0.106689453125,
0.1329345703125,
-0.1568603515625,
-0.3369140625,
-0.1610107421875,
-0.4453125,
0.2100830078125,
-0.5205078125,
-0.55810546875,
-0.61865234375,
-0.9541015625,
-0.34423828125,
-0.26806640625,
-0.61669921875,
-0.92236328125,
0.185546875,
0.65869140625,
0.5009765625,
0.4609375,
-0.54638671875,
0.416748046875,
1.1513671875,
0.79345703125,
-0.427734375,
0.93798828125,
0.4228515625,
-0.58154296875,
0.01061248779296875,
-0.138916015625,
0.697265625,
-0.29345703125,
-0.061431884765625,
-0.274169921875,
0.415283203125,
-1.015625,
-1.3095703125,
0.0504150390625,
0.72802734375,
0.3671875,
-0.546875,
-1.00390625,
-0.462890625,
-0.81884765625,
-0.045867919921875,
-0.818359375,
0.63232421875,
0.382568359375,
-0.1622314453125,
0.04608154296875,
-1.0244140625,
4.2578125,
0.99658203125,
0.8515625,
0.07489013671875,
0.0121612548828125,
0.93896484375,
0.0192108154296875,
-0.400634765625,
0.196044921875,
-0.3740234375,
0.78466796875,
-0.283203125,
-0.1058349609375,
0.626953125,
0.1607666015625,
0.414794921875,
-0.4892578125,
-0.066650390625,
-0.206298828125,
-1.0107421875,
-0.87939453125,
0.1136474609375,
0.31787109375,
0.13720703125,
0.10650634765625,
0.127685546875,
0.68701171875,
-0.62939453125,
-0.34912109375,
-0.66455078125,
-0.270751953125,
-0.65234375,
0.7890625,
-0.019195556640625,
-0.060760498046875,
0.5166015625,
0.15966796875,
-0.58251953125,
0.041595458984375,
0.5908203125,
-0.34521484375,
-0.41064453125,
0.8740234375,
-0.79931640625,
0.1572265625,
0.60498046875,
-0.365478515625,
0.327880859375,
0.64013671875,
-0.486083984375,
0.712890625,
-0.1710205078125,
0.775390625,
-0.7861328125,
-0.69189453125,
0.059967041015625,
0.23681640625,
-0.26904296875,
0.093505859375,
0.3662109375,
0.161376953125,
0.11669921875,
-0.007656097412109375,
0.469970703125,
-0.76123046875,
0.61962890625,
0.2076416015625,
0.2049560546875,
-0.5634765625,
0.09027099609375,
0.00823211669921875,
-0.08270263671875,
-0.365234375,
-0.57177734375,
0.51708984375,
0.2265625,
-0.05084228515625,
0.33642578125,
0.53662109375,
-0.84130859375,
0.0175323486328125,
-0.037506103515625,
-0.333740234375,
-0.363525390625,
0.55517578125,
1.580078125,
-0.681640625,
-0.394287109375,
-0.53857421875,
0.59521484375,
0.204345703125,
0.34765625,
0.60107421875,
-0.90185546875,
-0.333251953125
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Submitted Solution:
```
s=input()
n=len(s)
k=int(input())
l=[]
for i in range(k):
l.append(input())
ans=0
i=1
j=0
while i<n:
if i+1<n:
f=0
for x in range(k):
if s[j]+s[i]==l[x][0]+l[x][1] or s[j]+s[i]==l[x][1]+l[x][0]:
if i+1<n:
if s[i+1]==s[i] or s[i+1]==s[j]:
if s[i+1]==s[i]:
ans=ans+1
j=j-1
elif s[i+1]==s[j]:
ans=ans+1
i=i+2
j=i-1
else:
ans=ans+1
i=i+1
j=i-1
else:
ans=ans+1
i=i+1
j=i-1
f=1
break
if f==0:
i=i+1
j=i-1
else:
i=i+1
j=i-1
print(ans)
```
No
| 71,006 | [
0.30078125,
-0.062469482421875,
0.03240966796875,
0.20458984375,
-0.54833984375,
-0.6875,
0.06640625,
-0.06231689453125,
-0.203369140625,
0.943359375,
0.7431640625,
0.0479736328125,
-0.375244140625,
-0.91259765625,
-0.916015625,
-0.159423828125,
-0.9326171875,
-0.6044921875,
-0.5048828125,
-0.191162109375,
0.0599365234375,
-0.224365234375,
-1.6044921875,
-0.27880859375,
-0.45654296875,
1.1884765625,
0.309814453125,
-0.326416015625,
1.13671875,
0.72412109375,
-0.2783203125,
-0.2734375,
0.517578125,
-1.05859375,
-0.548828125,
-0.5869140625,
0.95166015625,
-0.46484375,
-0.0654296875,
-0.05462646484375,
0.572265625,
-0.25830078125,
0.467529296875,
-0.56005859375,
-1.3701171875,
-0.415771484375,
-0.09832763671875,
-0.5927734375,
-0.342529296875,
-0.442626953125,
0.3583984375,
-0.35888671875,
0.59765625,
-0.235595703125,
0.060516357421875,
0.28369140625,
0.256103515625,
0.1417236328125,
-0.78515625,
0.298583984375,
0.1729736328125,
0.319091796875,
0.1888427734375,
-0.8173828125,
-0.455810546875,
-0.08856201171875,
-0.2440185546875,
0.237548828125,
-0.00044155120849609375,
-0.461181640625,
-0.28466796875,
0.41259765625,
-0.390869140625,
-0.19189453125,
-0.64306640625,
0.07904052734375,
0.245361328125,
0.152099609375,
-0.65966796875,
0.89990234375,
0.29345703125,
1.1064453125,
0.72509765625,
-0.10723876953125,
-0.302734375,
-0.1356201171875,
0.06878662109375,
0.4150390625,
0.464599609375,
-0.2666015625,
-0.1451416015625,
0.446533203125,
-0.94091796875,
-0.201416015625,
0.6259765625,
0.396728515625,
-0.314697265625,
0.274658203125,
0.49560546875,
0.448974609375,
0.89501953125,
0.52490234375,
-0.287841796875,
0.87890625,
-0.5888671875,
0.11859130859375,
0.1024169921875,
0.1533203125,
0.015350341796875,
0.252685546875,
-0.22607421875,
-0.10162353515625,
0.459716796875,
0.484619140625,
-0.75341796875,
0.72119140625,
-0.2568359375,
0.428955078125,
-0.796875,
0.2294921875,
0.82080078125,
-0.07073974609375,
0.81787109375,
0.1185302734375,
0.2685546875,
-0.2265625,
-0.64697265625,
1.091796875,
-0.383056640625,
-0.02093505859375,
0.53564453125,
0.05596923828125,
-0.121337890625,
0.1397705078125,
-0.374267578125,
0.80517578125,
-0.30517578125,
0.61962890625,
0.55908203125,
-0.64453125,
0.5234375,
-0.1650390625,
0.01244354248046875,
1.5029296875,
0.634765625,
-0.1658935546875,
0.71533203125,
0.49951171875,
-0.92724609375,
0.1776123046875,
-1.3740234375,
0.85791015625,
0.051177978515625,
0.04443359375,
-0.6064453125,
-0.168701171875,
-0.216552734375,
0.06866455078125,
0.09478759765625,
0.1263427734375,
-0.437255859375,
0.18408203125,
-0.283203125,
0.63330078125,
-0.300048828125,
1.0244140625,
-0.6396484375,
0.03680419921875,
-0.1334228515625,
-0.54345703125,
0.2276611328125,
-0.03997802734375,
0.1929931640625,
1.064453125,
0.2119140625,
0.9189453125,
0.60400390625,
-0.313720703125,
0.6337890625,
0.5205078125,
-0.1890869140625,
0.383544921875,
0.17431640625,
0.41650390625,
0.5517578125,
0.419921875,
-0.144287109375,
-0.352294921875,
-0.78076171875,
-0.322509765625,
-0.040802001953125,
0.83544921875,
-0.421142578125,
0.410888671875,
-0.03094482421875,
-0.016510009765625,
-1.03125,
-0.307373046875,
0.1383056640625,
-1.1015625,
-0.5234375,
0.873046875,
0.16162109375,
0.68310546875,
-0.2763671875,
-0.671875,
0.54638671875,
1.462890625,
-0.276611328125,
0.351318359375,
0.7119140625,
-0.50732421875,
-0.29296875,
0.332763671875,
-0.1485595703125,
-0.1900634765625,
-0.85400390625,
0.69677734375,
-0.52685546875,
-0.024566650390625,
-0.2491455078125,
0.2227783203125,
0.247314453125,
0.66357421875,
-0.232666015625,
-0.40673828125,
0.7802734375,
1.1669921875,
-0.007129669189453125,
0.487548828125,
0.255859375,
0.77783203125,
0.1639404296875,
0.8193359375,
0.39404296875,
0.111572265625,
0.8974609375,
0.8515625,
0.08258056640625,
0.496826171875,
-0.1632080078125,
0.484375,
0.25927734375,
0.642578125,
0.432373046875,
0.2491455078125,
-0.310546875,
-0.0787353515625,
-0.31298828125,
0.141845703125,
-0.29736328125,
0.44384765625,
0.375,
0.487548828125,
-0.2041015625,
-0.1114501953125,
0.2425537109375,
0.7158203125,
-1.1689453125,
-0.55859375,
0.038299560546875,
0.1173095703125,
-0.0595703125,
0.0085601806640625,
0.169921875,
0.77197265625,
0.68310546875,
0.378662109375,
-0.56982421875,
-0.51416015625,
-1.1376953125,
-1.1005859375,
-1.0205078125,
-0.262939453125,
-0.8828125,
-0.08135986328125,
0.60595703125,
-1.0361328125,
0.439453125,
-0.365478515625,
-0.52392578125,
0.1236572265625,
-0.5576171875,
0.71240234375,
-0.196044921875,
0.78173828125,
-0.798828125,
0.693359375,
0.14990234375,
0.873046875,
-0.325439453125,
-0.33251953125,
-0.10137939453125,
-0.6357421875,
0.294189453125,
-0.07525634765625,
0.3232421875,
0.2763671875,
-0.6240234375,
-0.79931640625,
0.02734375,
-0.25927734375,
-0.609375,
0.1796875,
-0.77197265625,
0.80126953125,
0.91748046875,
-0.66748046875,
0.75537109375,
1.1669921875,
-0.93994140625,
0.08294677734375,
0.19677734375,
0.3642578125,
-0.5888671875,
1.1884765625,
0.343994140625,
0.3974609375,
-0.437255859375,
-0.52685546875,
-0.76904296875,
0.0267791748046875,
-0.006038665771484375,
-0.37841796875,
-0.0916748046875,
0.74755859375,
-0.255615234375,
-1.00390625,
0.77880859375,
-1.2822265625,
-0.06475830078125,
-0.07562255859375,
-0.62841796875,
1.0205078125,
0.451416015625,
0.355712890625,
-0.27001953125,
-0.845703125,
-0.2451171875,
0.82666015625,
0.1607666015625,
-0.58642578125,
0.0018444061279296875,
0.33740234375,
0.239501953125,
0.216552734375,
0.096435546875,
-0.2344970703125,
-0.3408203125,
0.0699462890625,
0.11981201171875,
0.99853515625,
0.28955078125,
0.4228515625,
0.273681640625,
0.837890625,
-0.6865234375,
-0.2587890625,
-0.27587890625,
0.716796875,
0.2900390625,
0.427001953125,
0.20068359375,
-0.1329345703125,
-0.48291015625,
-0.8369140625,
0.481201171875,
-0.36962890625,
0.79150390625,
-0.432861328125,
0.61669921875,
0.356201171875,
-0.556640625,
0.67578125,
-0.93115234375,
-0.344970703125,
0.8779296875,
-0.65673828125,
0.9697265625,
-0.98095703125,
0.1610107421875,
0.048980712890625,
0.069580078125,
0.68017578125,
0.59326171875,
0.8212890625,
-0.447021484375,
-0.5361328125,
-0.287841796875,
0.35400390625,
-0.1402587890625,
-0.478271484375,
0.11181640625,
-0.300537109375,
-0.513671875,
-0.9775390625,
0.489990234375,
0.78125,
0.64404296875,
0.28466796875,
0.36083984375,
0.1434326171875,
0.541015625,
0.95068359375,
0.017425537109375,
-0.05718994140625,
-0.77978515625,
0.984375,
0.02099609375,
-0.491455078125,
-0.343017578125,
-0.362060546875,
-0.342041015625,
0.2442626953125,
0.036468505859375,
0.06622314453125,
-0.92822265625,
-0.093505859375,
-0.12261962890625,
0.3408203125,
-0.77294921875,
-0.2763671875,
-0.1971435546875,
0.475341796875,
0.0760498046875,
-1.0712890625,
0.459716796875,
-0.720703125,
0.89404296875,
1.0283203125,
-0.00737762451171875,
-0.57958984375,
-0.09716796875,
-0.7021484375,
-0.95166015625,
-0.1475830078125,
0.603515625,
-0.123779296875,
0.2012939453125,
-1.3759765625,
0.5224609375,
0.385009765625,
-0.1368408203125,
0.316162109375,
0.1495361328125,
0.4951171875,
0.130126953125,
0.546875,
-0.62890625,
-0.66943359375,
0.384765625,
-1.142578125,
0.7314453125,
-0.59033203125,
0.58251953125,
-0.21240234375,
0.1688232421875,
0.145751953125,
0.48779296875,
-0.46435546875,
0.38818359375,
-0.0687255859375,
0.44482421875,
-1.0107421875,
-0.66650390625,
0.5283203125,
-0.1451416015625,
-0.71533203125,
0.53076171875,
0.2568359375,
-0.2998046875,
0.01102447509765625,
0.66748046875,
-0.442138671875,
0.49169921875,
-0.505859375,
0.64453125,
-0.08233642578125,
-0.74951171875,
-0.2144775390625,
-0.5263671875,
0.62939453125,
-0.242431640625,
-0.76318359375,
0.27978515625,
-1.1044921875,
-0.216064453125,
0.05621337890625,
-0.576171875,
0.41259765625,
0.290283203125,
0.11212158203125,
0.00106048583984375,
-0.48388671875,
-0.36572265625,
-0.18359375,
-0.51025390625,
-0.52001953125,
0.296875,
0.625,
0.66650390625,
0.25048828125,
-0.13720703125,
0.133056640625,
-0.0206298828125,
-0.1671142578125,
-0.60302734375,
-0.37255859375,
0.32470703125,
-0.58056640625,
-0.12353515625,
0.4013671875,
-0.0198211669921875,
0.39306640625,
0.86376953125,
-0.053314208984375,
0.229248046875,
0.323486328125,
-0.60107421875,
1.4384765625,
-0.142822265625,
-1.078125,
-0.41162109375,
0.2000732421875,
0.11907958984375,
0.66015625,
-0.2191162109375,
-0.74951171875,
-0.7392578125,
-1.1162109375,
0.12127685546875,
-0.56787109375,
-0.334228515625,
-0.91357421875,
-0.255859375,
-0.53271484375,
0.767578125,
-0.331787109375,
-0.357421875,
0.240478515625,
-1.3017578125,
0.206298828125,
-0.60791015625,
-0.335693359375,
-0.603515625,
-0.55859375,
-0.62255859375,
1.1220703125,
0.467041015625,
0.1578369140625,
0.4228515625,
-0.320556640625,
0.2354736328125,
-0.304443359375,
-0.59375,
-0.51513671875,
-0.20947265625,
0.293212890625,
-0.37841796875,
-0.3916015625,
-0.60693359375,
0.955078125,
-0.5078125,
0.2744140625,
-0.39306640625,
-0.52490234375,
-0.1783447265625,
-0.2047119140625,
0.80322265625,
-0.60498046875,
0.1904296875,
-0.59375,
0.56103515625,
0.409423828125,
-0.325927734375,
-0.53955078125,
-0.80908203125,
-0.55419921875,
-0.97021484375,
0.58544921875,
-0.5859375,
0.5986328125,
-0.7509765625,
-0.2418212890625,
0.9130859375,
-0.52197265625,
0.33984375,
1.431640625,
-0.1285400390625,
0.2283935546875,
-0.888671875,
0.63720703125,
-0.0269927978515625,
-0.6796875,
-0.304931640625,
-0.1119384765625,
-0.9345703125,
0.08038330078125,
-0.56494140625,
-0.873046875,
-0.54833984375,
0.73876953125,
1.3740234375,
-0.27099609375,
0.99169921875,
0.25537109375,
-1.201171875,
-0.78759765625,
0.75927734375,
0.39013671875,
0.51806640625,
1.1142578125,
-0.69482421875,
-0.1605224609375,
0.416015625,
-0.039276123046875,
-0.28369140625,
-0.197265625,
1.0185546875,
-0.46142578125,
-0.61279296875,
0.56005859375,
0.55322265625,
-1.1025390625,
-0.6337890625,
0.1180419921875,
-0.0272979736328125,
-0.027618408203125,
-0.6708984375,
0.2020263671875,
0.646484375,
-0.393310546875,
-0.013824462890625,
0.04400634765625,
-0.00948333740234375,
0.67724609375,
0.296875,
0.2890625,
-0.53955078125,
0.67626953125,
0.8642578125,
-0.80615234375,
-0.409912109375,
-0.89013671875,
-0.1422119140625,
-0.2081298828125,
0.296142578125,
0.7890625,
0.11431884765625,
0.2177734375,
0.76611328125,
-0.112060546875,
0.6572265625,
-0.47412109375,
-0.333251953125,
0.1614990234375,
-0.49365234375,
-0.250244140625,
-0.03656005859375,
0.20654296875,
0.1546630859375,
0.260009765625,
-0.6201171875,
-0.06719970703125,
0.494873046875,
0.32861328125,
-0.0484619140625,
-0.064208984375,
-0.350830078125,
-0.57861328125,
-0.4423828125,
-0.48681640625,
-0.8125,
-0.15380859375,
0.428466796875,
0.43115234375,
-0.72265625,
0.0382080078125,
0.8447265625,
-0.7978515625,
1.1630859375,
-0.79931640625,
0.31591796875,
-0.416748046875,
-0.16455078125,
-0.77685546875,
0.10595703125,
-0.486572265625,
-0.279296875,
-0.328369140625,
0.51171875,
0.40185546875,
0.5966796875,
-0.2371826171875,
0.246337890625,
-0.16357421875,
-0.77490234375,
-0.01462554931640625,
0.09051513671875,
0.054473876953125,
0.344970703125,
0.697265625,
0.4560546875,
0.1826171875,
-0.046173095703125,
-0.53662109375,
-0.427001953125,
0.1942138671875,
0.8984375,
0.00626373291015625,
-0.0687255859375,
-0.3115234375,
-0.0723876953125,
-0.60986328125,
0.2252197265625,
-0.26318359375,
-0.1207275390625,
0.08074951171875,
-0.76171875,
0.53515625,
1.2373046875,
-0.161376953125,
0.2152099609375,
-0.03314208984375,
0.369384765625,
0.388916015625,
0.1488037109375,
0.311279296875,
0.20703125,
0.06744384765625,
-0.228515625,
-0.09967041015625,
0.56591796875,
-0.00792694091796875,
0.4091796875,
-0.3388671875,
-0.7685546875,
-0.82080078125,
-0.0269317626953125,
-0.32666015625,
0.0227813720703125,
0.59375,
-0.8349609375,
-0.08984375,
0.135986328125,
-1.029296875,
0.21240234375,
-0.80810546875,
-0.7998046875,
0.1552734375,
-0.138427734375,
-0.79345703125,
-0.40234375,
-0.56103515625,
0.1148681640625,
0.212890625,
0.5009765625,
-0.74267578125,
0.171142578125,
-0.1153564453125,
0.3916015625,
-0.2607421875,
-0.08935546875,
0.096435546875,
0.2181396484375,
-0.53271484375,
-0.64794921875,
0.121337890625,
1.546875,
0.1912841796875,
-0.355712890625,
-0.66064453125,
0.133544921875,
-0.46533203125,
0.2083740234375,
-0.12359619140625,
-0.12432861328125,
-0.0298004150390625,
0.43994140625,
-1.1474609375,
-0.340087890625,
0.10650634765625,
0.337158203125,
-0.1324462890625,
-0.32958984375,
-0.2227783203125,
0.66162109375,
0.9306640625,
-0.1478271484375,
-0.0328369140625,
0.37646484375,
0.87890625,
-0.2890625,
-0.0989990234375,
-0.1290283203125,
0.323974609375,
0.56005859375,
0.365966796875,
-0.282470703125,
0.724609375,
0.9765625,
-0.3037109375,
-0.0789794921875,
0.51025390625,
0.049591064453125,
0.039154052734375,
-0.2274169921875,
-0.2296142578125,
-0.002803802490234375,
-0.034027099609375,
-0.82080078125,
0.2261962890625,
-0.329345703125,
-0.423583984375,
-0.1932373046875,
-0.71630859375,
1.0029296875,
-1.166015625,
0.42626953125,
-0.3193359375,
-0.1859130859375,
0.4609375,
0.95166015625,
0.037689208984375,
-0.0908203125,
0.495849609375,
0.438232421875,
0.64013671875,
0.83251953125,
0.2283935546875,
0.1160888671875,
-0.451904296875,
0.1641845703125,
0.0161285400390625,
0.023162841796875,
-0.5908203125,
-0.30615234375,
-1.2333984375,
0.64990234375,
-0.450927734375,
-0.09906005859375,
0.33984375,
-0.58056640625,
0.19384765625,
-0.303955078125,
0.83935546875,
-0.4794921875,
0.4287109375,
0.52734375,
-0.58740234375,
-0.46435546875,
0.85595703125,
-0.08673095703125,
0.39501953125,
0.209228515625,
0.7783203125,
0.3125,
1.7255859375,
0.2978515625,
-0.1956787109375,
-0.043060302734375,
0.053619384765625,
-0.1959228515625,
-0.59326171875,
-0.309814453125,
-0.311767578125,
-0.1688232421875,
-0.425537109375,
-0.339111328125,
-0.07940673828125,
0.6396484375,
0.059814453125,
-0.82666015625,
-0.08233642578125,
0.06561279296875,
-0.8720703125,
0.8359375,
0.136474609375,
0.1287841796875,
0.106689453125,
0.1329345703125,
-0.1568603515625,
-0.3369140625,
-0.1610107421875,
-0.4453125,
0.2100830078125,
-0.5205078125,
-0.55810546875,
-0.61865234375,
-0.9541015625,
-0.34423828125,
-0.26806640625,
-0.61669921875,
-0.92236328125,
0.185546875,
0.65869140625,
0.5009765625,
0.4609375,
-0.54638671875,
0.416748046875,
1.1513671875,
0.79345703125,
-0.427734375,
0.93798828125,
0.4228515625,
-0.58154296875,
0.01061248779296875,
-0.138916015625,
0.697265625,
-0.29345703125,
-0.061431884765625,
-0.274169921875,
0.415283203125,
-1.015625,
-1.3095703125,
0.0504150390625,
0.72802734375,
0.3671875,
-0.546875,
-1.00390625,
-0.462890625,
-0.81884765625,
-0.045867919921875,
-0.818359375,
0.63232421875,
0.382568359375,
-0.1622314453125,
0.04608154296875,
-1.0244140625,
4.2578125,
0.99658203125,
0.8515625,
0.07489013671875,
0.0121612548828125,
0.93896484375,
0.0192108154296875,
-0.400634765625,
0.196044921875,
-0.3740234375,
0.78466796875,
-0.283203125,
-0.1058349609375,
0.626953125,
0.1607666015625,
0.414794921875,
-0.4892578125,
-0.066650390625,
-0.206298828125,
-1.0107421875,
-0.87939453125,
0.1136474609375,
0.31787109375,
0.13720703125,
0.10650634765625,
0.127685546875,
0.68701171875,
-0.62939453125,
-0.34912109375,
-0.66455078125,
-0.270751953125,
-0.65234375,
0.7890625,
-0.019195556640625,
-0.060760498046875,
0.5166015625,
0.15966796875,
-0.58251953125,
0.041595458984375,
0.5908203125,
-0.34521484375,
-0.41064453125,
0.8740234375,
-0.79931640625,
0.1572265625,
0.60498046875,
-0.365478515625,
0.327880859375,
0.64013671875,
-0.486083984375,
0.712890625,
-0.1710205078125,
0.775390625,
-0.7861328125,
-0.69189453125,
0.059967041015625,
0.23681640625,
-0.26904296875,
0.093505859375,
0.3662109375,
0.161376953125,
0.11669921875,
-0.007656097412109375,
0.469970703125,
-0.76123046875,
0.61962890625,
0.2076416015625,
0.2049560546875,
-0.5634765625,
0.09027099609375,
0.00823211669921875,
-0.08270263671875,
-0.365234375,
-0.57177734375,
0.51708984375,
0.2265625,
-0.05084228515625,
0.33642578125,
0.53662109375,
-0.84130859375,
0.0175323486328125,
-0.037506103515625,
-0.333740234375,
-0.363525390625,
0.55517578125,
1.580078125,
-0.681640625,
-0.394287109375,
-0.53857421875,
0.59521484375,
0.204345703125,
0.34765625,
0.60107421875,
-0.90185546875,
-0.333251953125
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Submitted Solution:
```
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#-------------------game starts now----------------------------------------------------
s=input()
j=len(s)
n=int(input())
l=list()
for i in range (n):
t=input()
l.append(t)
l.append(t[::-1])
#print(*l)
c=0
i=1
while i<j:
sub=s[i-1:i+1]
if sub in l:
c+=1
i+=2
else:
i+=1
#print(sub,c,i)
print(c)
```
No
| 71,007 | [
0.30078125,
-0.062469482421875,
0.03240966796875,
0.20458984375,
-0.54833984375,
-0.6875,
0.06640625,
-0.06231689453125,
-0.203369140625,
0.943359375,
0.7431640625,
0.0479736328125,
-0.375244140625,
-0.91259765625,
-0.916015625,
-0.159423828125,
-0.9326171875,
-0.6044921875,
-0.5048828125,
-0.191162109375,
0.0599365234375,
-0.224365234375,
-1.6044921875,
-0.27880859375,
-0.45654296875,
1.1884765625,
0.309814453125,
-0.326416015625,
1.13671875,
0.72412109375,
-0.2783203125,
-0.2734375,
0.517578125,
-1.05859375,
-0.548828125,
-0.5869140625,
0.95166015625,
-0.46484375,
-0.0654296875,
-0.05462646484375,
0.572265625,
-0.25830078125,
0.467529296875,
-0.56005859375,
-1.3701171875,
-0.415771484375,
-0.09832763671875,
-0.5927734375,
-0.342529296875,
-0.442626953125,
0.3583984375,
-0.35888671875,
0.59765625,
-0.235595703125,
0.060516357421875,
0.28369140625,
0.256103515625,
0.1417236328125,
-0.78515625,
0.298583984375,
0.1729736328125,
0.319091796875,
0.1888427734375,
-0.8173828125,
-0.455810546875,
-0.08856201171875,
-0.2440185546875,
0.237548828125,
-0.00044155120849609375,
-0.461181640625,
-0.28466796875,
0.41259765625,
-0.390869140625,
-0.19189453125,
-0.64306640625,
0.07904052734375,
0.245361328125,
0.152099609375,
-0.65966796875,
0.89990234375,
0.29345703125,
1.1064453125,
0.72509765625,
-0.10723876953125,
-0.302734375,
-0.1356201171875,
0.06878662109375,
0.4150390625,
0.464599609375,
-0.2666015625,
-0.1451416015625,
0.446533203125,
-0.94091796875,
-0.201416015625,
0.6259765625,
0.396728515625,
-0.314697265625,
0.274658203125,
0.49560546875,
0.448974609375,
0.89501953125,
0.52490234375,
-0.287841796875,
0.87890625,
-0.5888671875,
0.11859130859375,
0.1024169921875,
0.1533203125,
0.015350341796875,
0.252685546875,
-0.22607421875,
-0.10162353515625,
0.459716796875,
0.484619140625,
-0.75341796875,
0.72119140625,
-0.2568359375,
0.428955078125,
-0.796875,
0.2294921875,
0.82080078125,
-0.07073974609375,
0.81787109375,
0.1185302734375,
0.2685546875,
-0.2265625,
-0.64697265625,
1.091796875,
-0.383056640625,
-0.02093505859375,
0.53564453125,
0.05596923828125,
-0.121337890625,
0.1397705078125,
-0.374267578125,
0.80517578125,
-0.30517578125,
0.61962890625,
0.55908203125,
-0.64453125,
0.5234375,
-0.1650390625,
0.01244354248046875,
1.5029296875,
0.634765625,
-0.1658935546875,
0.71533203125,
0.49951171875,
-0.92724609375,
0.1776123046875,
-1.3740234375,
0.85791015625,
0.051177978515625,
0.04443359375,
-0.6064453125,
-0.168701171875,
-0.216552734375,
0.06866455078125,
0.09478759765625,
0.1263427734375,
-0.437255859375,
0.18408203125,
-0.283203125,
0.63330078125,
-0.300048828125,
1.0244140625,
-0.6396484375,
0.03680419921875,
-0.1334228515625,
-0.54345703125,
0.2276611328125,
-0.03997802734375,
0.1929931640625,
1.064453125,
0.2119140625,
0.9189453125,
0.60400390625,
-0.313720703125,
0.6337890625,
0.5205078125,
-0.1890869140625,
0.383544921875,
0.17431640625,
0.41650390625,
0.5517578125,
0.419921875,
-0.144287109375,
-0.352294921875,
-0.78076171875,
-0.322509765625,
-0.040802001953125,
0.83544921875,
-0.421142578125,
0.410888671875,
-0.03094482421875,
-0.016510009765625,
-1.03125,
-0.307373046875,
0.1383056640625,
-1.1015625,
-0.5234375,
0.873046875,
0.16162109375,
0.68310546875,
-0.2763671875,
-0.671875,
0.54638671875,
1.462890625,
-0.276611328125,
0.351318359375,
0.7119140625,
-0.50732421875,
-0.29296875,
0.332763671875,
-0.1485595703125,
-0.1900634765625,
-0.85400390625,
0.69677734375,
-0.52685546875,
-0.024566650390625,
-0.2491455078125,
0.2227783203125,
0.247314453125,
0.66357421875,
-0.232666015625,
-0.40673828125,
0.7802734375,
1.1669921875,
-0.007129669189453125,
0.487548828125,
0.255859375,
0.77783203125,
0.1639404296875,
0.8193359375,
0.39404296875,
0.111572265625,
0.8974609375,
0.8515625,
0.08258056640625,
0.496826171875,
-0.1632080078125,
0.484375,
0.25927734375,
0.642578125,
0.432373046875,
0.2491455078125,
-0.310546875,
-0.0787353515625,
-0.31298828125,
0.141845703125,
-0.29736328125,
0.44384765625,
0.375,
0.487548828125,
-0.2041015625,
-0.1114501953125,
0.2425537109375,
0.7158203125,
-1.1689453125,
-0.55859375,
0.038299560546875,
0.1173095703125,
-0.0595703125,
0.0085601806640625,
0.169921875,
0.77197265625,
0.68310546875,
0.378662109375,
-0.56982421875,
-0.51416015625,
-1.1376953125,
-1.1005859375,
-1.0205078125,
-0.262939453125,
-0.8828125,
-0.08135986328125,
0.60595703125,
-1.0361328125,
0.439453125,
-0.365478515625,
-0.52392578125,
0.1236572265625,
-0.5576171875,
0.71240234375,
-0.196044921875,
0.78173828125,
-0.798828125,
0.693359375,
0.14990234375,
0.873046875,
-0.325439453125,
-0.33251953125,
-0.10137939453125,
-0.6357421875,
0.294189453125,
-0.07525634765625,
0.3232421875,
0.2763671875,
-0.6240234375,
-0.79931640625,
0.02734375,
-0.25927734375,
-0.609375,
0.1796875,
-0.77197265625,
0.80126953125,
0.91748046875,
-0.66748046875,
0.75537109375,
1.1669921875,
-0.93994140625,
0.08294677734375,
0.19677734375,
0.3642578125,
-0.5888671875,
1.1884765625,
0.343994140625,
0.3974609375,
-0.437255859375,
-0.52685546875,
-0.76904296875,
0.0267791748046875,
-0.006038665771484375,
-0.37841796875,
-0.0916748046875,
0.74755859375,
-0.255615234375,
-1.00390625,
0.77880859375,
-1.2822265625,
-0.06475830078125,
-0.07562255859375,
-0.62841796875,
1.0205078125,
0.451416015625,
0.355712890625,
-0.27001953125,
-0.845703125,
-0.2451171875,
0.82666015625,
0.1607666015625,
-0.58642578125,
0.0018444061279296875,
0.33740234375,
0.239501953125,
0.216552734375,
0.096435546875,
-0.2344970703125,
-0.3408203125,
0.0699462890625,
0.11981201171875,
0.99853515625,
0.28955078125,
0.4228515625,
0.273681640625,
0.837890625,
-0.6865234375,
-0.2587890625,
-0.27587890625,
0.716796875,
0.2900390625,
0.427001953125,
0.20068359375,
-0.1329345703125,
-0.48291015625,
-0.8369140625,
0.481201171875,
-0.36962890625,
0.79150390625,
-0.432861328125,
0.61669921875,
0.356201171875,
-0.556640625,
0.67578125,
-0.93115234375,
-0.344970703125,
0.8779296875,
-0.65673828125,
0.9697265625,
-0.98095703125,
0.1610107421875,
0.048980712890625,
0.069580078125,
0.68017578125,
0.59326171875,
0.8212890625,
-0.447021484375,
-0.5361328125,
-0.287841796875,
0.35400390625,
-0.1402587890625,
-0.478271484375,
0.11181640625,
-0.300537109375,
-0.513671875,
-0.9775390625,
0.489990234375,
0.78125,
0.64404296875,
0.28466796875,
0.36083984375,
0.1434326171875,
0.541015625,
0.95068359375,
0.017425537109375,
-0.05718994140625,
-0.77978515625,
0.984375,
0.02099609375,
-0.491455078125,
-0.343017578125,
-0.362060546875,
-0.342041015625,
0.2442626953125,
0.036468505859375,
0.06622314453125,
-0.92822265625,
-0.093505859375,
-0.12261962890625,
0.3408203125,
-0.77294921875,
-0.2763671875,
-0.1971435546875,
0.475341796875,
0.0760498046875,
-1.0712890625,
0.459716796875,
-0.720703125,
0.89404296875,
1.0283203125,
-0.00737762451171875,
-0.57958984375,
-0.09716796875,
-0.7021484375,
-0.95166015625,
-0.1475830078125,
0.603515625,
-0.123779296875,
0.2012939453125,
-1.3759765625,
0.5224609375,
0.385009765625,
-0.1368408203125,
0.316162109375,
0.1495361328125,
0.4951171875,
0.130126953125,
0.546875,
-0.62890625,
-0.66943359375,
0.384765625,
-1.142578125,
0.7314453125,
-0.59033203125,
0.58251953125,
-0.21240234375,
0.1688232421875,
0.145751953125,
0.48779296875,
-0.46435546875,
0.38818359375,
-0.0687255859375,
0.44482421875,
-1.0107421875,
-0.66650390625,
0.5283203125,
-0.1451416015625,
-0.71533203125,
0.53076171875,
0.2568359375,
-0.2998046875,
0.01102447509765625,
0.66748046875,
-0.442138671875,
0.49169921875,
-0.505859375,
0.64453125,
-0.08233642578125,
-0.74951171875,
-0.2144775390625,
-0.5263671875,
0.62939453125,
-0.242431640625,
-0.76318359375,
0.27978515625,
-1.1044921875,
-0.216064453125,
0.05621337890625,
-0.576171875,
0.41259765625,
0.290283203125,
0.11212158203125,
0.00106048583984375,
-0.48388671875,
-0.36572265625,
-0.18359375,
-0.51025390625,
-0.52001953125,
0.296875,
0.625,
0.66650390625,
0.25048828125,
-0.13720703125,
0.133056640625,
-0.0206298828125,
-0.1671142578125,
-0.60302734375,
-0.37255859375,
0.32470703125,
-0.58056640625,
-0.12353515625,
0.4013671875,
-0.0198211669921875,
0.39306640625,
0.86376953125,
-0.053314208984375,
0.229248046875,
0.323486328125,
-0.60107421875,
1.4384765625,
-0.142822265625,
-1.078125,
-0.41162109375,
0.2000732421875,
0.11907958984375,
0.66015625,
-0.2191162109375,
-0.74951171875,
-0.7392578125,
-1.1162109375,
0.12127685546875,
-0.56787109375,
-0.334228515625,
-0.91357421875,
-0.255859375,
-0.53271484375,
0.767578125,
-0.331787109375,
-0.357421875,
0.240478515625,
-1.3017578125,
0.206298828125,
-0.60791015625,
-0.335693359375,
-0.603515625,
-0.55859375,
-0.62255859375,
1.1220703125,
0.467041015625,
0.1578369140625,
0.4228515625,
-0.320556640625,
0.2354736328125,
-0.304443359375,
-0.59375,
-0.51513671875,
-0.20947265625,
0.293212890625,
-0.37841796875,
-0.3916015625,
-0.60693359375,
0.955078125,
-0.5078125,
0.2744140625,
-0.39306640625,
-0.52490234375,
-0.1783447265625,
-0.2047119140625,
0.80322265625,
-0.60498046875,
0.1904296875,
-0.59375,
0.56103515625,
0.409423828125,
-0.325927734375,
-0.53955078125,
-0.80908203125,
-0.55419921875,
-0.97021484375,
0.58544921875,
-0.5859375,
0.5986328125,
-0.7509765625,
-0.2418212890625,
0.9130859375,
-0.52197265625,
0.33984375,
1.431640625,
-0.1285400390625,
0.2283935546875,
-0.888671875,
0.63720703125,
-0.0269927978515625,
-0.6796875,
-0.304931640625,
-0.1119384765625,
-0.9345703125,
0.08038330078125,
-0.56494140625,
-0.873046875,
-0.54833984375,
0.73876953125,
1.3740234375,
-0.27099609375,
0.99169921875,
0.25537109375,
-1.201171875,
-0.78759765625,
0.75927734375,
0.39013671875,
0.51806640625,
1.1142578125,
-0.69482421875,
-0.1605224609375,
0.416015625,
-0.039276123046875,
-0.28369140625,
-0.197265625,
1.0185546875,
-0.46142578125,
-0.61279296875,
0.56005859375,
0.55322265625,
-1.1025390625,
-0.6337890625,
0.1180419921875,
-0.0272979736328125,
-0.027618408203125,
-0.6708984375,
0.2020263671875,
0.646484375,
-0.393310546875,
-0.013824462890625,
0.04400634765625,
-0.00948333740234375,
0.67724609375,
0.296875,
0.2890625,
-0.53955078125,
0.67626953125,
0.8642578125,
-0.80615234375,
-0.409912109375,
-0.89013671875,
-0.1422119140625,
-0.2081298828125,
0.296142578125,
0.7890625,
0.11431884765625,
0.2177734375,
0.76611328125,
-0.112060546875,
0.6572265625,
-0.47412109375,
-0.333251953125,
0.1614990234375,
-0.49365234375,
-0.250244140625,
-0.03656005859375,
0.20654296875,
0.1546630859375,
0.260009765625,
-0.6201171875,
-0.06719970703125,
0.494873046875,
0.32861328125,
-0.0484619140625,
-0.064208984375,
-0.350830078125,
-0.57861328125,
-0.4423828125,
-0.48681640625,
-0.8125,
-0.15380859375,
0.428466796875,
0.43115234375,
-0.72265625,
0.0382080078125,
0.8447265625,
-0.7978515625,
1.1630859375,
-0.79931640625,
0.31591796875,
-0.416748046875,
-0.16455078125,
-0.77685546875,
0.10595703125,
-0.486572265625,
-0.279296875,
-0.328369140625,
0.51171875,
0.40185546875,
0.5966796875,
-0.2371826171875,
0.246337890625,
-0.16357421875,
-0.77490234375,
-0.01462554931640625,
0.09051513671875,
0.054473876953125,
0.344970703125,
0.697265625,
0.4560546875,
0.1826171875,
-0.046173095703125,
-0.53662109375,
-0.427001953125,
0.1942138671875,
0.8984375,
0.00626373291015625,
-0.0687255859375,
-0.3115234375,
-0.0723876953125,
-0.60986328125,
0.2252197265625,
-0.26318359375,
-0.1207275390625,
0.08074951171875,
-0.76171875,
0.53515625,
1.2373046875,
-0.161376953125,
0.2152099609375,
-0.03314208984375,
0.369384765625,
0.388916015625,
0.1488037109375,
0.311279296875,
0.20703125,
0.06744384765625,
-0.228515625,
-0.09967041015625,
0.56591796875,
-0.00792694091796875,
0.4091796875,
-0.3388671875,
-0.7685546875,
-0.82080078125,
-0.0269317626953125,
-0.32666015625,
0.0227813720703125,
0.59375,
-0.8349609375,
-0.08984375,
0.135986328125,
-1.029296875,
0.21240234375,
-0.80810546875,
-0.7998046875,
0.1552734375,
-0.138427734375,
-0.79345703125,
-0.40234375,
-0.56103515625,
0.1148681640625,
0.212890625,
0.5009765625,
-0.74267578125,
0.171142578125,
-0.1153564453125,
0.3916015625,
-0.2607421875,
-0.08935546875,
0.096435546875,
0.2181396484375,
-0.53271484375,
-0.64794921875,
0.121337890625,
1.546875,
0.1912841796875,
-0.355712890625,
-0.66064453125,
0.133544921875,
-0.46533203125,
0.2083740234375,
-0.12359619140625,
-0.12432861328125,
-0.0298004150390625,
0.43994140625,
-1.1474609375,
-0.340087890625,
0.10650634765625,
0.337158203125,
-0.1324462890625,
-0.32958984375,
-0.2227783203125,
0.66162109375,
0.9306640625,
-0.1478271484375,
-0.0328369140625,
0.37646484375,
0.87890625,
-0.2890625,
-0.0989990234375,
-0.1290283203125,
0.323974609375,
0.56005859375,
0.365966796875,
-0.282470703125,
0.724609375,
0.9765625,
-0.3037109375,
-0.0789794921875,
0.51025390625,
0.049591064453125,
0.039154052734375,
-0.2274169921875,
-0.2296142578125,
-0.002803802490234375,
-0.034027099609375,
-0.82080078125,
0.2261962890625,
-0.329345703125,
-0.423583984375,
-0.1932373046875,
-0.71630859375,
1.0029296875,
-1.166015625,
0.42626953125,
-0.3193359375,
-0.1859130859375,
0.4609375,
0.95166015625,
0.037689208984375,
-0.0908203125,
0.495849609375,
0.438232421875,
0.64013671875,
0.83251953125,
0.2283935546875,
0.1160888671875,
-0.451904296875,
0.1641845703125,
0.0161285400390625,
0.023162841796875,
-0.5908203125,
-0.30615234375,
-1.2333984375,
0.64990234375,
-0.450927734375,
-0.09906005859375,
0.33984375,
-0.58056640625,
0.19384765625,
-0.303955078125,
0.83935546875,
-0.4794921875,
0.4287109375,
0.52734375,
-0.58740234375,
-0.46435546875,
0.85595703125,
-0.08673095703125,
0.39501953125,
0.209228515625,
0.7783203125,
0.3125,
1.7255859375,
0.2978515625,
-0.1956787109375,
-0.043060302734375,
0.053619384765625,
-0.1959228515625,
-0.59326171875,
-0.309814453125,
-0.311767578125,
-0.1688232421875,
-0.425537109375,
-0.339111328125,
-0.07940673828125,
0.6396484375,
0.059814453125,
-0.82666015625,
-0.08233642578125,
0.06561279296875,
-0.8720703125,
0.8359375,
0.136474609375,
0.1287841796875,
0.106689453125,
0.1329345703125,
-0.1568603515625,
-0.3369140625,
-0.1610107421875,
-0.4453125,
0.2100830078125,
-0.5205078125,
-0.55810546875,
-0.61865234375,
-0.9541015625,
-0.34423828125,
-0.26806640625,
-0.61669921875,
-0.92236328125,
0.185546875,
0.65869140625,
0.5009765625,
0.4609375,
-0.54638671875,
0.416748046875,
1.1513671875,
0.79345703125,
-0.427734375,
0.93798828125,
0.4228515625,
-0.58154296875,
0.01061248779296875,
-0.138916015625,
0.697265625,
-0.29345703125,
-0.061431884765625,
-0.274169921875,
0.415283203125,
-1.015625,
-1.3095703125,
0.0504150390625,
0.72802734375,
0.3671875,
-0.546875,
-1.00390625,
-0.462890625,
-0.81884765625,
-0.045867919921875,
-0.818359375,
0.63232421875,
0.382568359375,
-0.1622314453125,
0.04608154296875,
-1.0244140625,
4.2578125,
0.99658203125,
0.8515625,
0.07489013671875,
0.0121612548828125,
0.93896484375,
0.0192108154296875,
-0.400634765625,
0.196044921875,
-0.3740234375,
0.78466796875,
-0.283203125,
-0.1058349609375,
0.626953125,
0.1607666015625,
0.414794921875,
-0.4892578125,
-0.066650390625,
-0.206298828125,
-1.0107421875,
-0.87939453125,
0.1136474609375,
0.31787109375,
0.13720703125,
0.10650634765625,
0.127685546875,
0.68701171875,
-0.62939453125,
-0.34912109375,
-0.66455078125,
-0.270751953125,
-0.65234375,
0.7890625,
-0.019195556640625,
-0.060760498046875,
0.5166015625,
0.15966796875,
-0.58251953125,
0.041595458984375,
0.5908203125,
-0.34521484375,
-0.41064453125,
0.8740234375,
-0.79931640625,
0.1572265625,
0.60498046875,
-0.365478515625,
0.327880859375,
0.64013671875,
-0.486083984375,
0.712890625,
-0.1710205078125,
0.775390625,
-0.7861328125,
-0.69189453125,
0.059967041015625,
0.23681640625,
-0.26904296875,
0.093505859375,
0.3662109375,
0.161376953125,
0.11669921875,
-0.007656097412109375,
0.469970703125,
-0.76123046875,
0.61962890625,
0.2076416015625,
0.2049560546875,
-0.5634765625,
0.09027099609375,
0.00823211669921875,
-0.08270263671875,
-0.365234375,
-0.57177734375,
0.51708984375,
0.2265625,
-0.05084228515625,
0.33642578125,
0.53662109375,
-0.84130859375,
0.0175323486328125,
-0.037506103515625,
-0.333740234375,
-0.363525390625,
0.55517578125,
1.580078125,
-0.681640625,
-0.394287109375,
-0.53857421875,
0.59521484375,
0.204345703125,
0.34765625,
0.60107421875,
-0.90185546875,
-0.333251953125
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.
Sergey totally forgot about the task until half an hour before the next lesson and hastily scribbled something down. But then he recollected that in the last lesson he learned the grammar of N-ish. The spelling rules state that N-ish contains some "forbidden" pairs of letters: such letters can never occur in a sentence next to each other. Also, the order of the letters doesn't matter (for example, if the pair of letters "ab" is forbidden, then any occurrences of substrings "ab" and "ba" are also forbidden). Also, each pair has different letters and each letter occurs in no more than one forbidden pair.
Now Sergey wants to correct his sentence so that it doesn't contain any "forbidden" pairs of letters that stand next to each other. However, he is running out of time, so he decided to simply cross out some letters from the sentence. What smallest number of letters will he have to cross out? When a letter is crossed out, it is "removed" so that the letters to its left and right (if they existed), become neighboring. For example, if we cross out the first letter from the string "aba", we get the string "ba", and if we cross out the second letter, we get "aa".
Input
The first line contains a non-empty string s, consisting of lowercase Latin letters — that's the initial sentence in N-ish, written by Sergey. The length of string s doesn't exceed 105.
The next line contains integer k (0 ≤ k ≤ 13) — the number of forbidden pairs of letters.
Next k lines contain descriptions of forbidden pairs of letters. Each line contains exactly two different lowercase Latin letters without separators that represent the forbidden pairs. It is guaranteed that each letter is included in no more than one pair.
Output
Print the single number — the smallest number of letters that need to be removed to get a string without any forbidden pairs of neighboring letters. Please note that the answer always exists as it is always possible to remove all letters.
Examples
Input
ababa
1
ab
Output
2
Input
codeforces
2
do
cs
Output
1
Note
In the first sample you should remove two letters b.
In the second sample you should remove the second or the third letter. The second restriction doesn't influence the solution.
Submitted Solution:
```
a=input()
n=len(a)
k=int(input())
b=[input() for i in range(k)]
c=[]
d=0
for i in range(1,n):
if a[i]!=a[i-1]:
c.append(i-d)
d=i
c.append(n-d)
i=0
j=0
e=0
while j<n-1:
if a[j]+a[j+1] in b or a[j+1]+a[j] in b:
e+=min(c[i],c[i+1])
i+=1
j+=c[i]
j+=1
print(e)
```
No
| 71,008 | [
0.30078125,
-0.062469482421875,
0.03240966796875,
0.20458984375,
-0.54833984375,
-0.6875,
0.06640625,
-0.06231689453125,
-0.203369140625,
0.943359375,
0.7431640625,
0.0479736328125,
-0.375244140625,
-0.91259765625,
-0.916015625,
-0.159423828125,
-0.9326171875,
-0.6044921875,
-0.5048828125,
-0.191162109375,
0.0599365234375,
-0.224365234375,
-1.6044921875,
-0.27880859375,
-0.45654296875,
1.1884765625,
0.309814453125,
-0.326416015625,
1.13671875,
0.72412109375,
-0.2783203125,
-0.2734375,
0.517578125,
-1.05859375,
-0.548828125,
-0.5869140625,
0.95166015625,
-0.46484375,
-0.0654296875,
-0.05462646484375,
0.572265625,
-0.25830078125,
0.467529296875,
-0.56005859375,
-1.3701171875,
-0.415771484375,
-0.09832763671875,
-0.5927734375,
-0.342529296875,
-0.442626953125,
0.3583984375,
-0.35888671875,
0.59765625,
-0.235595703125,
0.060516357421875,
0.28369140625,
0.256103515625,
0.1417236328125,
-0.78515625,
0.298583984375,
0.1729736328125,
0.319091796875,
0.1888427734375,
-0.8173828125,
-0.455810546875,
-0.08856201171875,
-0.2440185546875,
0.237548828125,
-0.00044155120849609375,
-0.461181640625,
-0.28466796875,
0.41259765625,
-0.390869140625,
-0.19189453125,
-0.64306640625,
0.07904052734375,
0.245361328125,
0.152099609375,
-0.65966796875,
0.89990234375,
0.29345703125,
1.1064453125,
0.72509765625,
-0.10723876953125,
-0.302734375,
-0.1356201171875,
0.06878662109375,
0.4150390625,
0.464599609375,
-0.2666015625,
-0.1451416015625,
0.446533203125,
-0.94091796875,
-0.201416015625,
0.6259765625,
0.396728515625,
-0.314697265625,
0.274658203125,
0.49560546875,
0.448974609375,
0.89501953125,
0.52490234375,
-0.287841796875,
0.87890625,
-0.5888671875,
0.11859130859375,
0.1024169921875,
0.1533203125,
0.015350341796875,
0.252685546875,
-0.22607421875,
-0.10162353515625,
0.459716796875,
0.484619140625,
-0.75341796875,
0.72119140625,
-0.2568359375,
0.428955078125,
-0.796875,
0.2294921875,
0.82080078125,
-0.07073974609375,
0.81787109375,
0.1185302734375,
0.2685546875,
-0.2265625,
-0.64697265625,
1.091796875,
-0.383056640625,
-0.02093505859375,
0.53564453125,
0.05596923828125,
-0.121337890625,
0.1397705078125,
-0.374267578125,
0.80517578125,
-0.30517578125,
0.61962890625,
0.55908203125,
-0.64453125,
0.5234375,
-0.1650390625,
0.01244354248046875,
1.5029296875,
0.634765625,
-0.1658935546875,
0.71533203125,
0.49951171875,
-0.92724609375,
0.1776123046875,
-1.3740234375,
0.85791015625,
0.051177978515625,
0.04443359375,
-0.6064453125,
-0.168701171875,
-0.216552734375,
0.06866455078125,
0.09478759765625,
0.1263427734375,
-0.437255859375,
0.18408203125,
-0.283203125,
0.63330078125,
-0.300048828125,
1.0244140625,
-0.6396484375,
0.03680419921875,
-0.1334228515625,
-0.54345703125,
0.2276611328125,
-0.03997802734375,
0.1929931640625,
1.064453125,
0.2119140625,
0.9189453125,
0.60400390625,
-0.313720703125,
0.6337890625,
0.5205078125,
-0.1890869140625,
0.383544921875,
0.17431640625,
0.41650390625,
0.5517578125,
0.419921875,
-0.144287109375,
-0.352294921875,
-0.78076171875,
-0.322509765625,
-0.040802001953125,
0.83544921875,
-0.421142578125,
0.410888671875,
-0.03094482421875,
-0.016510009765625,
-1.03125,
-0.307373046875,
0.1383056640625,
-1.1015625,
-0.5234375,
0.873046875,
0.16162109375,
0.68310546875,
-0.2763671875,
-0.671875,
0.54638671875,
1.462890625,
-0.276611328125,
0.351318359375,
0.7119140625,
-0.50732421875,
-0.29296875,
0.332763671875,
-0.1485595703125,
-0.1900634765625,
-0.85400390625,
0.69677734375,
-0.52685546875,
-0.024566650390625,
-0.2491455078125,
0.2227783203125,
0.247314453125,
0.66357421875,
-0.232666015625,
-0.40673828125,
0.7802734375,
1.1669921875,
-0.007129669189453125,
0.487548828125,
0.255859375,
0.77783203125,
0.1639404296875,
0.8193359375,
0.39404296875,
0.111572265625,
0.8974609375,
0.8515625,
0.08258056640625,
0.496826171875,
-0.1632080078125,
0.484375,
0.25927734375,
0.642578125,
0.432373046875,
0.2491455078125,
-0.310546875,
-0.0787353515625,
-0.31298828125,
0.141845703125,
-0.29736328125,
0.44384765625,
0.375,
0.487548828125,
-0.2041015625,
-0.1114501953125,
0.2425537109375,
0.7158203125,
-1.1689453125,
-0.55859375,
0.038299560546875,
0.1173095703125,
-0.0595703125,
0.0085601806640625,
0.169921875,
0.77197265625,
0.68310546875,
0.378662109375,
-0.56982421875,
-0.51416015625,
-1.1376953125,
-1.1005859375,
-1.0205078125,
-0.262939453125,
-0.8828125,
-0.08135986328125,
0.60595703125,
-1.0361328125,
0.439453125,
-0.365478515625,
-0.52392578125,
0.1236572265625,
-0.5576171875,
0.71240234375,
-0.196044921875,
0.78173828125,
-0.798828125,
0.693359375,
0.14990234375,
0.873046875,
-0.325439453125,
-0.33251953125,
-0.10137939453125,
-0.6357421875,
0.294189453125,
-0.07525634765625,
0.3232421875,
0.2763671875,
-0.6240234375,
-0.79931640625,
0.02734375,
-0.25927734375,
-0.609375,
0.1796875,
-0.77197265625,
0.80126953125,
0.91748046875,
-0.66748046875,
0.75537109375,
1.1669921875,
-0.93994140625,
0.08294677734375,
0.19677734375,
0.3642578125,
-0.5888671875,
1.1884765625,
0.343994140625,
0.3974609375,
-0.437255859375,
-0.52685546875,
-0.76904296875,
0.0267791748046875,
-0.006038665771484375,
-0.37841796875,
-0.0916748046875,
0.74755859375,
-0.255615234375,
-1.00390625,
0.77880859375,
-1.2822265625,
-0.06475830078125,
-0.07562255859375,
-0.62841796875,
1.0205078125,
0.451416015625,
0.355712890625,
-0.27001953125,
-0.845703125,
-0.2451171875,
0.82666015625,
0.1607666015625,
-0.58642578125,
0.0018444061279296875,
0.33740234375,
0.239501953125,
0.216552734375,
0.096435546875,
-0.2344970703125,
-0.3408203125,
0.0699462890625,
0.11981201171875,
0.99853515625,
0.28955078125,
0.4228515625,
0.273681640625,
0.837890625,
-0.6865234375,
-0.2587890625,
-0.27587890625,
0.716796875,
0.2900390625,
0.427001953125,
0.20068359375,
-0.1329345703125,
-0.48291015625,
-0.8369140625,
0.481201171875,
-0.36962890625,
0.79150390625,
-0.432861328125,
0.61669921875,
0.356201171875,
-0.556640625,
0.67578125,
-0.93115234375,
-0.344970703125,
0.8779296875,
-0.65673828125,
0.9697265625,
-0.98095703125,
0.1610107421875,
0.048980712890625,
0.069580078125,
0.68017578125,
0.59326171875,
0.8212890625,
-0.447021484375,
-0.5361328125,
-0.287841796875,
0.35400390625,
-0.1402587890625,
-0.478271484375,
0.11181640625,
-0.300537109375,
-0.513671875,
-0.9775390625,
0.489990234375,
0.78125,
0.64404296875,
0.28466796875,
0.36083984375,
0.1434326171875,
0.541015625,
0.95068359375,
0.017425537109375,
-0.05718994140625,
-0.77978515625,
0.984375,
0.02099609375,
-0.491455078125,
-0.343017578125,
-0.362060546875,
-0.342041015625,
0.2442626953125,
0.036468505859375,
0.06622314453125,
-0.92822265625,
-0.093505859375,
-0.12261962890625,
0.3408203125,
-0.77294921875,
-0.2763671875,
-0.1971435546875,
0.475341796875,
0.0760498046875,
-1.0712890625,
0.459716796875,
-0.720703125,
0.89404296875,
1.0283203125,
-0.00737762451171875,
-0.57958984375,
-0.09716796875,
-0.7021484375,
-0.95166015625,
-0.1475830078125,
0.603515625,
-0.123779296875,
0.2012939453125,
-1.3759765625,
0.5224609375,
0.385009765625,
-0.1368408203125,
0.316162109375,
0.1495361328125,
0.4951171875,
0.130126953125,
0.546875,
-0.62890625,
-0.66943359375,
0.384765625,
-1.142578125,
0.7314453125,
-0.59033203125,
0.58251953125,
-0.21240234375,
0.1688232421875,
0.145751953125,
0.48779296875,
-0.46435546875,
0.38818359375,
-0.0687255859375,
0.44482421875,
-1.0107421875,
-0.66650390625,
0.5283203125,
-0.1451416015625,
-0.71533203125,
0.53076171875,
0.2568359375,
-0.2998046875,
0.01102447509765625,
0.66748046875,
-0.442138671875,
0.49169921875,
-0.505859375,
0.64453125,
-0.08233642578125,
-0.74951171875,
-0.2144775390625,
-0.5263671875,
0.62939453125,
-0.242431640625,
-0.76318359375,
0.27978515625,
-1.1044921875,
-0.216064453125,
0.05621337890625,
-0.576171875,
0.41259765625,
0.290283203125,
0.11212158203125,
0.00106048583984375,
-0.48388671875,
-0.36572265625,
-0.18359375,
-0.51025390625,
-0.52001953125,
0.296875,
0.625,
0.66650390625,
0.25048828125,
-0.13720703125,
0.133056640625,
-0.0206298828125,
-0.1671142578125,
-0.60302734375,
-0.37255859375,
0.32470703125,
-0.58056640625,
-0.12353515625,
0.4013671875,
-0.0198211669921875,
0.39306640625,
0.86376953125,
-0.053314208984375,
0.229248046875,
0.323486328125,
-0.60107421875,
1.4384765625,
-0.142822265625,
-1.078125,
-0.41162109375,
0.2000732421875,
0.11907958984375,
0.66015625,
-0.2191162109375,
-0.74951171875,
-0.7392578125,
-1.1162109375,
0.12127685546875,
-0.56787109375,
-0.334228515625,
-0.91357421875,
-0.255859375,
-0.53271484375,
0.767578125,
-0.331787109375,
-0.357421875,
0.240478515625,
-1.3017578125,
0.206298828125,
-0.60791015625,
-0.335693359375,
-0.603515625,
-0.55859375,
-0.62255859375,
1.1220703125,
0.467041015625,
0.1578369140625,
0.4228515625,
-0.320556640625,
0.2354736328125,
-0.304443359375,
-0.59375,
-0.51513671875,
-0.20947265625,
0.293212890625,
-0.37841796875,
-0.3916015625,
-0.60693359375,
0.955078125,
-0.5078125,
0.2744140625,
-0.39306640625,
-0.52490234375,
-0.1783447265625,
-0.2047119140625,
0.80322265625,
-0.60498046875,
0.1904296875,
-0.59375,
0.56103515625,
0.409423828125,
-0.325927734375,
-0.53955078125,
-0.80908203125,
-0.55419921875,
-0.97021484375,
0.58544921875,
-0.5859375,
0.5986328125,
-0.7509765625,
-0.2418212890625,
0.9130859375,
-0.52197265625,
0.33984375,
1.431640625,
-0.1285400390625,
0.2283935546875,
-0.888671875,
0.63720703125,
-0.0269927978515625,
-0.6796875,
-0.304931640625,
-0.1119384765625,
-0.9345703125,
0.08038330078125,
-0.56494140625,
-0.873046875,
-0.54833984375,
0.73876953125,
1.3740234375,
-0.27099609375,
0.99169921875,
0.25537109375,
-1.201171875,
-0.78759765625,
0.75927734375,
0.39013671875,
0.51806640625,
1.1142578125,
-0.69482421875,
-0.1605224609375,
0.416015625,
-0.039276123046875,
-0.28369140625,
-0.197265625,
1.0185546875,
-0.46142578125,
-0.61279296875,
0.56005859375,
0.55322265625,
-1.1025390625,
-0.6337890625,
0.1180419921875,
-0.0272979736328125,
-0.027618408203125,
-0.6708984375,
0.2020263671875,
0.646484375,
-0.393310546875,
-0.013824462890625,
0.04400634765625,
-0.00948333740234375,
0.67724609375,
0.296875,
0.2890625,
-0.53955078125,
0.67626953125,
0.8642578125,
-0.80615234375,
-0.409912109375,
-0.89013671875,
-0.1422119140625,
-0.2081298828125,
0.296142578125,
0.7890625,
0.11431884765625,
0.2177734375,
0.76611328125,
-0.112060546875,
0.6572265625,
-0.47412109375,
-0.333251953125,
0.1614990234375,
-0.49365234375,
-0.250244140625,
-0.03656005859375,
0.20654296875,
0.1546630859375,
0.260009765625,
-0.6201171875,
-0.06719970703125,
0.494873046875,
0.32861328125,
-0.0484619140625,
-0.064208984375,
-0.350830078125,
-0.57861328125,
-0.4423828125,
-0.48681640625,
-0.8125,
-0.15380859375,
0.428466796875,
0.43115234375,
-0.72265625,
0.0382080078125,
0.8447265625,
-0.7978515625,
1.1630859375,
-0.79931640625,
0.31591796875,
-0.416748046875,
-0.16455078125,
-0.77685546875,
0.10595703125,
-0.486572265625,
-0.279296875,
-0.328369140625,
0.51171875,
0.40185546875,
0.5966796875,
-0.2371826171875,
0.246337890625,
-0.16357421875,
-0.77490234375,
-0.01462554931640625,
0.09051513671875,
0.054473876953125,
0.344970703125,
0.697265625,
0.4560546875,
0.1826171875,
-0.046173095703125,
-0.53662109375,
-0.427001953125,
0.1942138671875,
0.8984375,
0.00626373291015625,
-0.0687255859375,
-0.3115234375,
-0.0723876953125,
-0.60986328125,
0.2252197265625,
-0.26318359375,
-0.1207275390625,
0.08074951171875,
-0.76171875,
0.53515625,
1.2373046875,
-0.161376953125,
0.2152099609375,
-0.03314208984375,
0.369384765625,
0.388916015625,
0.1488037109375,
0.311279296875,
0.20703125,
0.06744384765625,
-0.228515625,
-0.09967041015625,
0.56591796875,
-0.00792694091796875,
0.4091796875,
-0.3388671875,
-0.7685546875,
-0.82080078125,
-0.0269317626953125,
-0.32666015625,
0.0227813720703125,
0.59375,
-0.8349609375,
-0.08984375,
0.135986328125,
-1.029296875,
0.21240234375,
-0.80810546875,
-0.7998046875,
0.1552734375,
-0.138427734375,
-0.79345703125,
-0.40234375,
-0.56103515625,
0.1148681640625,
0.212890625,
0.5009765625,
-0.74267578125,
0.171142578125,
-0.1153564453125,
0.3916015625,
-0.2607421875,
-0.08935546875,
0.096435546875,
0.2181396484375,
-0.53271484375,
-0.64794921875,
0.121337890625,
1.546875,
0.1912841796875,
-0.355712890625,
-0.66064453125,
0.133544921875,
-0.46533203125,
0.2083740234375,
-0.12359619140625,
-0.12432861328125,
-0.0298004150390625,
0.43994140625,
-1.1474609375,
-0.340087890625,
0.10650634765625,
0.337158203125,
-0.1324462890625,
-0.32958984375,
-0.2227783203125,
0.66162109375,
0.9306640625,
-0.1478271484375,
-0.0328369140625,
0.37646484375,
0.87890625,
-0.2890625,
-0.0989990234375,
-0.1290283203125,
0.323974609375,
0.56005859375,
0.365966796875,
-0.282470703125,
0.724609375,
0.9765625,
-0.3037109375,
-0.0789794921875,
0.51025390625,
0.049591064453125,
0.039154052734375,
-0.2274169921875,
-0.2296142578125,
-0.002803802490234375,
-0.034027099609375,
-0.82080078125,
0.2261962890625,
-0.329345703125,
-0.423583984375,
-0.1932373046875,
-0.71630859375,
1.0029296875,
-1.166015625,
0.42626953125,
-0.3193359375,
-0.1859130859375,
0.4609375,
0.95166015625,
0.037689208984375,
-0.0908203125,
0.495849609375,
0.438232421875,
0.64013671875,
0.83251953125,
0.2283935546875,
0.1160888671875,
-0.451904296875,
0.1641845703125,
0.0161285400390625,
0.023162841796875,
-0.5908203125,
-0.30615234375,
-1.2333984375,
0.64990234375,
-0.450927734375,
-0.09906005859375,
0.33984375,
-0.58056640625,
0.19384765625,
-0.303955078125,
0.83935546875,
-0.4794921875,
0.4287109375,
0.52734375,
-0.58740234375,
-0.46435546875,
0.85595703125,
-0.08673095703125,
0.39501953125,
0.209228515625,
0.7783203125,
0.3125,
1.7255859375,
0.2978515625,
-0.1956787109375,
-0.043060302734375,
0.053619384765625,
-0.1959228515625,
-0.59326171875,
-0.309814453125,
-0.311767578125,
-0.1688232421875,
-0.425537109375,
-0.339111328125,
-0.07940673828125,
0.6396484375,
0.059814453125,
-0.82666015625,
-0.08233642578125,
0.06561279296875,
-0.8720703125,
0.8359375,
0.136474609375,
0.1287841796875,
0.106689453125,
0.1329345703125,
-0.1568603515625,
-0.3369140625,
-0.1610107421875,
-0.4453125,
0.2100830078125,
-0.5205078125,
-0.55810546875,
-0.61865234375,
-0.9541015625,
-0.34423828125,
-0.26806640625,
-0.61669921875,
-0.92236328125,
0.185546875,
0.65869140625,
0.5009765625,
0.4609375,
-0.54638671875,
0.416748046875,
1.1513671875,
0.79345703125,
-0.427734375,
0.93798828125,
0.4228515625,
-0.58154296875,
0.01061248779296875,
-0.138916015625,
0.697265625,
-0.29345703125,
-0.061431884765625,
-0.274169921875,
0.415283203125,
-1.015625,
-1.3095703125,
0.0504150390625,
0.72802734375,
0.3671875,
-0.546875,
-1.00390625,
-0.462890625,
-0.81884765625,
-0.045867919921875,
-0.818359375,
0.63232421875,
0.382568359375,
-0.1622314453125,
0.04608154296875,
-1.0244140625,
4.2578125,
0.99658203125,
0.8515625,
0.07489013671875,
0.0121612548828125,
0.93896484375,
0.0192108154296875,
-0.400634765625,
0.196044921875,
-0.3740234375,
0.78466796875,
-0.283203125,
-0.1058349609375,
0.626953125,
0.1607666015625,
0.414794921875,
-0.4892578125,
-0.066650390625,
-0.206298828125,
-1.0107421875,
-0.87939453125,
0.1136474609375,
0.31787109375,
0.13720703125,
0.10650634765625,
0.127685546875,
0.68701171875,
-0.62939453125,
-0.34912109375,
-0.66455078125,
-0.270751953125,
-0.65234375,
0.7890625,
-0.019195556640625,
-0.060760498046875,
0.5166015625,
0.15966796875,
-0.58251953125,
0.041595458984375,
0.5908203125,
-0.34521484375,
-0.41064453125,
0.8740234375,
-0.79931640625,
0.1572265625,
0.60498046875,
-0.365478515625,
0.327880859375,
0.64013671875,
-0.486083984375,
0.712890625,
-0.1710205078125,
0.775390625,
-0.7861328125,
-0.69189453125,
0.059967041015625,
0.23681640625,
-0.26904296875,
0.093505859375,
0.3662109375,
0.161376953125,
0.11669921875,
-0.007656097412109375,
0.469970703125,
-0.76123046875,
0.61962890625,
0.2076416015625,
0.2049560546875,
-0.5634765625,
0.09027099609375,
0.00823211669921875,
-0.08270263671875,
-0.365234375,
-0.57177734375,
0.51708984375,
0.2265625,
-0.05084228515625,
0.33642578125,
0.53662109375,
-0.84130859375,
0.0175323486328125,
-0.037506103515625,
-0.333740234375,
-0.363525390625,
0.55517578125,
1.580078125,
-0.681640625,
-0.394287109375,
-0.53857421875,
0.59521484375,
0.204345703125,
0.34765625,
0.60107421875,
-0.90185546875,
-0.333251953125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where
* <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
* <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
* <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.
The content of square brackets is optional — it can be present or can be absent.
There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.
Your task is to write program which checks if given string is a correct Jabber ID.
Input
The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.
Output
Print YES or NO.
Examples
Input
mike@codeforces.com
Output
YES
Input
john.smith@codeforces.ru/contest.icpc/12
Output
NO
Tags: implementation, strings
Correct Solution:
```
#In the name of GOD!
def chk(s):
if len(s) == 0 or len(s) > 16: return 1
for i in s:
if not(('a' <= i and i <= 'z') or ('A' <= i and i <= 'Z') or ('0' <= i and i <= '9') or i == '_'):
return 1
return 0
s = input()
c = ''
x = 0
b = 0
for i in s:
x += 1
if i == '@':
b += chk(c)
c = ''
break
c += i
d = 1
y = 0
for j in range(x, len(s)):
d = 0
i = s[j]
x += 1
if y > 32: b += 1
if i == '.':
b += chk(c)
c = ''
elif i == '/':
b += chk(c)
c = ''
break
else: c += i
y += 1
if len(c) > 0: b += chk(c)
for j in range(x, len(s)):
i = s[j]
if i == '/':
b += chk(c)
c = ''
else: c += i
if s[-1] == '/' or s[-1] == '.': b += 1
if b + d > 0: print("NO")
else: print("YES")
```
| 71,025 | [
0.5576171875,
-0.11749267578125,
-0.141357421875,
0.4833984375,
-0.0137176513671875,
-0.5537109375,
0.0428466796875,
-0.2286376953125,
0.1571044921875,
0.44580078125,
0.44140625,
0.027587890625,
0.06536865234375,
-0.880859375,
-0.59228515625,
-0.11767578125,
-0.564453125,
-0.90087890625,
-0.395751953125,
-0.467529296875,
0.346435546875,
0.054229736328125,
-1.2568359375,
-0.2093505859375,
-0.52001953125,
0.6923828125,
0.1287841796875,
0.361328125,
0.99267578125,
0.65234375,
-0.106689453125,
-0.6044921875,
0.42529296875,
-1.0087890625,
-0.364990234375,
-0.319091796875,
0.41845703125,
-1.048828125,
-0.57080078125,
-0.365234375,
0.157470703125,
-0.224609375,
0.1363525390625,
-1.0556640625,
-1.115234375,
0.1387939453125,
-0.54736328125,
-0.07525634765625,
-0.062469482421875,
-0.583984375,
0.2142333984375,
-0.1240234375,
0.6982421875,
-0.45263671875,
-0.19921875,
-0.29833984375,
-0.35302734375,
0.1124267578125,
-0.75048828125,
0.125,
-0.06201171875,
0.435546875,
-0.0112457275390625,
-0.68310546875,
-0.0682373046875,
0.01232147216796875,
0.06585693359375,
-0.1861572265625,
-0.09014892578125,
-0.87841796875,
-0.032806396484375,
0.361083984375,
-0.67236328125,
-0.70556640625,
-0.2255859375,
0.006015777587890625,
0.299072265625,
-0.078125,
-0.21728515625,
0.6787109375,
-0.0830078125,
1.328125,
0.37939453125,
0.1622314453125,
-0.77197265625,
-0.46142578125,
0.333740234375,
0.40673828125,
0.2379150390625,
-0.1937255859375,
-0.26416015625,
0.359130859375,
-0.560546875,
0.26806640625,
0.54443359375,
0.67578125,
0.1494140625,
0.63525390625,
0.1343994140625,
0.2337646484375,
0.626953125,
0.98828125,
-0.36083984375,
1.0341796875,
-0.41650390625,
0.2022705078125,
0.5361328125,
0.08270263671875,
-0.66015625,
-0.335205078125,
-0.1859130859375,
-0.75341796875,
0.3603515625,
0.09332275390625,
-0.298095703125,
0.4765625,
0.0021381378173828125,
0.49755859375,
-1.1357421875,
-0.005420684814453125,
0.465087890625,
-0.2958984375,
0.65087890625,
-0.402587890625,
-0.09637451171875,
-0.294189453125,
-0.55810546875,
1.00390625,
-0.31103515625,
-0.1427001953125,
0.259033203125,
-0.0279998779296875,
-0.272216796875,
-0.1427001953125,
0.1912841796875,
0.869140625,
0.0010471343994140625,
0.59228515625,
0.9833984375,
-0.95166015625,
0.6396484375,
0.1422119140625,
0.032135009765625,
1.65625,
0.490478515625,
0.1090087890625,
0.5830078125,
0.2783203125,
-0.57177734375,
0.0625,
-0.89404296875,
0.89501953125,
0.42919921875,
0.2037353515625,
-0.225341796875,
0.277099609375,
0.046295166015625,
0.57958984375,
0.1080322265625,
-0.07183837890625,
-0.479248046875,
0.4130859375,
-0.0921630859375,
0.97216796875,
-0.09698486328125,
0.453125,
0.039306640625,
-0.18603515625,
0.44921875,
-0.626953125,
0.5224609375,
-0.140869140625,
0.170166015625,
0.8310546875,
0.56298828125,
0.82470703125,
0.97607421875,
-0.10394287109375,
0.4306640625,
0.4892578125,
-0.51123046875,
0.3271484375,
0.12115478515625,
1.083984375,
0.008941650390625,
0.08837890625,
0.318603515625,
-0.429443359375,
-1.1337890625,
-0.6455078125,
0.11529541015625,
0.29931640625,
-0.367919921875,
0.392822265625,
0.459716796875,
-0.10894775390625,
-0.2071533203125,
-0.1492919921875,
0.11444091796875,
-1.046875,
0.00433349609375,
0.826171875,
-0.2109375,
0.402587890625,
0.031524658203125,
-0.6796875,
0.376220703125,
0.955078125,
-0.1326904296875,
0.031463623046875,
0.494384765625,
0.1141357421875,
-0.0966796875,
0.07122802734375,
0.2188720703125,
-0.10382080078125,
-0.57568359375,
0.80419921875,
-0.37548828125,
0.12353515625,
-0.174072265625,
0.349609375,
0.25830078125,
0.5947265625,
-0.4951171875,
-0.716796875,
-0.158447265625,
1.01953125,
-0.175537109375,
-0.116455078125,
-0.168212890625,
0.54443359375,
0.7216796875,
0.9873046875,
0.471435546875,
0.20361328125,
0.822265625,
0.76806640625,
0.037933349609375,
0.43115234375,
-0.203369140625,
0.2034912109375,
0.3046875,
0.6474609375,
0.1021728515625,
0.2354736328125,
-0.1512451171875,
-0.061676025390625,
-0.493896484375,
0.1932373046875,
-0.398193359375,
0.74267578125,
0.25927734375,
0.46435546875,
-0.84130859375,
-0.95654296875,
0.19384765625,
0.98779296875,
-1.0146484375,
-0.41943359375,
-0.328125,
-0.1409912109375,
0.29638671875,
0.07037353515625,
0.445068359375,
0.26953125,
0.45703125,
0.5810546875,
-0.169189453125,
-0.2486572265625,
-0.75048828125,
-0.4501953125,
-1.056640625,
-0.400390625,
-0.6923828125,
-0.1917724609375,
0.429931640625,
-1.0400390625,
0.428955078125,
-0.372314453125,
-0.1341552734375,
0.2125244140625,
-0.7451171875,
0.625,
-0.49560546875,
0.580078125,
-0.72021484375,
0.322021484375,
0.262451171875,
0.68701171875,
-0.544921875,
0.207763671875,
0.030975341796875,
-0.96484375,
0.033905029296875,
-0.21728515625,
0.47509765625,
0.2489013671875,
-0.80322265625,
-0.330322265625,
-0.35107421875,
-0.0828857421875,
-0.364990234375,
-0.03228759765625,
-0.73388671875,
0.463134765625,
0.83251953125,
-0.5048828125,
0.72021484375,
0.8857421875,
-1.166015625,
0.58544921875,
0.51611328125,
-0.0245513916015625,
-0.92919921875,
0.91552734375,
0.452880859375,
0.68603515625,
-0.67041015625,
-0.037384033203125,
-0.7861328125,
0.2017822265625,
0.397705078125,
-0.59619140625,
-0.56298828125,
0.63623046875,
0.183349609375,
-1.017578125,
0.5009765625,
-1.0751953125,
-0.4248046875,
-0.42724609375,
-0.157958984375,
0.85107421875,
0.88916015625,
0.4130859375,
-0.326416015625,
-0.369873046875,
-0.1259765625,
0.56884765625,
0.57080078125,
-0.34765625,
0.08477783203125,
1.01171875,
0.1810302734375,
-0.038604736328125,
0.378662109375,
-0.285888671875,
0.46240234375,
-0.4189453125,
-0.0180511474609375,
0.26904296875,
0.54248046875,
0.0938720703125,
0.4560546875,
0.85009765625,
-1.0263671875,
-0.156494140625,
-0.256103515625,
0.92236328125,
0.72412109375,
0.47314453125,
0.35595703125,
-0.23291015625,
-0.513671875,
-1.2021484375,
0.337646484375,
0.5712890625,
0.98974609375,
-0.94189453125,
0.29931640625,
-0.1939697265625,
-0.447509765625,
0.66748046875,
-0.7626953125,
0.174072265625,
1.2265625,
-0.045501708984375,
1.0849609375,
-0.414794921875,
0.277099609375,
-0.0168304443359375,
0.1712646484375,
0.68359375,
0.34765625,
0.210693359375,
-0.4462890625,
-0.7392578125,
-0.275390625,
-0.1630859375,
-0.26025390625,
-0.3359375,
0.1710205078125,
-0.15087890625,
-0.382568359375,
-0.65966796875,
0.12005615234375,
0.64013671875,
0.89892578125,
0.1654052734375,
0.459228515625,
0.1612548828125,
0.71875,
0.388671875,
-0.3486328125,
0.16552734375,
-0.705078125,
0.75244140625,
-0.203857421875,
-0.2357177734375,
-0.52587890625,
-0.012847900390625,
-0.21630859375,
0.226806640625,
-0.1495361328125,
-0.143798828125,
-1.001953125,
0.51611328125,
-0.1510009765625,
0.361328125,
-0.6689453125,
-0.25146484375,
-0.60205078125,
0.57958984375,
0.250732421875,
-0.548828125,
0.341064453125,
-0.53369140625,
0.72021484375,
0.59814453125,
-0.11688232421875,
-0.59423828125,
-0.338623046875,
-0.81201171875,
-0.248046875,
0.0254364013671875,
0.560546875,
-0.291015625,
0.0206298828125,
-0.99658203125,
0.46435546875,
-0.164306640625,
-0.10430908203125,
0.033111572265625,
-0.33837890625,
0.353515625,
0.274658203125,
0.7890625,
-0.481201171875,
-0.96337890625,
-0.063720703125,
-0.75732421875,
0.1614990234375,
-0.213134765625,
-0.0291900634765625,
0.275634765625,
0.254150390625,
0.40087890625,
0.372802734375,
-0.039520263671875,
0.12646484375,
-0.1566162109375,
0.1046142578125,
-0.7958984375,
-0.62646484375,
0.374755859375,
-0.102783203125,
-0.15966796875,
0.2509765625,
-0.0197601318359375,
-0.0467529296875,
0.078125,
0.63232421875,
-0.325927734375,
0.304931640625,
-0.040924072265625,
0.7802734375,
-0.30908203125,
-0.76611328125,
-0.159912109375,
-0.50732421875,
0.5830078125,
-0.2265625,
-1.091796875,
0.201171875,
-0.92236328125,
0.058380126953125,
-0.005519866943359375,
-0.1312255859375,
0.73974609375,
0.1417236328125,
-0.12176513671875,
-0.12347412109375,
-0.298828125,
-0.8662109375,
-0.421142578125,
-0.6318359375,
0.0909423828125,
0.31640625,
0.560546875,
1.2412109375,
0.10919189453125,
-0.161376953125,
0.1162109375,
0.320556640625,
0.04254150390625,
-0.320068359375,
-0.06060791015625,
-0.2041015625,
-0.163330078125,
-0.248779296875,
0.49365234375,
-0.37158203125,
0.373046875,
0.7998046875,
0.1474609375,
0.611328125,
0.0928955078125,
-0.7275390625,
0.364501953125,
0.0009765625,
-1.0009765625,
-0.361328125,
0.3583984375,
-0.1358642578125,
0.78125,
0.84619140625,
-0.65087890625,
-1.0234375,
-0.80078125,
0.09619140625,
-0.484130859375,
-0.4072265625,
-0.99609375,
-0.40380859375,
-0.5517578125,
0.5693359375,
-0.2259521484375,
-0.537109375,
-0.305908203125,
-0.92138671875,
0.392822265625,
-0.5810546875,
-0.818359375,
-0.529296875,
-0.1722412109375,
-0.09100341796875,
0.7236328125,
0.306396484375,
0.216552734375,
-0.408935546875,
-0.2333984375,
0.2281494140625,
0.304443359375,
-0.64013671875,
-0.1949462890625,
-0.277099609375,
-0.2415771484375,
-0.376708984375,
-0.10430908203125,
-0.42529296875,
1.02734375,
-0.54833984375,
0.026641845703125,
-0.12139892578125,
-0.61865234375,
-0.2890625,
0.02508544921875,
0.61083984375,
-0.2352294921875,
-0.221923828125,
0.0316162109375,
0.72216796875,
0.63623046875,
-0.63916015625,
-0.301513671875,
-0.7470703125,
-0.521484375,
-0.74462890625,
0.168212890625,
-0.72021484375,
0.123046875,
-0.1287841796875,
-0.27880859375,
0.8408203125,
-0.63037109375,
0.259765625,
1.2470703125,
-0.0123443603515625,
0.36962890625,
-0.619140625,
0.86474609375,
0.322021484375,
-0.5908203125,
-0.07574462890625,
-0.2464599609375,
-0.5029296875,
0.03729248046875,
-0.221923828125,
-1.330078125,
-0.8984375,
0.056060791015625,
1.08984375,
-0.397705078125,
0.98779296875,
0.02325439453125,
-1.1552734375,
-1.173828125,
0.71240234375,
-0.057525634765625,
0.350341796875,
1.005859375,
0.061279296875,
-0.061920166015625,
0.408203125,
-0.0234375,
0.364990234375,
-0.96875,
1.021484375,
0.156494140625,
-0.470947265625,
0.701171875,
1.0185546875,
-1.2802734375,
-0.64306640625,
0.2822265625,
-0.4677734375,
-0.343017578125,
-0.4462890625,
-0.06085205078125,
0.3896484375,
-0.72021484375,
-0.08642578125,
-0.033660888671875,
0.054779052734375,
0.42236328125,
-0.306396484375,
0.381591796875,
-0.2841796875,
0.81591796875,
0.8544921875,
-0.5732421875,
-0.033355712890625,
-0.736328125,
-0.272216796875,
-0.591796875,
0.275390625,
0.92041015625,
-0.53271484375,
0.0005879402160644531,
0.7763671875,
-0.1876220703125,
1.3935546875,
-0.12225341796875,
-0.0836181640625,
0.452880859375,
-0.74609375,
-0.7333984375,
0.218017578125,
0.408447265625,
-0.40185546875,
0.56298828125,
-0.279052734375,
0.289306640625,
0.06585693359375,
0.408203125,
0.05865478515625,
-0.74755859375,
-0.277587890625,
-0.8291015625,
-0.132080078125,
-0.451171875,
-0.09576416015625,
-0.290283203125,
-0.054107666015625,
0.1199951171875,
-0.479736328125,
-0.02655029296875,
0.58056640625,
-0.2071533203125,
0.189453125,
-0.794921875,
0.2021484375,
-0.91796875,
-0.74560546875,
-0.69140625,
-0.147216796875,
-0.290283203125,
0.0158538818359375,
-0.61962890625,
0.1851806640625,
-0.3623046875,
0.669921875,
-0.146240234375,
0.42626953125,
-0.1534423828125,
-0.8310546875,
-0.06610107421875,
0.0167083740234375,
-0.105712890625,
0.291748046875,
0.441650390625,
-0.1976318359375,
0.1138916015625,
-0.259765625,
-0.321044921875,
-0.0189208984375,
-0.12249755859375,
0.8623046875,
-0.0232086181640625,
-0.1224365234375,
-0.3447265625,
0.1844482421875,
-1.115234375,
0.3115234375,
-0.0936279296875,
-0.00543975830078125,
0.147705078125,
-0.1546630859375,
0.96240234375,
0.6923828125,
-0.4658203125,
0.2218017578125,
-0.0465087890625,
0.099853515625,
0.509765625,
0.086669921875,
0.22119140625,
-0.09576416015625,
0.4306640625,
-0.1229248046875,
0.08160400390625,
0.296630859375,
-0.10400390625,
0.486083984375,
-0.2490234375,
-0.5302734375,
-1.111328125,
-0.1844482421875,
0.264892578125,
0.191650390625,
-0.15771484375,
-0.313232421875,
0.25634765625,
0.149658203125,
-0.6650390625,
0.44384765625,
-1.373046875,
-0.712890625,
0.9501953125,
-0.28564453125,
-0.62548828125,
-0.8291015625,
-0.67626953125,
-0.003246307373046875,
0.0992431640625,
0.485107421875,
-0.50146484375,
0.55078125,
0.037994384765625,
0.7216796875,
-0.283447265625,
-0.29052734375,
0.0760498046875,
0.360595703125,
-0.81884765625,
-0.52294921875,
0.4072265625,
0.69091796875,
-0.03424072265625,
-0.19482421875,
-0.8173828125,
0.355712890625,
0.006038665771484375,
-0.39501953125,
-0.47705078125,
0.377685546875,
-0.20263671875,
0.46826171875,
-0.822265625,
-0.1090087890625,
-0.1097412109375,
-0.00875091552734375,
0.43359375,
-0.398681640625,
-0.31396484375,
0.496337890625,
0.83447265625,
-0.498291015625,
0.294921875,
0.188232421875,
0.4169921875,
0.00415802001953125,
-0.209716796875,
0.1427001953125,
0.8916015625,
0.74072265625,
0.50146484375,
-0.12841796875,
0.5908203125,
0.404296875,
-0.1533203125,
-0.1939697265625,
0.212890625,
0.48291015625,
-0.48974609375,
0.501953125,
0.06640625,
-0.1910400390625,
0.00856781005859375,
-0.488037109375,
0.365966796875,
-0.007053375244140625,
-0.38134765625,
-0.6865234375,
-0.8251953125,
0.56494140625,
-0.2052001953125,
0.374755859375,
0.26904296875,
-0.39111328125,
0.2481689453125,
0.884765625,
-0.1549072265625,
-0.335205078125,
0.93505859375,
0.51171875,
0.1927490234375,
0.79736328125,
0.0303955078125,
0.354248046875,
-1.0048828125,
0.64013671875,
0.20068359375,
-0.16357421875,
-0.40283203125,
-0.71728515625,
-0.98681640625,
0.59423828125,
-0.47119140625,
-0.178955078125,
0.97607421875,
-0.72998046875,
0.286865234375,
-0.2359619140625,
0.642578125,
-0.44580078125,
-0.0423583984375,
0.304443359375,
-0.5498046875,
-0.171875,
1.1162109375,
-0.318603515625,
0.398193359375,
0.05133056640625,
1.0029296875,
0.387451171875,
1.7138671875,
0.287109375,
-0.34375,
0.1494140625,
0.1373291015625,
-0.146728515625,
-0.6357421875,
-0.60302734375,
-0.298095703125,
0.2393798828125,
-0.5732421875,
-0.464599609375,
-0.274169921875,
0.73681640625,
0.11175537109375,
-1.40234375,
-0.1666259765625,
0.162841796875,
-0.9140625,
0.31787109375,
0.6162109375,
0.391845703125,
0.26318359375,
-0.12939453125,
0.24755859375,
-0.49853515625,
0.0716552734375,
-0.364501953125,
0.41259765625,
-0.22412109375,
-0.65673828125,
-0.4873046875,
-0.89111328125,
0.28515625,
-0.4453125,
-0.60400390625,
-0.58349609375,
0.317626953125,
1.072265625,
0.4501953125,
0.59619140625,
-0.5107421875,
-0.19873046875,
0.76318359375,
1.0556640625,
0.08355712890625,
0.505859375,
0.0247039794921875,
-0.1251220703125,
0.456787109375,
-0.44921875,
0.00852203369140625,
0.298828125,
-0.0712890625,
-0.3779296875,
-0.02117919921875,
-0.367919921875,
-1.2734375,
0.4794921875,
0.978515625,
0.3154296875,
-0.49755859375,
-1.064453125,
-0.343994140625,
-1.1552734375,
-0.026702880859375,
-0.53466796875,
0.57080078125,
0.05438232421875,
-0.27783203125,
0.095947265625,
-1.1884765625,
4.41015625,
0.9208984375,
0.87255859375,
0.178466796875,
-0.0634765625,
0.91357421875,
0.728515625,
-0.796875,
-0.005035400390625,
-0.31494140625,
0.493408203125,
-0.78564453125,
0.38916015625,
0.86767578125,
0.242431640625,
0.299560546875,
-0.28125,
0.031280517578125,
-0.0110321044921875,
-0.99755859375,
-0.9189453125,
-0.01085662841796875,
-0.1121826171875,
0.6943359375,
0.224609375,
0.4033203125,
0.291748046875,
-0.41845703125,
-0.12359619140625,
-0.76953125,
0.051177978515625,
-0.52197265625,
0.92431640625,
0.1502685546875,
-0.290283203125,
0.51025390625,
0.09619140625,
-0.79541015625,
-0.239990234375,
0.1671142578125,
-0.09173583984375,
-0.322265625,
0.478759765625,
-0.69140625,
0.36962890625,
0.501953125,
-0.4287109375,
0.332763671875,
0.85009765625,
-0.76123046875,
1.015625,
-0.1279296875,
0.288818359375,
-0.6240234375,
-0.99755859375,
0.58349609375,
0.105224609375,
0.01261138916015625,
-0.63427734375,
0.424072265625,
0.45751953125,
0.450439453125,
-0.1085205078125,
0.2327880859375,
-0.87890625,
0.9755859375,
-0.40234375,
0.85546875,
-0.45458984375,
-0.180419921875,
-0.1898193359375,
-0.4013671875,
-0.34814453125,
-0.5166015625,
0.72509765625,
0.2001953125,
-0.126220703125,
0.54345703125,
0.53515625,
-0.64990234375,
-0.09002685546875,
-0.25634765625,
-0.478515625,
-0.5947265625,
0.45361328125,
1.1904296875,
-0.4375,
-0.6904296875,
-0.52099609375,
0.76806640625,
0.669921875,
0.1805419921875,
-0.1046142578125,
-0.1761474609375,
-0.2685546875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where
* <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
* <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
* <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.
The content of square brackets is optional — it can be present or can be absent.
There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.
Your task is to write program which checks if given string is a correct Jabber ID.
Input
The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.
Output
Print YES or NO.
Examples
Input
mike@codeforces.com
Output
YES
Input
john.smith@codeforces.ru/contest.icpc/12
Output
NO
Tags: implementation, strings
Correct Solution:
```
try:
result = True
jabber_id = input().lower().replace("/n", "")
username = jabber_id.split("@", 1)[0]
hostname = jabber_id.split("@", 1)[1].split("/")[0]
try:
resource = jabber_id.split("@", 1)[1].split("/", 1)[1]
if not resource:
result = False
except:
resource = ""
usp = 'abcdefghijklmnopqrstuvwxyz_1234567890'
uhp = 'abcdefghijklmnopqrstuvwxyz_1234567890.'
for c in username:
if not c in usp:
#print("1")
result = False
for c in hostname:
if not c in uhp:
#print("2")
result = False
for c in resource:
if not c in usp:
#print("3")
result = False
if not( len(username)<=16 and len(username)>0):
#print("4")
result = False
if not( len(hostname)<=32 and len(hostname)>0):
#print("5")
result = False
if not len(resource)<=16:
#print("6")
result = False
#print(hostname.split("."))
for h in hostname.split("."):
if len(h)==0:
#print("7")
result = False
if resource:
for h in resource.split("/"):
if len(h)==0:
#print("8")
result = False
if result:
print("YES")
else:
print("NO")
except:
print("NO")
#print(username, " ", hostname, " ", resource)
```
| 71,026 | [
0.517578125,
-0.04302978515625,
-0.2047119140625,
0.5078125,
0.010498046875,
-0.52685546875,
0.033660888671875,
-0.2235107421875,
0.2373046875,
0.4658203125,
0.450439453125,
-0.0010023117065429688,
0.0848388671875,
-0.91064453125,
-0.580078125,
-0.07275390625,
-0.53369140625,
-0.93408203125,
-0.30615234375,
-0.463134765625,
0.2783203125,
0.06591796875,
-1.236328125,
-0.1859130859375,
-0.5244140625,
0.68115234375,
0.155517578125,
0.3623046875,
0.96630859375,
0.62841796875,
-0.0655517578125,
-0.68310546875,
0.423583984375,
-1,
-0.354736328125,
-0.23828125,
0.409912109375,
-1.0283203125,
-0.6220703125,
-0.44140625,
0.1685791015625,
-0.302001953125,
0.1820068359375,
-1.05078125,
-1.083984375,
0.1983642578125,
-0.5244140625,
-0.01348876953125,
-0.00203704833984375,
-0.59814453125,
0.22509765625,
-0.09857177734375,
0.74853515625,
-0.476806640625,
-0.1837158203125,
-0.296875,
-0.316162109375,
0.08697509765625,
-0.74072265625,
0.087890625,
-0.091552734375,
0.460693359375,
-0.0362548828125,
-0.7353515625,
-0.03399658203125,
0.040130615234375,
0.0386962890625,
-0.2132568359375,
-0.14892578125,
-0.9140625,
-0.0753173828125,
0.370849609375,
-0.65771484375,
-0.69580078125,
-0.1363525390625,
0.012908935546875,
0.276611328125,
-0.1156005859375,
-0.2198486328125,
0.65966796875,
-0.06805419921875,
1.3349609375,
0.382080078125,
0.1534423828125,
-0.75390625,
-0.432373046875,
0.33349609375,
0.44384765625,
0.244384765625,
-0.18359375,
-0.3056640625,
0.447021484375,
-0.54052734375,
0.228759765625,
0.53271484375,
0.71826171875,
0.1151123046875,
0.65234375,
0.07794189453125,
0.256591796875,
0.57373046875,
0.98779296875,
-0.340576171875,
1.0830078125,
-0.40673828125,
0.2188720703125,
0.5400390625,
-0.019195556640625,
-0.62109375,
-0.35009765625,
-0.1383056640625,
-0.76708984375,
0.3466796875,
0.07720947265625,
-0.307373046875,
0.47265625,
0.0240631103515625,
0.50146484375,
-1.1328125,
-0.007598876953125,
0.41796875,
-0.415771484375,
0.65234375,
-0.3671875,
-0.0841064453125,
-0.35546875,
-0.6015625,
1.0498046875,
-0.3154296875,
-0.108154296875,
0.338623046875,
-0.0667724609375,
-0.2802734375,
-0.1641845703125,
0.2186279296875,
0.89306640625,
-0.06292724609375,
0.60205078125,
1.029296875,
-1.009765625,
0.66845703125,
0.19775390625,
0.0994873046875,
1.71484375,
0.499755859375,
0.14453125,
0.57568359375,
0.25830078125,
-0.58642578125,
0.0908203125,
-0.89794921875,
0.89892578125,
0.473876953125,
0.2269287109375,
-0.2587890625,
0.29345703125,
-0.050262451171875,
0.68505859375,
0.1812744140625,
-0.07952880859375,
-0.41943359375,
0.50146484375,
-0.08575439453125,
0.94384765625,
-0.11602783203125,
0.48681640625,
0.00833892822265625,
-0.2437744140625,
0.459228515625,
-0.64453125,
0.517578125,
-0.1693115234375,
0.18115234375,
0.79638671875,
0.53369140625,
0.86474609375,
0.96826171875,
-0.1812744140625,
0.447509765625,
0.453125,
-0.5673828125,
0.3515625,
0.12359619140625,
1.0634765625,
0.0318603515625,
0.063232421875,
0.312255859375,
-0.50537109375,
-1.1640625,
-0.66015625,
0.161376953125,
0.294921875,
-0.38818359375,
0.4228515625,
0.447021484375,
-0.09759521484375,
-0.15966796875,
-0.1251220703125,
0.11749267578125,
-1.0224609375,
-0.040771484375,
0.82958984375,
-0.2303466796875,
0.3916015625,
0.10455322265625,
-0.7021484375,
0.390869140625,
0.9375,
-0.1614990234375,
0.07745361328125,
0.5419921875,
0.158203125,
-0.075927734375,
0.0306854248046875,
0.199951171875,
-0.1175537109375,
-0.56884765625,
0.833984375,
-0.34765625,
0.06842041015625,
-0.165771484375,
0.334716796875,
0.28662109375,
0.58935546875,
-0.56298828125,
-0.68017578125,
-0.1961669921875,
1.0185546875,
-0.1971435546875,
-0.2044677734375,
-0.1522216796875,
0.53759765625,
0.77197265625,
1.005859375,
0.50341796875,
0.260009765625,
0.78564453125,
0.8369140625,
0.01480865478515625,
0.4267578125,
-0.1595458984375,
0.2357177734375,
0.288330078125,
0.7373046875,
0.1290283203125,
0.181640625,
-0.1353759765625,
-0.0589599609375,
-0.515625,
0.2186279296875,
-0.40283203125,
0.77490234375,
0.1622314453125,
0.51513671875,
-0.8173828125,
-0.98828125,
0.175537109375,
0.96142578125,
-0.98876953125,
-0.37548828125,
-0.335693359375,
-0.1195068359375,
0.224853515625,
0.1456298828125,
0.51904296875,
0.30908203125,
0.40380859375,
0.61865234375,
-0.12200927734375,
-0.2210693359375,
-0.74609375,
-0.4658203125,
-1.056640625,
-0.3935546875,
-0.697265625,
-0.218994140625,
0.427490234375,
-1.0849609375,
0.40283203125,
-0.385009765625,
-0.119140625,
0.23583984375,
-0.76318359375,
0.70068359375,
-0.4853515625,
0.59619140625,
-0.78125,
0.3759765625,
0.254638671875,
0.681640625,
-0.54833984375,
0.1951904296875,
0.035552978515625,
-0.95166015625,
0.01032257080078125,
-0.24755859375,
0.5,
0.273681640625,
-0.7890625,
-0.39111328125,
-0.369873046875,
-0.04949951171875,
-0.46826171875,
-0.0029125213623046875,
-0.73779296875,
0.481689453125,
0.8232421875,
-0.467041015625,
0.765625,
0.912109375,
-1.1875,
0.72705078125,
0.53564453125,
0.01186370849609375,
-0.95458984375,
0.921875,
0.4296875,
0.68408203125,
-0.62646484375,
-0.0291748046875,
-0.7548828125,
0.1939697265625,
0.375,
-0.57763671875,
-0.544921875,
0.67724609375,
0.26416015625,
-1.0693359375,
0.400634765625,
-1.0595703125,
-0.330078125,
-0.450439453125,
-0.149169921875,
0.8779296875,
0.87646484375,
0.390625,
-0.329833984375,
-0.40771484375,
-0.120849609375,
0.544921875,
0.5927734375,
-0.38232421875,
0.1002197265625,
1.0927734375,
0.1507568359375,
0.025360107421875,
0.3984375,
-0.335693359375,
0.463623046875,
-0.443115234375,
0.006381988525390625,
0.2548828125,
0.54833984375,
0.138916015625,
0.477294921875,
0.82861328125,
-1.0546875,
-0.20654296875,
-0.26904296875,
0.888671875,
0.73095703125,
0.410400390625,
0.400634765625,
-0.298828125,
-0.50244140625,
-1.2353515625,
0.304931640625,
0.5224609375,
1.0478515625,
-0.9814453125,
0.34130859375,
-0.1817626953125,
-0.43896484375,
0.6630859375,
-0.76416015625,
0.1923828125,
1.2841796875,
-0.060394287109375,
1.02734375,
-0.468017578125,
0.309814453125,
-0.042510986328125,
0.220458984375,
0.69873046875,
0.32421875,
0.2225341796875,
-0.4697265625,
-0.73876953125,
-0.256591796875,
-0.2275390625,
-0.26220703125,
-0.39794921875,
0.156005859375,
-0.1705322265625,
-0.407470703125,
-0.68994140625,
0.1798095703125,
0.69287109375,
0.94677734375,
0.138671875,
0.52197265625,
0.1710205078125,
0.75439453125,
0.3876953125,
-0.32861328125,
0.1407470703125,
-0.703125,
0.79345703125,
-0.11676025390625,
-0.192138671875,
-0.50537109375,
-0.01316070556640625,
-0.287353515625,
0.1929931640625,
-0.1964111328125,
-0.12225341796875,
-1.0400390625,
0.5205078125,
-0.1568603515625,
0.348876953125,
-0.6171875,
-0.227294921875,
-0.67041015625,
0.56396484375,
0.287109375,
-0.55078125,
0.31689453125,
-0.5087890625,
0.75341796875,
0.61181640625,
-0.1326904296875,
-0.638671875,
-0.361083984375,
-0.8330078125,
-0.2216796875,
0.0501708984375,
0.55810546875,
-0.322998046875,
0.036041259765625,
-0.9404296875,
0.496337890625,
-0.1827392578125,
-0.1107177734375,
0.0238189697265625,
-0.392822265625,
0.34521484375,
0.268798828125,
0.7978515625,
-0.484619140625,
-1.0341796875,
-0.06793212890625,
-0.74560546875,
0.153564453125,
-0.291748046875,
0.0094757080078125,
0.2152099609375,
0.2369384765625,
0.359619140625,
0.377685546875,
-0.0128936767578125,
0.126708984375,
-0.126220703125,
0.10955810546875,
-0.83203125,
-0.61669921875,
0.367431640625,
-0.07305908203125,
-0.19921875,
0.273681640625,
-0.006603240966796875,
-0.12335205078125,
0.0894775390625,
0.6005859375,
-0.349609375,
0.25,
-0.10150146484375,
0.7470703125,
-0.301025390625,
-0.70751953125,
-0.1304931640625,
-0.5078125,
0.64697265625,
-0.1715087890625,
-1.0654296875,
0.1705322265625,
-0.93408203125,
0.1024169921875,
-0.0000022649765014648438,
-0.162353515625,
0.76513671875,
0.11920166015625,
-0.120361328125,
-0.109619140625,
-0.3203125,
-0.8671875,
-0.40478515625,
-0.66455078125,
0.0972900390625,
0.324462890625,
0.5078125,
1.275390625,
0.0791015625,
-0.1468505859375,
0.07928466796875,
0.2841796875,
0.04364013671875,
-0.3740234375,
-0.12261962890625,
-0.1942138671875,
-0.09979248046875,
-0.323486328125,
0.490234375,
-0.365478515625,
0.387939453125,
0.796875,
0.133056640625,
0.69091796875,
0.037078857421875,
-0.7744140625,
0.39453125,
-0.0150909423828125,
-1.009765625,
-0.329345703125,
0.3955078125,
-0.1588134765625,
0.79443359375,
0.81103515625,
-0.6376953125,
-1.00390625,
-0.8076171875,
0.1092529296875,
-0.50927734375,
-0.426513671875,
-1.0419921875,
-0.41455078125,
-0.54638671875,
0.5947265625,
-0.22021484375,
-0.6044921875,
-0.202880859375,
-0.86962890625,
0.2890625,
-0.611328125,
-0.82568359375,
-0.5107421875,
-0.09796142578125,
-0.041229248046875,
0.73583984375,
0.32666015625,
0.205078125,
-0.404052734375,
-0.222412109375,
0.221923828125,
0.355224609375,
-0.71533203125,
-0.1513671875,
-0.3115234375,
-0.3046875,
-0.35546875,
-0.06182861328125,
-0.46142578125,
0.94970703125,
-0.5458984375,
0.03521728515625,
-0.044342041015625,
-0.56103515625,
-0.321044921875,
-0.01197052001953125,
0.55908203125,
-0.19873046875,
-0.2064208984375,
0.0003979206085205078,
0.7099609375,
0.66259765625,
-0.62060546875,
-0.31689453125,
-0.72119140625,
-0.5400390625,
-0.73486328125,
0.24951171875,
-0.73974609375,
0.08465576171875,
-0.05010986328125,
-0.315673828125,
0.85107421875,
-0.6201171875,
0.322265625,
1.1884765625,
-0.056732177734375,
0.395751953125,
-0.64697265625,
0.8623046875,
0.372314453125,
-0.64111328125,
-0.0780029296875,
-0.260009765625,
-0.53662109375,
0.046112060546875,
-0.2476806640625,
-1.361328125,
-0.96044921875,
0.0156707763671875,
1.1337890625,
-0.40869140625,
1.0576171875,
0.0245208740234375,
-1.15625,
-1.1767578125,
0.71630859375,
-0.036468505859375,
0.27294921875,
1.0009765625,
0.0875244140625,
-0.04278564453125,
0.454345703125,
-0.035308837890625,
0.40234375,
-0.9208984375,
1.1171875,
0.260009765625,
-0.374755859375,
0.6904296875,
1.0341796875,
-1.349609375,
-0.626953125,
0.2279052734375,
-0.471435546875,
-0.38134765625,
-0.5009765625,
-0.09246826171875,
0.391357421875,
-0.7451171875,
-0.0931396484375,
-0.00811767578125,
0.08428955078125,
0.451171875,
-0.290283203125,
0.40234375,
-0.30859375,
0.79833984375,
0.8916015625,
-0.60595703125,
-0.04327392578125,
-0.69970703125,
-0.347412109375,
-0.54443359375,
0.30859375,
0.91455078125,
-0.578125,
0.0323486328125,
0.7880859375,
-0.1751708984375,
1.4423828125,
-0.14697265625,
-0.10430908203125,
0.442138671875,
-0.7548828125,
-0.724609375,
0.1937255859375,
0.434814453125,
-0.440673828125,
0.59716796875,
-0.35009765625,
0.2666015625,
0.032806396484375,
0.446533203125,
0.064697265625,
-0.7822265625,
-0.25390625,
-0.8447265625,
-0.148193359375,
-0.485107421875,
-0.09259033203125,
-0.29638671875,
-0.050445556640625,
0.1026611328125,
-0.473388671875,
-0.039459228515625,
0.560546875,
-0.153564453125,
0.151123046875,
-0.8056640625,
0.182861328125,
-0.93212890625,
-0.75146484375,
-0.7578125,
-0.1551513671875,
-0.306640625,
0.0469970703125,
-0.64697265625,
0.20654296875,
-0.464111328125,
0.71630859375,
-0.1136474609375,
0.43408203125,
-0.135009765625,
-0.87060546875,
-0.08734130859375,
0.051300048828125,
-0.17138671875,
0.32275390625,
0.460693359375,
-0.1839599609375,
0.2110595703125,
-0.307373046875,
-0.30126953125,
-0.030609130859375,
-0.10479736328125,
0.84130859375,
0.01161956787109375,
-0.1358642578125,
-0.41259765625,
0.154296875,
-1.08984375,
0.2958984375,
-0.123046875,
-0.034576416015625,
0.1424560546875,
-0.155517578125,
0.88671875,
0.72314453125,
-0.50146484375,
0.2156982421875,
-0.1231689453125,
0.1678466796875,
0.5029296875,
0.078125,
0.1483154296875,
-0.04345703125,
0.3876953125,
-0.09332275390625,
0.135009765625,
0.3046875,
-0.177490234375,
0.465576171875,
-0.3125,
-0.48828125,
-1.09375,
-0.2491455078125,
0.2308349609375,
0.204833984375,
-0.1588134765625,
-0.327880859375,
0.30712890625,
0.1314697265625,
-0.66357421875,
0.491943359375,
-1.306640625,
-0.7783203125,
1.015625,
-0.298828125,
-0.57470703125,
-0.865234375,
-0.69677734375,
-0.0160980224609375,
0.07373046875,
0.444091796875,
-0.495361328125,
0.5634765625,
0.097900390625,
0.7646484375,
-0.2880859375,
-0.33349609375,
0.08001708984375,
0.3935546875,
-0.85888671875,
-0.56787109375,
0.3564453125,
0.65625,
-0.011566162109375,
-0.199462890625,
-0.7119140625,
0.359130859375,
-0.048004150390625,
-0.2822265625,
-0.52099609375,
0.351318359375,
-0.1444091796875,
0.51171875,
-0.78369140625,
-0.08001708984375,
-0.161376953125,
-0.0178070068359375,
0.45556640625,
-0.475830078125,
-0.354248046875,
0.53173828125,
0.861328125,
-0.5576171875,
0.309814453125,
0.1287841796875,
0.389892578125,
-0.00930023193359375,
-0.1644287109375,
0.063232421875,
0.849609375,
0.72802734375,
0.54443359375,
-0.073974609375,
0.666015625,
0.4052734375,
-0.1549072265625,
-0.1973876953125,
0.290283203125,
0.454833984375,
-0.501953125,
0.482666015625,
0.023895263671875,
-0.2178955078125,
0.0015888214111328125,
-0.422607421875,
0.34716796875,
-0.0285491943359375,
-0.37353515625,
-0.72509765625,
-0.7900390625,
0.615234375,
-0.1439208984375,
0.301025390625,
0.2412109375,
-0.382080078125,
0.2103271484375,
0.9208984375,
-0.1435546875,
-0.327880859375,
0.9619140625,
0.48974609375,
0.1510009765625,
0.734375,
0.01560211181640625,
0.36572265625,
-0.966796875,
0.60302734375,
0.1689453125,
-0.11968994140625,
-0.38916015625,
-0.6943359375,
-1.0068359375,
0.58251953125,
-0.5048828125,
-0.1707763671875,
1.0009765625,
-0.77783203125,
0.2666015625,
-0.2685546875,
0.61474609375,
-0.44384765625,
-0.0097808837890625,
0.287841796875,
-0.55029296875,
-0.1705322265625,
1.130859375,
-0.3056640625,
0.365478515625,
0.033721923828125,
1.033203125,
0.38427734375,
1.6611328125,
0.267822265625,
-0.375732421875,
0.1251220703125,
0.1558837890625,
-0.17822265625,
-0.64013671875,
-0.56103515625,
-0.2783203125,
0.27783203125,
-0.58984375,
-0.544921875,
-0.239013671875,
0.814453125,
0.08135986328125,
-1.3984375,
-0.1888427734375,
0.248779296875,
-0.951171875,
0.324462890625,
0.6240234375,
0.380615234375,
0.349853515625,
-0.1978759765625,
0.261962890625,
-0.50048828125,
0.1378173828125,
-0.349853515625,
0.42578125,
-0.1488037109375,
-0.64990234375,
-0.472412109375,
-0.8583984375,
0.286376953125,
-0.484375,
-0.59716796875,
-0.544921875,
0.331787109375,
1.037109375,
0.4072265625,
0.61962890625,
-0.52978515625,
-0.2301025390625,
0.8369140625,
1.052734375,
0.0804443359375,
0.50244140625,
0.01416778564453125,
-0.146240234375,
0.470703125,
-0.38623046875,
-0.0088348388671875,
0.3447265625,
-0.10186767578125,
-0.295654296875,
0.00897216796875,
-0.379150390625,
-1.271484375,
0.44873046875,
0.95654296875,
0.30078125,
-0.59716796875,
-1.1142578125,
-0.382080078125,
-1.06640625,
-0.04986572265625,
-0.59375,
0.52490234375,
-0.016937255859375,
-0.258544921875,
0.0631103515625,
-1.1806640625,
4.3515625,
0.9228515625,
0.8759765625,
0.181640625,
-0.051116943359375,
0.95166015625,
0.71728515625,
-0.76806640625,
-0.00255584716796875,
-0.319580078125,
0.472900390625,
-0.75244140625,
0.405029296875,
0.98974609375,
0.29736328125,
0.333251953125,
-0.382080078125,
0.051849365234375,
0.02215576171875,
-0.95068359375,
-0.93017578125,
-0.087158203125,
-0.043975830078125,
0.6826171875,
0.207275390625,
0.408203125,
0.25390625,
-0.396728515625,
-0.12420654296875,
-0.80615234375,
0.06365966796875,
-0.5302734375,
0.9189453125,
0.1287841796875,
-0.256591796875,
0.458251953125,
0.113037109375,
-0.826171875,
-0.1976318359375,
0.1627197265625,
-0.08331298828125,
-0.32373046875,
0.438232421875,
-0.6708984375,
0.364990234375,
0.440185546875,
-0.430908203125,
0.32958984375,
0.8857421875,
-0.83251953125,
1.044921875,
-0.1087646484375,
0.2401123046875,
-0.64013671875,
-0.92626953125,
0.62841796875,
0.0467529296875,
0.061737060546875,
-0.60400390625,
0.45556640625,
0.471435546875,
0.48193359375,
-0.153564453125,
0.267333984375,
-0.9072265625,
0.98046875,
-0.401611328125,
0.85888671875,
-0.462158203125,
-0.256591796875,
-0.29052734375,
-0.4365234375,
-0.379150390625,
-0.56494140625,
0.759765625,
0.218017578125,
-0.1588134765625,
0.5546875,
0.611328125,
-0.66748046875,
-0.08203125,
-0.306396484375,
-0.48876953125,
-0.5498046875,
0.48486328125,
1.224609375,
-0.380859375,
-0.681640625,
-0.489013671875,
0.7509765625,
0.646484375,
0.206298828125,
-0.109130859375,
-0.11639404296875,
-0.29052734375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where
* <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
* <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
* <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.
The content of square brackets is optional — it can be present or can be absent.
There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.
Your task is to write program which checks if given string is a correct Jabber ID.
Input
The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.
Output
Print YES or NO.
Examples
Input
mike@codeforces.com
Output
YES
Input
john.smith@codeforces.ru/contest.icpc/12
Output
NO
Tags: implementation, strings
Correct Solution:
```
def check(txt: str) -> bool:
ln = len(txt)
if ln == 0 or ln > 16:
return False
for item in txt:
if not ('a' <= item <= 'z' or
'A' <= item <= 'Z' or
'0' <= item <= '9' or
item == '_'):
return False
return True
def checkHost(hostName: str) -> bool:
hostLen = len(hostName)
if hostLen == 0 or hostLen > 32:
return False
for token in hostName.split('.'):
if not check(token):
return False
return True
mail = input()
isUser, isHost, isRes = False, False, False
if '@' in mail:
atIndex = mail.index('@')
slashInd = mail.index('/') if '/' in mail else -1
userName = mail[:atIndex]
isUser = check(userName)
hostName = mail[atIndex + 1: slashInd] if slashInd != -1 else mail[atIndex + 1:]
isHost = checkHost(hostName)
if slashInd == -1:
isRes = True
else:
resource = mail[slashInd+1:]
isRes = check(resource)
'''
if isUser and isHost and isRes:
print('YES')
else:
print('NO')
'''
print('YES' if isUser and isHost and isRes else 'NO')
```
| 71,027 | [
0.5439453125,
-0.11138916015625,
-0.10638427734375,
0.4951171875,
0.0222320556640625,
-0.52587890625,
0.092529296875,
-0.1954345703125,
0.125,
0.44873046875,
0.4912109375,
0.006526947021484375,
0.062164306640625,
-0.861328125,
-0.681640625,
-0.1337890625,
-0.5693359375,
-0.8935546875,
-0.402099609375,
-0.50341796875,
0.28466796875,
0.10546875,
-1.28515625,
-0.191650390625,
-0.53857421875,
0.666015625,
0.11248779296875,
0.381103515625,
0.98876953125,
0.62255859375,
-0.0615234375,
-0.59375,
0.5078125,
-0.97705078125,
-0.408203125,
-0.41064453125,
0.46826171875,
-1.009765625,
-0.54638671875,
-0.44189453125,
0.09503173828125,
-0.1446533203125,
0.162841796875,
-1.0537109375,
-1.09375,
0.11114501953125,
-0.53857421875,
-0.068359375,
-0.036407470703125,
-0.55615234375,
0.2127685546875,
-0.11846923828125,
0.7294921875,
-0.421875,
-0.2401123046875,
-0.383544921875,
-0.36962890625,
0.1904296875,
-0.66748046875,
0.123779296875,
-0.108154296875,
0.41015625,
-0.0167083740234375,
-0.7353515625,
-0.03399658203125,
0.0235595703125,
0.1065673828125,
-0.1641845703125,
-0.1702880859375,
-0.876953125,
-0.0343017578125,
0.276611328125,
-0.74365234375,
-0.71875,
-0.282958984375,
0.10943603515625,
0.35009765625,
-0.1134033203125,
-0.278564453125,
0.63671875,
-0.08306884765625,
1.287109375,
0.399169921875,
0.192138671875,
-0.8349609375,
-0.466064453125,
0.39013671875,
0.390869140625,
0.324951171875,
-0.2049560546875,
-0.26806640625,
0.304931640625,
-0.52490234375,
0.2568359375,
0.5205078125,
0.61181640625,
0.1856689453125,
0.66357421875,
0.11968994140625,
0.26318359375,
0.564453125,
0.931640625,
-0.307861328125,
1.052734375,
-0.43603515625,
0.2958984375,
0.53076171875,
0.043731689453125,
-0.666015625,
-0.392333984375,
-0.2406005859375,
-0.7783203125,
0.201171875,
0.011383056640625,
-0.330322265625,
0.4462890625,
0.08660888671875,
0.426513671875,
-1.1728515625,
-0.11865234375,
0.46240234375,
-0.30078125,
0.6611328125,
-0.321533203125,
-0.10888671875,
-0.223876953125,
-0.5009765625,
1.0732421875,
-0.337890625,
-0.2462158203125,
0.260498046875,
-0.054473876953125,
-0.249267578125,
-0.08709716796875,
0.202880859375,
0.8515625,
-0.003429412841796875,
0.63671875,
0.984375,
-1.0302734375,
0.68408203125,
0.235595703125,
0.08282470703125,
1.6435546875,
0.396484375,
0.0750732421875,
0.5732421875,
0.22314453125,
-0.59033203125,
0.04156494140625,
-0.87451171875,
0.89697265625,
0.3505859375,
0.221435546875,
-0.240234375,
0.251953125,
-0.00325775146484375,
0.57568359375,
0.04486083984375,
-0.1265869140625,
-0.466796875,
0.446044921875,
-0.1331787109375,
0.921875,
-0.1165771484375,
0.4404296875,
0.00830841064453125,
-0.141357421875,
0.53173828125,
-0.685546875,
0.484130859375,
-0.10443115234375,
0.087890625,
0.8662109375,
0.59765625,
0.77978515625,
0.95751953125,
-0.19580078125,
0.42041015625,
0.482421875,
-0.54345703125,
0.363525390625,
0.04132080078125,
1.0693359375,
0.0095367431640625,
0.0408935546875,
0.34033203125,
-0.481689453125,
-1.19140625,
-0.67431640625,
0.1583251953125,
0.25634765625,
-0.253662109375,
0.452392578125,
0.44580078125,
-0.1763916015625,
-0.324462890625,
-0.14404296875,
0.11810302734375,
-1.0302734375,
-0.03802490234375,
0.875,
-0.195556640625,
0.377685546875,
0.06781005859375,
-0.71337890625,
0.4111328125,
0.912109375,
-0.128662109375,
0.085205078125,
0.48828125,
0.154052734375,
-0.0733642578125,
0.0634765625,
0.258056640625,
-0.0528564453125,
-0.6201171875,
0.77880859375,
-0.34033203125,
0.2188720703125,
-0.240478515625,
0.429931640625,
0.153564453125,
0.6103515625,
-0.54736328125,
-0.6875,
-0.1788330078125,
0.9775390625,
-0.1151123046875,
-0.1494140625,
-0.2252197265625,
0.60498046875,
0.67236328125,
1.0556640625,
0.53271484375,
0.2100830078125,
0.857421875,
0.75390625,
-0.029052734375,
0.47119140625,
-0.1865234375,
0.2164306640625,
0.229248046875,
0.669921875,
0.1527099609375,
0.2288818359375,
-0.1416015625,
-0.1741943359375,
-0.48681640625,
0.1470947265625,
-0.39404296875,
0.7109375,
0.2529296875,
0.464599609375,
-0.80615234375,
-0.9873046875,
0.13232421875,
1.0244140625,
-1.03125,
-0.38427734375,
-0.340576171875,
-0.22021484375,
0.193115234375,
0.06365966796875,
0.48974609375,
0.346435546875,
0.470458984375,
0.50732421875,
-0.1407470703125,
-0.1695556640625,
-0.728515625,
-0.418701171875,
-1.0576171875,
-0.391845703125,
-0.73681640625,
-0.1317138671875,
0.427490234375,
-1.10546875,
0.379638671875,
-0.3876953125,
-0.1201171875,
0.2445068359375,
-0.7802734375,
0.6416015625,
-0.51123046875,
0.52197265625,
-0.61083984375,
0.3154296875,
0.16650390625,
0.6669921875,
-0.56005859375,
0.1732177734375,
0.0225982666015625,
-0.93017578125,
0.048004150390625,
-0.2744140625,
0.51513671875,
0.2403564453125,
-0.7568359375,
-0.361572265625,
-0.361328125,
-0.1390380859375,
-0.316650390625,
0.01267242431640625,
-0.78955078125,
0.37939453125,
0.876953125,
-0.52685546875,
0.6640625,
0.87548828125,
-1.1533203125,
0.60107421875,
0.491455078125,
-0.038360595703125,
-0.9462890625,
0.8046875,
0.41796875,
0.68017578125,
-0.58154296875,
-0.0450439453125,
-0.810546875,
0.197998046875,
0.41943359375,
-0.607421875,
-0.5869140625,
0.64892578125,
0.251953125,
-1.0166015625,
0.5341796875,
-1.076171875,
-0.40185546875,
-0.40576171875,
-0.10107421875,
0.96728515625,
0.90087890625,
0.470703125,
-0.336669921875,
-0.38671875,
-0.13671875,
0.6142578125,
0.5078125,
-0.373291015625,
0.08953857421875,
0.99072265625,
0.140869140625,
0.0295562744140625,
0.412841796875,
-0.265625,
0.51708984375,
-0.42822265625,
0.05926513671875,
0.33837890625,
0.5087890625,
0.059906005859375,
0.453125,
0.81298828125,
-1.0625,
-0.08599853515625,
-0.302001953125,
0.98876953125,
0.611328125,
0.48681640625,
0.39013671875,
-0.1893310546875,
-0.53466796875,
-1.2470703125,
0.30859375,
0.6015625,
0.947265625,
-0.91162109375,
0.2890625,
-0.2091064453125,
-0.3662109375,
0.64501953125,
-0.7783203125,
0.2081298828125,
1.1220703125,
-0.059906005859375,
1.0947265625,
-0.45458984375,
0.277587890625,
-0.11285400390625,
0.183349609375,
0.65771484375,
0.324462890625,
0.153564453125,
-0.47265625,
-0.818359375,
-0.1683349609375,
-0.164306640625,
-0.324462890625,
-0.413818359375,
0.062255859375,
-0.11334228515625,
-0.446044921875,
-0.689453125,
0.157958984375,
0.6162109375,
0.9912109375,
0.16650390625,
0.5009765625,
0.1865234375,
0.79296875,
0.381103515625,
-0.31689453125,
0.3046875,
-0.67919921875,
0.74609375,
-0.2125244140625,
-0.1820068359375,
-0.50390625,
-0.01885986328125,
-0.2568359375,
0.1884765625,
-0.2137451171875,
-0.1275634765625,
-0.97607421875,
0.5732421875,
-0.111328125,
0.312255859375,
-0.5927734375,
-0.291259765625,
-0.6328125,
0.50927734375,
0.356201171875,
-0.47021484375,
0.386962890625,
-0.509765625,
0.76171875,
0.689453125,
-0.1793212890625,
-0.609375,
-0.364013671875,
-0.84423828125,
-0.256591796875,
0.001956939697265625,
0.59765625,
-0.353759765625,
-0.036468505859375,
-0.85693359375,
0.513671875,
-0.2261962890625,
-0.1505126953125,
0.04351806640625,
-0.3544921875,
0.26171875,
0.3173828125,
0.755859375,
-0.52734375,
-1.0478515625,
-0.060943603515625,
-0.728515625,
0.11138916015625,
-0.2568359375,
-0.11053466796875,
0.31689453125,
0.2386474609375,
0.408935546875,
0.3388671875,
-0.137939453125,
0.1790771484375,
-0.1571044921875,
0.1136474609375,
-0.86279296875,
-0.59326171875,
0.352294921875,
-0.113525390625,
-0.11309814453125,
0.215576171875,
-0.061065673828125,
-0.047821044921875,
0.035430908203125,
0.58154296875,
-0.30322265625,
0.2666015625,
-0.10467529296875,
0.73291015625,
-0.3046875,
-0.83740234375,
-0.034210205078125,
-0.57080078125,
0.498046875,
-0.2225341796875,
-1.0595703125,
0.247314453125,
-0.88134765625,
0.131103515625,
-0.003047943115234375,
-0.09661865234375,
0.78759765625,
0.068603515625,
-0.049102783203125,
-0.1453857421875,
-0.250732421875,
-0.9033203125,
-0.310302734375,
-0.71826171875,
0.0714111328125,
0.279052734375,
0.61083984375,
1.25390625,
0.09185791015625,
-0.12030029296875,
0.048431396484375,
0.337890625,
0.0061492919921875,
-0.305419921875,
-0.053314208984375,
-0.2049560546875,
-0.08795166015625,
-0.2607421875,
0.48828125,
-0.385986328125,
0.391845703125,
0.77978515625,
0.164306640625,
0.60888671875,
0.0750732421875,
-0.73095703125,
0.4248046875,
0.0921630859375,
-0.9853515625,
-0.3486328125,
0.365966796875,
-0.2493896484375,
0.765625,
0.91455078125,
-0.67822265625,
-0.990234375,
-0.74560546875,
0.05169677734375,
-0.471435546875,
-0.48486328125,
-1.0341796875,
-0.41259765625,
-0.59033203125,
0.6201171875,
-0.2017822265625,
-0.50244140625,
-0.2222900390625,
-0.91845703125,
0.460693359375,
-0.56298828125,
-0.806640625,
-0.451171875,
-0.1436767578125,
-0.1177978515625,
0.7841796875,
0.236328125,
0.17919921875,
-0.458251953125,
-0.2298583984375,
0.28271484375,
0.3427734375,
-0.7060546875,
-0.16064453125,
-0.2880859375,
-0.255126953125,
-0.380859375,
-0.0919189453125,
-0.51806640625,
0.9736328125,
-0.448486328125,
0.05755615234375,
-0.0309600830078125,
-0.603515625,
-0.306396484375,
0.1256103515625,
0.513671875,
-0.289794921875,
-0.1942138671875,
0.08636474609375,
0.7333984375,
0.58740234375,
-0.6259765625,
-0.31201171875,
-0.64794921875,
-0.55810546875,
-0.73681640625,
0.1610107421875,
-0.76708984375,
0.12646484375,
-0.1405029296875,
-0.305908203125,
0.87353515625,
-0.58056640625,
0.33837890625,
1.2353515625,
-0.00909423828125,
0.353271484375,
-0.62255859375,
0.8583984375,
0.27783203125,
-0.5947265625,
-0.1064453125,
-0.306396484375,
-0.46533203125,
0.0109100341796875,
-0.254638671875,
-1.359375,
-0.947265625,
0.114501953125,
0.98779296875,
-0.373291015625,
1.001953125,
-0.0272674560546875,
-1.0791015625,
-1.2060546875,
0.68994140625,
-0.0853271484375,
0.298095703125,
0.9951171875,
0.0845947265625,
-0.07537841796875,
0.493408203125,
-0.08544921875,
0.366455078125,
-0.94189453125,
0.97216796875,
0.258056640625,
-0.5537109375,
0.71728515625,
0.99072265625,
-1.26953125,
-0.62646484375,
0.308837890625,
-0.480224609375,
-0.2374267578125,
-0.452880859375,
-0.110107421875,
0.38427734375,
-0.67578125,
-0.028289794921875,
0.033203125,
0.0946044921875,
0.49267578125,
-0.34326171875,
0.465576171875,
-0.299560546875,
0.68798828125,
0.90283203125,
-0.64453125,
-0.044036865234375,
-0.80322265625,
-0.3916015625,
-0.58935546875,
0.3291015625,
0.90380859375,
-0.477294921875,
0.09942626953125,
0.818359375,
-0.1328125,
1.486328125,
-0.085693359375,
-0.08795166015625,
0.458984375,
-0.73046875,
-0.7021484375,
0.208251953125,
0.46875,
-0.409423828125,
0.525390625,
-0.2249755859375,
0.2493896484375,
0.0210418701171875,
0.385986328125,
0.18994140625,
-0.71875,
-0.3466796875,
-0.751953125,
-0.0736083984375,
-0.4521484375,
-0.1900634765625,
-0.229248046875,
-0.11492919921875,
0.09381103515625,
-0.388916015625,
-0.03350830078125,
0.56884765625,
-0.18310546875,
0.1634521484375,
-0.73095703125,
0.214111328125,
-0.85107421875,
-0.7431640625,
-0.76025390625,
-0.1473388671875,
-0.31396484375,
-0.027130126953125,
-0.578125,
0.1396484375,
-0.396240234375,
0.61572265625,
-0.1668701171875,
0.42822265625,
-0.15380859375,
-0.91259765625,
-0.08172607421875,
0.005664825439453125,
-0.0189208984375,
0.2919921875,
0.415771484375,
-0.18310546875,
0.2001953125,
-0.294921875,
-0.37744140625,
0.061187744140625,
-0.11944580078125,
0.91748046875,
0.00943756103515625,
-0.09307861328125,
-0.3623046875,
0.146728515625,
-1.0771484375,
0.258544921875,
-0.08892822265625,
0.05645751953125,
0.2113037109375,
-0.1265869140625,
0.8779296875,
0.7177734375,
-0.5244140625,
0.250244140625,
-0.07781982421875,
0.082763671875,
0.40380859375,
0.10931396484375,
0.2437744140625,
-0.046478271484375,
0.38232421875,
-0.042694091796875,
0.051727294921875,
0.2047119140625,
-0.05560302734375,
0.47314453125,
-0.1785888671875,
-0.529296875,
-1.0439453125,
-0.26220703125,
0.233154296875,
0.127685546875,
-0.1907958984375,
-0.2232666015625,
0.302734375,
0.1866455078125,
-0.6767578125,
0.51904296875,
-1.2880859375,
-0.68701171875,
0.8837890625,
-0.300537109375,
-0.65087890625,
-0.91796875,
-0.693359375,
-0.0121307373046875,
0.1829833984375,
0.467041015625,
-0.52880859375,
0.5966796875,
0.143310546875,
0.7890625,
-0.247802734375,
-0.313232421875,
0.09869384765625,
0.36572265625,
-0.79248046875,
-0.6220703125,
0.436279296875,
0.583984375,
0.037384033203125,
-0.213134765625,
-0.75439453125,
0.342529296875,
-0.04132080078125,
-0.34912109375,
-0.47802734375,
0.434814453125,
-0.1409912109375,
0.57666015625,
-0.888671875,
-0.10821533203125,
-0.042724609375,
-0.04278564453125,
0.471435546875,
-0.3876953125,
-0.35791015625,
0.407470703125,
0.84423828125,
-0.5869140625,
0.32666015625,
0.201171875,
0.444580078125,
-0.047088623046875,
-0.1741943359375,
0.1513671875,
0.85986328125,
0.72314453125,
0.52001953125,
-0.123779296875,
0.693359375,
0.361572265625,
-0.2373046875,
-0.2044677734375,
0.312744140625,
0.42041015625,
-0.59521484375,
0.5,
0.11859130859375,
-0.1343994140625,
-0.0162811279296875,
-0.436279296875,
0.361328125,
0.02935791015625,
-0.328857421875,
-0.66357421875,
-0.88134765625,
0.587890625,
-0.1063232421875,
0.39794921875,
0.26708984375,
-0.410888671875,
0.286865234375,
0.958984375,
-0.12066650390625,
-0.261474609375,
0.92529296875,
0.5126953125,
0.08795166015625,
0.734375,
0.08056640625,
0.337890625,
-1.01953125,
0.6337890625,
0.1849365234375,
-0.179931640625,
-0.4638671875,
-0.6767578125,
-1.0390625,
0.66455078125,
-0.5205078125,
-0.2110595703125,
1.0234375,
-0.7216796875,
0.33447265625,
-0.2705078125,
0.669921875,
-0.432861328125,
-0.0258331298828125,
0.26171875,
-0.49609375,
-0.1767578125,
1.0869140625,
-0.319091796875,
0.439697265625,
0.09619140625,
1.0322265625,
0.417236328125,
1.634765625,
0.301025390625,
-0.374267578125,
0.1766357421875,
0.076904296875,
-0.160888671875,
-0.61865234375,
-0.5830078125,
-0.374267578125,
0.2783203125,
-0.57421875,
-0.469482421875,
-0.282470703125,
0.78076171875,
0.07525634765625,
-1.357421875,
-0.2310791015625,
0.255615234375,
-0.92041015625,
0.323486328125,
0.64404296875,
0.4462890625,
0.2413330078125,
-0.255859375,
0.289794921875,
-0.50146484375,
0.130126953125,
-0.368408203125,
0.341552734375,
-0.1414794921875,
-0.67041015625,
-0.457763671875,
-0.8818359375,
0.26318359375,
-0.472412109375,
-0.63134765625,
-0.59716796875,
0.322998046875,
1.0634765625,
0.425537109375,
0.6611328125,
-0.53271484375,
-0.15771484375,
0.75537109375,
1.021484375,
0.10723876953125,
0.477294921875,
0.040191650390625,
-0.08251953125,
0.470458984375,
-0.380615234375,
-0.0270843505859375,
0.323486328125,
-0.0955810546875,
-0.4267578125,
-0.0257110595703125,
-0.37109375,
-1.20703125,
0.42236328125,
0.98095703125,
0.21240234375,
-0.58544921875,
-1.080078125,
-0.416015625,
-1.1083984375,
-0.0105438232421875,
-0.51611328125,
0.5791015625,
0.0831298828125,
-0.320068359375,
0.1429443359375,
-1.119140625,
4.390625,
0.97265625,
0.8369140625,
0.1629638671875,
-0.0212554931640625,
0.98046875,
0.6787109375,
-0.7978515625,
0.019439697265625,
-0.1817626953125,
0.53662109375,
-0.74755859375,
0.4248046875,
0.82666015625,
0.26171875,
0.317138671875,
-0.274658203125,
-0.09527587890625,
0.03485107421875,
-0.97900390625,
-0.828125,
-0.09710693359375,
-0.0692138671875,
0.673828125,
0.2366943359375,
0.4033203125,
0.285400390625,
-0.4169921875,
-0.06707763671875,
-0.830078125,
0.0117034912109375,
-0.5078125,
0.93359375,
0.1280517578125,
-0.246826171875,
0.517578125,
0.13623046875,
-0.86279296875,
-0.25341796875,
0.15185546875,
-0.06256103515625,
-0.348876953125,
0.478515625,
-0.77099609375,
0.401123046875,
0.4140625,
-0.44140625,
0.348388671875,
0.8798828125,
-0.84423828125,
1.1015625,
0.045928955078125,
0.259033203125,
-0.53564453125,
-0.9521484375,
0.63427734375,
0.1656494140625,
0.0875244140625,
-0.6181640625,
0.50537109375,
0.4306640625,
0.436279296875,
-0.175048828125,
0.26171875,
-0.857421875,
0.984375,
-0.44482421875,
0.92236328125,
-0.467041015625,
-0.28515625,
-0.1273193359375,
-0.412353515625,
-0.3583984375,
-0.4169921875,
0.66259765625,
0.237060546875,
-0.145263671875,
0.50537109375,
0.53466796875,
-0.60009765625,
-0.05584716796875,
-0.2529296875,
-0.5380859375,
-0.55322265625,
0.50537109375,
1.146484375,
-0.408935546875,
-0.7109375,
-0.61474609375,
0.70751953125,
0.65380859375,
0.12237548828125,
-0.11358642578125,
-0.11566162109375,
-0.305419921875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where
* <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
* <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
* <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.
The content of square brackets is optional — it can be present or can be absent.
There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.
Your task is to write program which checks if given string is a correct Jabber ID.
Input
The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.
Output
Print YES or NO.
Examples
Input
mike@codeforces.com
Output
YES
Input
john.smith@codeforces.ru/contest.icpc/12
Output
NO
Tags: implementation, strings
Correct Solution:
```
string = input()
answer = "YES"
Ausername = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789"
if "@" in string:
string = string.split("@")
if len(string) > 2: answer = "NO"
if len(string[0]) < 1 or len(string[0]) > 16: answer = "NO"
for char in string[0]:
if char not in Ausername: answer = "NO"
if "/" in string[1]:
string2 = string[1].split("/")
hostname = string2[0]
if len(string2) > 2: answer = "NO"
for char in string2[1]:
if char not in Ausername: answer = "NO"
if len(string2[1]) < 1 or len(string2[1]) > 16: answer = "NO"
else:
hostname = string[1]
if len(hostname) < 1 or len(hostname) > 32: answer = "NO"
if "." in hostname:
hostname = hostname.split(".")
for word in hostname:
if len(word) < 1 or len(word) > 16: answer = "NO"
for char in word:
if char not in Ausername: answer = "NO"
else:
for char in hostname:
if char not in Ausername: answer = "NO"
else:
answer = "NO"
print(answer)
```
| 71,028 | [
0.498046875,
-0.04840087890625,
-0.2430419921875,
0.475830078125,
-0.0023555755615234375,
-0.5654296875,
0.09912109375,
-0.1363525390625,
0.2427978515625,
0.469970703125,
0.53076171875,
-0.01512908935546875,
0.11260986328125,
-0.91455078125,
-0.61572265625,
-0.0831298828125,
-0.52734375,
-0.92724609375,
-0.33935546875,
-0.492431640625,
0.321533203125,
0.0732421875,
-1.3251953125,
-0.1435546875,
-0.5693359375,
0.69287109375,
0.2259521484375,
0.35888671875,
0.947265625,
0.69677734375,
-0.135498046875,
-0.66455078125,
0.4443359375,
-0.9873046875,
-0.365478515625,
-0.347900390625,
0.490234375,
-1.0703125,
-0.5703125,
-0.4326171875,
0.0728759765625,
-0.234375,
0.1468505859375,
-1.05859375,
-1.087890625,
0.1180419921875,
-0.52978515625,
-0.06475830078125,
-0.036956787109375,
-0.59716796875,
0.23388671875,
-0.1033935546875,
0.78369140625,
-0.419677734375,
-0.16748046875,
-0.289306640625,
-0.329833984375,
0.12939453125,
-0.74267578125,
0.1318359375,
-0.14599609375,
0.470947265625,
-0.05877685546875,
-0.7353515625,
-0.036773681640625,
0.056640625,
0.09564208984375,
-0.223388671875,
-0.11163330078125,
-0.900390625,
-0.061676025390625,
0.347412109375,
-0.6865234375,
-0.693359375,
-0.21923828125,
-0.0015659332275390625,
0.26123046875,
-0.1053466796875,
-0.1893310546875,
0.701171875,
-0.09576416015625,
1.30859375,
0.444580078125,
0.190673828125,
-0.705078125,
-0.4404296875,
0.332763671875,
0.415283203125,
0.2095947265625,
-0.1207275390625,
-0.281494140625,
0.394287109375,
-0.572265625,
0.2100830078125,
0.5146484375,
0.63720703125,
0.20849609375,
0.609375,
0.1070556640625,
0.277587890625,
0.6171875,
0.91162109375,
-0.31787109375,
1.033203125,
-0.46142578125,
0.243408203125,
0.59228515625,
-0.0220489501953125,
-0.64453125,
-0.41796875,
-0.2005615234375,
-0.716796875,
0.31103515625,
0.0216827392578125,
-0.322265625,
0.5068359375,
0.051605224609375,
0.433837890625,
-1.1640625,
-0.056976318359375,
0.440673828125,
-0.30126953125,
0.7080078125,
-0.365966796875,
-0.1351318359375,
-0.3466796875,
-0.5546875,
1.0478515625,
-0.319580078125,
-0.1331787109375,
0.2430419921875,
-0.051025390625,
-0.259033203125,
-0.130126953125,
0.2210693359375,
0.90625,
-0.00872039794921875,
0.5966796875,
1.0087890625,
-1.0302734375,
0.71630859375,
0.1533203125,
0.0791015625,
1.71875,
0.44775390625,
0.16064453125,
0.57568359375,
0.234375,
-0.609375,
0.01458740234375,
-0.9111328125,
0.9228515625,
0.4033203125,
0.1947021484375,
-0.260986328125,
0.30029296875,
0.036956787109375,
0.609375,
0.1026611328125,
-0.0738525390625,
-0.493408203125,
0.413330078125,
-0.1241455078125,
0.9736328125,
-0.10595703125,
0.461669921875,
0.042877197265625,
-0.15185546875,
0.49658203125,
-0.61572265625,
0.478271484375,
-0.1837158203125,
0.1795654296875,
0.86474609375,
0.5654296875,
0.87060546875,
0.9912109375,
-0.1536865234375,
0.4736328125,
0.433349609375,
-0.5673828125,
0.344482421875,
0.118408203125,
1.02734375,
0.055450439453125,
0.1312255859375,
0.304443359375,
-0.50439453125,
-1.1875,
-0.7138671875,
0.113525390625,
0.337646484375,
-0.3642578125,
0.441650390625,
0.436767578125,
-0.181884765625,
-0.229248046875,
-0.10931396484375,
0.0955810546875,
-1.0361328125,
-0.036346435546875,
0.82666015625,
-0.188232421875,
0.388671875,
0.05035400390625,
-0.74462890625,
0.359375,
0.99169921875,
-0.142822265625,
0.055419921875,
0.475830078125,
0.154541015625,
-0.099365234375,
0.052581787109375,
0.2320556640625,
-0.1356201171875,
-0.6005859375,
0.80126953125,
-0.394775390625,
0.09466552734375,
-0.216796875,
0.357421875,
0.259521484375,
0.60107421875,
-0.544921875,
-0.6787109375,
-0.064453125,
1.005859375,
-0.1490478515625,
-0.15185546875,
-0.15185546875,
0.59521484375,
0.73681640625,
1.03515625,
0.478515625,
0.305419921875,
0.78466796875,
0.81787109375,
0.08441162109375,
0.387939453125,
-0.164306640625,
0.2042236328125,
0.230224609375,
0.72900390625,
0.1533203125,
0.193359375,
-0.121826171875,
-0.09185791015625,
-0.484375,
0.1812744140625,
-0.401123046875,
0.80859375,
0.291015625,
0.5146484375,
-0.85205078125,
-0.9833984375,
0.1966552734375,
0.99267578125,
-1.0263671875,
-0.39208984375,
-0.281494140625,
-0.08160400390625,
0.198974609375,
0.08837890625,
0.49560546875,
0.281494140625,
0.517578125,
0.55224609375,
-0.12347412109375,
-0.2841796875,
-0.74072265625,
-0.458251953125,
-1.046875,
-0.41552734375,
-0.70068359375,
-0.228271484375,
0.44970703125,
-1.130859375,
0.364990234375,
-0.337890625,
-0.154541015625,
0.180908203125,
-0.796875,
0.69287109375,
-0.456787109375,
0.50537109375,
-0.724609375,
0.321533203125,
0.1964111328125,
0.775390625,
-0.5751953125,
0.13916015625,
0.03173828125,
-0.9853515625,
0.050140380859375,
-0.2003173828125,
0.47216796875,
0.2203369140625,
-0.8154296875,
-0.3818359375,
-0.396240234375,
-0.047576904296875,
-0.436767578125,
0.040557861328125,
-0.7548828125,
0.4599609375,
0.9111328125,
-0.474853515625,
0.75634765625,
0.95654296875,
-1.1669921875,
0.705078125,
0.517578125,
-0.02496337890625,
-0.94921875,
0.89697265625,
0.4189453125,
0.7109375,
-0.65625,
-0.03057861328125,
-0.763671875,
0.197998046875,
0.38818359375,
-0.57080078125,
-0.556640625,
0.6357421875,
0.179931640625,
-1.0888671875,
0.51513671875,
-1.1103515625,
-0.34765625,
-0.47802734375,
-0.178466796875,
0.91259765625,
0.8564453125,
0.3896484375,
-0.369873046875,
-0.3681640625,
-0.1571044921875,
0.49853515625,
0.59130859375,
-0.39013671875,
0.08221435546875,
1.0986328125,
0.1199951171875,
-0.0338134765625,
0.345458984375,
-0.290771484375,
0.41357421875,
-0.422119140625,
-0.00958251953125,
0.271728515625,
0.4970703125,
0.09564208984375,
0.4990234375,
0.87939453125,
-1.0712890625,
-0.14599609375,
-0.271240234375,
0.8955078125,
0.7041015625,
0.429931640625,
0.419189453125,
-0.2423095703125,
-0.440185546875,
-1.244140625,
0.308837890625,
0.54931640625,
1.01953125,
-0.96044921875,
0.317138671875,
-0.2425537109375,
-0.446044921875,
0.6650390625,
-0.78515625,
0.1337890625,
1.2333984375,
-0.1268310546875,
1.04296875,
-0.46484375,
0.325927734375,
-0.01593017578125,
0.1951904296875,
0.74267578125,
0.343505859375,
0.190185546875,
-0.494140625,
-0.82666015625,
-0.299560546875,
-0.1488037109375,
-0.269287109375,
-0.4287109375,
0.1162109375,
-0.1817626953125,
-0.418701171875,
-0.68017578125,
0.1553955078125,
0.599609375,
0.96533203125,
0.2366943359375,
0.465576171875,
0.1973876953125,
0.73828125,
0.362060546875,
-0.341064453125,
0.2012939453125,
-0.681640625,
0.74365234375,
-0.11572265625,
-0.23779296875,
-0.5234375,
-0.051910400390625,
-0.266845703125,
0.2119140625,
-0.2178955078125,
-0.1534423828125,
-1.021484375,
0.54736328125,
-0.1671142578125,
0.37841796875,
-0.63916015625,
-0.2315673828125,
-0.5986328125,
0.55908203125,
0.318359375,
-0.541015625,
0.3203125,
-0.52099609375,
0.7685546875,
0.63232421875,
-0.08648681640625,
-0.6787109375,
-0.3603515625,
-0.88916015625,
-0.24560546875,
0.0712890625,
0.5927734375,
-0.2744140625,
0.014862060546875,
-0.97265625,
0.50439453125,
-0.16357421875,
-0.156982421875,
-0.01812744140625,
-0.3486328125,
0.30078125,
0.253173828125,
0.79443359375,
-0.5380859375,
-1.0517578125,
-0.00881195068359375,
-0.76025390625,
0.175048828125,
-0.30322265625,
-0.01125335693359375,
0.285888671875,
0.2088623046875,
0.3974609375,
0.361572265625,
-0.06658935546875,
0.1846923828125,
-0.211669921875,
0.11065673828125,
-0.8271484375,
-0.6728515625,
0.409423828125,
-0.10040283203125,
-0.215576171875,
0.302001953125,
0.00420379638671875,
-0.07659912109375,
0.056243896484375,
0.576171875,
-0.357421875,
0.2802734375,
-0.0714111328125,
0.7666015625,
-0.30810546875,
-0.7626953125,
-0.1651611328125,
-0.5634765625,
0.53955078125,
-0.2225341796875,
-1.203125,
0.2017822265625,
-0.9755859375,
0.09881591796875,
-0.046417236328125,
-0.1064453125,
0.77734375,
0.1343994140625,
-0.0758056640625,
-0.1072998046875,
-0.240478515625,
-0.90087890625,
-0.354248046875,
-0.65087890625,
0.12030029296875,
0.288818359375,
0.54833984375,
1.302734375,
0.08984375,
-0.16064453125,
0.132568359375,
0.30712890625,
0.0025634765625,
-0.306884765625,
-0.0440673828125,
-0.2388916015625,
-0.1295166015625,
-0.2471923828125,
0.50732421875,
-0.37841796875,
0.40087890625,
0.77294921875,
0.11968994140625,
0.6826171875,
0.0982666015625,
-0.74658203125,
0.474609375,
0.0662841796875,
-0.9326171875,
-0.34326171875,
0.422119140625,
-0.13818359375,
0.79443359375,
0.8583984375,
-0.6953125,
-0.9873046875,
-0.8134765625,
0.081787109375,
-0.475341796875,
-0.41650390625,
-1.0478515625,
-0.36328125,
-0.6162109375,
0.6025390625,
-0.215576171875,
-0.47802734375,
-0.1353759765625,
-0.90283203125,
0.31787109375,
-0.65869140625,
-0.8125,
-0.5341796875,
-0.099609375,
-0.03955078125,
0.75537109375,
0.2626953125,
0.1942138671875,
-0.400634765625,
-0.218505859375,
0.2498779296875,
0.26025390625,
-0.6884765625,
-0.1475830078125,
-0.32861328125,
-0.24609375,
-0.368408203125,
-0.1240234375,
-0.459716796875,
1.0068359375,
-0.5244140625,
0.059356689453125,
-0.046875,
-0.57763671875,
-0.25048828125,
-0.00385284423828125,
0.6142578125,
-0.265380859375,
-0.203369140625,
0.10125732421875,
0.705078125,
0.66650390625,
-0.58837890625,
-0.2939453125,
-0.69775390625,
-0.481689453125,
-0.771484375,
0.171142578125,
-0.73388671875,
0.1224365234375,
-0.107177734375,
-0.22705078125,
0.83447265625,
-0.62060546875,
0.32421875,
1.228515625,
-0.039794921875,
0.386474609375,
-0.59912109375,
0.88427734375,
0.36083984375,
-0.61328125,
-0.06414794921875,
-0.2587890625,
-0.58984375,
0.0440673828125,
-0.27734375,
-1.39453125,
-0.93603515625,
0.051300048828125,
1.1240234375,
-0.37060546875,
0.9814453125,
0.058502197265625,
-1.1728515625,
-1.2109375,
0.76171875,
-0.045166015625,
0.3154296875,
1.06640625,
0.0941162109375,
-0.0858154296875,
0.5234375,
-0.06451416015625,
0.33935546875,
-0.90087890625,
1.078125,
0.1763916015625,
-0.432373046875,
0.70751953125,
0.98681640625,
-1.3046875,
-0.63525390625,
0.23974609375,
-0.497802734375,
-0.3681640625,
-0.477783203125,
-0.0701904296875,
0.348876953125,
-0.703125,
-0.0948486328125,
-0.054046630859375,
0.096923828125,
0.429931640625,
-0.32177734375,
0.3955078125,
-0.271728515625,
0.76171875,
0.9267578125,
-0.603515625,
-0.04779052734375,
-0.73046875,
-0.33056640625,
-0.607421875,
0.322509765625,
0.8896484375,
-0.5546875,
0.08062744140625,
0.76318359375,
-0.1790771484375,
1.333984375,
-0.09088134765625,
-0.116943359375,
0.469970703125,
-0.75048828125,
-0.7265625,
0.217529296875,
0.5078125,
-0.368896484375,
0.67041015625,
-0.292236328125,
0.270263671875,
0.009307861328125,
0.45703125,
0.067626953125,
-0.77490234375,
-0.27001953125,
-0.8310546875,
-0.12005615234375,
-0.484375,
-0.129150390625,
-0.2724609375,
-0.00567626953125,
0.137451171875,
-0.473388671875,
-0.02655029296875,
0.59423828125,
-0.1748046875,
0.21484375,
-0.78271484375,
0.2156982421875,
-0.9365234375,
-0.7275390625,
-0.7626953125,
-0.09906005859375,
-0.30517578125,
-0.02056884765625,
-0.57421875,
0.2340087890625,
-0.422607421875,
0.6767578125,
-0.128662109375,
0.490478515625,
-0.16845703125,
-0.80859375,
-0.08642578125,
0.0025234222412109375,
-0.1036376953125,
0.30029296875,
0.4453125,
-0.1744384765625,
0.189453125,
-0.308349609375,
-0.256591796875,
0.0611572265625,
-0.13330078125,
0.85986328125,
-0.060272216796875,
-0.112548828125,
-0.37841796875,
0.1361083984375,
-1.099609375,
0.326904296875,
-0.128662109375,
-0.046173095703125,
0.2188720703125,
-0.1651611328125,
0.86376953125,
0.7763671875,
-0.53369140625,
0.259765625,
-0.126220703125,
0.185302734375,
0.457763671875,
0.104248046875,
0.2269287109375,
-0.051971435546875,
0.380126953125,
-0.1175537109375,
0.1270751953125,
0.25927734375,
-0.120849609375,
0.47509765625,
-0.23193359375,
-0.58349609375,
-1.091796875,
-0.2213134765625,
0.17724609375,
0.11468505859375,
-0.1387939453125,
-0.3583984375,
0.2880859375,
0.165283203125,
-0.6728515625,
0.4677734375,
-1.28515625,
-0.7705078125,
0.9384765625,
-0.2445068359375,
-0.63232421875,
-0.841796875,
-0.6376953125,
0.00370025634765625,
0.057220458984375,
0.475341796875,
-0.5009765625,
0.556640625,
0.0953369140625,
0.79638671875,
-0.25048828125,
-0.297119140625,
0.0850830078125,
0.413330078125,
-0.86572265625,
-0.58642578125,
0.40234375,
0.599609375,
-0.051025390625,
-0.16943359375,
-0.72998046875,
0.318115234375,
-0.00017070770263671875,
-0.30224609375,
-0.46337890625,
0.37548828125,
-0.1624755859375,
0.53759765625,
-0.8740234375,
-0.073974609375,
-0.0479736328125,
-0.040985107421875,
0.424560546875,
-0.46337890625,
-0.367919921875,
0.54833984375,
0.86279296875,
-0.50830078125,
0.289794921875,
0.12548828125,
0.412353515625,
-0.0203857421875,
-0.2041015625,
0.139404296875,
0.828125,
0.76318359375,
0.47265625,
-0.09588623046875,
0.6689453125,
0.427001953125,
-0.177734375,
-0.132568359375,
0.293701171875,
0.46630859375,
-0.51513671875,
0.49658203125,
0.05303955078125,
-0.16796875,
-0.02734375,
-0.45751953125,
0.353515625,
-0.04168701171875,
-0.344970703125,
-0.7294921875,
-0.87939453125,
0.55712890625,
-0.1405029296875,
0.34619140625,
0.257568359375,
-0.3759765625,
0.2607421875,
0.9033203125,
-0.164794921875,
-0.294677734375,
0.95556640625,
0.53369140625,
0.1630859375,
0.72021484375,
0.058074951171875,
0.365234375,
-1.037109375,
0.6220703125,
0.1895751953125,
-0.17236328125,
-0.38671875,
-0.64990234375,
-1.05859375,
0.591796875,
-0.46630859375,
-0.1868896484375,
0.98876953125,
-0.7978515625,
0.357177734375,
-0.2117919921875,
0.6328125,
-0.49072265625,
-0.043487548828125,
0.328369140625,
-0.51953125,
-0.1392822265625,
1.1904296875,
-0.364990234375,
0.408935546875,
-0.00406646728515625,
1.0009765625,
0.374755859375,
1.72265625,
0.287353515625,
-0.418212890625,
0.12939453125,
0.1431884765625,
-0.26220703125,
-0.662109375,
-0.5693359375,
-0.3427734375,
0.283447265625,
-0.59033203125,
-0.464111328125,
-0.287109375,
0.7978515625,
0.0928955078125,
-1.400390625,
-0.22412109375,
0.1640625,
-0.95654296875,
0.361328125,
0.62841796875,
0.400146484375,
0.31689453125,
-0.1800537109375,
0.255615234375,
-0.462158203125,
0.10882568359375,
-0.3359375,
0.43994140625,
-0.2132568359375,
-0.66796875,
-0.49267578125,
-0.8388671875,
0.23046875,
-0.48974609375,
-0.59375,
-0.6064453125,
0.3388671875,
1.0126953125,
0.373779296875,
0.615234375,
-0.52001953125,
-0.17431640625,
0.78369140625,
1.0732421875,
0.048919677734375,
0.50537109375,
0.0145263671875,
-0.1851806640625,
0.465576171875,
-0.41650390625,
0.032379150390625,
0.355712890625,
-0.06781005859375,
-0.394775390625,
0.01258087158203125,
-0.365234375,
-1.236328125,
0.469482421875,
0.93212890625,
0.267822265625,
-0.5673828125,
-1.0654296875,
-0.371337890625,
-1.1708984375,
0.004497528076171875,
-0.5458984375,
0.63818359375,
-0.00556182861328125,
-0.279296875,
0.0887451171875,
-1.177734375,
4.328125,
0.93359375,
0.943359375,
0.1124267578125,
-0.09979248046875,
0.9462890625,
0.71728515625,
-0.7841796875,
0.01385498046875,
-0.309814453125,
0.5771484375,
-0.767578125,
0.406982421875,
0.94970703125,
0.29150390625,
0.379150390625,
-0.392333984375,
0.00913238525390625,
0.0034236907958984375,
-0.95068359375,
-0.935546875,
-0.054229736328125,
-0.05633544921875,
0.6640625,
0.212890625,
0.415771484375,
0.265625,
-0.407958984375,
-0.10906982421875,
-0.841796875,
0.080078125,
-0.521484375,
0.9541015625,
0.11444091796875,
-0.285888671875,
0.486083984375,
0.12371826171875,
-0.8779296875,
-0.17431640625,
0.163818359375,
-0.0826416015625,
-0.390625,
0.47265625,
-0.7392578125,
0.300537109375,
0.435302734375,
-0.448486328125,
0.389892578125,
0.87744140625,
-0.86083984375,
1.0244140625,
-0.1390380859375,
0.359130859375,
-0.60498046875,
-0.96240234375,
0.61083984375,
0.07855224609375,
0.031494140625,
-0.6103515625,
0.412109375,
0.46630859375,
0.486328125,
-0.158447265625,
0.2490234375,
-0.8564453125,
0.9892578125,
-0.410888671875,
0.9609375,
-0.46435546875,
-0.2003173828125,
-0.234130859375,
-0.41357421875,
-0.34033203125,
-0.52587890625,
0.73388671875,
0.2607421875,
-0.172607421875,
0.47265625,
0.5849609375,
-0.6103515625,
-0.032257080078125,
-0.26611328125,
-0.454345703125,
-0.5439453125,
0.53125,
1.20703125,
-0.425048828125,
-0.7314453125,
-0.478515625,
0.73779296875,
0.681640625,
0.169921875,
-0.1019287109375,
-0.1785888671875,
-0.295166015625
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where
* <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
* <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
* <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.
The content of square brackets is optional — it can be present or can be absent.
There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.
Your task is to write program which checks if given string is a correct Jabber ID.
Input
The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.
Output
Print YES or NO.
Examples
Input
mike@codeforces.com
Output
YES
Input
john.smith@codeforces.ru/contest.icpc/12
Output
NO
Tags: implementation, strings
Correct Solution:
```
'''
def userName(s):
for i in range(s.index('@')):
if not '0' <= s[i] <= '9' or 'a' <= s[i] <= 'z' or 'A' <= s[i] <= 'Z':
return False
else:
return True
def hostName(s):
if '/' in s:
for i in range(s.index('@') + 1, s.index('/')):
if not '0' <= s[i] <= '9' or 'a' <= s[i] <= 'z' or 'A' <= s[i] <= 'Z' or s[i] == '.':
return False
else:
return True
else:
for i in range(s.index('@', )):
if not '0' <= s[i] <= '9' or 'a' <= s[i] <= 'z' or 'A' <= s[i] <= 'Z' or s[i] == '.':
return False
else:
return True
def resourse(s):
for i in range(s.index('/'), s.rindex('/')):
if not '0' <= s[i] <= '9' or 'a' <= s[i] <= 'z' or 'A' <= s[i] <= 'Z' or s[i] == '.':
return False
else:
return True
s = input()
'''
'''
0123456789.......
s='something@ipsu.edu.tetu.ge/pageone'
userName='something'
'''
def check(s):
sLen = len(s)
if sLen == 0 or sLen > 16:
return False
for i in range(sLen):
if not ('A' <= s[i] <= 'Z' or
'a' <= s[i] <= 'z' or
'0' <= s[i] <= '9' or
s[i] == '_'):
return False
return True
def checkHost(hostName):
hostLen = len(hostName)
if hostLen == 0 or hostLen > 32:
return False
for item in hostName.split('.'):
if not check(item):
return False
return True
s = input()
isUser, isHost, isResource = False, False, False
if '@' in s:
atIndex = s.index('@')
userName = s[0:atIndex]
isUser = check(userName)
slashIndex = s.index('/') if '/' in s else -1
hostName = s[atIndex + 1: slashIndex] if slashIndex != -1 else s[atIndex + 1:]
isHost = checkHost(hostName)
if slashIndex == -1:
isResource = True
else:
resource = s[slashIndex + 1:]
isResource = check(resource)
print('YES' if isUser and isHost and isResource else 'NO')
```
| 71,029 | [
0.56005859375,
-0.1085205078125,
-0.1629638671875,
0.492431640625,
-0.0136260986328125,
-0.52783203125,
0.06622314453125,
-0.229736328125,
0.1158447265625,
0.4765625,
0.4638671875,
0.028564453125,
0.0694580078125,
-0.8740234375,
-0.58544921875,
-0.095703125,
-0.5400390625,
-0.87109375,
-0.406005859375,
-0.475830078125,
0.349609375,
0.07568359375,
-1.26953125,
-0.2115478515625,
-0.54052734375,
0.6923828125,
0.09600830078125,
0.376708984375,
1.0068359375,
0.64111328125,
-0.10455322265625,
-0.6455078125,
0.45849609375,
-0.96435546875,
-0.396728515625,
-0.33984375,
0.427734375,
-1.0419921875,
-0.5849609375,
-0.379638671875,
0.1370849609375,
-0.2301025390625,
0.1607666015625,
-1.0576171875,
-1.1181640625,
0.135986328125,
-0.58349609375,
-0.06427001953125,
-0.05950927734375,
-0.58984375,
0.1995849609375,
-0.10882568359375,
0.70849609375,
-0.44189453125,
-0.1973876953125,
-0.30517578125,
-0.3681640625,
0.119384765625,
-0.70556640625,
0.1514892578125,
-0.11602783203125,
0.42041015625,
-0.045013427734375,
-0.72265625,
-0.030242919921875,
0.025543212890625,
0.10223388671875,
-0.2203369140625,
-0.09869384765625,
-0.87841796875,
0.00110626220703125,
0.321533203125,
-0.69140625,
-0.68603515625,
-0.2225341796875,
0.00926971435546875,
0.26513671875,
-0.1019287109375,
-0.201416015625,
0.6708984375,
-0.04437255859375,
1.3056640625,
0.370849609375,
0.1326904296875,
-0.76708984375,
-0.481689453125,
0.32666015625,
0.40087890625,
0.2493896484375,
-0.1844482421875,
-0.2454833984375,
0.372802734375,
-0.521484375,
0.2374267578125,
0.52197265625,
0.6962890625,
0.177490234375,
0.64306640625,
0.1591796875,
0.26611328125,
0.5849609375,
0.9609375,
-0.3203125,
1.0546875,
-0.43017578125,
0.2183837890625,
0.52197265625,
0.050201416015625,
-0.65087890625,
-0.346923828125,
-0.166748046875,
-0.763671875,
0.3212890625,
0.029327392578125,
-0.33056640625,
0.445068359375,
0.04388427734375,
0.47802734375,
-1.15234375,
-0.02239990234375,
0.445068359375,
-0.3115234375,
0.6484375,
-0.394775390625,
-0.1397705078125,
-0.291748046875,
-0.5517578125,
1.0205078125,
-0.309326171875,
-0.171142578125,
0.272216796875,
-0.0914306640625,
-0.253173828125,
-0.1312255859375,
0.20849609375,
0.916015625,
-0.0279693603515625,
0.623046875,
0.97314453125,
-0.96826171875,
0.66357421875,
0.16796875,
0.08050537109375,
1.6435546875,
0.50732421875,
0.1043701171875,
0.5498046875,
0.2666015625,
-0.59765625,
0.0406494140625,
-0.8818359375,
0.88134765625,
0.39453125,
0.2052001953125,
-0.201904296875,
0.279052734375,
0.006229400634765625,
0.5908203125,
0.08209228515625,
-0.07440185546875,
-0.47900390625,
0.432373046875,
-0.0869140625,
0.93701171875,
-0.1103515625,
0.452880859375,
0.0167999267578125,
-0.1580810546875,
0.49072265625,
-0.626953125,
0.495849609375,
-0.1214599609375,
0.159912109375,
0.84130859375,
0.55322265625,
0.83740234375,
0.96337890625,
-0.13525390625,
0.4072265625,
0.476806640625,
-0.5234375,
0.3505859375,
0.11663818359375,
1.0849609375,
0.0137481689453125,
0.07080078125,
0.294677734375,
-0.46435546875,
-1.1455078125,
-0.6533203125,
0.104736328125,
0.264892578125,
-0.3037109375,
0.442626953125,
0.471435546875,
-0.1424560546875,
-0.236083984375,
-0.1307373046875,
0.142333984375,
-1.0380859375,
0.006195068359375,
0.85205078125,
-0.212890625,
0.381103515625,
0.0556640625,
-0.697265625,
0.35888671875,
0.943359375,
-0.1005859375,
0.0634765625,
0.481689453125,
0.13330078125,
-0.0703125,
0.050537109375,
0.25341796875,
-0.1080322265625,
-0.5830078125,
0.81494140625,
-0.37451171875,
0.147216796875,
-0.22265625,
0.34912109375,
0.2354736328125,
0.60595703125,
-0.47802734375,
-0.70263671875,
-0.158935546875,
1.005859375,
-0.1396484375,
-0.1553955078125,
-0.18017578125,
0.55859375,
0.69775390625,
1,
0.49267578125,
0.16552734375,
0.83251953125,
0.7666015625,
0.006496429443359375,
0.434814453125,
-0.16748046875,
0.1929931640625,
0.285888671875,
0.677734375,
0.12188720703125,
0.25634765625,
-0.1304931640625,
-0.09063720703125,
-0.521484375,
0.17724609375,
-0.398681640625,
0.72900390625,
0.254638671875,
0.464111328125,
-0.88671875,
-0.9638671875,
0.12188720703125,
0.98193359375,
-1.04296875,
-0.383056640625,
-0.330078125,
-0.16748046875,
0.2425537109375,
0.1014404296875,
0.437744140625,
0.29541015625,
0.4560546875,
0.57470703125,
-0.1627197265625,
-0.232421875,
-0.74365234375,
-0.4287109375,
-1.0419921875,
-0.42041015625,
-0.69384765625,
-0.2081298828125,
0.413818359375,
-1.03125,
0.44287109375,
-0.35791015625,
-0.140380859375,
0.24755859375,
-0.7177734375,
0.64501953125,
-0.491943359375,
0.5830078125,
-0.71875,
0.3408203125,
0.19921875,
0.72119140625,
-0.52099609375,
0.2222900390625,
0.0129547119140625,
-1.0048828125,
0.0517578125,
-0.2215576171875,
0.479736328125,
0.26513671875,
-0.81494140625,
-0.330078125,
-0.387451171875,
-0.044525146484375,
-0.361328125,
-0.0478515625,
-0.75048828125,
0.4404296875,
0.8525390625,
-0.481201171875,
0.7177734375,
0.927734375,
-1.1455078125,
0.63623046875,
0.52294921875,
-0.002048492431640625,
-0.9404296875,
0.85595703125,
0.4599609375,
0.6865234375,
-0.6435546875,
-0.0404052734375,
-0.77880859375,
0.181640625,
0.4609375,
-0.59912109375,
-0.5595703125,
0.6220703125,
0.2012939453125,
-1.0302734375,
0.49609375,
-1.072265625,
-0.404541015625,
-0.443359375,
-0.16015625,
0.8564453125,
0.85595703125,
0.4423828125,
-0.35986328125,
-0.37548828125,
-0.10699462890625,
0.548828125,
0.568359375,
-0.350830078125,
0.11041259765625,
0.9912109375,
0.184814453125,
0.010986328125,
0.362060546875,
-0.28564453125,
0.446044921875,
-0.43408203125,
0.0211944580078125,
0.28955078125,
0.5419921875,
0.10064697265625,
0.4765625,
0.84814453125,
-1.0703125,
-0.12371826171875,
-0.271240234375,
0.93896484375,
0.708984375,
0.470458984375,
0.36669921875,
-0.2425537109375,
-0.51171875,
-1.1826171875,
0.327392578125,
0.58251953125,
1.01171875,
-0.912109375,
0.317626953125,
-0.2421875,
-0.42919921875,
0.69140625,
-0.77001953125,
0.173828125,
1.2001953125,
-0.055938720703125,
1.0810546875,
-0.41455078125,
0.24169921875,
-0.0229034423828125,
0.2041015625,
0.65380859375,
0.333251953125,
0.1556396484375,
-0.468994140625,
-0.77783203125,
-0.22900390625,
-0.1712646484375,
-0.29248046875,
-0.35205078125,
0.122314453125,
-0.120849609375,
-0.4091796875,
-0.62158203125,
0.1202392578125,
0.6630859375,
0.93408203125,
0.13916015625,
0.488525390625,
0.2083740234375,
0.76513671875,
0.364990234375,
-0.33447265625,
0.187744140625,
-0.7373046875,
0.71630859375,
-0.202392578125,
-0.201904296875,
-0.5068359375,
-0.031341552734375,
-0.2293701171875,
0.21826171875,
-0.189453125,
-0.143310546875,
-1.0380859375,
0.5234375,
-0.1668701171875,
0.3818359375,
-0.6533203125,
-0.2626953125,
-0.62109375,
0.55126953125,
0.281494140625,
-0.51220703125,
0.32373046875,
-0.5,
0.73095703125,
0.6162109375,
-0.1397705078125,
-0.5888671875,
-0.3671875,
-0.8310546875,
-0.271240234375,
0.037628173828125,
0.552734375,
-0.32470703125,
-0.01537322998046875,
-0.97216796875,
0.491943359375,
-0.1964111328125,
-0.126708984375,
0.007049560546875,
-0.37109375,
0.334716796875,
0.291015625,
0.77587890625,
-0.501953125,
-1.0068359375,
-0.04345703125,
-0.69677734375,
0.14501953125,
-0.2130126953125,
0.0086822509765625,
0.28857421875,
0.225341796875,
0.384521484375,
0.35986328125,
-0.08514404296875,
0.151123046875,
-0.1668701171875,
0.10101318359375,
-0.79248046875,
-0.640625,
0.37255859375,
-0.115478515625,
-0.1474609375,
0.236328125,
-0.010955810546875,
-0.0653076171875,
0.08154296875,
0.5966796875,
-0.3203125,
0.283203125,
-0.054534912109375,
0.79052734375,
-0.282470703125,
-0.767578125,
-0.11932373046875,
-0.48388671875,
0.57958984375,
-0.2216796875,
-1.109375,
0.18701171875,
-0.96240234375,
0.0880126953125,
0.0027484893798828125,
-0.11956787109375,
0.79541015625,
0.10870361328125,
-0.09710693359375,
-0.10931396484375,
-0.2841796875,
-0.86279296875,
-0.409912109375,
-0.6416015625,
0.1085205078125,
0.28173828125,
0.56787109375,
1.236328125,
0.1295166015625,
-0.11834716796875,
0.08013916015625,
0.321533203125,
0.0306549072265625,
-0.31689453125,
-0.078369140625,
-0.185302734375,
-0.11944580078125,
-0.2666015625,
0.492919921875,
-0.392822265625,
0.364501953125,
0.802734375,
0.12030029296875,
0.63525390625,
0.0616455078125,
-0.7255859375,
0.391845703125,
0.05487060546875,
-0.97998046875,
-0.3408203125,
0.349365234375,
-0.16162109375,
0.7724609375,
0.8466796875,
-0.654296875,
-1.017578125,
-0.78662109375,
0.1156005859375,
-0.492431640625,
-0.425048828125,
-1.0205078125,
-0.390380859375,
-0.56103515625,
0.57080078125,
-0.1925048828125,
-0.49365234375,
-0.25634765625,
-0.93701171875,
0.384765625,
-0.60009765625,
-0.81689453125,
-0.52001953125,
-0.140869140625,
-0.0810546875,
0.75146484375,
0.285400390625,
0.22021484375,
-0.37451171875,
-0.225830078125,
0.252197265625,
0.33740234375,
-0.63818359375,
-0.1995849609375,
-0.28515625,
-0.25390625,
-0.390869140625,
-0.1156005859375,
-0.443359375,
1.0048828125,
-0.5166015625,
0.043670654296875,
-0.0899658203125,
-0.60205078125,
-0.271728515625,
0.05078125,
0.60107421875,
-0.277099609375,
-0.21826171875,
0.0216217041015625,
0.7294921875,
0.61181640625,
-0.650390625,
-0.290283203125,
-0.703125,
-0.5029296875,
-0.740234375,
0.1783447265625,
-0.7353515625,
0.1357421875,
-0.11700439453125,
-0.27685546875,
0.84130859375,
-0.61474609375,
0.286865234375,
1.2177734375,
-0.0210723876953125,
0.389892578125,
-0.6103515625,
0.8779296875,
0.345458984375,
-0.54248046875,
-0.07281494140625,
-0.270751953125,
-0.498779296875,
0.0631103515625,
-0.2490234375,
-1.32421875,
-0.888671875,
0.05816650390625,
1.0556640625,
-0.4326171875,
1.0107421875,
-0.0013799667358398438,
-1.146484375,
-1.177734375,
0.73681640625,
-0.07916259765625,
0.29296875,
0.9609375,
0.06243896484375,
-0.037628173828125,
0.46875,
-0.036346435546875,
0.346923828125,
-0.9375,
1.015625,
0.2071533203125,
-0.456298828125,
0.68701171875,
1.02734375,
-1.2822265625,
-0.6279296875,
0.2734375,
-0.473388671875,
-0.331298828125,
-0.470947265625,
-0.035400390625,
0.394775390625,
-0.7197265625,
-0.1363525390625,
-0.01461029052734375,
0.08953857421875,
0.44677734375,
-0.332275390625,
0.39111328125,
-0.31396484375,
0.77978515625,
0.86669921875,
-0.619140625,
-0.035736083984375,
-0.69384765625,
-0.307373046875,
-0.60546875,
0.28369140625,
0.935546875,
-0.509765625,
0.0240325927734375,
0.8017578125,
-0.156494140625,
1.4228515625,
-0.126220703125,
-0.06329345703125,
0.43359375,
-0.78515625,
-0.73974609375,
0.2076416015625,
0.427001953125,
-0.39013671875,
0.58447265625,
-0.291015625,
0.259033203125,
0.06353759765625,
0.375732421875,
0.081787109375,
-0.77783203125,
-0.255859375,
-0.8125,
-0.113037109375,
-0.462158203125,
-0.09613037109375,
-0.2425537109375,
-0.053375244140625,
0.0877685546875,
-0.46533203125,
-0.05712890625,
0.59423828125,
-0.1663818359375,
0.20361328125,
-0.7763671875,
0.17578125,
-0.9111328125,
-0.732421875,
-0.68408203125,
-0.144287109375,
-0.277099609375,
-0.005313873291015625,
-0.609375,
0.2044677734375,
-0.3720703125,
0.6494140625,
-0.1475830078125,
0.424560546875,
-0.1580810546875,
-0.83935546875,
-0.10589599609375,
0.0133209228515625,
-0.13525390625,
0.296630859375,
0.440673828125,
-0.187744140625,
0.1544189453125,
-0.258544921875,
-0.32275390625,
0.031707763671875,
-0.1212158203125,
0.88623046875,
-0.0283355712890625,
-0.15283203125,
-0.330322265625,
0.1611328125,
-1.115234375,
0.3232421875,
-0.0894775390625,
-0.04962158203125,
0.15283203125,
-0.130859375,
0.94873046875,
0.6767578125,
-0.4755859375,
0.2349853515625,
-0.061065673828125,
0.09771728515625,
0.466796875,
0.06585693359375,
0.21337890625,
-0.09490966796875,
0.391357421875,
-0.09820556640625,
0.0804443359375,
0.297607421875,
-0.1298828125,
0.4853515625,
-0.2275390625,
-0.5380859375,
-1.1005859375,
-0.227783203125,
0.272705078125,
0.1796875,
-0.2110595703125,
-0.27392578125,
0.272216796875,
0.139892578125,
-0.67919921875,
0.45458984375,
-1.3271484375,
-0.69970703125,
0.9453125,
-0.29931640625,
-0.64794921875,
-0.84033203125,
-0.68994140625,
0.0204315185546875,
0.10565185546875,
0.455322265625,
-0.4814453125,
0.55126953125,
0.04730224609375,
0.6953125,
-0.2880859375,
-0.327880859375,
0.06903076171875,
0.38134765625,
-0.7900390625,
-0.53759765625,
0.45166015625,
0.638671875,
-0.038360595703125,
-0.2052001953125,
-0.7900390625,
0.3369140625,
-0.01079559326171875,
-0.348388671875,
-0.444580078125,
0.395263671875,
-0.211181640625,
0.49658203125,
-0.81884765625,
-0.08123779296875,
-0.10626220703125,
-0.01983642578125,
0.42138671875,
-0.43115234375,
-0.333984375,
0.480712890625,
0.83984375,
-0.53369140625,
0.3212890625,
0.1651611328125,
0.412841796875,
-0.033447265625,
-0.208251953125,
0.1279296875,
0.88427734375,
0.751953125,
0.50390625,
-0.10430908203125,
0.6435546875,
0.394775390625,
-0.1475830078125,
-0.21044921875,
0.258544921875,
0.494140625,
-0.51220703125,
0.50732421875,
0.058746337890625,
-0.1622314453125,
-0.0088348388671875,
-0.449462890625,
0.373779296875,
-0.00421905517578125,
-0.375732421875,
-0.70263671875,
-0.82373046875,
0.564453125,
-0.172119140625,
0.394287109375,
0.246826171875,
-0.373046875,
0.25439453125,
0.87451171875,
-0.12359619140625,
-0.305908203125,
0.92919921875,
0.492919921875,
0.1646728515625,
0.77490234375,
0.038482666015625,
0.35986328125,
-0.990234375,
0.611328125,
0.20703125,
-0.1461181640625,
-0.43505859375,
-0.7314453125,
-0.98095703125,
0.5810546875,
-0.50244140625,
-0.1817626953125,
0.98828125,
-0.740234375,
0.269287109375,
-0.2208251953125,
0.6513671875,
-0.4453125,
-0.023040771484375,
0.29248046875,
-0.53564453125,
-0.1522216796875,
1.1337890625,
-0.311767578125,
0.39990234375,
0.0819091796875,
0.99658203125,
0.41455078125,
1.6884765625,
0.289794921875,
-0.351318359375,
0.16845703125,
0.12493896484375,
-0.17236328125,
-0.6484375,
-0.60986328125,
-0.29296875,
0.25390625,
-0.578125,
-0.467041015625,
-0.25439453125,
0.7626953125,
0.1263427734375,
-1.380859375,
-0.193115234375,
0.1993408203125,
-0.9296875,
0.30712890625,
0.619140625,
0.3935546875,
0.26171875,
-0.187744140625,
0.25634765625,
-0.50927734375,
0.0870361328125,
-0.3662109375,
0.371337890625,
-0.16015625,
-0.6689453125,
-0.4912109375,
-0.87255859375,
0.299072265625,
-0.43212890625,
-0.62109375,
-0.583984375,
0.31640625,
1.052734375,
0.41357421875,
0.5869140625,
-0.50830078125,
-0.201904296875,
0.7724609375,
1.0712890625,
0.08880615234375,
0.47314453125,
0.00046896934509277344,
-0.11273193359375,
0.47509765625,
-0.40380859375,
-0.0006361007690429688,
0.300048828125,
-0.08184814453125,
-0.375244140625,
-0.032806396484375,
-0.36083984375,
-1.23828125,
0.479248046875,
0.96728515625,
0.30419921875,
-0.5224609375,
-1.0615234375,
-0.40283203125,
-1.12109375,
-0.01146697998046875,
-0.5517578125,
0.55419921875,
0.04736328125,
-0.279296875,
0.09576416015625,
-1.1591796875,
4.41015625,
0.91064453125,
0.89013671875,
0.165771484375,
-0.068603515625,
0.9267578125,
0.7197265625,
-0.79833984375,
0.00586700439453125,
-0.335205078125,
0.5009765625,
-0.77685546875,
0.415771484375,
0.86376953125,
0.2423095703125,
0.302978515625,
-0.29736328125,
-0.006839752197265625,
0.01480865478515625,
-0.9921875,
-0.87109375,
-0.07061767578125,
-0.11468505859375,
0.708984375,
0.1982421875,
0.402099609375,
0.26513671875,
-0.42626953125,
-0.11407470703125,
-0.76416015625,
0.0211944580078125,
-0.513671875,
0.9208984375,
0.13671875,
-0.292236328125,
0.51171875,
0.107421875,
-0.79443359375,
-0.256591796875,
0.1602783203125,
-0.09027099609375,
-0.33740234375,
0.4892578125,
-0.728515625,
0.375732421875,
0.487548828125,
-0.437255859375,
0.2802734375,
0.85693359375,
-0.775390625,
1.046875,
-0.09881591796875,
0.304443359375,
-0.61279296875,
-0.9951171875,
0.60888671875,
0.09375,
0.032928466796875,
-0.6015625,
0.442626953125,
0.44580078125,
0.444091796875,
-0.1556396484375,
0.2130126953125,
-0.83740234375,
0.96728515625,
-0.382080078125,
0.8857421875,
-0.44140625,
-0.20947265625,
-0.2025146484375,
-0.398193359375,
-0.328125,
-0.5068359375,
0.72021484375,
0.1922607421875,
-0.12646484375,
0.54296875,
0.5302734375,
-0.64453125,
-0.07672119140625,
-0.28173828125,
-0.5146484375,
-0.59130859375,
0.46875,
1.1767578125,
-0.435791015625,
-0.7080078125,
-0.51416015625,
0.78662109375,
0.6806640625,
0.165283203125,
-0.10791015625,
-0.1060791015625,
-0.289794921875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where
* <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
* <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
* <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.
The content of square brackets is optional — it can be present or can be absent.
There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.
Your task is to write program which checks if given string is a correct Jabber ID.
Input
The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.
Output
Print YES or NO.
Examples
Input
mike@codeforces.com
Output
YES
Input
john.smith@codeforces.ru/contest.icpc/12
Output
NO
Tags: implementation, strings
Correct Solution:
```
import re
string = input( )
pattern = re.compile("^\w{1,16}@(\w{1,16}\.)*\w{1,16}(|/\w{1,16})$")
if pattern.match( string ) :
print( "YES" )
else :
print( "NO" )
```
| 71,030 | [
0.54150390625,
-0.0504150390625,
-0.205078125,
0.496826171875,
0.0012445449829101562,
-0.52880859375,
0.0285186767578125,
-0.235107421875,
0.2440185546875,
0.496337890625,
0.481689453125,
-0.00875091552734375,
0.12005615234375,
-0.935546875,
-0.56201171875,
-0.075439453125,
-0.53759765625,
-0.97216796875,
-0.36328125,
-0.428955078125,
0.25830078125,
0.0672607421875,
-1.27734375,
-0.24169921875,
-0.51025390625,
0.70166015625,
0.1697998046875,
0.369873046875,
0.9326171875,
0.64892578125,
-0.087890625,
-0.6181640625,
0.384765625,
-1.06640625,
-0.40380859375,
-0.34033203125,
0.47216796875,
-1.076171875,
-0.61328125,
-0.435791015625,
0.10943603515625,
-0.31494140625,
0.1700439453125,
-1.0732421875,
-1.087890625,
0.1270751953125,
-0.53564453125,
-0.036346435546875,
-0.049285888671875,
-0.599609375,
0.2880859375,
-0.11151123046875,
0.701171875,
-0.444580078125,
-0.16748046875,
-0.274169921875,
-0.30615234375,
0.1146240234375,
-0.7265625,
0.11395263671875,
-0.11663818359375,
0.39111328125,
-0.07464599609375,
-0.72314453125,
-0.08624267578125,
0.0985107421875,
0.05401611328125,
-0.2344970703125,
-0.0882568359375,
-0.912109375,
-0.05523681640625,
0.35498046875,
-0.62548828125,
-0.64453125,
-0.147216796875,
-0.048858642578125,
0.2783203125,
-0.1434326171875,
-0.267333984375,
0.65771484375,
-0.07366943359375,
1.3232421875,
0.38134765625,
0.1456298828125,
-0.6943359375,
-0.4677734375,
0.262939453125,
0.43408203125,
0.265869140625,
-0.2037353515625,
-0.328369140625,
0.400634765625,
-0.583984375,
0.2291259765625,
0.50830078125,
0.75048828125,
0.1566162109375,
0.634765625,
0.1015625,
0.263671875,
0.58203125,
0.9951171875,
-0.34423828125,
1.06640625,
-0.436767578125,
0.252197265625,
0.544921875,
-0.00266265869140625,
-0.599609375,
-0.374267578125,
-0.1795654296875,
-0.73095703125,
0.3232421875,
0.0889892578125,
-0.3330078125,
0.4990234375,
0.0654296875,
0.44580078125,
-1.1318359375,
-0.049560546875,
0.404052734375,
-0.295166015625,
0.66162109375,
-0.414306640625,
-0.10662841796875,
-0.325439453125,
-0.59423828125,
1.0458984375,
-0.320556640625,
-0.10894775390625,
0.23291015625,
-0.0210723876953125,
-0.223388671875,
-0.116455078125,
0.2271728515625,
0.94873046875,
-0.036285400390625,
0.60498046875,
0.94140625,
-0.96435546875,
0.7109375,
0.09716796875,
0.04913330078125,
1.703125,
0.492919921875,
0.1767578125,
0.6435546875,
0.281005859375,
-0.6298828125,
0.052276611328125,
-0.88232421875,
0.84912109375,
0.4228515625,
0.177001953125,
-0.1761474609375,
0.29345703125,
0.018768310546875,
0.57763671875,
0.0810546875,
-0.058258056640625,
-0.492431640625,
0.443359375,
-0.1300048828125,
0.89404296875,
-0.124755859375,
0.499755859375,
0.028533935546875,
-0.132080078125,
0.444580078125,
-0.6416015625,
0.529296875,
-0.139404296875,
0.189208984375,
0.83837890625,
0.52685546875,
0.87060546875,
0.982421875,
-0.129638671875,
0.431396484375,
0.4619140625,
-0.50146484375,
0.355712890625,
0.06512451171875,
1.0947265625,
0.063720703125,
0.11151123046875,
0.31396484375,
-0.445556640625,
-1.1943359375,
-0.7001953125,
0.1663818359375,
0.330078125,
-0.393310546875,
0.3720703125,
0.451171875,
-0.15869140625,
-0.1680908203125,
-0.139892578125,
0.051788330078125,
-1.0302734375,
-0.018310546875,
0.8115234375,
-0.17578125,
0.391845703125,
0.07647705078125,
-0.71337890625,
0.38818359375,
0.9453125,
-0.166748046875,
0.09405517578125,
0.51025390625,
0.1597900390625,
-0.075927734375,
0.05010986328125,
0.1949462890625,
-0.1260986328125,
-0.62109375,
0.84228515625,
-0.412841796875,
0.1209716796875,
-0.186767578125,
0.366943359375,
0.239990234375,
0.599609375,
-0.544921875,
-0.73046875,
-0.11175537109375,
1.001953125,
-0.0771484375,
-0.145263671875,
-0.251708984375,
0.58154296875,
0.70947265625,
0.96826171875,
0.44482421875,
0.268798828125,
0.83154296875,
0.84033203125,
0.044769287109375,
0.45263671875,
-0.188232421875,
0.2362060546875,
0.1976318359375,
0.70703125,
0.133056640625,
0.2342529296875,
-0.13623046875,
-0.0738525390625,
-0.51123046875,
0.1474609375,
-0.390380859375,
0.8291015625,
0.2978515625,
0.4638671875,
-0.859375,
-0.9658203125,
0.152099609375,
0.96142578125,
-1.0380859375,
-0.39892578125,
-0.292724609375,
-0.1334228515625,
0.266357421875,
0.1328125,
0.476806640625,
0.2783203125,
0.458984375,
0.60498046875,
-0.135009765625,
-0.2320556640625,
-0.80419921875,
-0.428466796875,
-1.0263671875,
-0.409912109375,
-0.67626953125,
-0.2470703125,
0.43603515625,
-1.0341796875,
0.3720703125,
-0.305908203125,
-0.17529296875,
0.25732421875,
-0.7919921875,
0.6787109375,
-0.5185546875,
0.56201171875,
-0.673828125,
0.346435546875,
0.255126953125,
0.75830078125,
-0.5537109375,
0.1878662109375,
0.0435791015625,
-0.98828125,
0.0635986328125,
-0.1884765625,
0.474609375,
0.2744140625,
-0.802734375,
-0.3154296875,
-0.41650390625,
-0.07611083984375,
-0.429931640625,
-0.06854248046875,
-0.77001953125,
0.46923828125,
0.8779296875,
-0.5068359375,
0.7294921875,
0.94921875,
-1.1533203125,
0.6513671875,
0.51953125,
-0.0015134811401367188,
-0.966796875,
0.9267578125,
0.45849609375,
0.724609375,
-0.64501953125,
-0.027679443359375,
-0.7822265625,
0.231201171875,
0.422119140625,
-0.533203125,
-0.58203125,
0.6484375,
0.2283935546875,
-1.0615234375,
0.55908203125,
-1.1298828125,
-0.433837890625,
-0.441162109375,
-0.09100341796875,
0.828125,
0.8671875,
0.402587890625,
-0.405029296875,
-0.386474609375,
-0.12481689453125,
0.54833984375,
0.5771484375,
-0.341064453125,
0.1011962890625,
1.1298828125,
0.138427734375,
0.0084991455078125,
0.349365234375,
-0.342529296875,
0.459716796875,
-0.376953125,
-0.0111236572265625,
0.2939453125,
0.55419921875,
0.11151123046875,
0.431396484375,
0.83447265625,
-1.087890625,
-0.139892578125,
-0.281982421875,
0.91552734375,
0.73779296875,
0.5126953125,
0.39111328125,
-0.30126953125,
-0.48779296875,
-1.2060546875,
0.348876953125,
0.52978515625,
1.0224609375,
-0.9306640625,
0.310791015625,
-0.1956787109375,
-0.453125,
0.6796875,
-0.76171875,
0.1153564453125,
1.2958984375,
-0.10552978515625,
1.01171875,
-0.447998046875,
0.304443359375,
-0.053131103515625,
0.2061767578125,
0.71826171875,
0.367431640625,
0.214599609375,
-0.455078125,
-0.7607421875,
-0.3017578125,
-0.1988525390625,
-0.2349853515625,
-0.352783203125,
0.1522216796875,
-0.1851806640625,
-0.374755859375,
-0.66015625,
0.148681640625,
0.6611328125,
0.86474609375,
0.211669921875,
0.50830078125,
0.1856689453125,
0.703125,
0.324462890625,
-0.365966796875,
0.2239990234375,
-0.70166015625,
0.7490234375,
-0.158935546875,
-0.1885986328125,
-0.5302734375,
-0.0284576416015625,
-0.2288818359375,
0.2398681640625,
-0.1783447265625,
-0.17333984375,
-1.0361328125,
0.564453125,
-0.1712646484375,
0.323486328125,
-0.6884765625,
-0.307861328125,
-0.6103515625,
0.63720703125,
0.319580078125,
-0.5478515625,
0.350341796875,
-0.47802734375,
0.716796875,
0.58935546875,
-0.10662841796875,
-0.61083984375,
-0.28076171875,
-0.86865234375,
-0.2437744140625,
0.053253173828125,
0.58740234375,
-0.341796875,
-0.0017347335815429688,
-0.98046875,
0.45166015625,
-0.1883544921875,
-0.1644287109375,
-0.0202789306640625,
-0.408935546875,
0.333740234375,
0.2357177734375,
0.83056640625,
-0.467529296875,
-1.037109375,
-0.01873779296875,
-0.78564453125,
0.14892578125,
-0.2261962890625,
0.026458740234375,
0.2381591796875,
0.2427978515625,
0.3671875,
0.360107421875,
-0.045440673828125,
0.116455078125,
-0.1458740234375,
0.11163330078125,
-0.81005859375,
-0.65185546875,
0.42138671875,
-0.06463623046875,
-0.2186279296875,
0.280517578125,
-0.0025959014892578125,
-0.046875,
0.058258056640625,
0.6083984375,
-0.304931640625,
0.247314453125,
-0.08026123046875,
0.7451171875,
-0.3427734375,
-0.71240234375,
-0.188720703125,
-0.50830078125,
0.5732421875,
-0.140380859375,
-1.1513671875,
0.1700439453125,
-0.93212890625,
0.047637939453125,
-0.0579833984375,
-0.1759033203125,
0.7763671875,
0.1162109375,
-0.1029052734375,
-0.08758544921875,
-0.321044921875,
-0.87109375,
-0.388671875,
-0.64501953125,
0.07086181640625,
0.31591796875,
0.5859375,
1.251953125,
0.07269287109375,
-0.1773681640625,
0.05816650390625,
0.263427734375,
0.0216217041015625,
-0.352783203125,
-0.027435302734375,
-0.177490234375,
-0.1053466796875,
-0.2491455078125,
0.4658203125,
-0.373779296875,
0.385498046875,
0.7890625,
0.068359375,
0.638671875,
0.094482421875,
-0.7509765625,
0.378173828125,
0.06494140625,
-0.9833984375,
-0.3369140625,
0.422607421875,
-0.09912109375,
0.8134765625,
0.81494140625,
-0.6376953125,
-1.03125,
-0.7978515625,
0.045135498046875,
-0.482421875,
-0.423828125,
-1.0908203125,
-0.45263671875,
-0.5498046875,
0.59033203125,
-0.216064453125,
-0.49609375,
-0.2578125,
-0.95654296875,
0.37744140625,
-0.646484375,
-0.82275390625,
-0.54443359375,
-0.1353759765625,
-0.1015625,
0.79150390625,
0.27099609375,
0.220947265625,
-0.33740234375,
-0.1993408203125,
0.2286376953125,
0.339111328125,
-0.6923828125,
-0.13623046875,
-0.239990234375,
-0.2025146484375,
-0.3544921875,
-0.141357421875,
-0.38623046875,
0.95849609375,
-0.5361328125,
0.1016845703125,
-0.1488037109375,
-0.54541015625,
-0.267578125,
0.0005269050598144531,
0.59619140625,
-0.2861328125,
-0.22119140625,
0.0126190185546875,
0.716796875,
0.57568359375,
-0.587890625,
-0.252197265625,
-0.7587890625,
-0.485595703125,
-0.72509765625,
0.189453125,
-0.7236328125,
0.1370849609375,
-0.15771484375,
-0.26806640625,
0.84814453125,
-0.68798828125,
0.31982421875,
1.2109375,
-0.024871826171875,
0.37890625,
-0.6591796875,
0.89892578125,
0.30322265625,
-0.58935546875,
-0.06439208984375,
-0.2391357421875,
-0.55615234375,
0.05108642578125,
-0.2340087890625,
-1.3310546875,
-0.86474609375,
0.006381988525390625,
1.138671875,
-0.391845703125,
1.0078125,
0.0802001953125,
-1.173828125,
-1.2177734375,
0.7744140625,
-0.064697265625,
0.367431640625,
0.98974609375,
0.033721923828125,
-0.04302978515625,
0.453369140625,
-0.07470703125,
0.3583984375,
-0.88232421875,
1.1025390625,
0.1278076171875,
-0.4208984375,
0.6591796875,
1.0458984375,
-1.3203125,
-0.67529296875,
0.2071533203125,
-0.47998046875,
-0.3623046875,
-0.499755859375,
-0.01137542724609375,
0.41357421875,
-0.70947265625,
-0.13623046875,
-0.03314208984375,
0.08935546875,
0.431396484375,
-0.330810546875,
0.362548828125,
-0.333740234375,
0.814453125,
0.9306640625,
-0.57470703125,
-0.039703369140625,
-0.650390625,
-0.27392578125,
-0.6552734375,
0.294921875,
0.91162109375,
-0.53955078125,
0.03509521484375,
0.78955078125,
-0.1787109375,
1.3623046875,
-0.1529541015625,
-0.09765625,
0.43896484375,
-0.76171875,
-0.73046875,
0.166259765625,
0.4482421875,
-0.413330078125,
0.65478515625,
-0.304931640625,
0.284912109375,
0.04437255859375,
0.456298828125,
0.1192626953125,
-0.81884765625,
-0.215576171875,
-0.8994140625,
-0.18896484375,
-0.46826171875,
-0.1656494140625,
-0.2255859375,
-0.048858642578125,
0.09429931640625,
-0.51318359375,
-0.09490966796875,
0.54345703125,
-0.1165771484375,
0.2724609375,
-0.79638671875,
0.2054443359375,
-0.96044921875,
-0.71484375,
-0.7041015625,
-0.1290283203125,
-0.28662109375,
-0.0035228729248046875,
-0.58740234375,
0.1845703125,
-0.37646484375,
0.6708984375,
-0.1185302734375,
0.4296875,
-0.15283203125,
-0.78515625,
-0.10211181640625,
-0.0284881591796875,
-0.12298583984375,
0.3349609375,
0.4765625,
-0.1820068359375,
0.131103515625,
-0.2327880859375,
-0.30029296875,
-0.0216217041015625,
-0.1405029296875,
0.87744140625,
-0.055908203125,
-0.17138671875,
-0.384521484375,
0.195556640625,
-1.13671875,
0.345947265625,
-0.08837890625,
-0.12939453125,
0.18701171875,
-0.1815185546875,
0.94287109375,
0.78271484375,
-0.479248046875,
0.253662109375,
-0.08673095703125,
0.093994140625,
0.484130859375,
0.116943359375,
0.185546875,
-0.11627197265625,
0.37841796875,
-0.06390380859375,
0.12408447265625,
0.304443359375,
-0.18896484375,
0.43359375,
-0.286865234375,
-0.50439453125,
-1.1572265625,
-0.25390625,
0.197265625,
0.16015625,
-0.1409912109375,
-0.341552734375,
0.27587890625,
0.11785888671875,
-0.66943359375,
0.439697265625,
-1.3583984375,
-0.7763671875,
1.013671875,
-0.2225341796875,
-0.62841796875,
-0.841796875,
-0.6494140625,
0.047027587890625,
0.11187744140625,
0.40380859375,
-0.51953125,
0.51611328125,
-0.001621246337890625,
0.716796875,
-0.253662109375,
-0.29638671875,
0.09478759765625,
0.384521484375,
-0.8212890625,
-0.509765625,
0.3603515625,
0.642578125,
-0.061920166015625,
-0.1494140625,
-0.73681640625,
0.36279296875,
-0.0224456787109375,
-0.347412109375,
-0.5537109375,
0.41943359375,
-0.1710205078125,
0.5244140625,
-0.85498046875,
-0.01332855224609375,
-0.123779296875,
-0.006763458251953125,
0.38037109375,
-0.465087890625,
-0.283935546875,
0.54296875,
0.84912109375,
-0.5234375,
0.319091796875,
0.1448974609375,
0.43603515625,
-0.0038967132568359375,
-0.2113037109375,
0.1024169921875,
0.8623046875,
0.728515625,
0.560546875,
-0.1287841796875,
0.716796875,
0.4169921875,
-0.0858154296875,
-0.1544189453125,
0.275146484375,
0.45263671875,
-0.48583984375,
0.50341796875,
0.0430908203125,
-0.1907958984375,
0.02740478515625,
-0.463134765625,
0.308349609375,
-0.03179931640625,
-0.38330078125,
-0.74755859375,
-0.83837890625,
0.62060546875,
-0.104736328125,
0.328857421875,
0.2430419921875,
-0.392333984375,
0.280029296875,
0.939453125,
-0.04632568359375,
-0.299072265625,
0.9560546875,
0.483642578125,
0.2166748046875,
0.7578125,
0.039398193359375,
0.32177734375,
-0.9814453125,
0.56982421875,
0.1905517578125,
-0.172119140625,
-0.403564453125,
-0.623046875,
-1.0576171875,
0.58447265625,
-0.52490234375,
-0.1500244140625,
0.962890625,
-0.779296875,
0.3408203125,
-0.23974609375,
0.6953125,
-0.446044921875,
-0.0223388671875,
0.327880859375,
-0.471923828125,
-0.151123046875,
1.197265625,
-0.353271484375,
0.42236328125,
0.1141357421875,
1.072265625,
0.39453125,
1.6826171875,
0.313720703125,
-0.353271484375,
0.178955078125,
0.2015380859375,
-0.233642578125,
-0.671875,
-0.55078125,
-0.2568359375,
0.241943359375,
-0.66015625,
-0.51025390625,
-0.2491455078125,
0.8203125,
0.0921630859375,
-1.3779296875,
-0.240234375,
0.18505859375,
-0.9326171875,
0.361083984375,
0.6279296875,
0.3212890625,
0.2335205078125,
-0.1593017578125,
0.24658203125,
-0.49267578125,
0.1153564453125,
-0.435791015625,
0.4580078125,
-0.1639404296875,
-0.68994140625,
-0.46630859375,
-0.90576171875,
0.26318359375,
-0.461669921875,
-0.56884765625,
-0.6044921875,
0.3525390625,
0.9697265625,
0.397705078125,
0.56396484375,
-0.515625,
-0.181640625,
0.75146484375,
1.0595703125,
0.06390380859375,
0.57421875,
0.01409912109375,
-0.1602783203125,
0.4755859375,
-0.473388671875,
0.01548004150390625,
0.29833984375,
-0.014190673828125,
-0.383056640625,
0.06341552734375,
-0.38330078125,
-1.2509765625,
0.445556640625,
0.93994140625,
0.3193359375,
-0.55615234375,
-1.1142578125,
-0.36328125,
-1.1533203125,
-0.0016574859619140625,
-0.57666015625,
0.59326171875,
0.05230712890625,
-0.27001953125,
0.043731689453125,
-1.1796875,
4.34765625,
0.9443359375,
0.93310546875,
0.1802978515625,
-0.03277587890625,
0.91357421875,
0.68408203125,
-0.82421875,
0.007717132568359375,
-0.294677734375,
0.52783203125,
-0.748046875,
0.40869140625,
0.95849609375,
0.262451171875,
0.391845703125,
-0.319091796875,
-0.0251312255859375,
0.0204620361328125,
-0.97998046875,
-0.89013671875,
-0.07354736328125,
-0.0706787109375,
0.64599609375,
0.2181396484375,
0.41748046875,
0.2802734375,
-0.40087890625,
-0.1541748046875,
-0.8037109375,
0.07958984375,
-0.5283203125,
0.95361328125,
0.1326904296875,
-0.29638671875,
0.50439453125,
0.08160400390625,
-0.83349609375,
-0.2353515625,
0.190673828125,
-0.0965576171875,
-0.33984375,
0.459228515625,
-0.72607421875,
0.29052734375,
0.427490234375,
-0.4375,
0.322021484375,
0.92626953125,
-0.8388671875,
1.0068359375,
-0.10491943359375,
0.33154296875,
-0.626953125,
-0.9931640625,
0.60595703125,
0.1287841796875,
0.01158905029296875,
-0.61279296875,
0.46142578125,
0.4453125,
0.470458984375,
-0.12744140625,
0.2147216796875,
-0.89404296875,
0.990234375,
-0.40625,
0.8701171875,
-0.4384765625,
-0.2158203125,
-0.2215576171875,
-0.44287109375,
-0.352783203125,
-0.5126953125,
0.7958984375,
0.247314453125,
-0.1865234375,
0.50048828125,
0.576171875,
-0.64453125,
-0.11419677734375,
-0.314697265625,
-0.4365234375,
-0.552734375,
0.454833984375,
1.19921875,
-0.38916015625,
-0.6767578125,
-0.5234375,
0.7998046875,
0.66552734375,
0.234130859375,
-0.079345703125,
-0.130126953125,
-0.3427734375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where
* <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
* <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
* <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.
The content of square brackets is optional — it can be present or can be absent.
There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.
Your task is to write program which checks if given string is a correct Jabber ID.
Input
The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.
Output
Print YES or NO.
Examples
Input
mike@codeforces.com
Output
YES
Input
john.smith@codeforces.ru/contest.icpc/12
Output
NO
Tags: implementation, strings
Correct Solution:
```
s=input()
a=s.split('@')
if len(a)!=2:
print("NO")
exit()
un=a[0].upper()
for c in un:
if not (c>="A" and c<="Z" or c=="_" or c>='0' and c<='9'):
print("NO")
exit()
if len(un)<1 or len(un)>16:
print("NO")
exit()
b=a[1].split("/")
if len(a)>2:
print("NO")
exit()
hn=b[0].upper()
if len(hn)>32:
print("NO")
exit()
for c in hn:
if not (c>="A" and c<="Z" or c=="_" or c=='.' or c>='0' and c<='9'):
print("NO")
exit()
c=hn.split('.')
for w in c:
if len(w)>16 or len(w)<1:
print("NO")
exit()
if len(b)==1:
print("YES")
exit()
res=b[1].upper()
if len(res)>16 or len(res)<1:
print("NO")
exit()
for c in res:
if not (c>="A" and c<="Z" or c=="_" or c>='0' and c<='9'):
print("NO")
exit()
print("YES")
```
| 71,031 | [
0.5390625,
-0.08355712890625,
-0.1715087890625,
0.468017578125,
0.0140228271484375,
-0.5517578125,
0.059478759765625,
-0.2203369140625,
0.1800537109375,
0.50244140625,
0.477783203125,
0.04583740234375,
0.052398681640625,
-0.9091796875,
-0.60205078125,
-0.07159423828125,
-0.53662109375,
-0.89892578125,
-0.306396484375,
-0.4501953125,
0.310546875,
0.036529541015625,
-1.259765625,
-0.1905517578125,
-0.53759765625,
0.68115234375,
0.1710205078125,
0.342041015625,
0.9462890625,
0.66796875,
-0.1285400390625,
-0.61962890625,
0.410888671875,
-1.0107421875,
-0.369384765625,
-0.32763671875,
0.41455078125,
-1.0859375,
-0.58251953125,
-0.4052734375,
0.1107177734375,
-0.2509765625,
0.1822509765625,
-1.0703125,
-1.1201171875,
0.12176513671875,
-0.52783203125,
-0.0293731689453125,
-0.032928466796875,
-0.5634765625,
0.2227783203125,
-0.09857177734375,
0.73876953125,
-0.452392578125,
-0.209716796875,
-0.280029296875,
-0.347412109375,
0.1063232421875,
-0.71533203125,
0.1505126953125,
-0.10540771484375,
0.4169921875,
-0.0196685791015625,
-0.6865234375,
-0.07476806640625,
0.0328369140625,
0.053863525390625,
-0.2061767578125,
-0.10638427734375,
-0.87744140625,
-0.046142578125,
0.350341796875,
-0.63330078125,
-0.65869140625,
-0.2236328125,
0.01690673828125,
0.269287109375,
-0.11846923828125,
-0.2425537109375,
0.7099609375,
-0.0943603515625,
1.32421875,
0.366943359375,
0.18603515625,
-0.7236328125,
-0.485595703125,
0.3173828125,
0.43701171875,
0.24951171875,
-0.172119140625,
-0.260986328125,
0.395751953125,
-0.57763671875,
0.2257080078125,
0.525390625,
0.67626953125,
0.1357421875,
0.62060546875,
0.13427734375,
0.2568359375,
0.5810546875,
0.93408203125,
-0.30322265625,
1.06640625,
-0.435791015625,
0.2474365234375,
0.54638671875,
0.03912353515625,
-0.6591796875,
-0.365966796875,
-0.2088623046875,
-0.74853515625,
0.36279296875,
0.0496826171875,
-0.349609375,
0.5048828125,
0.04486083984375,
0.4658203125,
-1.1826171875,
0.004108428955078125,
0.490966796875,
-0.307373046875,
0.69091796875,
-0.388671875,
-0.11212158203125,
-0.28759765625,
-0.58984375,
1.033203125,
-0.312744140625,
-0.172119140625,
0.2447509765625,
-0.01947021484375,
-0.253662109375,
-0.14697265625,
0.1942138671875,
0.888671875,
-0.0188446044921875,
0.61474609375,
0.9921875,
-1.001953125,
0.64453125,
0.1746826171875,
0.06500244140625,
1.6611328125,
0.499755859375,
0.1318359375,
0.57763671875,
0.298828125,
-0.609375,
0.07025146484375,
-0.93603515625,
0.94677734375,
0.408935546875,
0.174560546875,
-0.242431640625,
0.312255859375,
0.01430511474609375,
0.56103515625,
0.08807373046875,
-0.054229736328125,
-0.449951171875,
0.43798828125,
-0.086181640625,
0.9423828125,
-0.11920166015625,
0.46533203125,
0.0164794921875,
-0.1712646484375,
0.454345703125,
-0.6142578125,
0.51318359375,
-0.147705078125,
0.1593017578125,
0.82275390625,
0.53759765625,
0.876953125,
0.99609375,
-0.1510009765625,
0.43603515625,
0.47314453125,
-0.5283203125,
0.35205078125,
0.052398681640625,
1.05078125,
0.03216552734375,
0.10546875,
0.332275390625,
-0.48974609375,
-1.177734375,
-0.6455078125,
0.13671875,
0.298095703125,
-0.349609375,
0.4375,
0.4365234375,
-0.1485595703125,
-0.1636962890625,
-0.087158203125,
0.0921630859375,
-1.0498046875,
-0.0125274658203125,
0.85498046875,
-0.1968994140625,
0.407470703125,
0.0129547119140625,
-0.70556640625,
0.408447265625,
0.95166015625,
-0.1094970703125,
0.03594970703125,
0.492919921875,
0.1229248046875,
-0.1005859375,
0.07733154296875,
0.1873779296875,
-0.11920166015625,
-0.60205078125,
0.81103515625,
-0.384521484375,
0.1385498046875,
-0.18603515625,
0.340087890625,
0.2420654296875,
0.6142578125,
-0.482421875,
-0.7314453125,
-0.0955810546875,
1.005859375,
-0.1556396484375,
-0.122314453125,
-0.18115234375,
0.56005859375,
0.6953125,
1.0009765625,
0.4921875,
0.236328125,
0.8046875,
0.77880859375,
0.04705810546875,
0.443115234375,
-0.20947265625,
0.1932373046875,
0.270263671875,
0.68994140625,
0.116943359375,
0.2344970703125,
-0.1334228515625,
-0.07391357421875,
-0.4931640625,
0.2205810546875,
-0.39794921875,
0.76953125,
0.272705078125,
0.48828125,
-0.845703125,
-0.96533203125,
0.1807861328125,
0.92529296875,
-1.037109375,
-0.41357421875,
-0.302734375,
-0.142333984375,
0.27978515625,
0.110107421875,
0.44970703125,
0.29443359375,
0.46142578125,
0.58935546875,
-0.15185546875,
-0.260986328125,
-0.7314453125,
-0.41015625,
-1.044921875,
-0.4130859375,
-0.6865234375,
-0.195068359375,
0.433349609375,
-1.0390625,
0.3818359375,
-0.39990234375,
-0.1761474609375,
0.218017578125,
-0.7822265625,
0.65966796875,
-0.5107421875,
0.5517578125,
-0.720703125,
0.3271484375,
0.262939453125,
0.73388671875,
-0.5576171875,
0.2225341796875,
-0.0025463104248046875,
-0.9833984375,
0.061553955078125,
-0.2161865234375,
0.49609375,
0.279052734375,
-0.82666015625,
-0.351806640625,
-0.3857421875,
-0.0592041015625,
-0.40576171875,
-0.02496337890625,
-0.77001953125,
0.452392578125,
0.869140625,
-0.52001953125,
0.6796875,
0.935546875,
-1.154296875,
0.640625,
0.53564453125,
-0.0050048828125,
-0.93701171875,
0.90966796875,
0.4169921875,
0.72021484375,
-0.6337890625,
-0.03936767578125,
-0.765625,
0.2369384765625,
0.425537109375,
-0.55615234375,
-0.5341796875,
0.63720703125,
0.2127685546875,
-1.0146484375,
0.5185546875,
-1.080078125,
-0.37841796875,
-0.458984375,
-0.172119140625,
0.85986328125,
0.89501953125,
0.38427734375,
-0.371337890625,
-0.357666015625,
-0.1107177734375,
0.56298828125,
0.54248046875,
-0.38671875,
0.075439453125,
1.0859375,
0.19189453125,
-0.0423583984375,
0.346435546875,
-0.2734375,
0.454345703125,
-0.39990234375,
0.015869140625,
0.258056640625,
0.53271484375,
0.05389404296875,
0.493896484375,
0.84716796875,
-1.03515625,
-0.145751953125,
-0.315185546875,
0.91943359375,
0.73779296875,
0.453125,
0.396240234375,
-0.202392578125,
-0.509765625,
-1.2294921875,
0.35888671875,
0.55419921875,
0.98388671875,
-0.93212890625,
0.33837890625,
-0.2176513671875,
-0.43408203125,
0.650390625,
-0.78125,
0.17919921875,
1.2177734375,
-0.0692138671875,
1.0673828125,
-0.421630859375,
0.289794921875,
-0.06732177734375,
0.146240234375,
0.705078125,
0.33447265625,
0.1927490234375,
-0.461181640625,
-0.791015625,
-0.2486572265625,
-0.1575927734375,
-0.275390625,
-0.3916015625,
0.1304931640625,
-0.1375732421875,
-0.37109375,
-0.6298828125,
0.1629638671875,
0.65185546875,
0.91748046875,
0.1785888671875,
0.471923828125,
0.1689453125,
0.72900390625,
0.39013671875,
-0.348388671875,
0.1966552734375,
-0.6884765625,
0.73486328125,
-0.1890869140625,
-0.198974609375,
-0.53515625,
-0.0377197265625,
-0.2169189453125,
0.2147216796875,
-0.1932373046875,
-0.151611328125,
-0.9794921875,
0.55078125,
-0.1658935546875,
0.361083984375,
-0.708984375,
-0.2646484375,
-0.5634765625,
0.5869140625,
0.286865234375,
-0.56640625,
0.322509765625,
-0.50732421875,
0.73388671875,
0.58837890625,
-0.11566162109375,
-0.6357421875,
-0.375244140625,
-0.86083984375,
-0.22998046875,
0.031585693359375,
0.60791015625,
-0.3291015625,
0.0210418701171875,
-0.998046875,
0.469482421875,
-0.1556396484375,
-0.11053466796875,
-0.01153564453125,
-0.359375,
0.309814453125,
0.274658203125,
0.818359375,
-0.50927734375,
-1.0126953125,
-0.0394287109375,
-0.79833984375,
0.158935546875,
-0.296630859375,
-0.01471710205078125,
0.25146484375,
0.1859130859375,
0.402099609375,
0.340576171875,
-0.051055908203125,
0.1097412109375,
-0.1741943359375,
0.0916748046875,
-0.78564453125,
-0.66796875,
0.36376953125,
-0.10113525390625,
-0.187255859375,
0.28759765625,
-0.051483154296875,
-0.05059814453125,
0.05902099609375,
0.6259765625,
-0.324951171875,
0.26708984375,
-0.0626220703125,
0.7763671875,
-0.340087890625,
-0.73046875,
-0.1759033203125,
-0.5087890625,
0.58544921875,
-0.1759033203125,
-1.1474609375,
0.2105712890625,
-0.96533203125,
0.09002685546875,
-0.0291595458984375,
-0.11590576171875,
0.72314453125,
0.13818359375,
-0.0977783203125,
-0.07843017578125,
-0.3232421875,
-0.853515625,
-0.391845703125,
-0.67822265625,
0.0887451171875,
0.300537109375,
0.56787109375,
1.2265625,
0.12091064453125,
-0.1427001953125,
0.11676025390625,
0.30078125,
0.040435791015625,
-0.336669921875,
-0.07257080078125,
-0.2071533203125,
-0.08795166015625,
-0.2384033203125,
0.498046875,
-0.359130859375,
0.38330078125,
0.77587890625,
0.1165771484375,
0.60546875,
0.1273193359375,
-0.7255859375,
0.408447265625,
0.0218963623046875,
-0.9619140625,
-0.331298828125,
0.424072265625,
-0.143798828125,
0.78173828125,
0.8017578125,
-0.71142578125,
-1.015625,
-0.80224609375,
0.103271484375,
-0.483154296875,
-0.416259765625,
-1.0390625,
-0.414306640625,
-0.54296875,
0.55615234375,
-0.2476806640625,
-0.53271484375,
-0.2484130859375,
-0.93798828125,
0.35498046875,
-0.609375,
-0.82666015625,
-0.5537109375,
-0.1429443359375,
-0.07916259765625,
0.7177734375,
0.293212890625,
0.2154541015625,
-0.381103515625,
-0.23046875,
0.216064453125,
0.26416015625,
-0.6611328125,
-0.2078857421875,
-0.30224609375,
-0.2099609375,
-0.381591796875,
-0.12384033203125,
-0.40185546875,
0.98486328125,
-0.552734375,
0.051483154296875,
-0.0953369140625,
-0.58154296875,
-0.268310546875,
0.045013427734375,
0.6181640625,
-0.27197265625,
-0.208740234375,
0.058624267578125,
0.759765625,
0.642578125,
-0.619140625,
-0.322265625,
-0.724609375,
-0.51708984375,
-0.72119140625,
0.186767578125,
-0.6884765625,
0.12261962890625,
-0.1416015625,
-0.20751953125,
0.84521484375,
-0.64990234375,
0.31103515625,
1.23828125,
-0.05438232421875,
0.408203125,
-0.6181640625,
0.8505859375,
0.3251953125,
-0.583984375,
-0.045745849609375,
-0.22412109375,
-0.548828125,
0.06341552734375,
-0.261474609375,
-1.32421875,
-0.91259765625,
0.05694580078125,
1.107421875,
-0.3837890625,
0.98974609375,
0.0218505859375,
-1.1875,
-1.2001953125,
0.755859375,
-0.046417236328125,
0.37939453125,
1.0322265625,
0.058013916015625,
-0.043853759765625,
0.48193359375,
-0.06634521484375,
0.360595703125,
-0.9404296875,
1.0419921875,
0.165771484375,
-0.426513671875,
0.7197265625,
1.0078125,
-1.279296875,
-0.662109375,
0.251220703125,
-0.50048828125,
-0.366943359375,
-0.472900390625,
-0.0816650390625,
0.421142578125,
-0.69091796875,
-0.11822509765625,
-0.032196044921875,
0.08758544921875,
0.4453125,
-0.30224609375,
0.38037109375,
-0.303466796875,
0.8125,
0.8857421875,
-0.59033203125,
0.0277099609375,
-0.73388671875,
-0.2958984375,
-0.61083984375,
0.30078125,
0.89599609375,
-0.5068359375,
0.0257720947265625,
0.79638671875,
-0.19091796875,
1.404296875,
-0.1385498046875,
-0.08624267578125,
0.45849609375,
-0.783203125,
-0.7431640625,
0.2227783203125,
0.4130859375,
-0.422607421875,
0.61669921875,
-0.266357421875,
0.254150390625,
0.0304107666015625,
0.44189453125,
0.080078125,
-0.783203125,
-0.277587890625,
-0.7958984375,
-0.139892578125,
-0.47265625,
-0.10113525390625,
-0.278076171875,
-0.032073974609375,
0.10052490234375,
-0.46044921875,
-0.00799560546875,
0.5732421875,
-0.18017578125,
0.2320556640625,
-0.826171875,
0.20361328125,
-0.9375,
-0.74462890625,
-0.7265625,
-0.10882568359375,
-0.31787109375,
0.003814697265625,
-0.58740234375,
0.2052001953125,
-0.333251953125,
0.69775390625,
-0.14013671875,
0.39697265625,
-0.139892578125,
-0.8515625,
-0.0640869140625,
0.0005340576171875,
-0.113037109375,
0.3173828125,
0.456787109375,
-0.155517578125,
0.13671875,
-0.289794921875,
-0.308349609375,
-0.00464630126953125,
-0.1019287109375,
0.9052734375,
-0.0304718017578125,
-0.136474609375,
-0.36279296875,
0.15380859375,
-1.1083984375,
0.336181640625,
-0.12469482421875,
-0.04254150390625,
0.1748046875,
-0.1387939453125,
0.947265625,
0.72314453125,
-0.499267578125,
0.222900390625,
-0.078369140625,
0.08709716796875,
0.5087890625,
0.1256103515625,
0.200927734375,
-0.0875244140625,
0.40869140625,
-0.11065673828125,
0.09375,
0.278076171875,
-0.1396484375,
0.446044921875,
-0.2587890625,
-0.54248046875,
-1.125,
-0.20703125,
0.2237548828125,
0.1671142578125,
-0.1329345703125,
-0.338134765625,
0.27685546875,
0.1444091796875,
-0.6826171875,
0.4609375,
-1.322265625,
-0.75244140625,
0.939453125,
-0.235107421875,
-0.6298828125,
-0.80517578125,
-0.6708984375,
0.00685882568359375,
0.0657958984375,
0.498291015625,
-0.5146484375,
0.50830078125,
0.0316162109375,
0.73095703125,
-0.282958984375,
-0.27978515625,
0.07196044921875,
0.374267578125,
-0.796875,
-0.54638671875,
0.390380859375,
0.6279296875,
-0.06243896484375,
-0.2061767578125,
-0.79638671875,
0.3642578125,
-0.0255279541015625,
-0.37890625,
-0.4677734375,
0.383056640625,
-0.203125,
0.453857421875,
-0.87109375,
-0.079833984375,
-0.1031494140625,
-0.0229644775390625,
0.37451171875,
-0.465576171875,
-0.32080078125,
0.52197265625,
0.85791015625,
-0.5048828125,
0.29931640625,
0.17041015625,
0.4111328125,
-0.01358795166015625,
-0.1900634765625,
0.1478271484375,
0.85986328125,
0.763671875,
0.487060546875,
-0.12109375,
0.65869140625,
0.3974609375,
-0.15185546875,
-0.1522216796875,
0.27978515625,
0.4990234375,
-0.493408203125,
0.5283203125,
0.056121826171875,
-0.15869140625,
0.01036834716796875,
-0.48681640625,
0.350341796875,
-0.01275634765625,
-0.34619140625,
-0.728515625,
-0.8427734375,
0.5810546875,
-0.19189453125,
0.35009765625,
0.283935546875,
-0.3994140625,
0.239990234375,
0.900390625,
-0.1337890625,
-0.300537109375,
0.98974609375,
0.51708984375,
0.1805419921875,
0.78857421875,
0.029510498046875,
0.375,
-1.0166015625,
0.646484375,
0.157958984375,
-0.1761474609375,
-0.367919921875,
-0.70458984375,
-1.0166015625,
0.587890625,
-0.48828125,
-0.1644287109375,
0.96240234375,
-0.77783203125,
0.3125,
-0.22314453125,
0.66845703125,
-0.419677734375,
-0.0325927734375,
0.31494140625,
-0.580078125,
-0.1363525390625,
1.1640625,
-0.345458984375,
0.375732421875,
0.07366943359375,
0.99658203125,
0.417236328125,
1.7421875,
0.292236328125,
-0.3974609375,
0.1934814453125,
0.1334228515625,
-0.2032470703125,
-0.67236328125,
-0.57763671875,
-0.288330078125,
0.2396240234375,
-0.5517578125,
-0.4619140625,
-0.2880859375,
0.79248046875,
0.0960693359375,
-1.390625,
-0.256103515625,
0.1650390625,
-0.92236328125,
0.35205078125,
0.60107421875,
0.409912109375,
0.26513671875,
-0.150146484375,
0.2376708984375,
-0.491455078125,
0.08502197265625,
-0.40185546875,
0.383056640625,
-0.1934814453125,
-0.66748046875,
-0.4765625,
-0.9150390625,
0.285888671875,
-0.426513671875,
-0.6015625,
-0.5849609375,
0.311279296875,
1.037109375,
0.410888671875,
0.599609375,
-0.49267578125,
-0.1590576171875,
0.744140625,
1.060546875,
0.1019287109375,
0.48388671875,
0.04400634765625,
-0.1322021484375,
0.453857421875,
-0.4287109375,
0.0439453125,
0.308837890625,
-0.04217529296875,
-0.360595703125,
0.042694091796875,
-0.39697265625,
-1.2802734375,
0.457763671875,
0.95849609375,
0.308837890625,
-0.509765625,
-1.060546875,
-0.36279296875,
-1.1435546875,
-0.0002639293670654297,
-0.53857421875,
0.595703125,
0.00807952880859375,
-0.263671875,
0.0679931640625,
-1.1826171875,
4.37109375,
0.95263671875,
0.88427734375,
0.1798095703125,
-0.0770263671875,
0.8935546875,
0.66845703125,
-0.7978515625,
-0.045135498046875,
-0.30126953125,
0.5107421875,
-0.802734375,
0.399169921875,
0.94189453125,
0.254638671875,
0.3369140625,
-0.33203125,
-0.002178192138671875,
-0.0269927978515625,
-0.98583984375,
-0.9365234375,
-0.04248046875,
-0.0953369140625,
0.65673828125,
0.1971435546875,
0.4365234375,
0.278076171875,
-0.40283203125,
-0.1710205078125,
-0.87060546875,
0.048492431640625,
-0.5498046875,
0.8994140625,
0.162841796875,
-0.289794921875,
0.483154296875,
0.0843505859375,
-0.798828125,
-0.2261962890625,
0.1942138671875,
-0.07098388671875,
-0.327880859375,
0.460205078125,
-0.72705078125,
0.2978515625,
0.461181640625,
-0.489501953125,
0.376953125,
0.87353515625,
-0.81201171875,
1.005859375,
-0.0955810546875,
0.32861328125,
-0.59326171875,
-0.98828125,
0.60693359375,
0.1134033203125,
0.036163330078125,
-0.61328125,
0.45556640625,
0.450927734375,
0.443115234375,
-0.133544921875,
0.2232666015625,
-0.8671875,
1.005859375,
-0.396728515625,
0.921875,
-0.48095703125,
-0.2020263671875,
-0.2098388671875,
-0.42041015625,
-0.357421875,
-0.49853515625,
0.7548828125,
0.236083984375,
-0.1378173828125,
0.52001953125,
0.57421875,
-0.658203125,
-0.049591064453125,
-0.2578125,
-0.45849609375,
-0.5751953125,
0.480712890625,
1.2265625,
-0.407958984375,
-0.68310546875,
-0.50390625,
0.78369140625,
0.69140625,
0.1710205078125,
-0.07421875,
-0.1556396484375,
-0.308837890625
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where
* <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
* <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
* <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.
The content of square brackets is optional — it can be present or can be absent.
There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.
Your task is to write program which checks if given string is a correct Jabber ID.
Input
The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.
Output
Print YES or NO.
Examples
Input
mike@codeforces.com
Output
YES
Input
john.smith@codeforces.ru/contest.icpc/12
Output
NO
Tags: implementation, strings
Correct Solution:
```
def w(s):
return s.isalnum() and len(s) <= 16
def v(s):
i1, i2 = s.find('@'), s.rfind('/')
if i1 == -1 or (i2 > -1 and i1 > i2):
return False
elif not w(s[:i1]) or (i2 > -1 and not w(s[i2 + 1:])):
return False
else:
return all(w(x) for x in s[i1 + 1:(i2 if i2 > -1 else len(s))].split('.'))
print('YES' if v(input().replace('_', 'a')) else 'NO')
```
| 71,032 | [
0.56298828125,
-0.0718994140625,
-0.1947021484375,
0.51806640625,
0.015167236328125,
-0.556640625,
0.044097900390625,
-0.23046875,
0.15283203125,
0.484130859375,
0.444091796875,
-0.03668212890625,
0.0535888671875,
-0.91650390625,
-0.57763671875,
-0.0987548828125,
-0.53515625,
-0.89892578125,
-0.380126953125,
-0.482421875,
0.354736328125,
0.11187744140625,
-1.228515625,
-0.2587890625,
-0.52490234375,
0.67041015625,
0.1400146484375,
0.3544921875,
0.9716796875,
0.63671875,
-0.05413818359375,
-0.609375,
0.431396484375,
-1.0146484375,
-0.363525390625,
-0.344970703125,
0.468017578125,
-1.0087890625,
-0.5478515625,
-0.426025390625,
0.11566162109375,
-0.2139892578125,
0.14111328125,
-1.060546875,
-1.05859375,
0.11114501953125,
-0.546875,
-0.07470703125,
-0.0238189697265625,
-0.5712890625,
0.208740234375,
-0.07464599609375,
0.66845703125,
-0.455322265625,
-0.2056884765625,
-0.342041015625,
-0.345947265625,
0.1658935546875,
-0.6962890625,
0.131103515625,
-0.08697509765625,
0.421142578125,
-0.01532745361328125,
-0.6826171875,
-0.052886962890625,
0.018218994140625,
0.060455322265625,
-0.23095703125,
-0.1151123046875,
-0.90234375,
-0.057891845703125,
0.34228515625,
-0.65380859375,
-0.705078125,
-0.262939453125,
-0.017913818359375,
0.279296875,
-0.10797119140625,
-0.2135009765625,
0.6845703125,
-0.07135009765625,
1.2900390625,
0.35888671875,
0.1920166015625,
-0.75439453125,
-0.490478515625,
0.313720703125,
0.435302734375,
0.2467041015625,
-0.1890869140625,
-0.237060546875,
0.33837890625,
-0.576171875,
0.260986328125,
0.52392578125,
0.67724609375,
0.1590576171875,
0.6279296875,
0.1669921875,
0.26953125,
0.59326171875,
0.9677734375,
-0.348876953125,
1.05078125,
-0.44091796875,
0.28125,
0.55078125,
0.0200958251953125,
-0.6513671875,
-0.368408203125,
-0.212158203125,
-0.740234375,
0.320556640625,
0.0179901123046875,
-0.299072265625,
0.475341796875,
0.0406494140625,
0.48876953125,
-1.1474609375,
-0.0187225341796875,
0.449462890625,
-0.29541015625,
0.6484375,
-0.38232421875,
-0.1302490234375,
-0.294921875,
-0.56103515625,
1.005859375,
-0.36474609375,
-0.1593017578125,
0.2210693359375,
-0.05950927734375,
-0.26220703125,
-0.1348876953125,
0.259033203125,
0.8828125,
-0.01456451416015625,
0.6181640625,
0.91943359375,
-0.92822265625,
0.669921875,
0.11822509765625,
0.030792236328125,
1.630859375,
0.47705078125,
0.1480712890625,
0.564453125,
0.2861328125,
-0.5927734375,
0.043243408203125,
-0.869140625,
0.861328125,
0.4150390625,
0.1888427734375,
-0.2386474609375,
0.2802734375,
0.024383544921875,
0.56640625,
0.06927490234375,
-0.0819091796875,
-0.51171875,
0.403564453125,
-0.0782470703125,
0.94677734375,
-0.1275634765625,
0.461669921875,
0.041778564453125,
-0.1741943359375,
0.47119140625,
-0.63720703125,
0.492919921875,
-0.1680908203125,
0.1710205078125,
0.82177734375,
0.5126953125,
0.84814453125,
0.9765625,
-0.1343994140625,
0.455810546875,
0.483154296875,
-0.509765625,
0.291015625,
0.0972900390625,
1.0615234375,
0.0005383491516113281,
0.060638427734375,
0.32080078125,
-0.47216796875,
-1.17578125,
-0.67431640625,
0.09930419921875,
0.31005859375,
-0.330322265625,
0.396484375,
0.454833984375,
-0.12152099609375,
-0.210693359375,
-0.11248779296875,
0.1314697265625,
-1.0283203125,
0.00649261474609375,
0.86572265625,
-0.177001953125,
0.35400390625,
0.029022216796875,
-0.6552734375,
0.398681640625,
0.94677734375,
-0.093017578125,
0.07666015625,
0.50341796875,
0.1168212890625,
-0.07720947265625,
0.0416259765625,
0.2373046875,
-0.06317138671875,
-0.576171875,
0.7822265625,
-0.388916015625,
0.1314697265625,
-0.175048828125,
0.354736328125,
0.2225341796875,
0.6142578125,
-0.490478515625,
-0.712890625,
-0.12237548828125,
0.99609375,
-0.15185546875,
-0.12469482421875,
-0.171875,
0.55908203125,
0.69189453125,
0.9619140625,
0.491943359375,
0.1954345703125,
0.794921875,
0.7578125,
0.026611328125,
0.43896484375,
-0.1787109375,
0.211669921875,
0.24755859375,
0.6884765625,
0.131103515625,
0.253173828125,
-0.1732177734375,
-0.0953369140625,
-0.517578125,
0.181396484375,
-0.39306640625,
0.74853515625,
0.2548828125,
0.458251953125,
-0.828125,
-0.9765625,
0.1385498046875,
0.95556640625,
-1.025390625,
-0.417236328125,
-0.322021484375,
-0.12225341796875,
0.259765625,
0.10345458984375,
0.45458984375,
0.2802734375,
0.46142578125,
0.60400390625,
-0.1214599609375,
-0.23828125,
-0.740234375,
-0.4453125,
-1.0400390625,
-0.39501953125,
-0.671875,
-0.207275390625,
0.359130859375,
-1.05078125,
0.424072265625,
-0.37890625,
-0.12548828125,
0.236328125,
-0.7568359375,
0.6455078125,
-0.486328125,
0.56689453125,
-0.71875,
0.357666015625,
0.2227783203125,
0.7314453125,
-0.56298828125,
0.21240234375,
0.00988006591796875,
-0.99560546875,
0.053924560546875,
-0.2197265625,
0.46240234375,
0.237060546875,
-0.79638671875,
-0.30859375,
-0.34716796875,
-0.059600830078125,
-0.362548828125,
0.0038013458251953125,
-0.75146484375,
0.466796875,
0.859375,
-0.47607421875,
0.689453125,
0.90087890625,
-1.18359375,
0.6279296875,
0.54150390625,
0.023834228515625,
-0.91162109375,
0.841796875,
0.458740234375,
0.7001953125,
-0.59912109375,
-0.01535797119140625,
-0.7958984375,
0.182861328125,
0.471435546875,
-0.59423828125,
-0.5361328125,
0.6376953125,
0.226806640625,
-0.99658203125,
0.50341796875,
-1.0703125,
-0.4609375,
-0.425048828125,
-0.1541748046875,
0.87890625,
0.84130859375,
0.394775390625,
-0.385009765625,
-0.348876953125,
-0.1129150390625,
0.5458984375,
0.5693359375,
-0.365234375,
0.08526611328125,
1.015625,
0.1944580078125,
0.0116119384765625,
0.34912109375,
-0.273681640625,
0.499755859375,
-0.434814453125,
0.006023406982421875,
0.29736328125,
0.55712890625,
0.076904296875,
0.4599609375,
0.83154296875,
-1.0576171875,
-0.12548828125,
-0.268310546875,
0.95654296875,
0.68896484375,
0.447265625,
0.34716796875,
-0.230712890625,
-0.48974609375,
-1.19140625,
0.31787109375,
0.5849609375,
0.9990234375,
-0.91650390625,
0.30029296875,
-0.197021484375,
-0.3955078125,
0.66259765625,
-0.751953125,
0.1771240234375,
1.185546875,
-0.016082763671875,
1.04296875,
-0.432861328125,
0.270263671875,
-0.0416259765625,
0.1695556640625,
0.61181640625,
0.363037109375,
0.166259765625,
-0.44775390625,
-0.72509765625,
-0.278564453125,
-0.2181396484375,
-0.275146484375,
-0.361083984375,
0.1365966796875,
-0.143798828125,
-0.376708984375,
-0.64501953125,
0.12158203125,
0.65869140625,
0.8935546875,
0.1572265625,
0.496826171875,
0.1536865234375,
0.75,
0.38720703125,
-0.375244140625,
0.179931640625,
-0.693359375,
0.7529296875,
-0.21533203125,
-0.22216796875,
-0.4677734375,
-0.0050506591796875,
-0.230224609375,
0.2392578125,
-0.2076416015625,
-0.174560546875,
-1.0107421875,
0.53955078125,
-0.182373046875,
0.373291015625,
-0.6728515625,
-0.27197265625,
-0.62353515625,
0.53466796875,
0.25732421875,
-0.55322265625,
0.35009765625,
-0.53125,
0.7275390625,
0.59765625,
-0.12066650390625,
-0.58642578125,
-0.356689453125,
-0.8291015625,
-0.257568359375,
0.0307159423828125,
0.5712890625,
-0.32080078125,
0.01085662841796875,
-0.9677734375,
0.483642578125,
-0.1968994140625,
-0.1324462890625,
-0.0090484619140625,
-0.322021484375,
0.29736328125,
0.276123046875,
0.76220703125,
-0.4599609375,
-0.96435546875,
-0.04193115234375,
-0.71826171875,
0.15087890625,
-0.2491455078125,
-0.0073394775390625,
0.293212890625,
0.2431640625,
0.35595703125,
0.37744140625,
-0.053314208984375,
0.1383056640625,
-0.168212890625,
0.137451171875,
-0.8056640625,
-0.65087890625,
0.380859375,
-0.10516357421875,
-0.1522216796875,
0.2391357421875,
-0.040435791015625,
-0.08111572265625,
0.0513916015625,
0.58154296875,
-0.31103515625,
0.310791015625,
0.0016222000122070312,
0.76416015625,
-0.337158203125,
-0.77685546875,
-0.11639404296875,
-0.474365234375,
0.56298828125,
-0.2371826171875,
-1.103515625,
0.210205078125,
-0.9248046875,
0.09100341796875,
-0.0023345947265625,
-0.14013671875,
0.7744140625,
0.1055908203125,
-0.0831298828125,
-0.09869384765625,
-0.306396484375,
-0.8583984375,
-0.41015625,
-0.67138671875,
0.07952880859375,
0.29248046875,
0.5537109375,
1.1953125,
0.136474609375,
-0.134521484375,
0.0758056640625,
0.31689453125,
0.00827789306640625,
-0.32666015625,
-0.06146240234375,
-0.190673828125,
-0.1409912109375,
-0.2880859375,
0.51171875,
-0.343505859375,
0.35888671875,
0.765625,
0.13037109375,
0.62353515625,
0.1156005859375,
-0.685546875,
0.41845703125,
0.04412841796875,
-0.97998046875,
-0.3408203125,
0.392578125,
-0.1895751953125,
0.763671875,
0.87548828125,
-0.6591796875,
-1.013671875,
-0.79296875,
0.1058349609375,
-0.5029296875,
-0.41015625,
-1.03125,
-0.39697265625,
-0.54931640625,
0.6005859375,
-0.234375,
-0.5029296875,
-0.2081298828125,
-0.92333984375,
0.375,
-0.5498046875,
-0.84375,
-0.5283203125,
-0.1790771484375,
-0.10369873046875,
0.74658203125,
0.3173828125,
0.1702880859375,
-0.374267578125,
-0.204833984375,
0.271484375,
0.339111328125,
-0.65478515625,
-0.1605224609375,
-0.25390625,
-0.2431640625,
-0.370361328125,
-0.11785888671875,
-0.423583984375,
1.0087890625,
-0.55810546875,
0.01134490966796875,
-0.123291015625,
-0.625,
-0.25927734375,
0.0226287841796875,
0.5859375,
-0.278076171875,
-0.2130126953125,
0.03741455078125,
0.720703125,
0.60205078125,
-0.62109375,
-0.292724609375,
-0.70751953125,
-0.52685546875,
-0.74951171875,
0.185546875,
-0.7080078125,
0.1553955078125,
-0.1419677734375,
-0.27099609375,
0.85009765625,
-0.61474609375,
0.29931640625,
1.2001953125,
-0.00510406494140625,
0.372314453125,
-0.59716796875,
0.857421875,
0.306640625,
-0.56103515625,
-0.08447265625,
-0.285888671875,
-0.468505859375,
0.0726318359375,
-0.2288818359375,
-1.3154296875,
-0.88525390625,
0.07598876953125,
1.0390625,
-0.4384765625,
0.9970703125,
0.02838134765625,
-1.1552734375,
-1.166015625,
0.7109375,
-0.06439208984375,
0.349609375,
0.982421875,
0.01508331298828125,
-0.057403564453125,
0.477294921875,
-0.04852294921875,
0.322265625,
-0.92822265625,
1.0234375,
0.174072265625,
-0.492431640625,
0.71630859375,
1.0146484375,
-1.279296875,
-0.60595703125,
0.293212890625,
-0.458740234375,
-0.358642578125,
-0.46630859375,
-0.03948974609375,
0.385986328125,
-0.7197265625,
-0.09844970703125,
-0.0138397216796875,
0.072265625,
0.414306640625,
-0.30029296875,
0.410400390625,
-0.32958984375,
0.78564453125,
0.845703125,
-0.62744140625,
-0.03240966796875,
-0.7353515625,
-0.280029296875,
-0.61376953125,
0.283935546875,
0.91015625,
-0.51025390625,
0.03814697265625,
0.83984375,
-0.1668701171875,
1.4150390625,
-0.12066650390625,
-0.08154296875,
0.39404296875,
-0.748046875,
-0.73046875,
0.2015380859375,
0.443603515625,
-0.388916015625,
0.5810546875,
-0.281005859375,
0.279296875,
0.04833984375,
0.4169921875,
0.10296630859375,
-0.73974609375,
-0.2685546875,
-0.806640625,
-0.1507568359375,
-0.484619140625,
-0.10992431640625,
-0.246826171875,
-0.0748291015625,
0.07525634765625,
-0.439697265625,
0.03240966796875,
0.5859375,
-0.1571044921875,
0.205322265625,
-0.8037109375,
0.197509765625,
-0.89111328125,
-0.7197265625,
-0.7021484375,
-0.1390380859375,
-0.283935546875,
0.0186920166015625,
-0.65771484375,
0.1983642578125,
-0.36962890625,
0.6767578125,
-0.15625,
0.4033203125,
-0.1568603515625,
-0.81640625,
-0.12322998046875,
0.0404052734375,
-0.11602783203125,
0.294921875,
0.451416015625,
-0.1629638671875,
0.155517578125,
-0.234375,
-0.306884765625,
0.035125732421875,
-0.153564453125,
0.8994140625,
-0.01277923583984375,
-0.1353759765625,
-0.348876953125,
0.16455078125,
-1.1162109375,
0.36474609375,
-0.08551025390625,
-0.004230499267578125,
0.17626953125,
-0.12396240234375,
0.93408203125,
0.7333984375,
-0.489013671875,
0.2293701171875,
-0.050537109375,
0.080810546875,
0.483154296875,
0.09521484375,
0.196533203125,
-0.0838623046875,
0.401611328125,
-0.06341552734375,
0.015472412109375,
0.282470703125,
-0.15625,
0.467041015625,
-0.20751953125,
-0.50439453125,
-1.111328125,
-0.24853515625,
0.289794921875,
0.1866455078125,
-0.179931640625,
-0.284912109375,
0.253662109375,
0.1392822265625,
-0.69580078125,
0.42578125,
-1.33984375,
-0.734375,
0.93798828125,
-0.294189453125,
-0.65869140625,
-0.8525390625,
-0.66796875,
0.0160064697265625,
0.1307373046875,
0.48193359375,
-0.499267578125,
0.5498046875,
0.054229736328125,
0.6875,
-0.2408447265625,
-0.302001953125,
0.080078125,
0.37255859375,
-0.78076171875,
-0.55322265625,
0.3974609375,
0.65478515625,
-0.05126953125,
-0.176513671875,
-0.77001953125,
0.363037109375,
-0.01219940185546875,
-0.381591796875,
-0.46142578125,
0.415283203125,
-0.219482421875,
0.48828125,
-0.8427734375,
-0.1112060546875,
-0.0775146484375,
-0.0095977783203125,
0.40625,
-0.389404296875,
-0.355712890625,
0.47900390625,
0.84228515625,
-0.51416015625,
0.329833984375,
0.2012939453125,
0.395751953125,
-0.01097869873046875,
-0.205078125,
0.11785888671875,
0.8916015625,
0.7265625,
0.4736328125,
-0.13037109375,
0.625,
0.414306640625,
-0.1492919921875,
-0.1942138671875,
0.26171875,
0.5068359375,
-0.491455078125,
0.5068359375,
0.0684814453125,
-0.1417236328125,
-0.01218414306640625,
-0.465576171875,
0.36962890625,
0.026397705078125,
-0.38232421875,
-0.646484375,
-0.83154296875,
0.5888671875,
-0.1961669921875,
0.384521484375,
0.2288818359375,
-0.389404296875,
0.258544921875,
0.8798828125,
-0.08941650390625,
-0.32958984375,
0.97119140625,
0.467041015625,
0.1766357421875,
0.7841796875,
0.05242919921875,
0.35791015625,
-1.01171875,
0.61572265625,
0.1871337890625,
-0.1478271484375,
-0.39892578125,
-0.68896484375,
-1.02734375,
0.60205078125,
-0.46240234375,
-0.2069091796875,
1.0048828125,
-0.759765625,
0.2763671875,
-0.225341796875,
0.68408203125,
-0.391357421875,
-0.00518035888671875,
0.29150390625,
-0.57177734375,
-0.16552734375,
1.107421875,
-0.357177734375,
0.385498046875,
0.08758544921875,
1.0185546875,
0.426513671875,
1.7373046875,
0.27490234375,
-0.346435546875,
0.2030029296875,
0.1328125,
-0.1627197265625,
-0.61181640625,
-0.61474609375,
-0.2939453125,
0.254638671875,
-0.58154296875,
-0.48291015625,
-0.242431640625,
0.71875,
0.09136962890625,
-1.404296875,
-0.2138671875,
0.1834716796875,
-0.9052734375,
0.29931640625,
0.61572265625,
0.393798828125,
0.261962890625,
-0.164794921875,
0.279052734375,
-0.480224609375,
0.0931396484375,
-0.3759765625,
0.409423828125,
-0.1619873046875,
-0.66650390625,
-0.49658203125,
-0.8876953125,
0.29150390625,
-0.416748046875,
-0.6044921875,
-0.6533203125,
0.280029296875,
1.0380859375,
0.39990234375,
0.5712890625,
-0.5087890625,
-0.1922607421875,
0.740234375,
1.0625,
0.1116943359375,
0.46533203125,
0.0167388916015625,
-0.09893798828125,
0.452880859375,
-0.417724609375,
-0.020355224609375,
0.322509765625,
-0.05517578125,
-0.408203125,
-0.005672454833984375,
-0.408203125,
-1.28515625,
0.462158203125,
0.962890625,
0.31103515625,
-0.5234375,
-1.0654296875,
-0.363525390625,
-1.138671875,
0.0124053955078125,
-0.492431640625,
0.58935546875,
0.046112060546875,
-0.264404296875,
0.0975341796875,
-1.185546875,
4.421875,
0.9443359375,
0.89306640625,
0.169921875,
-0.08831787109375,
0.9365234375,
0.69384765625,
-0.81201171875,
0.00487518310546875,
-0.283203125,
0.46923828125,
-0.7568359375,
0.39306640625,
0.87158203125,
0.270751953125,
0.302734375,
-0.287353515625,
-0.00701904296875,
0.0005521774291992188,
-1.0263671875,
-0.890625,
-0.04962158203125,
-0.126708984375,
0.64404296875,
0.2069091796875,
0.416259765625,
0.310302734375,
-0.435546875,
-0.117919921875,
-0.796875,
0.00664520263671875,
-0.51904296875,
0.890625,
0.1502685546875,
-0.279296875,
0.52978515625,
0.10797119140625,
-0.83740234375,
-0.22900390625,
0.1583251953125,
-0.053924560546875,
-0.3623046875,
0.467041015625,
-0.70263671875,
0.334228515625,
0.466796875,
-0.460205078125,
0.309814453125,
0.84033203125,
-0.78466796875,
1.033203125,
-0.108642578125,
0.3291015625,
-0.59619140625,
-1.009765625,
0.62451171875,
0.0845947265625,
0.0185699462890625,
-0.60302734375,
0.461669921875,
0.459716796875,
0.454833984375,
-0.1343994140625,
0.2183837890625,
-0.84375,
0.9619140625,
-0.40283203125,
0.87158203125,
-0.44091796875,
-0.1954345703125,
-0.1732177734375,
-0.420654296875,
-0.3515625,
-0.4560546875,
0.7490234375,
0.1749267578125,
-0.1712646484375,
0.53466796875,
0.487548828125,
-0.6318359375,
-0.03857421875,
-0.2763671875,
-0.46142578125,
-0.57666015625,
0.4541015625,
1.1904296875,
-0.4228515625,
-0.72607421875,
-0.56640625,
0.765625,
0.6796875,
0.108154296875,
-0.0574951171875,
-0.1456298828125,
-0.27734375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Tags: dfs and similar, graphs, sortings
Correct Solution:
```
# Author : nitish420 --------------------------------------------------------------------
import os
import sys
from io import BytesIO, IOBase
def main():
n=int(input())
l=[]
for _ in range(n):
l.append(list(input()))
graph=[set() for _ in range(26)]
indegree=[0]*26
for i in range(n-1):
j=i+1
z=0
r=0
a,b=l[i],l[j]
while z<len(a) and r<len(b):
if a[z]!=b[r]:
x,y=ord(a[z])-97,ord(b[r])-97
if y not in graph[x]:
indegree[ord(b[r])-97]+=1
graph[ord(a[z])-97].add(ord(b[r])-97)
break
z+=1
r+=1
if r==len(b):
print("Impossible")
exit()
for i in range(26):
graph[i]=list(graph[i])
# check for cycle using dfs
visited=[0]*26
pos=[0]*26
for i in range(26):
if visited[i]:
continue
stack=[i]
visited[i]=2
while stack:
x=stack[-1]
y=pos[x]
if y==len(graph[x]):
visited[x]=1
stack.pop()
else:
z=graph[x][y]
if visited[z]==2:
print("Impossible")
exit()
visited[z]=2
stack.append(z)
pos[x]+=1
queue=[]
for i in range(26):
if not indegree[i]:
queue.append(i)
count=0
while count!=26:
z=queue[count]
for item in graph[z]:
indegree[item]-=1
if indegree[item]==0:
queue.append(item)
count+=1
for i in range(26):
queue[i]=chr(queue[i]+97)
print(*queue,sep="")
# print(len(queue))
# 6
# ax
# ay
# by
# bz
# cz
# cx
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = 'x' in file.mode or 'r' not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b'\n') + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode('ascii'))
self.read = lambda: self.buffer.read().decode('ascii')
self.readline = lambda: self.buffer.readline().decode('ascii')
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
# endregion
if __name__ == '__main__':
main()
```
| 72,040 | [
-0.180419921875,
-0.34375,
0.476318359375,
-0.2020263671875,
-0.327392578125,
-0.34375,
-0.08489990234375,
0.228271484375,
0.1395263671875,
0.65087890625,
0.74072265625,
-0.05401611328125,
0.298095703125,
-0.9091796875,
-0.88818359375,
0.163818359375,
-0.200439453125,
-0.394775390625,
-0.01727294921875,
-0.08355712890625,
0.49755859375,
0.21875,
-1.806640625,
0.09527587890625,
-0.55859375,
1.0693359375,
0.60888671875,
0.1409912109375,
1.2353515625,
0.9892578125,
-0.039581298828125,
-0.344970703125,
0.51025390625,
-0.94775390625,
-0.236083984375,
-0.17431640625,
0.650390625,
-0.496826171875,
-0.08154296875,
-0.65478515625,
0.5673828125,
-0.7802734375,
0.45458984375,
-0.83984375,
-0.84765625,
-0.302001953125,
-0.1900634765625,
-0.19189453125,
-0.5048828125,
-1.283203125,
0.1494140625,
-0.28173828125,
0.6982421875,
-0.425537109375,
-0.1627197265625,
-0.040618896484375,
0.336669921875,
-0.06414794921875,
-0.471435546875,
0.53369140625,
-0.007320404052734375,
0.399169921875,
-0.320068359375,
-0.481201171875,
-0.328369140625,
0.223388671875,
0.14111328125,
-0.1376953125,
0.08001708984375,
-0.61328125,
-0.2451171875,
0.414306640625,
-0.29736328125,
-0.0411376953125,
-0.50830078125,
0.049407958984375,
-0.1990966796875,
-0.180419921875,
-0.3681640625,
0.58154296875,
0.279296875,
0.56787109375,
0.06695556640625,
0.314208984375,
-0.2646484375,
-0.34228515625,
-0.1282958984375,
0.17919921875,
0.2734375,
0.163818359375,
0.2088623046875,
0.441650390625,
-0.83642578125,
-0.29931640625,
0.39501953125,
0.60791015625,
-0.03558349609375,
0.2259521484375,
0.12188720703125,
0.140625,
0.939453125,
1.271484375,
-0.150390625,
0.9345703125,
-0.77490234375,
0.1658935546875,
-0.08001708984375,
-0.15478515625,
0.036529541015625,
-0.298583984375,
-0.205810546875,
-0.2303466796875,
0.2130126953125,
0.26953125,
0.11968994140625,
0.68310546875,
-0.446533203125,
0.385986328125,
-0.9931640625,
0.00644683837890625,
0.49169921875,
0.10150146484375,
0.053436279296875,
0.0784912109375,
0.2705078125,
-0.203369140625,
-0.1695556640625,
0.8974609375,
-0.452880859375,
-0.0908203125,
0.48388671875,
-0.055450439453125,
-0.548828125,
0.258056640625,
-0.106689453125,
0.8095703125,
-0.06402587890625,
0.52685546875,
0.55029296875,
-0.45654296875,
0.630859375,
-0.16943359375,
-0.035888671875,
1.53515625,
-0.007335662841796875,
-0.2384033203125,
0.41064453125,
0.2081298828125,
-0.76611328125,
0.5595703125,
-1.0556640625,
0.76513671875,
0.3828125,
0.33154296875,
-0.452880859375,
0.47216796875,
-0.186767578125,
0.42236328125,
0.65673828125,
0.64111328125,
-0.349609375,
-0.2298583984375,
-0.1202392578125,
1.0712890625,
-0.27197265625,
1.1962890625,
-0.61767578125,
-0.10089111328125,
0.07366943359375,
-0.2110595703125,
0.07696533203125,
0.043701171875,
-0.619140625,
1.0029296875,
0.289794921875,
0.81591796875,
0.437255859375,
-0.4677734375,
0.1600341796875,
0.08984375,
-0.33349609375,
0.473388671875,
-0.0029888153076171875,
0.76513671875,
0.176513671875,
0.1239013671875,
0.259765625,
-0.79052734375,
-0.35400390625,
-0.681640625,
-0.25390625,
0.7685546875,
-0.460205078125,
0.27734375,
-0.037139892578125,
-0.1365966796875,
-0.71142578125,
0.194580078125,
0.810546875,
-0.95166015625,
-0.200439453125,
0.52099609375,
-0.2176513671875,
0.6328125,
-0.74365234375,
-0.492919921875,
0.28662109375,
1.130859375,
0.00972747802734375,
-0.03955078125,
0.198486328125,
0.1295166015625,
-0.5048828125,
0.2362060546875,
0.30517578125,
-0.08441162109375,
-0.399658203125,
0.7060546875,
-0.515625,
-0.1280517578125,
0.280517578125,
0.970703125,
0.93408203125,
0.1883544921875,
-0.1307373046875,
0.158935546875,
1.251953125,
1.2890625,
-0.355712890625,
0.11578369140625,
0.0980224609375,
1.0859375,
0.3828125,
0.61279296875,
0.55712890625,
0.00441741943359375,
0.6884765625,
0.623046875,
-0.2130126953125,
0.08154296875,
0.07928466796875,
0.54150390625,
0.7685546875,
0.673828125,
-0.1881103515625,
0.5419921875,
-0.1519775390625,
0.1856689453125,
-0.236328125,
0.5732421875,
0.2293701171875,
0.8544921875,
0.125,
0.2376708984375,
-0.470703125,
-0.51513671875,
-0.281494140625,
0.463134765625,
-0.9306640625,
-0.59228515625,
-0.343994140625,
-0.10369873046875,
0.1632080078125,
0.0161590576171875,
0.2357177734375,
0.279052734375,
0.427001953125,
0.270263671875,
-0.2227783203125,
-0.61669921875,
-1.064453125,
-0.85791015625,
-1.21484375,
-0.347900390625,
-0.6962890625,
0.0826416015625,
0.436279296875,
-0.487060546875,
0.44921875,
-0.218505859375,
-0.251953125,
0.411865234375,
-0.47021484375,
0.58642578125,
0.08990478515625,
0.8486328125,
-0.497314453125,
0.262451171875,
-0.366943359375,
1.2314453125,
-0.65087890625,
-0.2425537109375,
-0.50048828125,
-0.7216796875,
0.444091796875,
0.5166015625,
0.60791015625,
0.063232421875,
-0.56884765625,
-1.1923828125,
-0.60693359375,
-0.0836181640625,
-1.0029296875,
0.349853515625,
-0.7978515625,
1.046875,
0.20166015625,
-0.666015625,
0.429443359375,
0.7060546875,
-0.6767578125,
0.888671875,
0.454345703125,
0.1466064453125,
-0.92431640625,
1.423828125,
0.00554656982421875,
0.478515625,
-0.456298828125,
-0.5263671875,
-0.41796875,
0.3564453125,
0.72021484375,
-0.98681640625,
0.0186767578125,
0.80712890625,
-0.037933349609375,
-1.134765625,
0.6630859375,
-0.6513671875,
-0.67529296875,
-0.1212158203125,
-0.5517578125,
0.69091796875,
0.8154296875,
0.5244140625,
0.250732421875,
-0.307373046875,
-0.24169921875,
0.58544921875,
-0.158935546875,
-0.55322265625,
-0.224609375,
0.3896484375,
-0.2115478515625,
-0.2176513671875,
0.2427978515625,
-0.340087890625,
-0.1195068359375,
-0.01041412353515625,
-0.06103515625,
0.90966796875,
0.13916015625,
0.142578125,
-0.047882080078125,
0.8505859375,
-0.7021484375,
-0.599609375,
-0.51318359375,
0.771484375,
0.578125,
0.36572265625,
0.41357421875,
-0.1962890625,
-0.413818359375,
-0.84423828125,
0.27001953125,
0.1402587890625,
0.71875,
-0.75732421875,
0.8779296875,
0.28173828125,
-0.59228515625,
0.322509765625,
-0.8037109375,
-0.252685546875,
1.4169921875,
-0.312744140625,
0.814453125,
-0.55224609375,
0.062225341796875,
-0.276611328125,
0.470947265625,
0.50927734375,
0.28662109375,
0.64453125,
-0.34033203125,
-0.035919189453125,
-0.451416015625,
-0.57958984375,
0.1668701171875,
-0.75146484375,
0.215087890625,
-0.09765625,
-0.385009765625,
-0.84375,
0.64794921875,
0.54345703125,
0.149658203125,
0.19287109375,
0.720703125,
0.236328125,
0.36572265625,
1.0625,
-0.41650390625,
0.1900634765625,
-0.59326171875,
0.88720703125,
0.27490234375,
-0.065185546875,
0.024688720703125,
-0.044952392578125,
-0.16552734375,
0.1524658203125,
-0.1810302734375,
-0.179931640625,
-0.6044921875,
0.14306640625,
0.2998046875,
0.70947265625,
-0.474853515625,
-0.51953125,
-0.196533203125,
0.56982421875,
0.326171875,
-0.56884765625,
0.10198974609375,
-0.69189453125,
0.3818359375,
0.56005859375,
-0.027374267578125,
-0.52734375,
-0.6494140625,
-1.1162109375,
-0.404296875,
0.62939453125,
0.343994140625,
0.134033203125,
-0.12030029296875,
-0.794921875,
0.7939453125,
0.031341552734375,
-0.2220458984375,
0.1448974609375,
-0.1868896484375,
-0.01380157470703125,
-0.1309814453125,
0.54736328125,
0.09814453125,
-0.63623046875,
0.35205078125,
-1.18359375,
0.58154296875,
-0.86328125,
0.57373046875,
0.09197998046875,
0.2137451171875,
-0.208251953125,
0.331787109375,
-0.51806640625,
-0.1370849609375,
-0.3017578125,
0.51708984375,
-0.97216796875,
-0.78564453125,
0.775390625,
-0.0621337890625,
-0.02008056640625,
0.71533203125,
-0.03131103515625,
-0.49169921875,
0.14013671875,
0.380615234375,
-0.56201171875,
0.23583984375,
-0.3994140625,
0.236083984375,
-0.6875,
-0.410888671875,
-0.133544921875,
-0.436767578125,
0.68115234375,
0.287841796875,
-0.7841796875,
-0.38623046875,
-0.99072265625,
-0.03631591796875,
-0.1553955078125,
-0.58251953125,
0.26953125,
-0.2310791015625,
-0.2861328125,
-0.285888671875,
-0.33984375,
-0.6572265625,
0.036102294921875,
-0.68896484375,
-0.319091796875,
0.2222900390625,
0.38427734375,
0.60009765625,
0.07110595703125,
-0.38720703125,
0.13525390625,
-0.2392578125,
-0.043792724609375,
-0.287353515625,
-0.14013671875,
-0.203857421875,
-0.349853515625,
-0.257568359375,
-0.1185302734375,
0.458740234375,
0.244140625,
0.23193359375,
0.270751953125,
0.419189453125,
0.5107421875,
-0.42919921875,
0.66455078125,
0.0200347900390625,
-0.54833984375,
-0.50537109375,
0.5400390625,
-0.2066650390625,
0.94189453125,
0.34033203125,
-1.359375,
-0.779296875,
-1.2626953125,
-0.0192413330078125,
-0.315673828125,
-0.102294921875,
-0.76953125,
0.03851318359375,
-0.61376953125,
0.2900390625,
-0.2073974609375,
-0.458984375,
0.1669921875,
-1.3349609375,
-0.0733642578125,
-0.64453125,
-0.56982421875,
-0.28173828125,
-0.58056640625,
-0.1610107421875,
0.9658203125,
0.279541015625,
0.266357421875,
0.1497802734375,
0.070068359375,
0.023529052734375,
-0.312744140625,
-0.9482421875,
-0.37939453125,
0.049163818359375,
0.307373046875,
0.08575439453125,
-0.073974609375,
-0.4814453125,
0.84228515625,
-1.021484375,
-0.1070556640625,
-0.2105712890625,
-0.249755859375,
-0.10577392578125,
-0.1485595703125,
1.162109375,
-0.375244140625,
-0.0247344970703125,
-0.0141448974609375,
0.50390625,
0.460693359375,
-0.3916015625,
-0.42041015625,
-0.6728515625,
-0.466796875,
-0.89208984375,
0.71826171875,
-0.7138671875,
0.1417236328125,
-0.64501953125,
-0.401611328125,
1.1923828125,
-0.87158203125,
0.50732421875,
0.81884765625,
-0.03875732421875,
0.1959228515625,
-0.81396484375,
0.6005859375,
0.455322265625,
-0.5458984375,
-0.12451171875,
0.307861328125,
-0.469482421875,
0.369873046875,
0.068359375,
-1.037109375,
-0.70361328125,
0.615234375,
1.330078125,
-0.078857421875,
0.63818359375,
-0.168701171875,
-0.361083984375,
-0.49560546875,
1.046875,
-0.1063232421875,
0.037689208984375,
1.0263671875,
-0.65869140625,
-0.323974609375,
0.09930419921875,
-0.0367431640625,
-0.56787109375,
-0.4765625,
1.544921875,
-0.15478515625,
-0.2178955078125,
0.951171875,
0.8583984375,
-0.66748046875,
-0.5478515625,
-0.38037109375,
0.376708984375,
-0.042083740234375,
-0.8212890625,
0.212158203125,
0.658203125,
-0.7705078125,
-0.2025146484375,
0.537109375,
-0.18115234375,
0.336181640625,
0.1722412109375,
0.4423828125,
-0.315185546875,
0.333251953125,
0.64208984375,
-0.73876953125,
-0.059600830078125,
-1.0849609375,
0.25341796875,
-0.27880859375,
-0.51220703125,
0.7802734375,
-0.247314453125,
0.44921875,
0.88134765625,
-0.1973876953125,
0.49853515625,
-0.58740234375,
-0.58056640625,
0.2220458984375,
-1.0048828125,
-0.70751953125,
-0.391357421875,
0.467529296875,
-0.268798828125,
0.1336669921875,
-1.146484375,
0.279541015625,
0.42578125,
0.440185546875,
-0.6513671875,
-0.8525390625,
0.027252197265625,
-0.96923828125,
-0.384521484375,
-0.576171875,
-0.69091796875,
-0.2861328125,
-0.068603515625,
-0.0841064453125,
-0.5498046875,
0.368896484375,
0.40625,
-0.32763671875,
0.9091796875,
-0.470458984375,
0.5263671875,
-0.64599609375,
-0.169677734375,
-0.7255859375,
0.054412841796875,
-0.30419921875,
0.00188446044921875,
-0.5986328125,
0.264892578125,
0.50244140625,
0.2464599609375,
0.10260009765625,
-0.18505859375,
-0.583984375,
-0.6875,
-0.11517333984375,
0.1363525390625,
-0.432373046875,
0.68212890625,
0.434814453125,
0.2303466796875,
0.85498046875,
-0.1943359375,
-0.56884765625,
-0.0034770965576171875,
0.6015625,
0.6845703125,
-0.366455078125,
-0.033660888671875,
-0.33837890625,
0.058929443359375,
-0.85498046875,
0.097412109375,
-0.036865234375,
0.2205810546875,
0.033233642578125,
-0.26025390625,
0.374755859375,
1.1865234375,
0.1539306640625,
0.64990234375,
0.2421875,
0.255126953125,
0.260498046875,
-0.546875,
-0.14794921875,
0.484619140625,
0.11102294921875,
-0.3427734375,
-0.05926513671875,
0.451416015625,
-0.060760498046875,
0.35888671875,
0.159912109375,
-0.892578125,
-1.1484375,
-0.445068359375,
0.1986083984375,
0.481689453125,
0.64013671875,
-0.490234375,
-0.254638671875,
-0.47802734375,
-0.78515625,
0.65478515625,
-1.0009765625,
-0.66455078125,
0.472900390625,
-0.1937255859375,
-0.65185546875,
-0.11016845703125,
-0.52978515625,
0.035125732421875,
0.060394287109375,
0.45556640625,
-0.7080078125,
0.1859130859375,
0.2509765625,
0.46142578125,
-0.265869140625,
-0.221923828125,
0.00904083251953125,
0.322998046875,
-0.281494140625,
-0.1754150390625,
0.41064453125,
1.0595703125,
0.1998291015625,
-0.0292816162109375,
-0.7841796875,
0.0867919921875,
0.6162109375,
0.159423828125,
-0.383056640625,
-0.1495361328125,
-0.63134765625,
0.71630859375,
-0.81787109375,
-0.0201873779296875,
0.028778076171875,
0.1767578125,
0.2353515625,
-0.427490234375,
-0.58935546875,
0.9248046875,
1.2392578125,
-0.2373046875,
0.48388671875,
0.10125732421875,
0.10333251953125,
-0.25927734375,
-0.147705078125,
-0.45361328125,
0.3974609375,
0.1356201171875,
0.419677734375,
-0.062286376953125,
0.73974609375,
0.76806640625,
-0.1968994140625,
0.1383056640625,
0.356201171875,
0.02069091796875,
-0.09619140625,
0.0274200439453125,
-0.02142333984375,
0.2388916015625,
0.439453125,
-0.6884765625,
0.3818359375,
-0.87451171875,
-0.234130859375,
0.027618408203125,
-0.595703125,
0.8203125,
-0.99462890625,
-0.0799560546875,
-0.1124267578125,
-0.4833984375,
0.1649169921875,
0.7294921875,
0.389404296875,
-0.008453369140625,
0.57373046875,
0.80615234375,
0.217041015625,
1.0234375,
0.63916015625,
0.354248046875,
-0.75390625,
0.26025390625,
0.093505859375,
-0.256103515625,
-0.489501953125,
-0.19482421875,
-0.77490234375,
0.472412109375,
-0.056732177734375,
-0.51953125,
0.482421875,
-0.79443359375,
-0.330322265625,
0.1639404296875,
0.77978515625,
-0.254638671875,
0.463134765625,
0.11920166015625,
-0.37744140625,
-0.7900390625,
1.0087890625,
-0.178466796875,
0.344970703125,
0.19189453125,
0.828125,
-0.072509765625,
1.1201171875,
0.37353515625,
-0.26904296875,
-0.0062713623046875,
0.076416015625,
-0.419189453125,
-1.01953125,
-0.2646484375,
-0.63818359375,
0.229248046875,
-0.310546875,
0.0288238525390625,
-0.0230865478515625,
0.6923828125,
-0.08575439453125,
-0.9072265625,
-0.387939453125,
0.056671142578125,
-0.6943359375,
0.5400390625,
0.40380859375,
0.156005859375,
0.322021484375,
-0.019744873046875,
-0.30712890625,
-0.6318359375,
-0.034423828125,
-0.81298828125,
0.28271484375,
-0.349365234375,
-0.2381591796875,
-0.76806640625,
-0.8671875,
-0.361572265625,
0.10186767578125,
-0.15673828125,
-0.89794921875,
0.306396484375,
0.01318359375,
0.54541015625,
0.0888671875,
-0.318115234375,
0.6513671875,
0.83056640625,
0.9716796875,
0.029754638671875,
0.80078125,
0.3388671875,
-0.3134765625,
0.2276611328125,
-0.277587890625,
0.336669921875,
-0.5986328125,
0.2257080078125,
-0.27294921875,
0.38232421875,
-0.5625,
-1.34375,
-0.2138671875,
0.57666015625,
0.305419921875,
-0.7373046875,
-1.0751953125,
-0.56005859375,
-0.65771484375,
0.314208984375,
-0.78125,
0.3857421875,
-0.0428466796875,
0.361083984375,
-0.1588134765625,
-0.95166015625,
4.37890625,
1.1064453125,
1.2724609375,
0.4619140625,
0.0538330078125,
0.9296875,
0.3818359375,
-0.1962890625,
-0.13427734375,
-0.6533203125,
0.373779296875,
-0.244140625,
-0.1439208984375,
1.04296875,
0.391357421875,
0.7744140625,
-0.8798828125,
-0.2152099609375,
0.007049560546875,
-0.5546875,
-0.72314453125,
0.041412353515625,
-0.552734375,
0.2177734375,
-0.198974609375,
0.386474609375,
0.69091796875,
-0.943359375,
-0.394775390625,
-0.3046875,
0.1309814453125,
-0.78466796875,
1.1328125,
-0.455810546875,
-0.2393798828125,
0.37060546875,
-0.2022705078125,
-0.5654296875,
-0.018341064453125,
0.420654296875,
0.1971435546875,
0.400634765625,
1.013671875,
-0.263671875,
0.48583984375,
0.465576171875,
-0.50830078125,
-0.003570556640625,
-0.320068359375,
-0.86083984375,
1.056640625,
-0.4853515625,
0.268310546875,
-0.46826171875,
-0.939453125,
0.253662109375,
-0.126220703125,
-0.365234375,
-0.228759765625,
0.188720703125,
0.2388916015625,
-0.0133514404296875,
-0.080810546875,
0.310791015625,
-1.00390625,
0.64111328125,
-0.039215087890625,
0.1954345703125,
-0.61328125,
-0.378662109375,
-0.1844482421875,
-0.25927734375,
-0.33251953125,
-0.408935546875,
0.53955078125,
0.1756591796875,
0.118896484375,
0.3916015625,
0.63720703125,
-0.80029296875,
-0.03790283203125,
-0.156982421875,
-0.59326171875,
-0.53955078125,
0.77099609375,
0.9716796875,
-0.7041015625,
-0.5146484375,
-0.1650390625,
0.383056640625,
0.58544921875,
0.38623046875,
0.454345703125,
-0.062347412109375,
-0.1766357421875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Tags: dfs and similar, graphs, sortings
Correct Solution:
```
__author__ = 'Utena'
n=int(input())
e=[]
def cmp(a,b):
for i in range(min(len(a),len(b))):
if a[i]!=b[i]:
e.append((a[i],b[i]))
return 0
if len(a)>len(b):
print('Impossible')
exit(0)
def indegree0(v,e):
if v==[]:
return None
tmp=v[:]
for i in e:
if i[1] in tmp:
tmp.remove(i[1])
tmp=tmp[:1]
if tmp==[]:
return -1
for t in tmp:
for i in range(len(e)):
if t in e[i]:
e[i]=(0,0) #占位,之后删掉
if e:
eset=set(e)
if(0,0)in eset:eset.remove((0,0))
e[:]=list(eset)
if v:
for t in tmp:
v.remove(t)
return tmp
def topoSort(v,e):
result=[]
while True:
nodes=indegree0(v,e)
if nodes==None:
break
if nodes==-1:
print("Impossible" )
return None
result.extend(nodes)
print(''.join(map(str,result)))
return result
names=[]
for i in range(n):
names.append(input())
for i in range(n-1):
cmp(names[i],names[i+1])
afs=[chr(i) for i in range(97,123)]
topoSort(afs,e)
```
| 72,041 | [
-0.180419921875,
-0.34375,
0.476318359375,
-0.2020263671875,
-0.327392578125,
-0.34375,
-0.08489990234375,
0.228271484375,
0.1395263671875,
0.65087890625,
0.74072265625,
-0.05401611328125,
0.298095703125,
-0.9091796875,
-0.88818359375,
0.163818359375,
-0.200439453125,
-0.394775390625,
-0.01727294921875,
-0.08355712890625,
0.49755859375,
0.21875,
-1.806640625,
0.09527587890625,
-0.55859375,
1.0693359375,
0.60888671875,
0.1409912109375,
1.2353515625,
0.9892578125,
-0.039581298828125,
-0.344970703125,
0.51025390625,
-0.94775390625,
-0.236083984375,
-0.17431640625,
0.650390625,
-0.496826171875,
-0.08154296875,
-0.65478515625,
0.5673828125,
-0.7802734375,
0.45458984375,
-0.83984375,
-0.84765625,
-0.302001953125,
-0.1900634765625,
-0.19189453125,
-0.5048828125,
-1.283203125,
0.1494140625,
-0.28173828125,
0.6982421875,
-0.425537109375,
-0.1627197265625,
-0.040618896484375,
0.336669921875,
-0.06414794921875,
-0.471435546875,
0.53369140625,
-0.007320404052734375,
0.399169921875,
-0.320068359375,
-0.481201171875,
-0.328369140625,
0.223388671875,
0.14111328125,
-0.1376953125,
0.08001708984375,
-0.61328125,
-0.2451171875,
0.414306640625,
-0.29736328125,
-0.0411376953125,
-0.50830078125,
0.049407958984375,
-0.1990966796875,
-0.180419921875,
-0.3681640625,
0.58154296875,
0.279296875,
0.56787109375,
0.06695556640625,
0.314208984375,
-0.2646484375,
-0.34228515625,
-0.1282958984375,
0.17919921875,
0.2734375,
0.163818359375,
0.2088623046875,
0.441650390625,
-0.83642578125,
-0.29931640625,
0.39501953125,
0.60791015625,
-0.03558349609375,
0.2259521484375,
0.12188720703125,
0.140625,
0.939453125,
1.271484375,
-0.150390625,
0.9345703125,
-0.77490234375,
0.1658935546875,
-0.08001708984375,
-0.15478515625,
0.036529541015625,
-0.298583984375,
-0.205810546875,
-0.2303466796875,
0.2130126953125,
0.26953125,
0.11968994140625,
0.68310546875,
-0.446533203125,
0.385986328125,
-0.9931640625,
0.00644683837890625,
0.49169921875,
0.10150146484375,
0.053436279296875,
0.0784912109375,
0.2705078125,
-0.203369140625,
-0.1695556640625,
0.8974609375,
-0.452880859375,
-0.0908203125,
0.48388671875,
-0.055450439453125,
-0.548828125,
0.258056640625,
-0.106689453125,
0.8095703125,
-0.06402587890625,
0.52685546875,
0.55029296875,
-0.45654296875,
0.630859375,
-0.16943359375,
-0.035888671875,
1.53515625,
-0.007335662841796875,
-0.2384033203125,
0.41064453125,
0.2081298828125,
-0.76611328125,
0.5595703125,
-1.0556640625,
0.76513671875,
0.3828125,
0.33154296875,
-0.452880859375,
0.47216796875,
-0.186767578125,
0.42236328125,
0.65673828125,
0.64111328125,
-0.349609375,
-0.2298583984375,
-0.1202392578125,
1.0712890625,
-0.27197265625,
1.1962890625,
-0.61767578125,
-0.10089111328125,
0.07366943359375,
-0.2110595703125,
0.07696533203125,
0.043701171875,
-0.619140625,
1.0029296875,
0.289794921875,
0.81591796875,
0.437255859375,
-0.4677734375,
0.1600341796875,
0.08984375,
-0.33349609375,
0.473388671875,
-0.0029888153076171875,
0.76513671875,
0.176513671875,
0.1239013671875,
0.259765625,
-0.79052734375,
-0.35400390625,
-0.681640625,
-0.25390625,
0.7685546875,
-0.460205078125,
0.27734375,
-0.037139892578125,
-0.1365966796875,
-0.71142578125,
0.194580078125,
0.810546875,
-0.95166015625,
-0.200439453125,
0.52099609375,
-0.2176513671875,
0.6328125,
-0.74365234375,
-0.492919921875,
0.28662109375,
1.130859375,
0.00972747802734375,
-0.03955078125,
0.198486328125,
0.1295166015625,
-0.5048828125,
0.2362060546875,
0.30517578125,
-0.08441162109375,
-0.399658203125,
0.7060546875,
-0.515625,
-0.1280517578125,
0.280517578125,
0.970703125,
0.93408203125,
0.1883544921875,
-0.1307373046875,
0.158935546875,
1.251953125,
1.2890625,
-0.355712890625,
0.11578369140625,
0.0980224609375,
1.0859375,
0.3828125,
0.61279296875,
0.55712890625,
0.00441741943359375,
0.6884765625,
0.623046875,
-0.2130126953125,
0.08154296875,
0.07928466796875,
0.54150390625,
0.7685546875,
0.673828125,
-0.1881103515625,
0.5419921875,
-0.1519775390625,
0.1856689453125,
-0.236328125,
0.5732421875,
0.2293701171875,
0.8544921875,
0.125,
0.2376708984375,
-0.470703125,
-0.51513671875,
-0.281494140625,
0.463134765625,
-0.9306640625,
-0.59228515625,
-0.343994140625,
-0.10369873046875,
0.1632080078125,
0.0161590576171875,
0.2357177734375,
0.279052734375,
0.427001953125,
0.270263671875,
-0.2227783203125,
-0.61669921875,
-1.064453125,
-0.85791015625,
-1.21484375,
-0.347900390625,
-0.6962890625,
0.0826416015625,
0.436279296875,
-0.487060546875,
0.44921875,
-0.218505859375,
-0.251953125,
0.411865234375,
-0.47021484375,
0.58642578125,
0.08990478515625,
0.8486328125,
-0.497314453125,
0.262451171875,
-0.366943359375,
1.2314453125,
-0.65087890625,
-0.2425537109375,
-0.50048828125,
-0.7216796875,
0.444091796875,
0.5166015625,
0.60791015625,
0.063232421875,
-0.56884765625,
-1.1923828125,
-0.60693359375,
-0.0836181640625,
-1.0029296875,
0.349853515625,
-0.7978515625,
1.046875,
0.20166015625,
-0.666015625,
0.429443359375,
0.7060546875,
-0.6767578125,
0.888671875,
0.454345703125,
0.1466064453125,
-0.92431640625,
1.423828125,
0.00554656982421875,
0.478515625,
-0.456298828125,
-0.5263671875,
-0.41796875,
0.3564453125,
0.72021484375,
-0.98681640625,
0.0186767578125,
0.80712890625,
-0.037933349609375,
-1.134765625,
0.6630859375,
-0.6513671875,
-0.67529296875,
-0.1212158203125,
-0.5517578125,
0.69091796875,
0.8154296875,
0.5244140625,
0.250732421875,
-0.307373046875,
-0.24169921875,
0.58544921875,
-0.158935546875,
-0.55322265625,
-0.224609375,
0.3896484375,
-0.2115478515625,
-0.2176513671875,
0.2427978515625,
-0.340087890625,
-0.1195068359375,
-0.01041412353515625,
-0.06103515625,
0.90966796875,
0.13916015625,
0.142578125,
-0.047882080078125,
0.8505859375,
-0.7021484375,
-0.599609375,
-0.51318359375,
0.771484375,
0.578125,
0.36572265625,
0.41357421875,
-0.1962890625,
-0.413818359375,
-0.84423828125,
0.27001953125,
0.1402587890625,
0.71875,
-0.75732421875,
0.8779296875,
0.28173828125,
-0.59228515625,
0.322509765625,
-0.8037109375,
-0.252685546875,
1.4169921875,
-0.312744140625,
0.814453125,
-0.55224609375,
0.062225341796875,
-0.276611328125,
0.470947265625,
0.50927734375,
0.28662109375,
0.64453125,
-0.34033203125,
-0.035919189453125,
-0.451416015625,
-0.57958984375,
0.1668701171875,
-0.75146484375,
0.215087890625,
-0.09765625,
-0.385009765625,
-0.84375,
0.64794921875,
0.54345703125,
0.149658203125,
0.19287109375,
0.720703125,
0.236328125,
0.36572265625,
1.0625,
-0.41650390625,
0.1900634765625,
-0.59326171875,
0.88720703125,
0.27490234375,
-0.065185546875,
0.024688720703125,
-0.044952392578125,
-0.16552734375,
0.1524658203125,
-0.1810302734375,
-0.179931640625,
-0.6044921875,
0.14306640625,
0.2998046875,
0.70947265625,
-0.474853515625,
-0.51953125,
-0.196533203125,
0.56982421875,
0.326171875,
-0.56884765625,
0.10198974609375,
-0.69189453125,
0.3818359375,
0.56005859375,
-0.027374267578125,
-0.52734375,
-0.6494140625,
-1.1162109375,
-0.404296875,
0.62939453125,
0.343994140625,
0.134033203125,
-0.12030029296875,
-0.794921875,
0.7939453125,
0.031341552734375,
-0.2220458984375,
0.1448974609375,
-0.1868896484375,
-0.01380157470703125,
-0.1309814453125,
0.54736328125,
0.09814453125,
-0.63623046875,
0.35205078125,
-1.18359375,
0.58154296875,
-0.86328125,
0.57373046875,
0.09197998046875,
0.2137451171875,
-0.208251953125,
0.331787109375,
-0.51806640625,
-0.1370849609375,
-0.3017578125,
0.51708984375,
-0.97216796875,
-0.78564453125,
0.775390625,
-0.0621337890625,
-0.02008056640625,
0.71533203125,
-0.03131103515625,
-0.49169921875,
0.14013671875,
0.380615234375,
-0.56201171875,
0.23583984375,
-0.3994140625,
0.236083984375,
-0.6875,
-0.410888671875,
-0.133544921875,
-0.436767578125,
0.68115234375,
0.287841796875,
-0.7841796875,
-0.38623046875,
-0.99072265625,
-0.03631591796875,
-0.1553955078125,
-0.58251953125,
0.26953125,
-0.2310791015625,
-0.2861328125,
-0.285888671875,
-0.33984375,
-0.6572265625,
0.036102294921875,
-0.68896484375,
-0.319091796875,
0.2222900390625,
0.38427734375,
0.60009765625,
0.07110595703125,
-0.38720703125,
0.13525390625,
-0.2392578125,
-0.043792724609375,
-0.287353515625,
-0.14013671875,
-0.203857421875,
-0.349853515625,
-0.257568359375,
-0.1185302734375,
0.458740234375,
0.244140625,
0.23193359375,
0.270751953125,
0.419189453125,
0.5107421875,
-0.42919921875,
0.66455078125,
0.0200347900390625,
-0.54833984375,
-0.50537109375,
0.5400390625,
-0.2066650390625,
0.94189453125,
0.34033203125,
-1.359375,
-0.779296875,
-1.2626953125,
-0.0192413330078125,
-0.315673828125,
-0.102294921875,
-0.76953125,
0.03851318359375,
-0.61376953125,
0.2900390625,
-0.2073974609375,
-0.458984375,
0.1669921875,
-1.3349609375,
-0.0733642578125,
-0.64453125,
-0.56982421875,
-0.28173828125,
-0.58056640625,
-0.1610107421875,
0.9658203125,
0.279541015625,
0.266357421875,
0.1497802734375,
0.070068359375,
0.023529052734375,
-0.312744140625,
-0.9482421875,
-0.37939453125,
0.049163818359375,
0.307373046875,
0.08575439453125,
-0.073974609375,
-0.4814453125,
0.84228515625,
-1.021484375,
-0.1070556640625,
-0.2105712890625,
-0.249755859375,
-0.10577392578125,
-0.1485595703125,
1.162109375,
-0.375244140625,
-0.0247344970703125,
-0.0141448974609375,
0.50390625,
0.460693359375,
-0.3916015625,
-0.42041015625,
-0.6728515625,
-0.466796875,
-0.89208984375,
0.71826171875,
-0.7138671875,
0.1417236328125,
-0.64501953125,
-0.401611328125,
1.1923828125,
-0.87158203125,
0.50732421875,
0.81884765625,
-0.03875732421875,
0.1959228515625,
-0.81396484375,
0.6005859375,
0.455322265625,
-0.5458984375,
-0.12451171875,
0.307861328125,
-0.469482421875,
0.369873046875,
0.068359375,
-1.037109375,
-0.70361328125,
0.615234375,
1.330078125,
-0.078857421875,
0.63818359375,
-0.168701171875,
-0.361083984375,
-0.49560546875,
1.046875,
-0.1063232421875,
0.037689208984375,
1.0263671875,
-0.65869140625,
-0.323974609375,
0.09930419921875,
-0.0367431640625,
-0.56787109375,
-0.4765625,
1.544921875,
-0.15478515625,
-0.2178955078125,
0.951171875,
0.8583984375,
-0.66748046875,
-0.5478515625,
-0.38037109375,
0.376708984375,
-0.042083740234375,
-0.8212890625,
0.212158203125,
0.658203125,
-0.7705078125,
-0.2025146484375,
0.537109375,
-0.18115234375,
0.336181640625,
0.1722412109375,
0.4423828125,
-0.315185546875,
0.333251953125,
0.64208984375,
-0.73876953125,
-0.059600830078125,
-1.0849609375,
0.25341796875,
-0.27880859375,
-0.51220703125,
0.7802734375,
-0.247314453125,
0.44921875,
0.88134765625,
-0.1973876953125,
0.49853515625,
-0.58740234375,
-0.58056640625,
0.2220458984375,
-1.0048828125,
-0.70751953125,
-0.391357421875,
0.467529296875,
-0.268798828125,
0.1336669921875,
-1.146484375,
0.279541015625,
0.42578125,
0.440185546875,
-0.6513671875,
-0.8525390625,
0.027252197265625,
-0.96923828125,
-0.384521484375,
-0.576171875,
-0.69091796875,
-0.2861328125,
-0.068603515625,
-0.0841064453125,
-0.5498046875,
0.368896484375,
0.40625,
-0.32763671875,
0.9091796875,
-0.470458984375,
0.5263671875,
-0.64599609375,
-0.169677734375,
-0.7255859375,
0.054412841796875,
-0.30419921875,
0.00188446044921875,
-0.5986328125,
0.264892578125,
0.50244140625,
0.2464599609375,
0.10260009765625,
-0.18505859375,
-0.583984375,
-0.6875,
-0.11517333984375,
0.1363525390625,
-0.432373046875,
0.68212890625,
0.434814453125,
0.2303466796875,
0.85498046875,
-0.1943359375,
-0.56884765625,
-0.0034770965576171875,
0.6015625,
0.6845703125,
-0.366455078125,
-0.033660888671875,
-0.33837890625,
0.058929443359375,
-0.85498046875,
0.097412109375,
-0.036865234375,
0.2205810546875,
0.033233642578125,
-0.26025390625,
0.374755859375,
1.1865234375,
0.1539306640625,
0.64990234375,
0.2421875,
0.255126953125,
0.260498046875,
-0.546875,
-0.14794921875,
0.484619140625,
0.11102294921875,
-0.3427734375,
-0.05926513671875,
0.451416015625,
-0.060760498046875,
0.35888671875,
0.159912109375,
-0.892578125,
-1.1484375,
-0.445068359375,
0.1986083984375,
0.481689453125,
0.64013671875,
-0.490234375,
-0.254638671875,
-0.47802734375,
-0.78515625,
0.65478515625,
-1.0009765625,
-0.66455078125,
0.472900390625,
-0.1937255859375,
-0.65185546875,
-0.11016845703125,
-0.52978515625,
0.035125732421875,
0.060394287109375,
0.45556640625,
-0.7080078125,
0.1859130859375,
0.2509765625,
0.46142578125,
-0.265869140625,
-0.221923828125,
0.00904083251953125,
0.322998046875,
-0.281494140625,
-0.1754150390625,
0.41064453125,
1.0595703125,
0.1998291015625,
-0.0292816162109375,
-0.7841796875,
0.0867919921875,
0.6162109375,
0.159423828125,
-0.383056640625,
-0.1495361328125,
-0.63134765625,
0.71630859375,
-0.81787109375,
-0.0201873779296875,
0.028778076171875,
0.1767578125,
0.2353515625,
-0.427490234375,
-0.58935546875,
0.9248046875,
1.2392578125,
-0.2373046875,
0.48388671875,
0.10125732421875,
0.10333251953125,
-0.25927734375,
-0.147705078125,
-0.45361328125,
0.3974609375,
0.1356201171875,
0.419677734375,
-0.062286376953125,
0.73974609375,
0.76806640625,
-0.1968994140625,
0.1383056640625,
0.356201171875,
0.02069091796875,
-0.09619140625,
0.0274200439453125,
-0.02142333984375,
0.2388916015625,
0.439453125,
-0.6884765625,
0.3818359375,
-0.87451171875,
-0.234130859375,
0.027618408203125,
-0.595703125,
0.8203125,
-0.99462890625,
-0.0799560546875,
-0.1124267578125,
-0.4833984375,
0.1649169921875,
0.7294921875,
0.389404296875,
-0.008453369140625,
0.57373046875,
0.80615234375,
0.217041015625,
1.0234375,
0.63916015625,
0.354248046875,
-0.75390625,
0.26025390625,
0.093505859375,
-0.256103515625,
-0.489501953125,
-0.19482421875,
-0.77490234375,
0.472412109375,
-0.056732177734375,
-0.51953125,
0.482421875,
-0.79443359375,
-0.330322265625,
0.1639404296875,
0.77978515625,
-0.254638671875,
0.463134765625,
0.11920166015625,
-0.37744140625,
-0.7900390625,
1.0087890625,
-0.178466796875,
0.344970703125,
0.19189453125,
0.828125,
-0.072509765625,
1.1201171875,
0.37353515625,
-0.26904296875,
-0.0062713623046875,
0.076416015625,
-0.419189453125,
-1.01953125,
-0.2646484375,
-0.63818359375,
0.229248046875,
-0.310546875,
0.0288238525390625,
-0.0230865478515625,
0.6923828125,
-0.08575439453125,
-0.9072265625,
-0.387939453125,
0.056671142578125,
-0.6943359375,
0.5400390625,
0.40380859375,
0.156005859375,
0.322021484375,
-0.019744873046875,
-0.30712890625,
-0.6318359375,
-0.034423828125,
-0.81298828125,
0.28271484375,
-0.349365234375,
-0.2381591796875,
-0.76806640625,
-0.8671875,
-0.361572265625,
0.10186767578125,
-0.15673828125,
-0.89794921875,
0.306396484375,
0.01318359375,
0.54541015625,
0.0888671875,
-0.318115234375,
0.6513671875,
0.83056640625,
0.9716796875,
0.029754638671875,
0.80078125,
0.3388671875,
-0.3134765625,
0.2276611328125,
-0.277587890625,
0.336669921875,
-0.5986328125,
0.2257080078125,
-0.27294921875,
0.38232421875,
-0.5625,
-1.34375,
-0.2138671875,
0.57666015625,
0.305419921875,
-0.7373046875,
-1.0751953125,
-0.56005859375,
-0.65771484375,
0.314208984375,
-0.78125,
0.3857421875,
-0.0428466796875,
0.361083984375,
-0.1588134765625,
-0.95166015625,
4.37890625,
1.1064453125,
1.2724609375,
0.4619140625,
0.0538330078125,
0.9296875,
0.3818359375,
-0.1962890625,
-0.13427734375,
-0.6533203125,
0.373779296875,
-0.244140625,
-0.1439208984375,
1.04296875,
0.391357421875,
0.7744140625,
-0.8798828125,
-0.2152099609375,
0.007049560546875,
-0.5546875,
-0.72314453125,
0.041412353515625,
-0.552734375,
0.2177734375,
-0.198974609375,
0.386474609375,
0.69091796875,
-0.943359375,
-0.394775390625,
-0.3046875,
0.1309814453125,
-0.78466796875,
1.1328125,
-0.455810546875,
-0.2393798828125,
0.37060546875,
-0.2022705078125,
-0.5654296875,
-0.018341064453125,
0.420654296875,
0.1971435546875,
0.400634765625,
1.013671875,
-0.263671875,
0.48583984375,
0.465576171875,
-0.50830078125,
-0.003570556640625,
-0.320068359375,
-0.86083984375,
1.056640625,
-0.4853515625,
0.268310546875,
-0.46826171875,
-0.939453125,
0.253662109375,
-0.126220703125,
-0.365234375,
-0.228759765625,
0.188720703125,
0.2388916015625,
-0.0133514404296875,
-0.080810546875,
0.310791015625,
-1.00390625,
0.64111328125,
-0.039215087890625,
0.1954345703125,
-0.61328125,
-0.378662109375,
-0.1844482421875,
-0.25927734375,
-0.33251953125,
-0.408935546875,
0.53955078125,
0.1756591796875,
0.118896484375,
0.3916015625,
0.63720703125,
-0.80029296875,
-0.03790283203125,
-0.156982421875,
-0.59326171875,
-0.53955078125,
0.77099609375,
0.9716796875,
-0.7041015625,
-0.5146484375,
-0.1650390625,
0.383056640625,
0.58544921875,
0.38623046875,
0.454345703125,
-0.062347412109375,
-0.1766357421875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Tags: dfs and similar, graphs, sortings
Correct Solution:
```
from collections import deque
from sys import stdout
def toposort(graph, indegrees):
sort = deque()
zeros = deque()
for node in indegrees:
if indegrees[node] == 0:
zeros.append(node)
while len(zeros) > 0:
node = zeros.popleft()
sort.append(node)
for to in graph[node]:
indegrees[to] -= 1
if indegrees[to] == 0:
zeros.append(to)
for node in indegrees:
if indegrees[node] != 0:
return None
return sort
def solve():
def strcmp(str1, str2):
if str1 == None:
return True
assert not str1 == str2
if len(str1) < len(str2):
if str2[:len(str1)] == str1:
return True
if len(str1) > len(str2):
if str1[:len(str2)] == str2:
return False
length = min(len(str1), len(str2))
for i in range(length):
if str1[i] != str2[i]:
return (str1[i], str2[i])
t = int(input().rstrip())
letters = 'abcdefghijklmnopqrstuvwxyz'
assert len(letters) == 26
graph = {}
indegrees = {}
for letter in letters:
graph[letter] = []
indegrees[letter] = 0
prev = None
for i in range(t):
name = str(input().rstrip())
val = strcmp(prev, name)
if val == False:
return False
elif val == True:
pass
else:
graph[val[0]].append(val[1])
indegrees[val[1]] += 1
prev = name
sort = toposort(graph, indegrees)
if sort == None:
return False
else:
assert len(sort) == 26
return sort
if __name__ == '__main__':
sort = solve()
if sort == False:
print('Impossible')
else:
for i in sort:
stdout.write(str(i))
stdout.write("\n")
```
| 72,042 | [
-0.180419921875,
-0.34375,
0.476318359375,
-0.2020263671875,
-0.327392578125,
-0.34375,
-0.08489990234375,
0.228271484375,
0.1395263671875,
0.65087890625,
0.74072265625,
-0.05401611328125,
0.298095703125,
-0.9091796875,
-0.88818359375,
0.163818359375,
-0.200439453125,
-0.394775390625,
-0.01727294921875,
-0.08355712890625,
0.49755859375,
0.21875,
-1.806640625,
0.09527587890625,
-0.55859375,
1.0693359375,
0.60888671875,
0.1409912109375,
1.2353515625,
0.9892578125,
-0.039581298828125,
-0.344970703125,
0.51025390625,
-0.94775390625,
-0.236083984375,
-0.17431640625,
0.650390625,
-0.496826171875,
-0.08154296875,
-0.65478515625,
0.5673828125,
-0.7802734375,
0.45458984375,
-0.83984375,
-0.84765625,
-0.302001953125,
-0.1900634765625,
-0.19189453125,
-0.5048828125,
-1.283203125,
0.1494140625,
-0.28173828125,
0.6982421875,
-0.425537109375,
-0.1627197265625,
-0.040618896484375,
0.336669921875,
-0.06414794921875,
-0.471435546875,
0.53369140625,
-0.007320404052734375,
0.399169921875,
-0.320068359375,
-0.481201171875,
-0.328369140625,
0.223388671875,
0.14111328125,
-0.1376953125,
0.08001708984375,
-0.61328125,
-0.2451171875,
0.414306640625,
-0.29736328125,
-0.0411376953125,
-0.50830078125,
0.049407958984375,
-0.1990966796875,
-0.180419921875,
-0.3681640625,
0.58154296875,
0.279296875,
0.56787109375,
0.06695556640625,
0.314208984375,
-0.2646484375,
-0.34228515625,
-0.1282958984375,
0.17919921875,
0.2734375,
0.163818359375,
0.2088623046875,
0.441650390625,
-0.83642578125,
-0.29931640625,
0.39501953125,
0.60791015625,
-0.03558349609375,
0.2259521484375,
0.12188720703125,
0.140625,
0.939453125,
1.271484375,
-0.150390625,
0.9345703125,
-0.77490234375,
0.1658935546875,
-0.08001708984375,
-0.15478515625,
0.036529541015625,
-0.298583984375,
-0.205810546875,
-0.2303466796875,
0.2130126953125,
0.26953125,
0.11968994140625,
0.68310546875,
-0.446533203125,
0.385986328125,
-0.9931640625,
0.00644683837890625,
0.49169921875,
0.10150146484375,
0.053436279296875,
0.0784912109375,
0.2705078125,
-0.203369140625,
-0.1695556640625,
0.8974609375,
-0.452880859375,
-0.0908203125,
0.48388671875,
-0.055450439453125,
-0.548828125,
0.258056640625,
-0.106689453125,
0.8095703125,
-0.06402587890625,
0.52685546875,
0.55029296875,
-0.45654296875,
0.630859375,
-0.16943359375,
-0.035888671875,
1.53515625,
-0.007335662841796875,
-0.2384033203125,
0.41064453125,
0.2081298828125,
-0.76611328125,
0.5595703125,
-1.0556640625,
0.76513671875,
0.3828125,
0.33154296875,
-0.452880859375,
0.47216796875,
-0.186767578125,
0.42236328125,
0.65673828125,
0.64111328125,
-0.349609375,
-0.2298583984375,
-0.1202392578125,
1.0712890625,
-0.27197265625,
1.1962890625,
-0.61767578125,
-0.10089111328125,
0.07366943359375,
-0.2110595703125,
0.07696533203125,
0.043701171875,
-0.619140625,
1.0029296875,
0.289794921875,
0.81591796875,
0.437255859375,
-0.4677734375,
0.1600341796875,
0.08984375,
-0.33349609375,
0.473388671875,
-0.0029888153076171875,
0.76513671875,
0.176513671875,
0.1239013671875,
0.259765625,
-0.79052734375,
-0.35400390625,
-0.681640625,
-0.25390625,
0.7685546875,
-0.460205078125,
0.27734375,
-0.037139892578125,
-0.1365966796875,
-0.71142578125,
0.194580078125,
0.810546875,
-0.95166015625,
-0.200439453125,
0.52099609375,
-0.2176513671875,
0.6328125,
-0.74365234375,
-0.492919921875,
0.28662109375,
1.130859375,
0.00972747802734375,
-0.03955078125,
0.198486328125,
0.1295166015625,
-0.5048828125,
0.2362060546875,
0.30517578125,
-0.08441162109375,
-0.399658203125,
0.7060546875,
-0.515625,
-0.1280517578125,
0.280517578125,
0.970703125,
0.93408203125,
0.1883544921875,
-0.1307373046875,
0.158935546875,
1.251953125,
1.2890625,
-0.355712890625,
0.11578369140625,
0.0980224609375,
1.0859375,
0.3828125,
0.61279296875,
0.55712890625,
0.00441741943359375,
0.6884765625,
0.623046875,
-0.2130126953125,
0.08154296875,
0.07928466796875,
0.54150390625,
0.7685546875,
0.673828125,
-0.1881103515625,
0.5419921875,
-0.1519775390625,
0.1856689453125,
-0.236328125,
0.5732421875,
0.2293701171875,
0.8544921875,
0.125,
0.2376708984375,
-0.470703125,
-0.51513671875,
-0.281494140625,
0.463134765625,
-0.9306640625,
-0.59228515625,
-0.343994140625,
-0.10369873046875,
0.1632080078125,
0.0161590576171875,
0.2357177734375,
0.279052734375,
0.427001953125,
0.270263671875,
-0.2227783203125,
-0.61669921875,
-1.064453125,
-0.85791015625,
-1.21484375,
-0.347900390625,
-0.6962890625,
0.0826416015625,
0.436279296875,
-0.487060546875,
0.44921875,
-0.218505859375,
-0.251953125,
0.411865234375,
-0.47021484375,
0.58642578125,
0.08990478515625,
0.8486328125,
-0.497314453125,
0.262451171875,
-0.366943359375,
1.2314453125,
-0.65087890625,
-0.2425537109375,
-0.50048828125,
-0.7216796875,
0.444091796875,
0.5166015625,
0.60791015625,
0.063232421875,
-0.56884765625,
-1.1923828125,
-0.60693359375,
-0.0836181640625,
-1.0029296875,
0.349853515625,
-0.7978515625,
1.046875,
0.20166015625,
-0.666015625,
0.429443359375,
0.7060546875,
-0.6767578125,
0.888671875,
0.454345703125,
0.1466064453125,
-0.92431640625,
1.423828125,
0.00554656982421875,
0.478515625,
-0.456298828125,
-0.5263671875,
-0.41796875,
0.3564453125,
0.72021484375,
-0.98681640625,
0.0186767578125,
0.80712890625,
-0.037933349609375,
-1.134765625,
0.6630859375,
-0.6513671875,
-0.67529296875,
-0.1212158203125,
-0.5517578125,
0.69091796875,
0.8154296875,
0.5244140625,
0.250732421875,
-0.307373046875,
-0.24169921875,
0.58544921875,
-0.158935546875,
-0.55322265625,
-0.224609375,
0.3896484375,
-0.2115478515625,
-0.2176513671875,
0.2427978515625,
-0.340087890625,
-0.1195068359375,
-0.01041412353515625,
-0.06103515625,
0.90966796875,
0.13916015625,
0.142578125,
-0.047882080078125,
0.8505859375,
-0.7021484375,
-0.599609375,
-0.51318359375,
0.771484375,
0.578125,
0.36572265625,
0.41357421875,
-0.1962890625,
-0.413818359375,
-0.84423828125,
0.27001953125,
0.1402587890625,
0.71875,
-0.75732421875,
0.8779296875,
0.28173828125,
-0.59228515625,
0.322509765625,
-0.8037109375,
-0.252685546875,
1.4169921875,
-0.312744140625,
0.814453125,
-0.55224609375,
0.062225341796875,
-0.276611328125,
0.470947265625,
0.50927734375,
0.28662109375,
0.64453125,
-0.34033203125,
-0.035919189453125,
-0.451416015625,
-0.57958984375,
0.1668701171875,
-0.75146484375,
0.215087890625,
-0.09765625,
-0.385009765625,
-0.84375,
0.64794921875,
0.54345703125,
0.149658203125,
0.19287109375,
0.720703125,
0.236328125,
0.36572265625,
1.0625,
-0.41650390625,
0.1900634765625,
-0.59326171875,
0.88720703125,
0.27490234375,
-0.065185546875,
0.024688720703125,
-0.044952392578125,
-0.16552734375,
0.1524658203125,
-0.1810302734375,
-0.179931640625,
-0.6044921875,
0.14306640625,
0.2998046875,
0.70947265625,
-0.474853515625,
-0.51953125,
-0.196533203125,
0.56982421875,
0.326171875,
-0.56884765625,
0.10198974609375,
-0.69189453125,
0.3818359375,
0.56005859375,
-0.027374267578125,
-0.52734375,
-0.6494140625,
-1.1162109375,
-0.404296875,
0.62939453125,
0.343994140625,
0.134033203125,
-0.12030029296875,
-0.794921875,
0.7939453125,
0.031341552734375,
-0.2220458984375,
0.1448974609375,
-0.1868896484375,
-0.01380157470703125,
-0.1309814453125,
0.54736328125,
0.09814453125,
-0.63623046875,
0.35205078125,
-1.18359375,
0.58154296875,
-0.86328125,
0.57373046875,
0.09197998046875,
0.2137451171875,
-0.208251953125,
0.331787109375,
-0.51806640625,
-0.1370849609375,
-0.3017578125,
0.51708984375,
-0.97216796875,
-0.78564453125,
0.775390625,
-0.0621337890625,
-0.02008056640625,
0.71533203125,
-0.03131103515625,
-0.49169921875,
0.14013671875,
0.380615234375,
-0.56201171875,
0.23583984375,
-0.3994140625,
0.236083984375,
-0.6875,
-0.410888671875,
-0.133544921875,
-0.436767578125,
0.68115234375,
0.287841796875,
-0.7841796875,
-0.38623046875,
-0.99072265625,
-0.03631591796875,
-0.1553955078125,
-0.58251953125,
0.26953125,
-0.2310791015625,
-0.2861328125,
-0.285888671875,
-0.33984375,
-0.6572265625,
0.036102294921875,
-0.68896484375,
-0.319091796875,
0.2222900390625,
0.38427734375,
0.60009765625,
0.07110595703125,
-0.38720703125,
0.13525390625,
-0.2392578125,
-0.043792724609375,
-0.287353515625,
-0.14013671875,
-0.203857421875,
-0.349853515625,
-0.257568359375,
-0.1185302734375,
0.458740234375,
0.244140625,
0.23193359375,
0.270751953125,
0.419189453125,
0.5107421875,
-0.42919921875,
0.66455078125,
0.0200347900390625,
-0.54833984375,
-0.50537109375,
0.5400390625,
-0.2066650390625,
0.94189453125,
0.34033203125,
-1.359375,
-0.779296875,
-1.2626953125,
-0.0192413330078125,
-0.315673828125,
-0.102294921875,
-0.76953125,
0.03851318359375,
-0.61376953125,
0.2900390625,
-0.2073974609375,
-0.458984375,
0.1669921875,
-1.3349609375,
-0.0733642578125,
-0.64453125,
-0.56982421875,
-0.28173828125,
-0.58056640625,
-0.1610107421875,
0.9658203125,
0.279541015625,
0.266357421875,
0.1497802734375,
0.070068359375,
0.023529052734375,
-0.312744140625,
-0.9482421875,
-0.37939453125,
0.049163818359375,
0.307373046875,
0.08575439453125,
-0.073974609375,
-0.4814453125,
0.84228515625,
-1.021484375,
-0.1070556640625,
-0.2105712890625,
-0.249755859375,
-0.10577392578125,
-0.1485595703125,
1.162109375,
-0.375244140625,
-0.0247344970703125,
-0.0141448974609375,
0.50390625,
0.460693359375,
-0.3916015625,
-0.42041015625,
-0.6728515625,
-0.466796875,
-0.89208984375,
0.71826171875,
-0.7138671875,
0.1417236328125,
-0.64501953125,
-0.401611328125,
1.1923828125,
-0.87158203125,
0.50732421875,
0.81884765625,
-0.03875732421875,
0.1959228515625,
-0.81396484375,
0.6005859375,
0.455322265625,
-0.5458984375,
-0.12451171875,
0.307861328125,
-0.469482421875,
0.369873046875,
0.068359375,
-1.037109375,
-0.70361328125,
0.615234375,
1.330078125,
-0.078857421875,
0.63818359375,
-0.168701171875,
-0.361083984375,
-0.49560546875,
1.046875,
-0.1063232421875,
0.037689208984375,
1.0263671875,
-0.65869140625,
-0.323974609375,
0.09930419921875,
-0.0367431640625,
-0.56787109375,
-0.4765625,
1.544921875,
-0.15478515625,
-0.2178955078125,
0.951171875,
0.8583984375,
-0.66748046875,
-0.5478515625,
-0.38037109375,
0.376708984375,
-0.042083740234375,
-0.8212890625,
0.212158203125,
0.658203125,
-0.7705078125,
-0.2025146484375,
0.537109375,
-0.18115234375,
0.336181640625,
0.1722412109375,
0.4423828125,
-0.315185546875,
0.333251953125,
0.64208984375,
-0.73876953125,
-0.059600830078125,
-1.0849609375,
0.25341796875,
-0.27880859375,
-0.51220703125,
0.7802734375,
-0.247314453125,
0.44921875,
0.88134765625,
-0.1973876953125,
0.49853515625,
-0.58740234375,
-0.58056640625,
0.2220458984375,
-1.0048828125,
-0.70751953125,
-0.391357421875,
0.467529296875,
-0.268798828125,
0.1336669921875,
-1.146484375,
0.279541015625,
0.42578125,
0.440185546875,
-0.6513671875,
-0.8525390625,
0.027252197265625,
-0.96923828125,
-0.384521484375,
-0.576171875,
-0.69091796875,
-0.2861328125,
-0.068603515625,
-0.0841064453125,
-0.5498046875,
0.368896484375,
0.40625,
-0.32763671875,
0.9091796875,
-0.470458984375,
0.5263671875,
-0.64599609375,
-0.169677734375,
-0.7255859375,
0.054412841796875,
-0.30419921875,
0.00188446044921875,
-0.5986328125,
0.264892578125,
0.50244140625,
0.2464599609375,
0.10260009765625,
-0.18505859375,
-0.583984375,
-0.6875,
-0.11517333984375,
0.1363525390625,
-0.432373046875,
0.68212890625,
0.434814453125,
0.2303466796875,
0.85498046875,
-0.1943359375,
-0.56884765625,
-0.0034770965576171875,
0.6015625,
0.6845703125,
-0.366455078125,
-0.033660888671875,
-0.33837890625,
0.058929443359375,
-0.85498046875,
0.097412109375,
-0.036865234375,
0.2205810546875,
0.033233642578125,
-0.26025390625,
0.374755859375,
1.1865234375,
0.1539306640625,
0.64990234375,
0.2421875,
0.255126953125,
0.260498046875,
-0.546875,
-0.14794921875,
0.484619140625,
0.11102294921875,
-0.3427734375,
-0.05926513671875,
0.451416015625,
-0.060760498046875,
0.35888671875,
0.159912109375,
-0.892578125,
-1.1484375,
-0.445068359375,
0.1986083984375,
0.481689453125,
0.64013671875,
-0.490234375,
-0.254638671875,
-0.47802734375,
-0.78515625,
0.65478515625,
-1.0009765625,
-0.66455078125,
0.472900390625,
-0.1937255859375,
-0.65185546875,
-0.11016845703125,
-0.52978515625,
0.035125732421875,
0.060394287109375,
0.45556640625,
-0.7080078125,
0.1859130859375,
0.2509765625,
0.46142578125,
-0.265869140625,
-0.221923828125,
0.00904083251953125,
0.322998046875,
-0.281494140625,
-0.1754150390625,
0.41064453125,
1.0595703125,
0.1998291015625,
-0.0292816162109375,
-0.7841796875,
0.0867919921875,
0.6162109375,
0.159423828125,
-0.383056640625,
-0.1495361328125,
-0.63134765625,
0.71630859375,
-0.81787109375,
-0.0201873779296875,
0.028778076171875,
0.1767578125,
0.2353515625,
-0.427490234375,
-0.58935546875,
0.9248046875,
1.2392578125,
-0.2373046875,
0.48388671875,
0.10125732421875,
0.10333251953125,
-0.25927734375,
-0.147705078125,
-0.45361328125,
0.3974609375,
0.1356201171875,
0.419677734375,
-0.062286376953125,
0.73974609375,
0.76806640625,
-0.1968994140625,
0.1383056640625,
0.356201171875,
0.02069091796875,
-0.09619140625,
0.0274200439453125,
-0.02142333984375,
0.2388916015625,
0.439453125,
-0.6884765625,
0.3818359375,
-0.87451171875,
-0.234130859375,
0.027618408203125,
-0.595703125,
0.8203125,
-0.99462890625,
-0.0799560546875,
-0.1124267578125,
-0.4833984375,
0.1649169921875,
0.7294921875,
0.389404296875,
-0.008453369140625,
0.57373046875,
0.80615234375,
0.217041015625,
1.0234375,
0.63916015625,
0.354248046875,
-0.75390625,
0.26025390625,
0.093505859375,
-0.256103515625,
-0.489501953125,
-0.19482421875,
-0.77490234375,
0.472412109375,
-0.056732177734375,
-0.51953125,
0.482421875,
-0.79443359375,
-0.330322265625,
0.1639404296875,
0.77978515625,
-0.254638671875,
0.463134765625,
0.11920166015625,
-0.37744140625,
-0.7900390625,
1.0087890625,
-0.178466796875,
0.344970703125,
0.19189453125,
0.828125,
-0.072509765625,
1.1201171875,
0.37353515625,
-0.26904296875,
-0.0062713623046875,
0.076416015625,
-0.419189453125,
-1.01953125,
-0.2646484375,
-0.63818359375,
0.229248046875,
-0.310546875,
0.0288238525390625,
-0.0230865478515625,
0.6923828125,
-0.08575439453125,
-0.9072265625,
-0.387939453125,
0.056671142578125,
-0.6943359375,
0.5400390625,
0.40380859375,
0.156005859375,
0.322021484375,
-0.019744873046875,
-0.30712890625,
-0.6318359375,
-0.034423828125,
-0.81298828125,
0.28271484375,
-0.349365234375,
-0.2381591796875,
-0.76806640625,
-0.8671875,
-0.361572265625,
0.10186767578125,
-0.15673828125,
-0.89794921875,
0.306396484375,
0.01318359375,
0.54541015625,
0.0888671875,
-0.318115234375,
0.6513671875,
0.83056640625,
0.9716796875,
0.029754638671875,
0.80078125,
0.3388671875,
-0.3134765625,
0.2276611328125,
-0.277587890625,
0.336669921875,
-0.5986328125,
0.2257080078125,
-0.27294921875,
0.38232421875,
-0.5625,
-1.34375,
-0.2138671875,
0.57666015625,
0.305419921875,
-0.7373046875,
-1.0751953125,
-0.56005859375,
-0.65771484375,
0.314208984375,
-0.78125,
0.3857421875,
-0.0428466796875,
0.361083984375,
-0.1588134765625,
-0.95166015625,
4.37890625,
1.1064453125,
1.2724609375,
0.4619140625,
0.0538330078125,
0.9296875,
0.3818359375,
-0.1962890625,
-0.13427734375,
-0.6533203125,
0.373779296875,
-0.244140625,
-0.1439208984375,
1.04296875,
0.391357421875,
0.7744140625,
-0.8798828125,
-0.2152099609375,
0.007049560546875,
-0.5546875,
-0.72314453125,
0.041412353515625,
-0.552734375,
0.2177734375,
-0.198974609375,
0.386474609375,
0.69091796875,
-0.943359375,
-0.394775390625,
-0.3046875,
0.1309814453125,
-0.78466796875,
1.1328125,
-0.455810546875,
-0.2393798828125,
0.37060546875,
-0.2022705078125,
-0.5654296875,
-0.018341064453125,
0.420654296875,
0.1971435546875,
0.400634765625,
1.013671875,
-0.263671875,
0.48583984375,
0.465576171875,
-0.50830078125,
-0.003570556640625,
-0.320068359375,
-0.86083984375,
1.056640625,
-0.4853515625,
0.268310546875,
-0.46826171875,
-0.939453125,
0.253662109375,
-0.126220703125,
-0.365234375,
-0.228759765625,
0.188720703125,
0.2388916015625,
-0.0133514404296875,
-0.080810546875,
0.310791015625,
-1.00390625,
0.64111328125,
-0.039215087890625,
0.1954345703125,
-0.61328125,
-0.378662109375,
-0.1844482421875,
-0.25927734375,
-0.33251953125,
-0.408935546875,
0.53955078125,
0.1756591796875,
0.118896484375,
0.3916015625,
0.63720703125,
-0.80029296875,
-0.03790283203125,
-0.156982421875,
-0.59326171875,
-0.53955078125,
0.77099609375,
0.9716796875,
-0.7041015625,
-0.5146484375,
-0.1650390625,
0.383056640625,
0.58544921875,
0.38623046875,
0.454345703125,
-0.062347412109375,
-0.1766357421875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Tags: dfs and similar, graphs, sortings
Correct Solution:
```
# 510C
import string
__author__ = 'artyom'
graph = dict((c, set()) for c in string.ascii_lowercase)
ordered = []
visited = set()
in_stack = dict((c, 0) for c in string.ascii_lowercase)
def dfs(v):
visited.add(v)
in_stack[v] = 1
for u in graph[v]:
if in_stack[u]:
print('Impossible')
exit()
if u not in visited:
dfs(u)
in_stack[v] = 0
ordered.append(v)
n = int(input())
names = [input() for _ in range(n)]
lengths = [len(name) for name in names]
for i in range(n - 1):
m = min(lengths[i], lengths[i + 1])
for j in range(m):
u, v = names[i][j], names[i + 1][j]
if u != v:
graph[u].add(v)
break
else:
if lengths[i] > m:
print('Impossible')
exit()
for v in graph.keys():
if v not in visited:
dfs(v)
print(''.join(reversed(ordered)))
```
| 72,043 | [
-0.180419921875,
-0.34375,
0.476318359375,
-0.2020263671875,
-0.327392578125,
-0.34375,
-0.08489990234375,
0.228271484375,
0.1395263671875,
0.65087890625,
0.74072265625,
-0.05401611328125,
0.298095703125,
-0.9091796875,
-0.88818359375,
0.163818359375,
-0.200439453125,
-0.394775390625,
-0.01727294921875,
-0.08355712890625,
0.49755859375,
0.21875,
-1.806640625,
0.09527587890625,
-0.55859375,
1.0693359375,
0.60888671875,
0.1409912109375,
1.2353515625,
0.9892578125,
-0.039581298828125,
-0.344970703125,
0.51025390625,
-0.94775390625,
-0.236083984375,
-0.17431640625,
0.650390625,
-0.496826171875,
-0.08154296875,
-0.65478515625,
0.5673828125,
-0.7802734375,
0.45458984375,
-0.83984375,
-0.84765625,
-0.302001953125,
-0.1900634765625,
-0.19189453125,
-0.5048828125,
-1.283203125,
0.1494140625,
-0.28173828125,
0.6982421875,
-0.425537109375,
-0.1627197265625,
-0.040618896484375,
0.336669921875,
-0.06414794921875,
-0.471435546875,
0.53369140625,
-0.007320404052734375,
0.399169921875,
-0.320068359375,
-0.481201171875,
-0.328369140625,
0.223388671875,
0.14111328125,
-0.1376953125,
0.08001708984375,
-0.61328125,
-0.2451171875,
0.414306640625,
-0.29736328125,
-0.0411376953125,
-0.50830078125,
0.049407958984375,
-0.1990966796875,
-0.180419921875,
-0.3681640625,
0.58154296875,
0.279296875,
0.56787109375,
0.06695556640625,
0.314208984375,
-0.2646484375,
-0.34228515625,
-0.1282958984375,
0.17919921875,
0.2734375,
0.163818359375,
0.2088623046875,
0.441650390625,
-0.83642578125,
-0.29931640625,
0.39501953125,
0.60791015625,
-0.03558349609375,
0.2259521484375,
0.12188720703125,
0.140625,
0.939453125,
1.271484375,
-0.150390625,
0.9345703125,
-0.77490234375,
0.1658935546875,
-0.08001708984375,
-0.15478515625,
0.036529541015625,
-0.298583984375,
-0.205810546875,
-0.2303466796875,
0.2130126953125,
0.26953125,
0.11968994140625,
0.68310546875,
-0.446533203125,
0.385986328125,
-0.9931640625,
0.00644683837890625,
0.49169921875,
0.10150146484375,
0.053436279296875,
0.0784912109375,
0.2705078125,
-0.203369140625,
-0.1695556640625,
0.8974609375,
-0.452880859375,
-0.0908203125,
0.48388671875,
-0.055450439453125,
-0.548828125,
0.258056640625,
-0.106689453125,
0.8095703125,
-0.06402587890625,
0.52685546875,
0.55029296875,
-0.45654296875,
0.630859375,
-0.16943359375,
-0.035888671875,
1.53515625,
-0.007335662841796875,
-0.2384033203125,
0.41064453125,
0.2081298828125,
-0.76611328125,
0.5595703125,
-1.0556640625,
0.76513671875,
0.3828125,
0.33154296875,
-0.452880859375,
0.47216796875,
-0.186767578125,
0.42236328125,
0.65673828125,
0.64111328125,
-0.349609375,
-0.2298583984375,
-0.1202392578125,
1.0712890625,
-0.27197265625,
1.1962890625,
-0.61767578125,
-0.10089111328125,
0.07366943359375,
-0.2110595703125,
0.07696533203125,
0.043701171875,
-0.619140625,
1.0029296875,
0.289794921875,
0.81591796875,
0.437255859375,
-0.4677734375,
0.1600341796875,
0.08984375,
-0.33349609375,
0.473388671875,
-0.0029888153076171875,
0.76513671875,
0.176513671875,
0.1239013671875,
0.259765625,
-0.79052734375,
-0.35400390625,
-0.681640625,
-0.25390625,
0.7685546875,
-0.460205078125,
0.27734375,
-0.037139892578125,
-0.1365966796875,
-0.71142578125,
0.194580078125,
0.810546875,
-0.95166015625,
-0.200439453125,
0.52099609375,
-0.2176513671875,
0.6328125,
-0.74365234375,
-0.492919921875,
0.28662109375,
1.130859375,
0.00972747802734375,
-0.03955078125,
0.198486328125,
0.1295166015625,
-0.5048828125,
0.2362060546875,
0.30517578125,
-0.08441162109375,
-0.399658203125,
0.7060546875,
-0.515625,
-0.1280517578125,
0.280517578125,
0.970703125,
0.93408203125,
0.1883544921875,
-0.1307373046875,
0.158935546875,
1.251953125,
1.2890625,
-0.355712890625,
0.11578369140625,
0.0980224609375,
1.0859375,
0.3828125,
0.61279296875,
0.55712890625,
0.00441741943359375,
0.6884765625,
0.623046875,
-0.2130126953125,
0.08154296875,
0.07928466796875,
0.54150390625,
0.7685546875,
0.673828125,
-0.1881103515625,
0.5419921875,
-0.1519775390625,
0.1856689453125,
-0.236328125,
0.5732421875,
0.2293701171875,
0.8544921875,
0.125,
0.2376708984375,
-0.470703125,
-0.51513671875,
-0.281494140625,
0.463134765625,
-0.9306640625,
-0.59228515625,
-0.343994140625,
-0.10369873046875,
0.1632080078125,
0.0161590576171875,
0.2357177734375,
0.279052734375,
0.427001953125,
0.270263671875,
-0.2227783203125,
-0.61669921875,
-1.064453125,
-0.85791015625,
-1.21484375,
-0.347900390625,
-0.6962890625,
0.0826416015625,
0.436279296875,
-0.487060546875,
0.44921875,
-0.218505859375,
-0.251953125,
0.411865234375,
-0.47021484375,
0.58642578125,
0.08990478515625,
0.8486328125,
-0.497314453125,
0.262451171875,
-0.366943359375,
1.2314453125,
-0.65087890625,
-0.2425537109375,
-0.50048828125,
-0.7216796875,
0.444091796875,
0.5166015625,
0.60791015625,
0.063232421875,
-0.56884765625,
-1.1923828125,
-0.60693359375,
-0.0836181640625,
-1.0029296875,
0.349853515625,
-0.7978515625,
1.046875,
0.20166015625,
-0.666015625,
0.429443359375,
0.7060546875,
-0.6767578125,
0.888671875,
0.454345703125,
0.1466064453125,
-0.92431640625,
1.423828125,
0.00554656982421875,
0.478515625,
-0.456298828125,
-0.5263671875,
-0.41796875,
0.3564453125,
0.72021484375,
-0.98681640625,
0.0186767578125,
0.80712890625,
-0.037933349609375,
-1.134765625,
0.6630859375,
-0.6513671875,
-0.67529296875,
-0.1212158203125,
-0.5517578125,
0.69091796875,
0.8154296875,
0.5244140625,
0.250732421875,
-0.307373046875,
-0.24169921875,
0.58544921875,
-0.158935546875,
-0.55322265625,
-0.224609375,
0.3896484375,
-0.2115478515625,
-0.2176513671875,
0.2427978515625,
-0.340087890625,
-0.1195068359375,
-0.01041412353515625,
-0.06103515625,
0.90966796875,
0.13916015625,
0.142578125,
-0.047882080078125,
0.8505859375,
-0.7021484375,
-0.599609375,
-0.51318359375,
0.771484375,
0.578125,
0.36572265625,
0.41357421875,
-0.1962890625,
-0.413818359375,
-0.84423828125,
0.27001953125,
0.1402587890625,
0.71875,
-0.75732421875,
0.8779296875,
0.28173828125,
-0.59228515625,
0.322509765625,
-0.8037109375,
-0.252685546875,
1.4169921875,
-0.312744140625,
0.814453125,
-0.55224609375,
0.062225341796875,
-0.276611328125,
0.470947265625,
0.50927734375,
0.28662109375,
0.64453125,
-0.34033203125,
-0.035919189453125,
-0.451416015625,
-0.57958984375,
0.1668701171875,
-0.75146484375,
0.215087890625,
-0.09765625,
-0.385009765625,
-0.84375,
0.64794921875,
0.54345703125,
0.149658203125,
0.19287109375,
0.720703125,
0.236328125,
0.36572265625,
1.0625,
-0.41650390625,
0.1900634765625,
-0.59326171875,
0.88720703125,
0.27490234375,
-0.065185546875,
0.024688720703125,
-0.044952392578125,
-0.16552734375,
0.1524658203125,
-0.1810302734375,
-0.179931640625,
-0.6044921875,
0.14306640625,
0.2998046875,
0.70947265625,
-0.474853515625,
-0.51953125,
-0.196533203125,
0.56982421875,
0.326171875,
-0.56884765625,
0.10198974609375,
-0.69189453125,
0.3818359375,
0.56005859375,
-0.027374267578125,
-0.52734375,
-0.6494140625,
-1.1162109375,
-0.404296875,
0.62939453125,
0.343994140625,
0.134033203125,
-0.12030029296875,
-0.794921875,
0.7939453125,
0.031341552734375,
-0.2220458984375,
0.1448974609375,
-0.1868896484375,
-0.01380157470703125,
-0.1309814453125,
0.54736328125,
0.09814453125,
-0.63623046875,
0.35205078125,
-1.18359375,
0.58154296875,
-0.86328125,
0.57373046875,
0.09197998046875,
0.2137451171875,
-0.208251953125,
0.331787109375,
-0.51806640625,
-0.1370849609375,
-0.3017578125,
0.51708984375,
-0.97216796875,
-0.78564453125,
0.775390625,
-0.0621337890625,
-0.02008056640625,
0.71533203125,
-0.03131103515625,
-0.49169921875,
0.14013671875,
0.380615234375,
-0.56201171875,
0.23583984375,
-0.3994140625,
0.236083984375,
-0.6875,
-0.410888671875,
-0.133544921875,
-0.436767578125,
0.68115234375,
0.287841796875,
-0.7841796875,
-0.38623046875,
-0.99072265625,
-0.03631591796875,
-0.1553955078125,
-0.58251953125,
0.26953125,
-0.2310791015625,
-0.2861328125,
-0.285888671875,
-0.33984375,
-0.6572265625,
0.036102294921875,
-0.68896484375,
-0.319091796875,
0.2222900390625,
0.38427734375,
0.60009765625,
0.07110595703125,
-0.38720703125,
0.13525390625,
-0.2392578125,
-0.043792724609375,
-0.287353515625,
-0.14013671875,
-0.203857421875,
-0.349853515625,
-0.257568359375,
-0.1185302734375,
0.458740234375,
0.244140625,
0.23193359375,
0.270751953125,
0.419189453125,
0.5107421875,
-0.42919921875,
0.66455078125,
0.0200347900390625,
-0.54833984375,
-0.50537109375,
0.5400390625,
-0.2066650390625,
0.94189453125,
0.34033203125,
-1.359375,
-0.779296875,
-1.2626953125,
-0.0192413330078125,
-0.315673828125,
-0.102294921875,
-0.76953125,
0.03851318359375,
-0.61376953125,
0.2900390625,
-0.2073974609375,
-0.458984375,
0.1669921875,
-1.3349609375,
-0.0733642578125,
-0.64453125,
-0.56982421875,
-0.28173828125,
-0.58056640625,
-0.1610107421875,
0.9658203125,
0.279541015625,
0.266357421875,
0.1497802734375,
0.070068359375,
0.023529052734375,
-0.312744140625,
-0.9482421875,
-0.37939453125,
0.049163818359375,
0.307373046875,
0.08575439453125,
-0.073974609375,
-0.4814453125,
0.84228515625,
-1.021484375,
-0.1070556640625,
-0.2105712890625,
-0.249755859375,
-0.10577392578125,
-0.1485595703125,
1.162109375,
-0.375244140625,
-0.0247344970703125,
-0.0141448974609375,
0.50390625,
0.460693359375,
-0.3916015625,
-0.42041015625,
-0.6728515625,
-0.466796875,
-0.89208984375,
0.71826171875,
-0.7138671875,
0.1417236328125,
-0.64501953125,
-0.401611328125,
1.1923828125,
-0.87158203125,
0.50732421875,
0.81884765625,
-0.03875732421875,
0.1959228515625,
-0.81396484375,
0.6005859375,
0.455322265625,
-0.5458984375,
-0.12451171875,
0.307861328125,
-0.469482421875,
0.369873046875,
0.068359375,
-1.037109375,
-0.70361328125,
0.615234375,
1.330078125,
-0.078857421875,
0.63818359375,
-0.168701171875,
-0.361083984375,
-0.49560546875,
1.046875,
-0.1063232421875,
0.037689208984375,
1.0263671875,
-0.65869140625,
-0.323974609375,
0.09930419921875,
-0.0367431640625,
-0.56787109375,
-0.4765625,
1.544921875,
-0.15478515625,
-0.2178955078125,
0.951171875,
0.8583984375,
-0.66748046875,
-0.5478515625,
-0.38037109375,
0.376708984375,
-0.042083740234375,
-0.8212890625,
0.212158203125,
0.658203125,
-0.7705078125,
-0.2025146484375,
0.537109375,
-0.18115234375,
0.336181640625,
0.1722412109375,
0.4423828125,
-0.315185546875,
0.333251953125,
0.64208984375,
-0.73876953125,
-0.059600830078125,
-1.0849609375,
0.25341796875,
-0.27880859375,
-0.51220703125,
0.7802734375,
-0.247314453125,
0.44921875,
0.88134765625,
-0.1973876953125,
0.49853515625,
-0.58740234375,
-0.58056640625,
0.2220458984375,
-1.0048828125,
-0.70751953125,
-0.391357421875,
0.467529296875,
-0.268798828125,
0.1336669921875,
-1.146484375,
0.279541015625,
0.42578125,
0.440185546875,
-0.6513671875,
-0.8525390625,
0.027252197265625,
-0.96923828125,
-0.384521484375,
-0.576171875,
-0.69091796875,
-0.2861328125,
-0.068603515625,
-0.0841064453125,
-0.5498046875,
0.368896484375,
0.40625,
-0.32763671875,
0.9091796875,
-0.470458984375,
0.5263671875,
-0.64599609375,
-0.169677734375,
-0.7255859375,
0.054412841796875,
-0.30419921875,
0.00188446044921875,
-0.5986328125,
0.264892578125,
0.50244140625,
0.2464599609375,
0.10260009765625,
-0.18505859375,
-0.583984375,
-0.6875,
-0.11517333984375,
0.1363525390625,
-0.432373046875,
0.68212890625,
0.434814453125,
0.2303466796875,
0.85498046875,
-0.1943359375,
-0.56884765625,
-0.0034770965576171875,
0.6015625,
0.6845703125,
-0.366455078125,
-0.033660888671875,
-0.33837890625,
0.058929443359375,
-0.85498046875,
0.097412109375,
-0.036865234375,
0.2205810546875,
0.033233642578125,
-0.26025390625,
0.374755859375,
1.1865234375,
0.1539306640625,
0.64990234375,
0.2421875,
0.255126953125,
0.260498046875,
-0.546875,
-0.14794921875,
0.484619140625,
0.11102294921875,
-0.3427734375,
-0.05926513671875,
0.451416015625,
-0.060760498046875,
0.35888671875,
0.159912109375,
-0.892578125,
-1.1484375,
-0.445068359375,
0.1986083984375,
0.481689453125,
0.64013671875,
-0.490234375,
-0.254638671875,
-0.47802734375,
-0.78515625,
0.65478515625,
-1.0009765625,
-0.66455078125,
0.472900390625,
-0.1937255859375,
-0.65185546875,
-0.11016845703125,
-0.52978515625,
0.035125732421875,
0.060394287109375,
0.45556640625,
-0.7080078125,
0.1859130859375,
0.2509765625,
0.46142578125,
-0.265869140625,
-0.221923828125,
0.00904083251953125,
0.322998046875,
-0.281494140625,
-0.1754150390625,
0.41064453125,
1.0595703125,
0.1998291015625,
-0.0292816162109375,
-0.7841796875,
0.0867919921875,
0.6162109375,
0.159423828125,
-0.383056640625,
-0.1495361328125,
-0.63134765625,
0.71630859375,
-0.81787109375,
-0.0201873779296875,
0.028778076171875,
0.1767578125,
0.2353515625,
-0.427490234375,
-0.58935546875,
0.9248046875,
1.2392578125,
-0.2373046875,
0.48388671875,
0.10125732421875,
0.10333251953125,
-0.25927734375,
-0.147705078125,
-0.45361328125,
0.3974609375,
0.1356201171875,
0.419677734375,
-0.062286376953125,
0.73974609375,
0.76806640625,
-0.1968994140625,
0.1383056640625,
0.356201171875,
0.02069091796875,
-0.09619140625,
0.0274200439453125,
-0.02142333984375,
0.2388916015625,
0.439453125,
-0.6884765625,
0.3818359375,
-0.87451171875,
-0.234130859375,
0.027618408203125,
-0.595703125,
0.8203125,
-0.99462890625,
-0.0799560546875,
-0.1124267578125,
-0.4833984375,
0.1649169921875,
0.7294921875,
0.389404296875,
-0.008453369140625,
0.57373046875,
0.80615234375,
0.217041015625,
1.0234375,
0.63916015625,
0.354248046875,
-0.75390625,
0.26025390625,
0.093505859375,
-0.256103515625,
-0.489501953125,
-0.19482421875,
-0.77490234375,
0.472412109375,
-0.056732177734375,
-0.51953125,
0.482421875,
-0.79443359375,
-0.330322265625,
0.1639404296875,
0.77978515625,
-0.254638671875,
0.463134765625,
0.11920166015625,
-0.37744140625,
-0.7900390625,
1.0087890625,
-0.178466796875,
0.344970703125,
0.19189453125,
0.828125,
-0.072509765625,
1.1201171875,
0.37353515625,
-0.26904296875,
-0.0062713623046875,
0.076416015625,
-0.419189453125,
-1.01953125,
-0.2646484375,
-0.63818359375,
0.229248046875,
-0.310546875,
0.0288238525390625,
-0.0230865478515625,
0.6923828125,
-0.08575439453125,
-0.9072265625,
-0.387939453125,
0.056671142578125,
-0.6943359375,
0.5400390625,
0.40380859375,
0.156005859375,
0.322021484375,
-0.019744873046875,
-0.30712890625,
-0.6318359375,
-0.034423828125,
-0.81298828125,
0.28271484375,
-0.349365234375,
-0.2381591796875,
-0.76806640625,
-0.8671875,
-0.361572265625,
0.10186767578125,
-0.15673828125,
-0.89794921875,
0.306396484375,
0.01318359375,
0.54541015625,
0.0888671875,
-0.318115234375,
0.6513671875,
0.83056640625,
0.9716796875,
0.029754638671875,
0.80078125,
0.3388671875,
-0.3134765625,
0.2276611328125,
-0.277587890625,
0.336669921875,
-0.5986328125,
0.2257080078125,
-0.27294921875,
0.38232421875,
-0.5625,
-1.34375,
-0.2138671875,
0.57666015625,
0.305419921875,
-0.7373046875,
-1.0751953125,
-0.56005859375,
-0.65771484375,
0.314208984375,
-0.78125,
0.3857421875,
-0.0428466796875,
0.361083984375,
-0.1588134765625,
-0.95166015625,
4.37890625,
1.1064453125,
1.2724609375,
0.4619140625,
0.0538330078125,
0.9296875,
0.3818359375,
-0.1962890625,
-0.13427734375,
-0.6533203125,
0.373779296875,
-0.244140625,
-0.1439208984375,
1.04296875,
0.391357421875,
0.7744140625,
-0.8798828125,
-0.2152099609375,
0.007049560546875,
-0.5546875,
-0.72314453125,
0.041412353515625,
-0.552734375,
0.2177734375,
-0.198974609375,
0.386474609375,
0.69091796875,
-0.943359375,
-0.394775390625,
-0.3046875,
0.1309814453125,
-0.78466796875,
1.1328125,
-0.455810546875,
-0.2393798828125,
0.37060546875,
-0.2022705078125,
-0.5654296875,
-0.018341064453125,
0.420654296875,
0.1971435546875,
0.400634765625,
1.013671875,
-0.263671875,
0.48583984375,
0.465576171875,
-0.50830078125,
-0.003570556640625,
-0.320068359375,
-0.86083984375,
1.056640625,
-0.4853515625,
0.268310546875,
-0.46826171875,
-0.939453125,
0.253662109375,
-0.126220703125,
-0.365234375,
-0.228759765625,
0.188720703125,
0.2388916015625,
-0.0133514404296875,
-0.080810546875,
0.310791015625,
-1.00390625,
0.64111328125,
-0.039215087890625,
0.1954345703125,
-0.61328125,
-0.378662109375,
-0.1844482421875,
-0.25927734375,
-0.33251953125,
-0.408935546875,
0.53955078125,
0.1756591796875,
0.118896484375,
0.3916015625,
0.63720703125,
-0.80029296875,
-0.03790283203125,
-0.156982421875,
-0.59326171875,
-0.53955078125,
0.77099609375,
0.9716796875,
-0.7041015625,
-0.5146484375,
-0.1650390625,
0.383056640625,
0.58544921875,
0.38623046875,
0.454345703125,
-0.062347412109375,
-0.1766357421875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Tags: dfs and similar, graphs, sortings
Correct Solution:
```
import string
__author__ = 'artyom'
graph = dict((c, set()) for c in string.ascii_lowercase)
ordered = []
visited = set()
in_stack = dict((c, 0) for c in string.ascii_lowercase)
def dfs(v):
visited.add(v)
in_stack[v] = 1
for u in graph[v]:
if in_stack[u]:
print('Impossible')
exit()
if u not in visited:
dfs(u)
in_stack[v] = 0
ordered.append(v)
n = int(input())
names = [input() for _ in range(n)]
lengths = [len(name) for name in names]
for i in range(n - 1):
m = min(lengths[i], lengths[i + 1])
for j in range(m):
u, v = names[i][j], names[i + 1][j]
if u != v:
graph[u].add(v)
break
else:
if lengths[i] > m:
print('Impossible')
exit()
for v in graph.keys():
if v not in visited:
dfs(v)
print(''.join(reversed(ordered)))
```
| 72,044 | [
-0.180419921875,
-0.34375,
0.476318359375,
-0.2020263671875,
-0.327392578125,
-0.34375,
-0.08489990234375,
0.228271484375,
0.1395263671875,
0.65087890625,
0.74072265625,
-0.05401611328125,
0.298095703125,
-0.9091796875,
-0.88818359375,
0.163818359375,
-0.200439453125,
-0.394775390625,
-0.01727294921875,
-0.08355712890625,
0.49755859375,
0.21875,
-1.806640625,
0.09527587890625,
-0.55859375,
1.0693359375,
0.60888671875,
0.1409912109375,
1.2353515625,
0.9892578125,
-0.039581298828125,
-0.344970703125,
0.51025390625,
-0.94775390625,
-0.236083984375,
-0.17431640625,
0.650390625,
-0.496826171875,
-0.08154296875,
-0.65478515625,
0.5673828125,
-0.7802734375,
0.45458984375,
-0.83984375,
-0.84765625,
-0.302001953125,
-0.1900634765625,
-0.19189453125,
-0.5048828125,
-1.283203125,
0.1494140625,
-0.28173828125,
0.6982421875,
-0.425537109375,
-0.1627197265625,
-0.040618896484375,
0.336669921875,
-0.06414794921875,
-0.471435546875,
0.53369140625,
-0.007320404052734375,
0.399169921875,
-0.320068359375,
-0.481201171875,
-0.328369140625,
0.223388671875,
0.14111328125,
-0.1376953125,
0.08001708984375,
-0.61328125,
-0.2451171875,
0.414306640625,
-0.29736328125,
-0.0411376953125,
-0.50830078125,
0.049407958984375,
-0.1990966796875,
-0.180419921875,
-0.3681640625,
0.58154296875,
0.279296875,
0.56787109375,
0.06695556640625,
0.314208984375,
-0.2646484375,
-0.34228515625,
-0.1282958984375,
0.17919921875,
0.2734375,
0.163818359375,
0.2088623046875,
0.441650390625,
-0.83642578125,
-0.29931640625,
0.39501953125,
0.60791015625,
-0.03558349609375,
0.2259521484375,
0.12188720703125,
0.140625,
0.939453125,
1.271484375,
-0.150390625,
0.9345703125,
-0.77490234375,
0.1658935546875,
-0.08001708984375,
-0.15478515625,
0.036529541015625,
-0.298583984375,
-0.205810546875,
-0.2303466796875,
0.2130126953125,
0.26953125,
0.11968994140625,
0.68310546875,
-0.446533203125,
0.385986328125,
-0.9931640625,
0.00644683837890625,
0.49169921875,
0.10150146484375,
0.053436279296875,
0.0784912109375,
0.2705078125,
-0.203369140625,
-0.1695556640625,
0.8974609375,
-0.452880859375,
-0.0908203125,
0.48388671875,
-0.055450439453125,
-0.548828125,
0.258056640625,
-0.106689453125,
0.8095703125,
-0.06402587890625,
0.52685546875,
0.55029296875,
-0.45654296875,
0.630859375,
-0.16943359375,
-0.035888671875,
1.53515625,
-0.007335662841796875,
-0.2384033203125,
0.41064453125,
0.2081298828125,
-0.76611328125,
0.5595703125,
-1.0556640625,
0.76513671875,
0.3828125,
0.33154296875,
-0.452880859375,
0.47216796875,
-0.186767578125,
0.42236328125,
0.65673828125,
0.64111328125,
-0.349609375,
-0.2298583984375,
-0.1202392578125,
1.0712890625,
-0.27197265625,
1.1962890625,
-0.61767578125,
-0.10089111328125,
0.07366943359375,
-0.2110595703125,
0.07696533203125,
0.043701171875,
-0.619140625,
1.0029296875,
0.289794921875,
0.81591796875,
0.437255859375,
-0.4677734375,
0.1600341796875,
0.08984375,
-0.33349609375,
0.473388671875,
-0.0029888153076171875,
0.76513671875,
0.176513671875,
0.1239013671875,
0.259765625,
-0.79052734375,
-0.35400390625,
-0.681640625,
-0.25390625,
0.7685546875,
-0.460205078125,
0.27734375,
-0.037139892578125,
-0.1365966796875,
-0.71142578125,
0.194580078125,
0.810546875,
-0.95166015625,
-0.200439453125,
0.52099609375,
-0.2176513671875,
0.6328125,
-0.74365234375,
-0.492919921875,
0.28662109375,
1.130859375,
0.00972747802734375,
-0.03955078125,
0.198486328125,
0.1295166015625,
-0.5048828125,
0.2362060546875,
0.30517578125,
-0.08441162109375,
-0.399658203125,
0.7060546875,
-0.515625,
-0.1280517578125,
0.280517578125,
0.970703125,
0.93408203125,
0.1883544921875,
-0.1307373046875,
0.158935546875,
1.251953125,
1.2890625,
-0.355712890625,
0.11578369140625,
0.0980224609375,
1.0859375,
0.3828125,
0.61279296875,
0.55712890625,
0.00441741943359375,
0.6884765625,
0.623046875,
-0.2130126953125,
0.08154296875,
0.07928466796875,
0.54150390625,
0.7685546875,
0.673828125,
-0.1881103515625,
0.5419921875,
-0.1519775390625,
0.1856689453125,
-0.236328125,
0.5732421875,
0.2293701171875,
0.8544921875,
0.125,
0.2376708984375,
-0.470703125,
-0.51513671875,
-0.281494140625,
0.463134765625,
-0.9306640625,
-0.59228515625,
-0.343994140625,
-0.10369873046875,
0.1632080078125,
0.0161590576171875,
0.2357177734375,
0.279052734375,
0.427001953125,
0.270263671875,
-0.2227783203125,
-0.61669921875,
-1.064453125,
-0.85791015625,
-1.21484375,
-0.347900390625,
-0.6962890625,
0.0826416015625,
0.436279296875,
-0.487060546875,
0.44921875,
-0.218505859375,
-0.251953125,
0.411865234375,
-0.47021484375,
0.58642578125,
0.08990478515625,
0.8486328125,
-0.497314453125,
0.262451171875,
-0.366943359375,
1.2314453125,
-0.65087890625,
-0.2425537109375,
-0.50048828125,
-0.7216796875,
0.444091796875,
0.5166015625,
0.60791015625,
0.063232421875,
-0.56884765625,
-1.1923828125,
-0.60693359375,
-0.0836181640625,
-1.0029296875,
0.349853515625,
-0.7978515625,
1.046875,
0.20166015625,
-0.666015625,
0.429443359375,
0.7060546875,
-0.6767578125,
0.888671875,
0.454345703125,
0.1466064453125,
-0.92431640625,
1.423828125,
0.00554656982421875,
0.478515625,
-0.456298828125,
-0.5263671875,
-0.41796875,
0.3564453125,
0.72021484375,
-0.98681640625,
0.0186767578125,
0.80712890625,
-0.037933349609375,
-1.134765625,
0.6630859375,
-0.6513671875,
-0.67529296875,
-0.1212158203125,
-0.5517578125,
0.69091796875,
0.8154296875,
0.5244140625,
0.250732421875,
-0.307373046875,
-0.24169921875,
0.58544921875,
-0.158935546875,
-0.55322265625,
-0.224609375,
0.3896484375,
-0.2115478515625,
-0.2176513671875,
0.2427978515625,
-0.340087890625,
-0.1195068359375,
-0.01041412353515625,
-0.06103515625,
0.90966796875,
0.13916015625,
0.142578125,
-0.047882080078125,
0.8505859375,
-0.7021484375,
-0.599609375,
-0.51318359375,
0.771484375,
0.578125,
0.36572265625,
0.41357421875,
-0.1962890625,
-0.413818359375,
-0.84423828125,
0.27001953125,
0.1402587890625,
0.71875,
-0.75732421875,
0.8779296875,
0.28173828125,
-0.59228515625,
0.322509765625,
-0.8037109375,
-0.252685546875,
1.4169921875,
-0.312744140625,
0.814453125,
-0.55224609375,
0.062225341796875,
-0.276611328125,
0.470947265625,
0.50927734375,
0.28662109375,
0.64453125,
-0.34033203125,
-0.035919189453125,
-0.451416015625,
-0.57958984375,
0.1668701171875,
-0.75146484375,
0.215087890625,
-0.09765625,
-0.385009765625,
-0.84375,
0.64794921875,
0.54345703125,
0.149658203125,
0.19287109375,
0.720703125,
0.236328125,
0.36572265625,
1.0625,
-0.41650390625,
0.1900634765625,
-0.59326171875,
0.88720703125,
0.27490234375,
-0.065185546875,
0.024688720703125,
-0.044952392578125,
-0.16552734375,
0.1524658203125,
-0.1810302734375,
-0.179931640625,
-0.6044921875,
0.14306640625,
0.2998046875,
0.70947265625,
-0.474853515625,
-0.51953125,
-0.196533203125,
0.56982421875,
0.326171875,
-0.56884765625,
0.10198974609375,
-0.69189453125,
0.3818359375,
0.56005859375,
-0.027374267578125,
-0.52734375,
-0.6494140625,
-1.1162109375,
-0.404296875,
0.62939453125,
0.343994140625,
0.134033203125,
-0.12030029296875,
-0.794921875,
0.7939453125,
0.031341552734375,
-0.2220458984375,
0.1448974609375,
-0.1868896484375,
-0.01380157470703125,
-0.1309814453125,
0.54736328125,
0.09814453125,
-0.63623046875,
0.35205078125,
-1.18359375,
0.58154296875,
-0.86328125,
0.57373046875,
0.09197998046875,
0.2137451171875,
-0.208251953125,
0.331787109375,
-0.51806640625,
-0.1370849609375,
-0.3017578125,
0.51708984375,
-0.97216796875,
-0.78564453125,
0.775390625,
-0.0621337890625,
-0.02008056640625,
0.71533203125,
-0.03131103515625,
-0.49169921875,
0.14013671875,
0.380615234375,
-0.56201171875,
0.23583984375,
-0.3994140625,
0.236083984375,
-0.6875,
-0.410888671875,
-0.133544921875,
-0.436767578125,
0.68115234375,
0.287841796875,
-0.7841796875,
-0.38623046875,
-0.99072265625,
-0.03631591796875,
-0.1553955078125,
-0.58251953125,
0.26953125,
-0.2310791015625,
-0.2861328125,
-0.285888671875,
-0.33984375,
-0.6572265625,
0.036102294921875,
-0.68896484375,
-0.319091796875,
0.2222900390625,
0.38427734375,
0.60009765625,
0.07110595703125,
-0.38720703125,
0.13525390625,
-0.2392578125,
-0.043792724609375,
-0.287353515625,
-0.14013671875,
-0.203857421875,
-0.349853515625,
-0.257568359375,
-0.1185302734375,
0.458740234375,
0.244140625,
0.23193359375,
0.270751953125,
0.419189453125,
0.5107421875,
-0.42919921875,
0.66455078125,
0.0200347900390625,
-0.54833984375,
-0.50537109375,
0.5400390625,
-0.2066650390625,
0.94189453125,
0.34033203125,
-1.359375,
-0.779296875,
-1.2626953125,
-0.0192413330078125,
-0.315673828125,
-0.102294921875,
-0.76953125,
0.03851318359375,
-0.61376953125,
0.2900390625,
-0.2073974609375,
-0.458984375,
0.1669921875,
-1.3349609375,
-0.0733642578125,
-0.64453125,
-0.56982421875,
-0.28173828125,
-0.58056640625,
-0.1610107421875,
0.9658203125,
0.279541015625,
0.266357421875,
0.1497802734375,
0.070068359375,
0.023529052734375,
-0.312744140625,
-0.9482421875,
-0.37939453125,
0.049163818359375,
0.307373046875,
0.08575439453125,
-0.073974609375,
-0.4814453125,
0.84228515625,
-1.021484375,
-0.1070556640625,
-0.2105712890625,
-0.249755859375,
-0.10577392578125,
-0.1485595703125,
1.162109375,
-0.375244140625,
-0.0247344970703125,
-0.0141448974609375,
0.50390625,
0.460693359375,
-0.3916015625,
-0.42041015625,
-0.6728515625,
-0.466796875,
-0.89208984375,
0.71826171875,
-0.7138671875,
0.1417236328125,
-0.64501953125,
-0.401611328125,
1.1923828125,
-0.87158203125,
0.50732421875,
0.81884765625,
-0.03875732421875,
0.1959228515625,
-0.81396484375,
0.6005859375,
0.455322265625,
-0.5458984375,
-0.12451171875,
0.307861328125,
-0.469482421875,
0.369873046875,
0.068359375,
-1.037109375,
-0.70361328125,
0.615234375,
1.330078125,
-0.078857421875,
0.63818359375,
-0.168701171875,
-0.361083984375,
-0.49560546875,
1.046875,
-0.1063232421875,
0.037689208984375,
1.0263671875,
-0.65869140625,
-0.323974609375,
0.09930419921875,
-0.0367431640625,
-0.56787109375,
-0.4765625,
1.544921875,
-0.15478515625,
-0.2178955078125,
0.951171875,
0.8583984375,
-0.66748046875,
-0.5478515625,
-0.38037109375,
0.376708984375,
-0.042083740234375,
-0.8212890625,
0.212158203125,
0.658203125,
-0.7705078125,
-0.2025146484375,
0.537109375,
-0.18115234375,
0.336181640625,
0.1722412109375,
0.4423828125,
-0.315185546875,
0.333251953125,
0.64208984375,
-0.73876953125,
-0.059600830078125,
-1.0849609375,
0.25341796875,
-0.27880859375,
-0.51220703125,
0.7802734375,
-0.247314453125,
0.44921875,
0.88134765625,
-0.1973876953125,
0.49853515625,
-0.58740234375,
-0.58056640625,
0.2220458984375,
-1.0048828125,
-0.70751953125,
-0.391357421875,
0.467529296875,
-0.268798828125,
0.1336669921875,
-1.146484375,
0.279541015625,
0.42578125,
0.440185546875,
-0.6513671875,
-0.8525390625,
0.027252197265625,
-0.96923828125,
-0.384521484375,
-0.576171875,
-0.69091796875,
-0.2861328125,
-0.068603515625,
-0.0841064453125,
-0.5498046875,
0.368896484375,
0.40625,
-0.32763671875,
0.9091796875,
-0.470458984375,
0.5263671875,
-0.64599609375,
-0.169677734375,
-0.7255859375,
0.054412841796875,
-0.30419921875,
0.00188446044921875,
-0.5986328125,
0.264892578125,
0.50244140625,
0.2464599609375,
0.10260009765625,
-0.18505859375,
-0.583984375,
-0.6875,
-0.11517333984375,
0.1363525390625,
-0.432373046875,
0.68212890625,
0.434814453125,
0.2303466796875,
0.85498046875,
-0.1943359375,
-0.56884765625,
-0.0034770965576171875,
0.6015625,
0.6845703125,
-0.366455078125,
-0.033660888671875,
-0.33837890625,
0.058929443359375,
-0.85498046875,
0.097412109375,
-0.036865234375,
0.2205810546875,
0.033233642578125,
-0.26025390625,
0.374755859375,
1.1865234375,
0.1539306640625,
0.64990234375,
0.2421875,
0.255126953125,
0.260498046875,
-0.546875,
-0.14794921875,
0.484619140625,
0.11102294921875,
-0.3427734375,
-0.05926513671875,
0.451416015625,
-0.060760498046875,
0.35888671875,
0.159912109375,
-0.892578125,
-1.1484375,
-0.445068359375,
0.1986083984375,
0.481689453125,
0.64013671875,
-0.490234375,
-0.254638671875,
-0.47802734375,
-0.78515625,
0.65478515625,
-1.0009765625,
-0.66455078125,
0.472900390625,
-0.1937255859375,
-0.65185546875,
-0.11016845703125,
-0.52978515625,
0.035125732421875,
0.060394287109375,
0.45556640625,
-0.7080078125,
0.1859130859375,
0.2509765625,
0.46142578125,
-0.265869140625,
-0.221923828125,
0.00904083251953125,
0.322998046875,
-0.281494140625,
-0.1754150390625,
0.41064453125,
1.0595703125,
0.1998291015625,
-0.0292816162109375,
-0.7841796875,
0.0867919921875,
0.6162109375,
0.159423828125,
-0.383056640625,
-0.1495361328125,
-0.63134765625,
0.71630859375,
-0.81787109375,
-0.0201873779296875,
0.028778076171875,
0.1767578125,
0.2353515625,
-0.427490234375,
-0.58935546875,
0.9248046875,
1.2392578125,
-0.2373046875,
0.48388671875,
0.10125732421875,
0.10333251953125,
-0.25927734375,
-0.147705078125,
-0.45361328125,
0.3974609375,
0.1356201171875,
0.419677734375,
-0.062286376953125,
0.73974609375,
0.76806640625,
-0.1968994140625,
0.1383056640625,
0.356201171875,
0.02069091796875,
-0.09619140625,
0.0274200439453125,
-0.02142333984375,
0.2388916015625,
0.439453125,
-0.6884765625,
0.3818359375,
-0.87451171875,
-0.234130859375,
0.027618408203125,
-0.595703125,
0.8203125,
-0.99462890625,
-0.0799560546875,
-0.1124267578125,
-0.4833984375,
0.1649169921875,
0.7294921875,
0.389404296875,
-0.008453369140625,
0.57373046875,
0.80615234375,
0.217041015625,
1.0234375,
0.63916015625,
0.354248046875,
-0.75390625,
0.26025390625,
0.093505859375,
-0.256103515625,
-0.489501953125,
-0.19482421875,
-0.77490234375,
0.472412109375,
-0.056732177734375,
-0.51953125,
0.482421875,
-0.79443359375,
-0.330322265625,
0.1639404296875,
0.77978515625,
-0.254638671875,
0.463134765625,
0.11920166015625,
-0.37744140625,
-0.7900390625,
1.0087890625,
-0.178466796875,
0.344970703125,
0.19189453125,
0.828125,
-0.072509765625,
1.1201171875,
0.37353515625,
-0.26904296875,
-0.0062713623046875,
0.076416015625,
-0.419189453125,
-1.01953125,
-0.2646484375,
-0.63818359375,
0.229248046875,
-0.310546875,
0.0288238525390625,
-0.0230865478515625,
0.6923828125,
-0.08575439453125,
-0.9072265625,
-0.387939453125,
0.056671142578125,
-0.6943359375,
0.5400390625,
0.40380859375,
0.156005859375,
0.322021484375,
-0.019744873046875,
-0.30712890625,
-0.6318359375,
-0.034423828125,
-0.81298828125,
0.28271484375,
-0.349365234375,
-0.2381591796875,
-0.76806640625,
-0.8671875,
-0.361572265625,
0.10186767578125,
-0.15673828125,
-0.89794921875,
0.306396484375,
0.01318359375,
0.54541015625,
0.0888671875,
-0.318115234375,
0.6513671875,
0.83056640625,
0.9716796875,
0.029754638671875,
0.80078125,
0.3388671875,
-0.3134765625,
0.2276611328125,
-0.277587890625,
0.336669921875,
-0.5986328125,
0.2257080078125,
-0.27294921875,
0.38232421875,
-0.5625,
-1.34375,
-0.2138671875,
0.57666015625,
0.305419921875,
-0.7373046875,
-1.0751953125,
-0.56005859375,
-0.65771484375,
0.314208984375,
-0.78125,
0.3857421875,
-0.0428466796875,
0.361083984375,
-0.1588134765625,
-0.95166015625,
4.37890625,
1.1064453125,
1.2724609375,
0.4619140625,
0.0538330078125,
0.9296875,
0.3818359375,
-0.1962890625,
-0.13427734375,
-0.6533203125,
0.373779296875,
-0.244140625,
-0.1439208984375,
1.04296875,
0.391357421875,
0.7744140625,
-0.8798828125,
-0.2152099609375,
0.007049560546875,
-0.5546875,
-0.72314453125,
0.041412353515625,
-0.552734375,
0.2177734375,
-0.198974609375,
0.386474609375,
0.69091796875,
-0.943359375,
-0.394775390625,
-0.3046875,
0.1309814453125,
-0.78466796875,
1.1328125,
-0.455810546875,
-0.2393798828125,
0.37060546875,
-0.2022705078125,
-0.5654296875,
-0.018341064453125,
0.420654296875,
0.1971435546875,
0.400634765625,
1.013671875,
-0.263671875,
0.48583984375,
0.465576171875,
-0.50830078125,
-0.003570556640625,
-0.320068359375,
-0.86083984375,
1.056640625,
-0.4853515625,
0.268310546875,
-0.46826171875,
-0.939453125,
0.253662109375,
-0.126220703125,
-0.365234375,
-0.228759765625,
0.188720703125,
0.2388916015625,
-0.0133514404296875,
-0.080810546875,
0.310791015625,
-1.00390625,
0.64111328125,
-0.039215087890625,
0.1954345703125,
-0.61328125,
-0.378662109375,
-0.1844482421875,
-0.25927734375,
-0.33251953125,
-0.408935546875,
0.53955078125,
0.1756591796875,
0.118896484375,
0.3916015625,
0.63720703125,
-0.80029296875,
-0.03790283203125,
-0.156982421875,
-0.59326171875,
-0.53955078125,
0.77099609375,
0.9716796875,
-0.7041015625,
-0.5146484375,
-0.1650390625,
0.383056640625,
0.58544921875,
0.38623046875,
0.454345703125,
-0.062347412109375,
-0.1766357421875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Tags: dfs and similar, graphs, sortings
Correct Solution:
```
s, n = 1, int(input())
a, b = [], []
t = ''
d = [0] * 26
u = input()
exit = False
for i in range(n - 1):
v = input()
j = 0
while j < min(len(u), len(v)) and u[j] == v[j]:
j += 1
if j == min(len(u), len(v)):
if len(u) >= len(v):
exit = True
break
else:
q = (ord(u[j]) - 97, ord(v[j]) - 97)
a.append(q)
u = v
d[q[1]] = s
if (not exit):
while a:
b = [q for q in a if d[q[0]] == s]
s += 1
for q in b: d[q[1]] = s
if len(a) == len(b):
exit = True
break
else:
a, b = b, []
if (exit):
print('Impossible')
else:
for x in sorted(enumerate(d), key=lambda x: x[1]):
t += chr(x[0] + 97)
print(t)
```
| 72,045 | [
-0.180419921875,
-0.34375,
0.476318359375,
-0.2020263671875,
-0.327392578125,
-0.34375,
-0.08489990234375,
0.228271484375,
0.1395263671875,
0.65087890625,
0.74072265625,
-0.05401611328125,
0.298095703125,
-0.9091796875,
-0.88818359375,
0.163818359375,
-0.200439453125,
-0.394775390625,
-0.01727294921875,
-0.08355712890625,
0.49755859375,
0.21875,
-1.806640625,
0.09527587890625,
-0.55859375,
1.0693359375,
0.60888671875,
0.1409912109375,
1.2353515625,
0.9892578125,
-0.039581298828125,
-0.344970703125,
0.51025390625,
-0.94775390625,
-0.236083984375,
-0.17431640625,
0.650390625,
-0.496826171875,
-0.08154296875,
-0.65478515625,
0.5673828125,
-0.7802734375,
0.45458984375,
-0.83984375,
-0.84765625,
-0.302001953125,
-0.1900634765625,
-0.19189453125,
-0.5048828125,
-1.283203125,
0.1494140625,
-0.28173828125,
0.6982421875,
-0.425537109375,
-0.1627197265625,
-0.040618896484375,
0.336669921875,
-0.06414794921875,
-0.471435546875,
0.53369140625,
-0.007320404052734375,
0.399169921875,
-0.320068359375,
-0.481201171875,
-0.328369140625,
0.223388671875,
0.14111328125,
-0.1376953125,
0.08001708984375,
-0.61328125,
-0.2451171875,
0.414306640625,
-0.29736328125,
-0.0411376953125,
-0.50830078125,
0.049407958984375,
-0.1990966796875,
-0.180419921875,
-0.3681640625,
0.58154296875,
0.279296875,
0.56787109375,
0.06695556640625,
0.314208984375,
-0.2646484375,
-0.34228515625,
-0.1282958984375,
0.17919921875,
0.2734375,
0.163818359375,
0.2088623046875,
0.441650390625,
-0.83642578125,
-0.29931640625,
0.39501953125,
0.60791015625,
-0.03558349609375,
0.2259521484375,
0.12188720703125,
0.140625,
0.939453125,
1.271484375,
-0.150390625,
0.9345703125,
-0.77490234375,
0.1658935546875,
-0.08001708984375,
-0.15478515625,
0.036529541015625,
-0.298583984375,
-0.205810546875,
-0.2303466796875,
0.2130126953125,
0.26953125,
0.11968994140625,
0.68310546875,
-0.446533203125,
0.385986328125,
-0.9931640625,
0.00644683837890625,
0.49169921875,
0.10150146484375,
0.053436279296875,
0.0784912109375,
0.2705078125,
-0.203369140625,
-0.1695556640625,
0.8974609375,
-0.452880859375,
-0.0908203125,
0.48388671875,
-0.055450439453125,
-0.548828125,
0.258056640625,
-0.106689453125,
0.8095703125,
-0.06402587890625,
0.52685546875,
0.55029296875,
-0.45654296875,
0.630859375,
-0.16943359375,
-0.035888671875,
1.53515625,
-0.007335662841796875,
-0.2384033203125,
0.41064453125,
0.2081298828125,
-0.76611328125,
0.5595703125,
-1.0556640625,
0.76513671875,
0.3828125,
0.33154296875,
-0.452880859375,
0.47216796875,
-0.186767578125,
0.42236328125,
0.65673828125,
0.64111328125,
-0.349609375,
-0.2298583984375,
-0.1202392578125,
1.0712890625,
-0.27197265625,
1.1962890625,
-0.61767578125,
-0.10089111328125,
0.07366943359375,
-0.2110595703125,
0.07696533203125,
0.043701171875,
-0.619140625,
1.0029296875,
0.289794921875,
0.81591796875,
0.437255859375,
-0.4677734375,
0.1600341796875,
0.08984375,
-0.33349609375,
0.473388671875,
-0.0029888153076171875,
0.76513671875,
0.176513671875,
0.1239013671875,
0.259765625,
-0.79052734375,
-0.35400390625,
-0.681640625,
-0.25390625,
0.7685546875,
-0.460205078125,
0.27734375,
-0.037139892578125,
-0.1365966796875,
-0.71142578125,
0.194580078125,
0.810546875,
-0.95166015625,
-0.200439453125,
0.52099609375,
-0.2176513671875,
0.6328125,
-0.74365234375,
-0.492919921875,
0.28662109375,
1.130859375,
0.00972747802734375,
-0.03955078125,
0.198486328125,
0.1295166015625,
-0.5048828125,
0.2362060546875,
0.30517578125,
-0.08441162109375,
-0.399658203125,
0.7060546875,
-0.515625,
-0.1280517578125,
0.280517578125,
0.970703125,
0.93408203125,
0.1883544921875,
-0.1307373046875,
0.158935546875,
1.251953125,
1.2890625,
-0.355712890625,
0.11578369140625,
0.0980224609375,
1.0859375,
0.3828125,
0.61279296875,
0.55712890625,
0.00441741943359375,
0.6884765625,
0.623046875,
-0.2130126953125,
0.08154296875,
0.07928466796875,
0.54150390625,
0.7685546875,
0.673828125,
-0.1881103515625,
0.5419921875,
-0.1519775390625,
0.1856689453125,
-0.236328125,
0.5732421875,
0.2293701171875,
0.8544921875,
0.125,
0.2376708984375,
-0.470703125,
-0.51513671875,
-0.281494140625,
0.463134765625,
-0.9306640625,
-0.59228515625,
-0.343994140625,
-0.10369873046875,
0.1632080078125,
0.0161590576171875,
0.2357177734375,
0.279052734375,
0.427001953125,
0.270263671875,
-0.2227783203125,
-0.61669921875,
-1.064453125,
-0.85791015625,
-1.21484375,
-0.347900390625,
-0.6962890625,
0.0826416015625,
0.436279296875,
-0.487060546875,
0.44921875,
-0.218505859375,
-0.251953125,
0.411865234375,
-0.47021484375,
0.58642578125,
0.08990478515625,
0.8486328125,
-0.497314453125,
0.262451171875,
-0.366943359375,
1.2314453125,
-0.65087890625,
-0.2425537109375,
-0.50048828125,
-0.7216796875,
0.444091796875,
0.5166015625,
0.60791015625,
0.063232421875,
-0.56884765625,
-1.1923828125,
-0.60693359375,
-0.0836181640625,
-1.0029296875,
0.349853515625,
-0.7978515625,
1.046875,
0.20166015625,
-0.666015625,
0.429443359375,
0.7060546875,
-0.6767578125,
0.888671875,
0.454345703125,
0.1466064453125,
-0.92431640625,
1.423828125,
0.00554656982421875,
0.478515625,
-0.456298828125,
-0.5263671875,
-0.41796875,
0.3564453125,
0.72021484375,
-0.98681640625,
0.0186767578125,
0.80712890625,
-0.037933349609375,
-1.134765625,
0.6630859375,
-0.6513671875,
-0.67529296875,
-0.1212158203125,
-0.5517578125,
0.69091796875,
0.8154296875,
0.5244140625,
0.250732421875,
-0.307373046875,
-0.24169921875,
0.58544921875,
-0.158935546875,
-0.55322265625,
-0.224609375,
0.3896484375,
-0.2115478515625,
-0.2176513671875,
0.2427978515625,
-0.340087890625,
-0.1195068359375,
-0.01041412353515625,
-0.06103515625,
0.90966796875,
0.13916015625,
0.142578125,
-0.047882080078125,
0.8505859375,
-0.7021484375,
-0.599609375,
-0.51318359375,
0.771484375,
0.578125,
0.36572265625,
0.41357421875,
-0.1962890625,
-0.413818359375,
-0.84423828125,
0.27001953125,
0.1402587890625,
0.71875,
-0.75732421875,
0.8779296875,
0.28173828125,
-0.59228515625,
0.322509765625,
-0.8037109375,
-0.252685546875,
1.4169921875,
-0.312744140625,
0.814453125,
-0.55224609375,
0.062225341796875,
-0.276611328125,
0.470947265625,
0.50927734375,
0.28662109375,
0.64453125,
-0.34033203125,
-0.035919189453125,
-0.451416015625,
-0.57958984375,
0.1668701171875,
-0.75146484375,
0.215087890625,
-0.09765625,
-0.385009765625,
-0.84375,
0.64794921875,
0.54345703125,
0.149658203125,
0.19287109375,
0.720703125,
0.236328125,
0.36572265625,
1.0625,
-0.41650390625,
0.1900634765625,
-0.59326171875,
0.88720703125,
0.27490234375,
-0.065185546875,
0.024688720703125,
-0.044952392578125,
-0.16552734375,
0.1524658203125,
-0.1810302734375,
-0.179931640625,
-0.6044921875,
0.14306640625,
0.2998046875,
0.70947265625,
-0.474853515625,
-0.51953125,
-0.196533203125,
0.56982421875,
0.326171875,
-0.56884765625,
0.10198974609375,
-0.69189453125,
0.3818359375,
0.56005859375,
-0.027374267578125,
-0.52734375,
-0.6494140625,
-1.1162109375,
-0.404296875,
0.62939453125,
0.343994140625,
0.134033203125,
-0.12030029296875,
-0.794921875,
0.7939453125,
0.031341552734375,
-0.2220458984375,
0.1448974609375,
-0.1868896484375,
-0.01380157470703125,
-0.1309814453125,
0.54736328125,
0.09814453125,
-0.63623046875,
0.35205078125,
-1.18359375,
0.58154296875,
-0.86328125,
0.57373046875,
0.09197998046875,
0.2137451171875,
-0.208251953125,
0.331787109375,
-0.51806640625,
-0.1370849609375,
-0.3017578125,
0.51708984375,
-0.97216796875,
-0.78564453125,
0.775390625,
-0.0621337890625,
-0.02008056640625,
0.71533203125,
-0.03131103515625,
-0.49169921875,
0.14013671875,
0.380615234375,
-0.56201171875,
0.23583984375,
-0.3994140625,
0.236083984375,
-0.6875,
-0.410888671875,
-0.133544921875,
-0.436767578125,
0.68115234375,
0.287841796875,
-0.7841796875,
-0.38623046875,
-0.99072265625,
-0.03631591796875,
-0.1553955078125,
-0.58251953125,
0.26953125,
-0.2310791015625,
-0.2861328125,
-0.285888671875,
-0.33984375,
-0.6572265625,
0.036102294921875,
-0.68896484375,
-0.319091796875,
0.2222900390625,
0.38427734375,
0.60009765625,
0.07110595703125,
-0.38720703125,
0.13525390625,
-0.2392578125,
-0.043792724609375,
-0.287353515625,
-0.14013671875,
-0.203857421875,
-0.349853515625,
-0.257568359375,
-0.1185302734375,
0.458740234375,
0.244140625,
0.23193359375,
0.270751953125,
0.419189453125,
0.5107421875,
-0.42919921875,
0.66455078125,
0.0200347900390625,
-0.54833984375,
-0.50537109375,
0.5400390625,
-0.2066650390625,
0.94189453125,
0.34033203125,
-1.359375,
-0.779296875,
-1.2626953125,
-0.0192413330078125,
-0.315673828125,
-0.102294921875,
-0.76953125,
0.03851318359375,
-0.61376953125,
0.2900390625,
-0.2073974609375,
-0.458984375,
0.1669921875,
-1.3349609375,
-0.0733642578125,
-0.64453125,
-0.56982421875,
-0.28173828125,
-0.58056640625,
-0.1610107421875,
0.9658203125,
0.279541015625,
0.266357421875,
0.1497802734375,
0.070068359375,
0.023529052734375,
-0.312744140625,
-0.9482421875,
-0.37939453125,
0.049163818359375,
0.307373046875,
0.08575439453125,
-0.073974609375,
-0.4814453125,
0.84228515625,
-1.021484375,
-0.1070556640625,
-0.2105712890625,
-0.249755859375,
-0.10577392578125,
-0.1485595703125,
1.162109375,
-0.375244140625,
-0.0247344970703125,
-0.0141448974609375,
0.50390625,
0.460693359375,
-0.3916015625,
-0.42041015625,
-0.6728515625,
-0.466796875,
-0.89208984375,
0.71826171875,
-0.7138671875,
0.1417236328125,
-0.64501953125,
-0.401611328125,
1.1923828125,
-0.87158203125,
0.50732421875,
0.81884765625,
-0.03875732421875,
0.1959228515625,
-0.81396484375,
0.6005859375,
0.455322265625,
-0.5458984375,
-0.12451171875,
0.307861328125,
-0.469482421875,
0.369873046875,
0.068359375,
-1.037109375,
-0.70361328125,
0.615234375,
1.330078125,
-0.078857421875,
0.63818359375,
-0.168701171875,
-0.361083984375,
-0.49560546875,
1.046875,
-0.1063232421875,
0.037689208984375,
1.0263671875,
-0.65869140625,
-0.323974609375,
0.09930419921875,
-0.0367431640625,
-0.56787109375,
-0.4765625,
1.544921875,
-0.15478515625,
-0.2178955078125,
0.951171875,
0.8583984375,
-0.66748046875,
-0.5478515625,
-0.38037109375,
0.376708984375,
-0.042083740234375,
-0.8212890625,
0.212158203125,
0.658203125,
-0.7705078125,
-0.2025146484375,
0.537109375,
-0.18115234375,
0.336181640625,
0.1722412109375,
0.4423828125,
-0.315185546875,
0.333251953125,
0.64208984375,
-0.73876953125,
-0.059600830078125,
-1.0849609375,
0.25341796875,
-0.27880859375,
-0.51220703125,
0.7802734375,
-0.247314453125,
0.44921875,
0.88134765625,
-0.1973876953125,
0.49853515625,
-0.58740234375,
-0.58056640625,
0.2220458984375,
-1.0048828125,
-0.70751953125,
-0.391357421875,
0.467529296875,
-0.268798828125,
0.1336669921875,
-1.146484375,
0.279541015625,
0.42578125,
0.440185546875,
-0.6513671875,
-0.8525390625,
0.027252197265625,
-0.96923828125,
-0.384521484375,
-0.576171875,
-0.69091796875,
-0.2861328125,
-0.068603515625,
-0.0841064453125,
-0.5498046875,
0.368896484375,
0.40625,
-0.32763671875,
0.9091796875,
-0.470458984375,
0.5263671875,
-0.64599609375,
-0.169677734375,
-0.7255859375,
0.054412841796875,
-0.30419921875,
0.00188446044921875,
-0.5986328125,
0.264892578125,
0.50244140625,
0.2464599609375,
0.10260009765625,
-0.18505859375,
-0.583984375,
-0.6875,
-0.11517333984375,
0.1363525390625,
-0.432373046875,
0.68212890625,
0.434814453125,
0.2303466796875,
0.85498046875,
-0.1943359375,
-0.56884765625,
-0.0034770965576171875,
0.6015625,
0.6845703125,
-0.366455078125,
-0.033660888671875,
-0.33837890625,
0.058929443359375,
-0.85498046875,
0.097412109375,
-0.036865234375,
0.2205810546875,
0.033233642578125,
-0.26025390625,
0.374755859375,
1.1865234375,
0.1539306640625,
0.64990234375,
0.2421875,
0.255126953125,
0.260498046875,
-0.546875,
-0.14794921875,
0.484619140625,
0.11102294921875,
-0.3427734375,
-0.05926513671875,
0.451416015625,
-0.060760498046875,
0.35888671875,
0.159912109375,
-0.892578125,
-1.1484375,
-0.445068359375,
0.1986083984375,
0.481689453125,
0.64013671875,
-0.490234375,
-0.254638671875,
-0.47802734375,
-0.78515625,
0.65478515625,
-1.0009765625,
-0.66455078125,
0.472900390625,
-0.1937255859375,
-0.65185546875,
-0.11016845703125,
-0.52978515625,
0.035125732421875,
0.060394287109375,
0.45556640625,
-0.7080078125,
0.1859130859375,
0.2509765625,
0.46142578125,
-0.265869140625,
-0.221923828125,
0.00904083251953125,
0.322998046875,
-0.281494140625,
-0.1754150390625,
0.41064453125,
1.0595703125,
0.1998291015625,
-0.0292816162109375,
-0.7841796875,
0.0867919921875,
0.6162109375,
0.159423828125,
-0.383056640625,
-0.1495361328125,
-0.63134765625,
0.71630859375,
-0.81787109375,
-0.0201873779296875,
0.028778076171875,
0.1767578125,
0.2353515625,
-0.427490234375,
-0.58935546875,
0.9248046875,
1.2392578125,
-0.2373046875,
0.48388671875,
0.10125732421875,
0.10333251953125,
-0.25927734375,
-0.147705078125,
-0.45361328125,
0.3974609375,
0.1356201171875,
0.419677734375,
-0.062286376953125,
0.73974609375,
0.76806640625,
-0.1968994140625,
0.1383056640625,
0.356201171875,
0.02069091796875,
-0.09619140625,
0.0274200439453125,
-0.02142333984375,
0.2388916015625,
0.439453125,
-0.6884765625,
0.3818359375,
-0.87451171875,
-0.234130859375,
0.027618408203125,
-0.595703125,
0.8203125,
-0.99462890625,
-0.0799560546875,
-0.1124267578125,
-0.4833984375,
0.1649169921875,
0.7294921875,
0.389404296875,
-0.008453369140625,
0.57373046875,
0.80615234375,
0.217041015625,
1.0234375,
0.63916015625,
0.354248046875,
-0.75390625,
0.26025390625,
0.093505859375,
-0.256103515625,
-0.489501953125,
-0.19482421875,
-0.77490234375,
0.472412109375,
-0.056732177734375,
-0.51953125,
0.482421875,
-0.79443359375,
-0.330322265625,
0.1639404296875,
0.77978515625,
-0.254638671875,
0.463134765625,
0.11920166015625,
-0.37744140625,
-0.7900390625,
1.0087890625,
-0.178466796875,
0.344970703125,
0.19189453125,
0.828125,
-0.072509765625,
1.1201171875,
0.37353515625,
-0.26904296875,
-0.0062713623046875,
0.076416015625,
-0.419189453125,
-1.01953125,
-0.2646484375,
-0.63818359375,
0.229248046875,
-0.310546875,
0.0288238525390625,
-0.0230865478515625,
0.6923828125,
-0.08575439453125,
-0.9072265625,
-0.387939453125,
0.056671142578125,
-0.6943359375,
0.5400390625,
0.40380859375,
0.156005859375,
0.322021484375,
-0.019744873046875,
-0.30712890625,
-0.6318359375,
-0.034423828125,
-0.81298828125,
0.28271484375,
-0.349365234375,
-0.2381591796875,
-0.76806640625,
-0.8671875,
-0.361572265625,
0.10186767578125,
-0.15673828125,
-0.89794921875,
0.306396484375,
0.01318359375,
0.54541015625,
0.0888671875,
-0.318115234375,
0.6513671875,
0.83056640625,
0.9716796875,
0.029754638671875,
0.80078125,
0.3388671875,
-0.3134765625,
0.2276611328125,
-0.277587890625,
0.336669921875,
-0.5986328125,
0.2257080078125,
-0.27294921875,
0.38232421875,
-0.5625,
-1.34375,
-0.2138671875,
0.57666015625,
0.305419921875,
-0.7373046875,
-1.0751953125,
-0.56005859375,
-0.65771484375,
0.314208984375,
-0.78125,
0.3857421875,
-0.0428466796875,
0.361083984375,
-0.1588134765625,
-0.95166015625,
4.37890625,
1.1064453125,
1.2724609375,
0.4619140625,
0.0538330078125,
0.9296875,
0.3818359375,
-0.1962890625,
-0.13427734375,
-0.6533203125,
0.373779296875,
-0.244140625,
-0.1439208984375,
1.04296875,
0.391357421875,
0.7744140625,
-0.8798828125,
-0.2152099609375,
0.007049560546875,
-0.5546875,
-0.72314453125,
0.041412353515625,
-0.552734375,
0.2177734375,
-0.198974609375,
0.386474609375,
0.69091796875,
-0.943359375,
-0.394775390625,
-0.3046875,
0.1309814453125,
-0.78466796875,
1.1328125,
-0.455810546875,
-0.2393798828125,
0.37060546875,
-0.2022705078125,
-0.5654296875,
-0.018341064453125,
0.420654296875,
0.1971435546875,
0.400634765625,
1.013671875,
-0.263671875,
0.48583984375,
0.465576171875,
-0.50830078125,
-0.003570556640625,
-0.320068359375,
-0.86083984375,
1.056640625,
-0.4853515625,
0.268310546875,
-0.46826171875,
-0.939453125,
0.253662109375,
-0.126220703125,
-0.365234375,
-0.228759765625,
0.188720703125,
0.2388916015625,
-0.0133514404296875,
-0.080810546875,
0.310791015625,
-1.00390625,
0.64111328125,
-0.039215087890625,
0.1954345703125,
-0.61328125,
-0.378662109375,
-0.1844482421875,
-0.25927734375,
-0.33251953125,
-0.408935546875,
0.53955078125,
0.1756591796875,
0.118896484375,
0.3916015625,
0.63720703125,
-0.80029296875,
-0.03790283203125,
-0.156982421875,
-0.59326171875,
-0.53955078125,
0.77099609375,
0.9716796875,
-0.7041015625,
-0.5146484375,
-0.1650390625,
0.383056640625,
0.58544921875,
0.38623046875,
0.454345703125,
-0.062347412109375,
-0.1766357421875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Tags: dfs and similar, graphs, sortings
Correct Solution:
```
from heapq import heappush, heappop
def ts_kahn(graph, result):
indegree = [0] * (V+1)
zero_indegree = []
for u in range(1,V+1):
for v in graph[u]:
indegree[v] += 1
for i in range(1,V+1):
if (indegree[i] == 0):
heappush(zero_indegree, i)
while (len(zero_indegree) != 0):
u = heappop(zero_indegree)
result.append(u)
for v in graph[u]:
indegree[v] -= 1
if (indegree[v] == 0):
heappush(zero_indegree, v)
for i in range(1,V+1):
if (indegree[i] != 0):
return False
return True
if __name__ == "__main__":
n = int(input())
V = 26
imp = False
graph = [[] for i in range(V + 1)]
result = []
names = []
for i in range(n):
names.append(list(input()))
exist = set()
exist.add(names[0][0])
for i in range(n - 1):
na = names[i]
nb = names[i + 1]
size = min(len(na), len(nb))
for j in range(size):
if (na[j] != nb[j]):
graph[ord(na[j]) - 96].append(ord(nb[j]) - 96)
break
elif (j == size - 1) and (len(nb) < len(na)):
imp = True
break
if imp:
print('Impossible')
else:
if (ts_kahn(graph, result)):
for i in range(V): print(chr(result[i] + 96), end='')
else:
print('Impossible')
```
| 72,046 | [
-0.180419921875,
-0.34375,
0.476318359375,
-0.2020263671875,
-0.327392578125,
-0.34375,
-0.08489990234375,
0.228271484375,
0.1395263671875,
0.65087890625,
0.74072265625,
-0.05401611328125,
0.298095703125,
-0.9091796875,
-0.88818359375,
0.163818359375,
-0.200439453125,
-0.394775390625,
-0.01727294921875,
-0.08355712890625,
0.49755859375,
0.21875,
-1.806640625,
0.09527587890625,
-0.55859375,
1.0693359375,
0.60888671875,
0.1409912109375,
1.2353515625,
0.9892578125,
-0.039581298828125,
-0.344970703125,
0.51025390625,
-0.94775390625,
-0.236083984375,
-0.17431640625,
0.650390625,
-0.496826171875,
-0.08154296875,
-0.65478515625,
0.5673828125,
-0.7802734375,
0.45458984375,
-0.83984375,
-0.84765625,
-0.302001953125,
-0.1900634765625,
-0.19189453125,
-0.5048828125,
-1.283203125,
0.1494140625,
-0.28173828125,
0.6982421875,
-0.425537109375,
-0.1627197265625,
-0.040618896484375,
0.336669921875,
-0.06414794921875,
-0.471435546875,
0.53369140625,
-0.007320404052734375,
0.399169921875,
-0.320068359375,
-0.481201171875,
-0.328369140625,
0.223388671875,
0.14111328125,
-0.1376953125,
0.08001708984375,
-0.61328125,
-0.2451171875,
0.414306640625,
-0.29736328125,
-0.0411376953125,
-0.50830078125,
0.049407958984375,
-0.1990966796875,
-0.180419921875,
-0.3681640625,
0.58154296875,
0.279296875,
0.56787109375,
0.06695556640625,
0.314208984375,
-0.2646484375,
-0.34228515625,
-0.1282958984375,
0.17919921875,
0.2734375,
0.163818359375,
0.2088623046875,
0.441650390625,
-0.83642578125,
-0.29931640625,
0.39501953125,
0.60791015625,
-0.03558349609375,
0.2259521484375,
0.12188720703125,
0.140625,
0.939453125,
1.271484375,
-0.150390625,
0.9345703125,
-0.77490234375,
0.1658935546875,
-0.08001708984375,
-0.15478515625,
0.036529541015625,
-0.298583984375,
-0.205810546875,
-0.2303466796875,
0.2130126953125,
0.26953125,
0.11968994140625,
0.68310546875,
-0.446533203125,
0.385986328125,
-0.9931640625,
0.00644683837890625,
0.49169921875,
0.10150146484375,
0.053436279296875,
0.0784912109375,
0.2705078125,
-0.203369140625,
-0.1695556640625,
0.8974609375,
-0.452880859375,
-0.0908203125,
0.48388671875,
-0.055450439453125,
-0.548828125,
0.258056640625,
-0.106689453125,
0.8095703125,
-0.06402587890625,
0.52685546875,
0.55029296875,
-0.45654296875,
0.630859375,
-0.16943359375,
-0.035888671875,
1.53515625,
-0.007335662841796875,
-0.2384033203125,
0.41064453125,
0.2081298828125,
-0.76611328125,
0.5595703125,
-1.0556640625,
0.76513671875,
0.3828125,
0.33154296875,
-0.452880859375,
0.47216796875,
-0.186767578125,
0.42236328125,
0.65673828125,
0.64111328125,
-0.349609375,
-0.2298583984375,
-0.1202392578125,
1.0712890625,
-0.27197265625,
1.1962890625,
-0.61767578125,
-0.10089111328125,
0.07366943359375,
-0.2110595703125,
0.07696533203125,
0.043701171875,
-0.619140625,
1.0029296875,
0.289794921875,
0.81591796875,
0.437255859375,
-0.4677734375,
0.1600341796875,
0.08984375,
-0.33349609375,
0.473388671875,
-0.0029888153076171875,
0.76513671875,
0.176513671875,
0.1239013671875,
0.259765625,
-0.79052734375,
-0.35400390625,
-0.681640625,
-0.25390625,
0.7685546875,
-0.460205078125,
0.27734375,
-0.037139892578125,
-0.1365966796875,
-0.71142578125,
0.194580078125,
0.810546875,
-0.95166015625,
-0.200439453125,
0.52099609375,
-0.2176513671875,
0.6328125,
-0.74365234375,
-0.492919921875,
0.28662109375,
1.130859375,
0.00972747802734375,
-0.03955078125,
0.198486328125,
0.1295166015625,
-0.5048828125,
0.2362060546875,
0.30517578125,
-0.08441162109375,
-0.399658203125,
0.7060546875,
-0.515625,
-0.1280517578125,
0.280517578125,
0.970703125,
0.93408203125,
0.1883544921875,
-0.1307373046875,
0.158935546875,
1.251953125,
1.2890625,
-0.355712890625,
0.11578369140625,
0.0980224609375,
1.0859375,
0.3828125,
0.61279296875,
0.55712890625,
0.00441741943359375,
0.6884765625,
0.623046875,
-0.2130126953125,
0.08154296875,
0.07928466796875,
0.54150390625,
0.7685546875,
0.673828125,
-0.1881103515625,
0.5419921875,
-0.1519775390625,
0.1856689453125,
-0.236328125,
0.5732421875,
0.2293701171875,
0.8544921875,
0.125,
0.2376708984375,
-0.470703125,
-0.51513671875,
-0.281494140625,
0.463134765625,
-0.9306640625,
-0.59228515625,
-0.343994140625,
-0.10369873046875,
0.1632080078125,
0.0161590576171875,
0.2357177734375,
0.279052734375,
0.427001953125,
0.270263671875,
-0.2227783203125,
-0.61669921875,
-1.064453125,
-0.85791015625,
-1.21484375,
-0.347900390625,
-0.6962890625,
0.0826416015625,
0.436279296875,
-0.487060546875,
0.44921875,
-0.218505859375,
-0.251953125,
0.411865234375,
-0.47021484375,
0.58642578125,
0.08990478515625,
0.8486328125,
-0.497314453125,
0.262451171875,
-0.366943359375,
1.2314453125,
-0.65087890625,
-0.2425537109375,
-0.50048828125,
-0.7216796875,
0.444091796875,
0.5166015625,
0.60791015625,
0.063232421875,
-0.56884765625,
-1.1923828125,
-0.60693359375,
-0.0836181640625,
-1.0029296875,
0.349853515625,
-0.7978515625,
1.046875,
0.20166015625,
-0.666015625,
0.429443359375,
0.7060546875,
-0.6767578125,
0.888671875,
0.454345703125,
0.1466064453125,
-0.92431640625,
1.423828125,
0.00554656982421875,
0.478515625,
-0.456298828125,
-0.5263671875,
-0.41796875,
0.3564453125,
0.72021484375,
-0.98681640625,
0.0186767578125,
0.80712890625,
-0.037933349609375,
-1.134765625,
0.6630859375,
-0.6513671875,
-0.67529296875,
-0.1212158203125,
-0.5517578125,
0.69091796875,
0.8154296875,
0.5244140625,
0.250732421875,
-0.307373046875,
-0.24169921875,
0.58544921875,
-0.158935546875,
-0.55322265625,
-0.224609375,
0.3896484375,
-0.2115478515625,
-0.2176513671875,
0.2427978515625,
-0.340087890625,
-0.1195068359375,
-0.01041412353515625,
-0.06103515625,
0.90966796875,
0.13916015625,
0.142578125,
-0.047882080078125,
0.8505859375,
-0.7021484375,
-0.599609375,
-0.51318359375,
0.771484375,
0.578125,
0.36572265625,
0.41357421875,
-0.1962890625,
-0.413818359375,
-0.84423828125,
0.27001953125,
0.1402587890625,
0.71875,
-0.75732421875,
0.8779296875,
0.28173828125,
-0.59228515625,
0.322509765625,
-0.8037109375,
-0.252685546875,
1.4169921875,
-0.312744140625,
0.814453125,
-0.55224609375,
0.062225341796875,
-0.276611328125,
0.470947265625,
0.50927734375,
0.28662109375,
0.64453125,
-0.34033203125,
-0.035919189453125,
-0.451416015625,
-0.57958984375,
0.1668701171875,
-0.75146484375,
0.215087890625,
-0.09765625,
-0.385009765625,
-0.84375,
0.64794921875,
0.54345703125,
0.149658203125,
0.19287109375,
0.720703125,
0.236328125,
0.36572265625,
1.0625,
-0.41650390625,
0.1900634765625,
-0.59326171875,
0.88720703125,
0.27490234375,
-0.065185546875,
0.024688720703125,
-0.044952392578125,
-0.16552734375,
0.1524658203125,
-0.1810302734375,
-0.179931640625,
-0.6044921875,
0.14306640625,
0.2998046875,
0.70947265625,
-0.474853515625,
-0.51953125,
-0.196533203125,
0.56982421875,
0.326171875,
-0.56884765625,
0.10198974609375,
-0.69189453125,
0.3818359375,
0.56005859375,
-0.027374267578125,
-0.52734375,
-0.6494140625,
-1.1162109375,
-0.404296875,
0.62939453125,
0.343994140625,
0.134033203125,
-0.12030029296875,
-0.794921875,
0.7939453125,
0.031341552734375,
-0.2220458984375,
0.1448974609375,
-0.1868896484375,
-0.01380157470703125,
-0.1309814453125,
0.54736328125,
0.09814453125,
-0.63623046875,
0.35205078125,
-1.18359375,
0.58154296875,
-0.86328125,
0.57373046875,
0.09197998046875,
0.2137451171875,
-0.208251953125,
0.331787109375,
-0.51806640625,
-0.1370849609375,
-0.3017578125,
0.51708984375,
-0.97216796875,
-0.78564453125,
0.775390625,
-0.0621337890625,
-0.02008056640625,
0.71533203125,
-0.03131103515625,
-0.49169921875,
0.14013671875,
0.380615234375,
-0.56201171875,
0.23583984375,
-0.3994140625,
0.236083984375,
-0.6875,
-0.410888671875,
-0.133544921875,
-0.436767578125,
0.68115234375,
0.287841796875,
-0.7841796875,
-0.38623046875,
-0.99072265625,
-0.03631591796875,
-0.1553955078125,
-0.58251953125,
0.26953125,
-0.2310791015625,
-0.2861328125,
-0.285888671875,
-0.33984375,
-0.6572265625,
0.036102294921875,
-0.68896484375,
-0.319091796875,
0.2222900390625,
0.38427734375,
0.60009765625,
0.07110595703125,
-0.38720703125,
0.13525390625,
-0.2392578125,
-0.043792724609375,
-0.287353515625,
-0.14013671875,
-0.203857421875,
-0.349853515625,
-0.257568359375,
-0.1185302734375,
0.458740234375,
0.244140625,
0.23193359375,
0.270751953125,
0.419189453125,
0.5107421875,
-0.42919921875,
0.66455078125,
0.0200347900390625,
-0.54833984375,
-0.50537109375,
0.5400390625,
-0.2066650390625,
0.94189453125,
0.34033203125,
-1.359375,
-0.779296875,
-1.2626953125,
-0.0192413330078125,
-0.315673828125,
-0.102294921875,
-0.76953125,
0.03851318359375,
-0.61376953125,
0.2900390625,
-0.2073974609375,
-0.458984375,
0.1669921875,
-1.3349609375,
-0.0733642578125,
-0.64453125,
-0.56982421875,
-0.28173828125,
-0.58056640625,
-0.1610107421875,
0.9658203125,
0.279541015625,
0.266357421875,
0.1497802734375,
0.070068359375,
0.023529052734375,
-0.312744140625,
-0.9482421875,
-0.37939453125,
0.049163818359375,
0.307373046875,
0.08575439453125,
-0.073974609375,
-0.4814453125,
0.84228515625,
-1.021484375,
-0.1070556640625,
-0.2105712890625,
-0.249755859375,
-0.10577392578125,
-0.1485595703125,
1.162109375,
-0.375244140625,
-0.0247344970703125,
-0.0141448974609375,
0.50390625,
0.460693359375,
-0.3916015625,
-0.42041015625,
-0.6728515625,
-0.466796875,
-0.89208984375,
0.71826171875,
-0.7138671875,
0.1417236328125,
-0.64501953125,
-0.401611328125,
1.1923828125,
-0.87158203125,
0.50732421875,
0.81884765625,
-0.03875732421875,
0.1959228515625,
-0.81396484375,
0.6005859375,
0.455322265625,
-0.5458984375,
-0.12451171875,
0.307861328125,
-0.469482421875,
0.369873046875,
0.068359375,
-1.037109375,
-0.70361328125,
0.615234375,
1.330078125,
-0.078857421875,
0.63818359375,
-0.168701171875,
-0.361083984375,
-0.49560546875,
1.046875,
-0.1063232421875,
0.037689208984375,
1.0263671875,
-0.65869140625,
-0.323974609375,
0.09930419921875,
-0.0367431640625,
-0.56787109375,
-0.4765625,
1.544921875,
-0.15478515625,
-0.2178955078125,
0.951171875,
0.8583984375,
-0.66748046875,
-0.5478515625,
-0.38037109375,
0.376708984375,
-0.042083740234375,
-0.8212890625,
0.212158203125,
0.658203125,
-0.7705078125,
-0.2025146484375,
0.537109375,
-0.18115234375,
0.336181640625,
0.1722412109375,
0.4423828125,
-0.315185546875,
0.333251953125,
0.64208984375,
-0.73876953125,
-0.059600830078125,
-1.0849609375,
0.25341796875,
-0.27880859375,
-0.51220703125,
0.7802734375,
-0.247314453125,
0.44921875,
0.88134765625,
-0.1973876953125,
0.49853515625,
-0.58740234375,
-0.58056640625,
0.2220458984375,
-1.0048828125,
-0.70751953125,
-0.391357421875,
0.467529296875,
-0.268798828125,
0.1336669921875,
-1.146484375,
0.279541015625,
0.42578125,
0.440185546875,
-0.6513671875,
-0.8525390625,
0.027252197265625,
-0.96923828125,
-0.384521484375,
-0.576171875,
-0.69091796875,
-0.2861328125,
-0.068603515625,
-0.0841064453125,
-0.5498046875,
0.368896484375,
0.40625,
-0.32763671875,
0.9091796875,
-0.470458984375,
0.5263671875,
-0.64599609375,
-0.169677734375,
-0.7255859375,
0.054412841796875,
-0.30419921875,
0.00188446044921875,
-0.5986328125,
0.264892578125,
0.50244140625,
0.2464599609375,
0.10260009765625,
-0.18505859375,
-0.583984375,
-0.6875,
-0.11517333984375,
0.1363525390625,
-0.432373046875,
0.68212890625,
0.434814453125,
0.2303466796875,
0.85498046875,
-0.1943359375,
-0.56884765625,
-0.0034770965576171875,
0.6015625,
0.6845703125,
-0.366455078125,
-0.033660888671875,
-0.33837890625,
0.058929443359375,
-0.85498046875,
0.097412109375,
-0.036865234375,
0.2205810546875,
0.033233642578125,
-0.26025390625,
0.374755859375,
1.1865234375,
0.1539306640625,
0.64990234375,
0.2421875,
0.255126953125,
0.260498046875,
-0.546875,
-0.14794921875,
0.484619140625,
0.11102294921875,
-0.3427734375,
-0.05926513671875,
0.451416015625,
-0.060760498046875,
0.35888671875,
0.159912109375,
-0.892578125,
-1.1484375,
-0.445068359375,
0.1986083984375,
0.481689453125,
0.64013671875,
-0.490234375,
-0.254638671875,
-0.47802734375,
-0.78515625,
0.65478515625,
-1.0009765625,
-0.66455078125,
0.472900390625,
-0.1937255859375,
-0.65185546875,
-0.11016845703125,
-0.52978515625,
0.035125732421875,
0.060394287109375,
0.45556640625,
-0.7080078125,
0.1859130859375,
0.2509765625,
0.46142578125,
-0.265869140625,
-0.221923828125,
0.00904083251953125,
0.322998046875,
-0.281494140625,
-0.1754150390625,
0.41064453125,
1.0595703125,
0.1998291015625,
-0.0292816162109375,
-0.7841796875,
0.0867919921875,
0.6162109375,
0.159423828125,
-0.383056640625,
-0.1495361328125,
-0.63134765625,
0.71630859375,
-0.81787109375,
-0.0201873779296875,
0.028778076171875,
0.1767578125,
0.2353515625,
-0.427490234375,
-0.58935546875,
0.9248046875,
1.2392578125,
-0.2373046875,
0.48388671875,
0.10125732421875,
0.10333251953125,
-0.25927734375,
-0.147705078125,
-0.45361328125,
0.3974609375,
0.1356201171875,
0.419677734375,
-0.062286376953125,
0.73974609375,
0.76806640625,
-0.1968994140625,
0.1383056640625,
0.356201171875,
0.02069091796875,
-0.09619140625,
0.0274200439453125,
-0.02142333984375,
0.2388916015625,
0.439453125,
-0.6884765625,
0.3818359375,
-0.87451171875,
-0.234130859375,
0.027618408203125,
-0.595703125,
0.8203125,
-0.99462890625,
-0.0799560546875,
-0.1124267578125,
-0.4833984375,
0.1649169921875,
0.7294921875,
0.389404296875,
-0.008453369140625,
0.57373046875,
0.80615234375,
0.217041015625,
1.0234375,
0.63916015625,
0.354248046875,
-0.75390625,
0.26025390625,
0.093505859375,
-0.256103515625,
-0.489501953125,
-0.19482421875,
-0.77490234375,
0.472412109375,
-0.056732177734375,
-0.51953125,
0.482421875,
-0.79443359375,
-0.330322265625,
0.1639404296875,
0.77978515625,
-0.254638671875,
0.463134765625,
0.11920166015625,
-0.37744140625,
-0.7900390625,
1.0087890625,
-0.178466796875,
0.344970703125,
0.19189453125,
0.828125,
-0.072509765625,
1.1201171875,
0.37353515625,
-0.26904296875,
-0.0062713623046875,
0.076416015625,
-0.419189453125,
-1.01953125,
-0.2646484375,
-0.63818359375,
0.229248046875,
-0.310546875,
0.0288238525390625,
-0.0230865478515625,
0.6923828125,
-0.08575439453125,
-0.9072265625,
-0.387939453125,
0.056671142578125,
-0.6943359375,
0.5400390625,
0.40380859375,
0.156005859375,
0.322021484375,
-0.019744873046875,
-0.30712890625,
-0.6318359375,
-0.034423828125,
-0.81298828125,
0.28271484375,
-0.349365234375,
-0.2381591796875,
-0.76806640625,
-0.8671875,
-0.361572265625,
0.10186767578125,
-0.15673828125,
-0.89794921875,
0.306396484375,
0.01318359375,
0.54541015625,
0.0888671875,
-0.318115234375,
0.6513671875,
0.83056640625,
0.9716796875,
0.029754638671875,
0.80078125,
0.3388671875,
-0.3134765625,
0.2276611328125,
-0.277587890625,
0.336669921875,
-0.5986328125,
0.2257080078125,
-0.27294921875,
0.38232421875,
-0.5625,
-1.34375,
-0.2138671875,
0.57666015625,
0.305419921875,
-0.7373046875,
-1.0751953125,
-0.56005859375,
-0.65771484375,
0.314208984375,
-0.78125,
0.3857421875,
-0.0428466796875,
0.361083984375,
-0.1588134765625,
-0.95166015625,
4.37890625,
1.1064453125,
1.2724609375,
0.4619140625,
0.0538330078125,
0.9296875,
0.3818359375,
-0.1962890625,
-0.13427734375,
-0.6533203125,
0.373779296875,
-0.244140625,
-0.1439208984375,
1.04296875,
0.391357421875,
0.7744140625,
-0.8798828125,
-0.2152099609375,
0.007049560546875,
-0.5546875,
-0.72314453125,
0.041412353515625,
-0.552734375,
0.2177734375,
-0.198974609375,
0.386474609375,
0.69091796875,
-0.943359375,
-0.394775390625,
-0.3046875,
0.1309814453125,
-0.78466796875,
1.1328125,
-0.455810546875,
-0.2393798828125,
0.37060546875,
-0.2022705078125,
-0.5654296875,
-0.018341064453125,
0.420654296875,
0.1971435546875,
0.400634765625,
1.013671875,
-0.263671875,
0.48583984375,
0.465576171875,
-0.50830078125,
-0.003570556640625,
-0.320068359375,
-0.86083984375,
1.056640625,
-0.4853515625,
0.268310546875,
-0.46826171875,
-0.939453125,
0.253662109375,
-0.126220703125,
-0.365234375,
-0.228759765625,
0.188720703125,
0.2388916015625,
-0.0133514404296875,
-0.080810546875,
0.310791015625,
-1.00390625,
0.64111328125,
-0.039215087890625,
0.1954345703125,
-0.61328125,
-0.378662109375,
-0.1844482421875,
-0.25927734375,
-0.33251953125,
-0.408935546875,
0.53955078125,
0.1756591796875,
0.118896484375,
0.3916015625,
0.63720703125,
-0.80029296875,
-0.03790283203125,
-0.156982421875,
-0.59326171875,
-0.53955078125,
0.77099609375,
0.9716796875,
-0.7041015625,
-0.5146484375,
-0.1650390625,
0.383056640625,
0.58544921875,
0.38623046875,
0.454345703125,
-0.062347412109375,
-0.1766357421875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Tags: dfs and similar, graphs, sortings
Correct Solution:
```
from itertools import zip_longest
def main():
names = [input() for _ in range(int(input()))]
edges = [set() for _ in range(27)]
for na, nb in zip(names, names[1:]):
for a, b in zip_longest(na, nb, fillvalue='`'):
if a != b:
edges[ord(a) - 96].add(ord(b) - 96)
break
chars, i, visited = list(range(27)), 27, [False] * (27 * 27)
while i:
i -= 1
a = chars[i]
j = a * 27 + i
if visited[j]:
chars[0] = 1
break
visited[j] = True
for b in edges[a]:
j = chars.index(b)
if j < i:
chars[i], chars[j] = b, a
i += 1
break
print('Impossible' if chars[0] else ''.join(chr(c + 96) for c in chars[1:]))
if __name__ == '__main__':
main()
```
| 72,047 | [
-0.180419921875,
-0.34375,
0.476318359375,
-0.2020263671875,
-0.327392578125,
-0.34375,
-0.08489990234375,
0.228271484375,
0.1395263671875,
0.65087890625,
0.74072265625,
-0.05401611328125,
0.298095703125,
-0.9091796875,
-0.88818359375,
0.163818359375,
-0.200439453125,
-0.394775390625,
-0.01727294921875,
-0.08355712890625,
0.49755859375,
0.21875,
-1.806640625,
0.09527587890625,
-0.55859375,
1.0693359375,
0.60888671875,
0.1409912109375,
1.2353515625,
0.9892578125,
-0.039581298828125,
-0.344970703125,
0.51025390625,
-0.94775390625,
-0.236083984375,
-0.17431640625,
0.650390625,
-0.496826171875,
-0.08154296875,
-0.65478515625,
0.5673828125,
-0.7802734375,
0.45458984375,
-0.83984375,
-0.84765625,
-0.302001953125,
-0.1900634765625,
-0.19189453125,
-0.5048828125,
-1.283203125,
0.1494140625,
-0.28173828125,
0.6982421875,
-0.425537109375,
-0.1627197265625,
-0.040618896484375,
0.336669921875,
-0.06414794921875,
-0.471435546875,
0.53369140625,
-0.007320404052734375,
0.399169921875,
-0.320068359375,
-0.481201171875,
-0.328369140625,
0.223388671875,
0.14111328125,
-0.1376953125,
0.08001708984375,
-0.61328125,
-0.2451171875,
0.414306640625,
-0.29736328125,
-0.0411376953125,
-0.50830078125,
0.049407958984375,
-0.1990966796875,
-0.180419921875,
-0.3681640625,
0.58154296875,
0.279296875,
0.56787109375,
0.06695556640625,
0.314208984375,
-0.2646484375,
-0.34228515625,
-0.1282958984375,
0.17919921875,
0.2734375,
0.163818359375,
0.2088623046875,
0.441650390625,
-0.83642578125,
-0.29931640625,
0.39501953125,
0.60791015625,
-0.03558349609375,
0.2259521484375,
0.12188720703125,
0.140625,
0.939453125,
1.271484375,
-0.150390625,
0.9345703125,
-0.77490234375,
0.1658935546875,
-0.08001708984375,
-0.15478515625,
0.036529541015625,
-0.298583984375,
-0.205810546875,
-0.2303466796875,
0.2130126953125,
0.26953125,
0.11968994140625,
0.68310546875,
-0.446533203125,
0.385986328125,
-0.9931640625,
0.00644683837890625,
0.49169921875,
0.10150146484375,
0.053436279296875,
0.0784912109375,
0.2705078125,
-0.203369140625,
-0.1695556640625,
0.8974609375,
-0.452880859375,
-0.0908203125,
0.48388671875,
-0.055450439453125,
-0.548828125,
0.258056640625,
-0.106689453125,
0.8095703125,
-0.06402587890625,
0.52685546875,
0.55029296875,
-0.45654296875,
0.630859375,
-0.16943359375,
-0.035888671875,
1.53515625,
-0.007335662841796875,
-0.2384033203125,
0.41064453125,
0.2081298828125,
-0.76611328125,
0.5595703125,
-1.0556640625,
0.76513671875,
0.3828125,
0.33154296875,
-0.452880859375,
0.47216796875,
-0.186767578125,
0.42236328125,
0.65673828125,
0.64111328125,
-0.349609375,
-0.2298583984375,
-0.1202392578125,
1.0712890625,
-0.27197265625,
1.1962890625,
-0.61767578125,
-0.10089111328125,
0.07366943359375,
-0.2110595703125,
0.07696533203125,
0.043701171875,
-0.619140625,
1.0029296875,
0.289794921875,
0.81591796875,
0.437255859375,
-0.4677734375,
0.1600341796875,
0.08984375,
-0.33349609375,
0.473388671875,
-0.0029888153076171875,
0.76513671875,
0.176513671875,
0.1239013671875,
0.259765625,
-0.79052734375,
-0.35400390625,
-0.681640625,
-0.25390625,
0.7685546875,
-0.460205078125,
0.27734375,
-0.037139892578125,
-0.1365966796875,
-0.71142578125,
0.194580078125,
0.810546875,
-0.95166015625,
-0.200439453125,
0.52099609375,
-0.2176513671875,
0.6328125,
-0.74365234375,
-0.492919921875,
0.28662109375,
1.130859375,
0.00972747802734375,
-0.03955078125,
0.198486328125,
0.1295166015625,
-0.5048828125,
0.2362060546875,
0.30517578125,
-0.08441162109375,
-0.399658203125,
0.7060546875,
-0.515625,
-0.1280517578125,
0.280517578125,
0.970703125,
0.93408203125,
0.1883544921875,
-0.1307373046875,
0.158935546875,
1.251953125,
1.2890625,
-0.355712890625,
0.11578369140625,
0.0980224609375,
1.0859375,
0.3828125,
0.61279296875,
0.55712890625,
0.00441741943359375,
0.6884765625,
0.623046875,
-0.2130126953125,
0.08154296875,
0.07928466796875,
0.54150390625,
0.7685546875,
0.673828125,
-0.1881103515625,
0.5419921875,
-0.1519775390625,
0.1856689453125,
-0.236328125,
0.5732421875,
0.2293701171875,
0.8544921875,
0.125,
0.2376708984375,
-0.470703125,
-0.51513671875,
-0.281494140625,
0.463134765625,
-0.9306640625,
-0.59228515625,
-0.343994140625,
-0.10369873046875,
0.1632080078125,
0.0161590576171875,
0.2357177734375,
0.279052734375,
0.427001953125,
0.270263671875,
-0.2227783203125,
-0.61669921875,
-1.064453125,
-0.85791015625,
-1.21484375,
-0.347900390625,
-0.6962890625,
0.0826416015625,
0.436279296875,
-0.487060546875,
0.44921875,
-0.218505859375,
-0.251953125,
0.411865234375,
-0.47021484375,
0.58642578125,
0.08990478515625,
0.8486328125,
-0.497314453125,
0.262451171875,
-0.366943359375,
1.2314453125,
-0.65087890625,
-0.2425537109375,
-0.50048828125,
-0.7216796875,
0.444091796875,
0.5166015625,
0.60791015625,
0.063232421875,
-0.56884765625,
-1.1923828125,
-0.60693359375,
-0.0836181640625,
-1.0029296875,
0.349853515625,
-0.7978515625,
1.046875,
0.20166015625,
-0.666015625,
0.429443359375,
0.7060546875,
-0.6767578125,
0.888671875,
0.454345703125,
0.1466064453125,
-0.92431640625,
1.423828125,
0.00554656982421875,
0.478515625,
-0.456298828125,
-0.5263671875,
-0.41796875,
0.3564453125,
0.72021484375,
-0.98681640625,
0.0186767578125,
0.80712890625,
-0.037933349609375,
-1.134765625,
0.6630859375,
-0.6513671875,
-0.67529296875,
-0.1212158203125,
-0.5517578125,
0.69091796875,
0.8154296875,
0.5244140625,
0.250732421875,
-0.307373046875,
-0.24169921875,
0.58544921875,
-0.158935546875,
-0.55322265625,
-0.224609375,
0.3896484375,
-0.2115478515625,
-0.2176513671875,
0.2427978515625,
-0.340087890625,
-0.1195068359375,
-0.01041412353515625,
-0.06103515625,
0.90966796875,
0.13916015625,
0.142578125,
-0.047882080078125,
0.8505859375,
-0.7021484375,
-0.599609375,
-0.51318359375,
0.771484375,
0.578125,
0.36572265625,
0.41357421875,
-0.1962890625,
-0.413818359375,
-0.84423828125,
0.27001953125,
0.1402587890625,
0.71875,
-0.75732421875,
0.8779296875,
0.28173828125,
-0.59228515625,
0.322509765625,
-0.8037109375,
-0.252685546875,
1.4169921875,
-0.312744140625,
0.814453125,
-0.55224609375,
0.062225341796875,
-0.276611328125,
0.470947265625,
0.50927734375,
0.28662109375,
0.64453125,
-0.34033203125,
-0.035919189453125,
-0.451416015625,
-0.57958984375,
0.1668701171875,
-0.75146484375,
0.215087890625,
-0.09765625,
-0.385009765625,
-0.84375,
0.64794921875,
0.54345703125,
0.149658203125,
0.19287109375,
0.720703125,
0.236328125,
0.36572265625,
1.0625,
-0.41650390625,
0.1900634765625,
-0.59326171875,
0.88720703125,
0.27490234375,
-0.065185546875,
0.024688720703125,
-0.044952392578125,
-0.16552734375,
0.1524658203125,
-0.1810302734375,
-0.179931640625,
-0.6044921875,
0.14306640625,
0.2998046875,
0.70947265625,
-0.474853515625,
-0.51953125,
-0.196533203125,
0.56982421875,
0.326171875,
-0.56884765625,
0.10198974609375,
-0.69189453125,
0.3818359375,
0.56005859375,
-0.027374267578125,
-0.52734375,
-0.6494140625,
-1.1162109375,
-0.404296875,
0.62939453125,
0.343994140625,
0.134033203125,
-0.12030029296875,
-0.794921875,
0.7939453125,
0.031341552734375,
-0.2220458984375,
0.1448974609375,
-0.1868896484375,
-0.01380157470703125,
-0.1309814453125,
0.54736328125,
0.09814453125,
-0.63623046875,
0.35205078125,
-1.18359375,
0.58154296875,
-0.86328125,
0.57373046875,
0.09197998046875,
0.2137451171875,
-0.208251953125,
0.331787109375,
-0.51806640625,
-0.1370849609375,
-0.3017578125,
0.51708984375,
-0.97216796875,
-0.78564453125,
0.775390625,
-0.0621337890625,
-0.02008056640625,
0.71533203125,
-0.03131103515625,
-0.49169921875,
0.14013671875,
0.380615234375,
-0.56201171875,
0.23583984375,
-0.3994140625,
0.236083984375,
-0.6875,
-0.410888671875,
-0.133544921875,
-0.436767578125,
0.68115234375,
0.287841796875,
-0.7841796875,
-0.38623046875,
-0.99072265625,
-0.03631591796875,
-0.1553955078125,
-0.58251953125,
0.26953125,
-0.2310791015625,
-0.2861328125,
-0.285888671875,
-0.33984375,
-0.6572265625,
0.036102294921875,
-0.68896484375,
-0.319091796875,
0.2222900390625,
0.38427734375,
0.60009765625,
0.07110595703125,
-0.38720703125,
0.13525390625,
-0.2392578125,
-0.043792724609375,
-0.287353515625,
-0.14013671875,
-0.203857421875,
-0.349853515625,
-0.257568359375,
-0.1185302734375,
0.458740234375,
0.244140625,
0.23193359375,
0.270751953125,
0.419189453125,
0.5107421875,
-0.42919921875,
0.66455078125,
0.0200347900390625,
-0.54833984375,
-0.50537109375,
0.5400390625,
-0.2066650390625,
0.94189453125,
0.34033203125,
-1.359375,
-0.779296875,
-1.2626953125,
-0.0192413330078125,
-0.315673828125,
-0.102294921875,
-0.76953125,
0.03851318359375,
-0.61376953125,
0.2900390625,
-0.2073974609375,
-0.458984375,
0.1669921875,
-1.3349609375,
-0.0733642578125,
-0.64453125,
-0.56982421875,
-0.28173828125,
-0.58056640625,
-0.1610107421875,
0.9658203125,
0.279541015625,
0.266357421875,
0.1497802734375,
0.070068359375,
0.023529052734375,
-0.312744140625,
-0.9482421875,
-0.37939453125,
0.049163818359375,
0.307373046875,
0.08575439453125,
-0.073974609375,
-0.4814453125,
0.84228515625,
-1.021484375,
-0.1070556640625,
-0.2105712890625,
-0.249755859375,
-0.10577392578125,
-0.1485595703125,
1.162109375,
-0.375244140625,
-0.0247344970703125,
-0.0141448974609375,
0.50390625,
0.460693359375,
-0.3916015625,
-0.42041015625,
-0.6728515625,
-0.466796875,
-0.89208984375,
0.71826171875,
-0.7138671875,
0.1417236328125,
-0.64501953125,
-0.401611328125,
1.1923828125,
-0.87158203125,
0.50732421875,
0.81884765625,
-0.03875732421875,
0.1959228515625,
-0.81396484375,
0.6005859375,
0.455322265625,
-0.5458984375,
-0.12451171875,
0.307861328125,
-0.469482421875,
0.369873046875,
0.068359375,
-1.037109375,
-0.70361328125,
0.615234375,
1.330078125,
-0.078857421875,
0.63818359375,
-0.168701171875,
-0.361083984375,
-0.49560546875,
1.046875,
-0.1063232421875,
0.037689208984375,
1.0263671875,
-0.65869140625,
-0.323974609375,
0.09930419921875,
-0.0367431640625,
-0.56787109375,
-0.4765625,
1.544921875,
-0.15478515625,
-0.2178955078125,
0.951171875,
0.8583984375,
-0.66748046875,
-0.5478515625,
-0.38037109375,
0.376708984375,
-0.042083740234375,
-0.8212890625,
0.212158203125,
0.658203125,
-0.7705078125,
-0.2025146484375,
0.537109375,
-0.18115234375,
0.336181640625,
0.1722412109375,
0.4423828125,
-0.315185546875,
0.333251953125,
0.64208984375,
-0.73876953125,
-0.059600830078125,
-1.0849609375,
0.25341796875,
-0.27880859375,
-0.51220703125,
0.7802734375,
-0.247314453125,
0.44921875,
0.88134765625,
-0.1973876953125,
0.49853515625,
-0.58740234375,
-0.58056640625,
0.2220458984375,
-1.0048828125,
-0.70751953125,
-0.391357421875,
0.467529296875,
-0.268798828125,
0.1336669921875,
-1.146484375,
0.279541015625,
0.42578125,
0.440185546875,
-0.6513671875,
-0.8525390625,
0.027252197265625,
-0.96923828125,
-0.384521484375,
-0.576171875,
-0.69091796875,
-0.2861328125,
-0.068603515625,
-0.0841064453125,
-0.5498046875,
0.368896484375,
0.40625,
-0.32763671875,
0.9091796875,
-0.470458984375,
0.5263671875,
-0.64599609375,
-0.169677734375,
-0.7255859375,
0.054412841796875,
-0.30419921875,
0.00188446044921875,
-0.5986328125,
0.264892578125,
0.50244140625,
0.2464599609375,
0.10260009765625,
-0.18505859375,
-0.583984375,
-0.6875,
-0.11517333984375,
0.1363525390625,
-0.432373046875,
0.68212890625,
0.434814453125,
0.2303466796875,
0.85498046875,
-0.1943359375,
-0.56884765625,
-0.0034770965576171875,
0.6015625,
0.6845703125,
-0.366455078125,
-0.033660888671875,
-0.33837890625,
0.058929443359375,
-0.85498046875,
0.097412109375,
-0.036865234375,
0.2205810546875,
0.033233642578125,
-0.26025390625,
0.374755859375,
1.1865234375,
0.1539306640625,
0.64990234375,
0.2421875,
0.255126953125,
0.260498046875,
-0.546875,
-0.14794921875,
0.484619140625,
0.11102294921875,
-0.3427734375,
-0.05926513671875,
0.451416015625,
-0.060760498046875,
0.35888671875,
0.159912109375,
-0.892578125,
-1.1484375,
-0.445068359375,
0.1986083984375,
0.481689453125,
0.64013671875,
-0.490234375,
-0.254638671875,
-0.47802734375,
-0.78515625,
0.65478515625,
-1.0009765625,
-0.66455078125,
0.472900390625,
-0.1937255859375,
-0.65185546875,
-0.11016845703125,
-0.52978515625,
0.035125732421875,
0.060394287109375,
0.45556640625,
-0.7080078125,
0.1859130859375,
0.2509765625,
0.46142578125,
-0.265869140625,
-0.221923828125,
0.00904083251953125,
0.322998046875,
-0.281494140625,
-0.1754150390625,
0.41064453125,
1.0595703125,
0.1998291015625,
-0.0292816162109375,
-0.7841796875,
0.0867919921875,
0.6162109375,
0.159423828125,
-0.383056640625,
-0.1495361328125,
-0.63134765625,
0.71630859375,
-0.81787109375,
-0.0201873779296875,
0.028778076171875,
0.1767578125,
0.2353515625,
-0.427490234375,
-0.58935546875,
0.9248046875,
1.2392578125,
-0.2373046875,
0.48388671875,
0.10125732421875,
0.10333251953125,
-0.25927734375,
-0.147705078125,
-0.45361328125,
0.3974609375,
0.1356201171875,
0.419677734375,
-0.062286376953125,
0.73974609375,
0.76806640625,
-0.1968994140625,
0.1383056640625,
0.356201171875,
0.02069091796875,
-0.09619140625,
0.0274200439453125,
-0.02142333984375,
0.2388916015625,
0.439453125,
-0.6884765625,
0.3818359375,
-0.87451171875,
-0.234130859375,
0.027618408203125,
-0.595703125,
0.8203125,
-0.99462890625,
-0.0799560546875,
-0.1124267578125,
-0.4833984375,
0.1649169921875,
0.7294921875,
0.389404296875,
-0.008453369140625,
0.57373046875,
0.80615234375,
0.217041015625,
1.0234375,
0.63916015625,
0.354248046875,
-0.75390625,
0.26025390625,
0.093505859375,
-0.256103515625,
-0.489501953125,
-0.19482421875,
-0.77490234375,
0.472412109375,
-0.056732177734375,
-0.51953125,
0.482421875,
-0.79443359375,
-0.330322265625,
0.1639404296875,
0.77978515625,
-0.254638671875,
0.463134765625,
0.11920166015625,
-0.37744140625,
-0.7900390625,
1.0087890625,
-0.178466796875,
0.344970703125,
0.19189453125,
0.828125,
-0.072509765625,
1.1201171875,
0.37353515625,
-0.26904296875,
-0.0062713623046875,
0.076416015625,
-0.419189453125,
-1.01953125,
-0.2646484375,
-0.63818359375,
0.229248046875,
-0.310546875,
0.0288238525390625,
-0.0230865478515625,
0.6923828125,
-0.08575439453125,
-0.9072265625,
-0.387939453125,
0.056671142578125,
-0.6943359375,
0.5400390625,
0.40380859375,
0.156005859375,
0.322021484375,
-0.019744873046875,
-0.30712890625,
-0.6318359375,
-0.034423828125,
-0.81298828125,
0.28271484375,
-0.349365234375,
-0.2381591796875,
-0.76806640625,
-0.8671875,
-0.361572265625,
0.10186767578125,
-0.15673828125,
-0.89794921875,
0.306396484375,
0.01318359375,
0.54541015625,
0.0888671875,
-0.318115234375,
0.6513671875,
0.83056640625,
0.9716796875,
0.029754638671875,
0.80078125,
0.3388671875,
-0.3134765625,
0.2276611328125,
-0.277587890625,
0.336669921875,
-0.5986328125,
0.2257080078125,
-0.27294921875,
0.38232421875,
-0.5625,
-1.34375,
-0.2138671875,
0.57666015625,
0.305419921875,
-0.7373046875,
-1.0751953125,
-0.56005859375,
-0.65771484375,
0.314208984375,
-0.78125,
0.3857421875,
-0.0428466796875,
0.361083984375,
-0.1588134765625,
-0.95166015625,
4.37890625,
1.1064453125,
1.2724609375,
0.4619140625,
0.0538330078125,
0.9296875,
0.3818359375,
-0.1962890625,
-0.13427734375,
-0.6533203125,
0.373779296875,
-0.244140625,
-0.1439208984375,
1.04296875,
0.391357421875,
0.7744140625,
-0.8798828125,
-0.2152099609375,
0.007049560546875,
-0.5546875,
-0.72314453125,
0.041412353515625,
-0.552734375,
0.2177734375,
-0.198974609375,
0.386474609375,
0.69091796875,
-0.943359375,
-0.394775390625,
-0.3046875,
0.1309814453125,
-0.78466796875,
1.1328125,
-0.455810546875,
-0.2393798828125,
0.37060546875,
-0.2022705078125,
-0.5654296875,
-0.018341064453125,
0.420654296875,
0.1971435546875,
0.400634765625,
1.013671875,
-0.263671875,
0.48583984375,
0.465576171875,
-0.50830078125,
-0.003570556640625,
-0.320068359375,
-0.86083984375,
1.056640625,
-0.4853515625,
0.268310546875,
-0.46826171875,
-0.939453125,
0.253662109375,
-0.126220703125,
-0.365234375,
-0.228759765625,
0.188720703125,
0.2388916015625,
-0.0133514404296875,
-0.080810546875,
0.310791015625,
-1.00390625,
0.64111328125,
-0.039215087890625,
0.1954345703125,
-0.61328125,
-0.378662109375,
-0.1844482421875,
-0.25927734375,
-0.33251953125,
-0.408935546875,
0.53955078125,
0.1756591796875,
0.118896484375,
0.3916015625,
0.63720703125,
-0.80029296875,
-0.03790283203125,
-0.156982421875,
-0.59326171875,
-0.53955078125,
0.77099609375,
0.9716796875,
-0.7041015625,
-0.5146484375,
-0.1650390625,
0.383056640625,
0.58544921875,
0.38623046875,
0.454345703125,
-0.062347412109375,
-0.1766357421875
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Submitted Solution:
```
"""
pppppppppppppppppppp
ppppp ppppppppppppppppppp
ppppppp ppppppppppppppppppppp
pppppppp pppppppppppppppppppppp
pppppppppppppppppppppppppppppppp
pppppppppppppppppppppppp
ppppppppppppppppppppppppppppppppppppppppppppppp pppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppppp ppppppppppppppppppppp
ppppppppppppppppppppppppppppppppppppppppppppppppp pppppppppppppppppppppp
ppppppppppppppppppppppppppppppppppppppppppppppp pppppppppppppppppppppppp
pppppppppppppppppppppppppppppppppppppppppppppp pppppppppppppppppppppppppp
ppppppppppppppppppppppppppppppppppppppppppppp pppppppppppppppppppppppppppp
pppppppppppppppppppppppppppppppp pppppppppppppppppppppppppppppppp
pppppppppppppppppppppppppppp pppppppppppppppppppppppppppppppppppppppppppppp
ppppppppppppppppppppppppppp pppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppp pppppppppppppppppppppppppppppppppppppppppppppppppp
ppppppppppppppppppppppp ppppppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppp ppppppppppppppppppppppppppppppppppppppppppppppp
ppppppppppppppppppppp ppppppppppppppppppppppppppppppppppppppppppppp
pppppppppppppppppppppppp
pppppppppppppppppppppppppppppppp
pppppppppppppppppppppp pppppppp
ppppppppppppppppppppp ppppppp
ppppppppppppppppppp ppppp
pppppppppppppppppppp
"""
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var): sys.stdout.write(str(var))
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
def dfs(source):
vis[source] = 1
for child in graph[source]:
if vis[child] == 1:
out("Impossible")
exit()
if not vis[child]:
dfs(child)
answer.append(source)
vis[source] = 2
n = int(data())
names = [list(data()) for i in range(n)]
graph = dd(set)
r = True
order = []
for i in range(n - 1):
j = i + 1
a = 0
while a < min(len(names[i]), len(names[j])) and names[i][a] == names[j][a]:
a += 1
if a < min(len(names[i]), len(names[j])) and names[i][a] != names[j][a]:
graph[names[i][a]].add(names[j][a])
continue
if len(names[i]) > len(names[j]):
out("Impossible")
exit()
vis = dd(int)
answer = []
for i in range(26):
c = chr(i + 97)
if not vis[c]:
dfs(c)
out(''.join(answer[::-1]))
```
Yes
| 72,048 | [
-0.0347900390625,
-0.2958984375,
0.419677734375,
-0.2406005859375,
-0.400634765625,
-0.288330078125,
-0.093994140625,
0.26318359375,
0.09747314453125,
0.603515625,
0.6552734375,
0.0177154541015625,
0.22216796875,
-0.8720703125,
-0.8095703125,
0.137939453125,
-0.180419921875,
-0.413330078125,
-0.04302978515625,
-0.1639404296875,
0.428955078125,
0.2188720703125,
-1.6826171875,
0.10687255859375,
-0.583984375,
0.9892578125,
0.53173828125,
0.1768798828125,
1.2421875,
0.92578125,
-0.077880859375,
-0.40576171875,
0.5224609375,
-0.82763671875,
-0.211181640625,
-0.303955078125,
0.67822265625,
-0.51220703125,
-0.1773681640625,
-0.7197265625,
0.421875,
-0.67822265625,
0.406494140625,
-0.81591796875,
-0.89697265625,
-0.347412109375,
-0.1845703125,
-0.2103271484375,
-0.45263671875,
-1.2236328125,
0.2249755859375,
-0.2197265625,
0.62353515625,
-0.499755859375,
-0.10601806640625,
0.102294921875,
0.341796875,
0.0197296142578125,
-0.495849609375,
0.3818359375,
0.015960693359375,
0.351806640625,
-0.383056640625,
-0.63330078125,
-0.33447265625,
0.253662109375,
0.141357421875,
-0.1221923828125,
0.1630859375,
-0.49853515625,
-0.2242431640625,
0.312255859375,
-0.34765625,
0.06622314453125,
-0.51171875,
0.08294677734375,
-0.1854248046875,
-0.1673583984375,
-0.484375,
0.59765625,
0.26416015625,
0.6728515625,
0.1380615234375,
0.366943359375,
-0.2724609375,
-0.30517578125,
-0.006076812744140625,
0.1400146484375,
0.26123046875,
0.1253662109375,
0.2259521484375,
0.359619140625,
-0.7763671875,
-0.284912109375,
0.472900390625,
0.53271484375,
-0.0203857421875,
0.252685546875,
0.10882568359375,
0.1519775390625,
0.96142578125,
1.19140625,
-0.1544189453125,
0.98291015625,
-0.75439453125,
0.12274169921875,
-0.11260986328125,
-0.2318115234375,
0.11370849609375,
-0.34033203125,
-0.1241455078125,
-0.289794921875,
0.1488037109375,
0.22802734375,
0.0005865097045898438,
0.6865234375,
-0.423828125,
0.428466796875,
-0.86962890625,
-0.1019287109375,
0.497802734375,
0.043243408203125,
0.01403045654296875,
0.06243896484375,
0.39111328125,
-0.266845703125,
-0.266357421875,
0.90380859375,
-0.435302734375,
-0.08660888671875,
0.474609375,
-0.10601806640625,
-0.5556640625,
0.2481689453125,
-0.1397705078125,
0.74560546875,
-0.03253173828125,
0.476318359375,
0.5791015625,
-0.498291015625,
0.63916015625,
-0.0911865234375,
0.0460205078125,
1.5751953125,
-0.060333251953125,
-0.2724609375,
0.298828125,
0.2093505859375,
-0.7548828125,
0.517578125,
-0.99755859375,
0.78271484375,
0.2447509765625,
0.2386474609375,
-0.53271484375,
0.419677734375,
-0.1954345703125,
0.382568359375,
0.615234375,
0.56591796875,
-0.33203125,
-0.1103515625,
-0.212890625,
0.98828125,
-0.3076171875,
1.0341796875,
-0.5234375,
-0.0975341796875,
0.04864501953125,
-0.1348876953125,
0.066162109375,
0.0762939453125,
-0.367431640625,
1.046875,
0.307373046875,
0.83642578125,
0.416015625,
-0.378662109375,
0.12127685546875,
0.1669921875,
-0.359130859375,
0.42822265625,
0.0236053466796875,
0.8271484375,
0.1929931640625,
0.2078857421875,
0.2841796875,
-0.72216796875,
-0.30908203125,
-0.6884765625,
-0.222900390625,
0.79443359375,
-0.5009765625,
0.408447265625,
-0.0689697265625,
-0.1278076171875,
-0.62451171875,
0.1302490234375,
0.8681640625,
-0.947265625,
-0.2325439453125,
0.5703125,
-0.183837890625,
0.6025390625,
-0.71337890625,
-0.53662109375,
0.371337890625,
1.0849609375,
0.0574951171875,
0.037017822265625,
0.238037109375,
0.23828125,
-0.48828125,
0.0780029296875,
0.31982421875,
-0.036865234375,
-0.427734375,
0.59814453125,
-0.425048828125,
-0.15380859375,
0.268310546875,
0.908203125,
0.802734375,
0.25146484375,
-0.27685546875,
-0.0227203369140625,
1.01171875,
1.3388671875,
-0.326171875,
0.07818603515625,
0.09735107421875,
1.0947265625,
0.3623046875,
0.6923828125,
0.56103515625,
-0.0753173828125,
0.80615234375,
0.58447265625,
-0.391845703125,
0.0987548828125,
0.03424072265625,
0.587890625,
0.70751953125,
0.65625,
-0.1058349609375,
0.45849609375,
-0.1751708984375,
0.1563720703125,
-0.281005859375,
0.6513671875,
0.18505859375,
0.85546875,
0.06396484375,
0.31494140625,
-0.479736328125,
-0.525390625,
-0.2001953125,
0.51318359375,
-0.96630859375,
-0.70166015625,
-0.32763671875,
-0.1954345703125,
0.07611083984375,
0.033935546875,
0.1790771484375,
0.19189453125,
0.347412109375,
0.30322265625,
-0.24755859375,
-0.6416015625,
-0.984375,
-0.869140625,
-1.2646484375,
-0.343505859375,
-0.73193359375,
-0.023162841796875,
0.32080078125,
-0.472412109375,
0.419189453125,
-0.2568359375,
-0.1495361328125,
0.34375,
-0.458740234375,
0.6435546875,
0.09197998046875,
0.83642578125,
-0.55419921875,
0.164306640625,
-0.199462890625,
1.1845703125,
-0.64404296875,
-0.1546630859375,
-0.50927734375,
-0.6962890625,
0.458740234375,
0.442138671875,
0.57861328125,
0.06024169921875,
-0.59033203125,
-1.15625,
-0.54052734375,
0.06304931640625,
-0.8876953125,
0.2490234375,
-0.73681640625,
1.0263671875,
0.10906982421875,
-0.681640625,
0.40771484375,
0.76171875,
-0.7451171875,
0.84716796875,
0.471435546875,
0.188232421875,
-0.87548828125,
1.49609375,
0.07525634765625,
0.47998046875,
-0.4697265625,
-0.484130859375,
-0.428955078125,
0.29638671875,
0.7529296875,
-1.0107421875,
-0.09112548828125,
0.78759765625,
-0.0080413818359375,
-1.1474609375,
0.7333984375,
-0.8271484375,
-0.7119140625,
-0.0684814453125,
-0.6455078125,
0.68212890625,
0.83837890625,
0.5908203125,
0.1959228515625,
-0.37451171875,
-0.2025146484375,
0.56884765625,
-0.033966064453125,
-0.6259765625,
-0.2252197265625,
0.428955078125,
-0.1868896484375,
-0.156982421875,
0.162353515625,
-0.39208984375,
-0.08416748046875,
-0.05023193359375,
-0.174560546875,
0.9970703125,
0.1295166015625,
0.18603515625,
-0.054168701171875,
0.87060546875,
-0.74365234375,
-0.496337890625,
-0.52685546875,
0.7265625,
0.6279296875,
0.425537109375,
0.455810546875,
-0.12109375,
-0.43212890625,
-0.81884765625,
0.277099609375,
-0.003963470458984375,
0.63134765625,
-0.67041015625,
0.830078125,
0.2017822265625,
-0.56103515625,
0.431884765625,
-0.80517578125,
-0.25146484375,
1.33203125,
-0.298828125,
0.83251953125,
-0.626953125,
0.09320068359375,
-0.3017578125,
0.359619140625,
0.44775390625,
0.2314453125,
0.67333984375,
-0.413330078125,
0.00014770030975341797,
-0.391357421875,
-0.499755859375,
0.15283203125,
-0.75048828125,
0.084228515625,
-0.105224609375,
-0.440185546875,
-0.8916015625,
0.72119140625,
0.5283203125,
0.1832275390625,
0.1519775390625,
0.70068359375,
0.1890869140625,
0.293701171875,
1.01171875,
-0.34521484375,
0.1781005859375,
-0.65087890625,
0.8720703125,
0.26416015625,
-0.153076171875,
-0.0038909912109375,
-0.01934814453125,
-0.12060546875,
0.153564453125,
-0.1595458984375,
-0.150634765625,
-0.7548828125,
0.236083984375,
0.2239990234375,
0.71484375,
-0.54150390625,
-0.5712890625,
-0.1719970703125,
0.58251953125,
0.318115234375,
-0.5927734375,
0.1116943359375,
-0.69970703125,
0.308349609375,
0.5927734375,
-0.124267578125,
-0.521484375,
-0.57763671875,
-1.318359375,
-0.450927734375,
0.60546875,
0.4013671875,
0.08184814453125,
-0.11737060546875,
-0.8779296875,
0.716796875,
0.10693359375,
-0.291259765625,
0.1651611328125,
-0.293701171875,
-0.0293426513671875,
-0.1441650390625,
0.55908203125,
0.035247802734375,
-0.72265625,
0.326171875,
-1.095703125,
0.6103515625,
-0.8203125,
0.54931640625,
0.056121826171875,
0.1942138671875,
-0.1727294921875,
0.38037109375,
-0.487548828125,
-0.05755615234375,
-0.306396484375,
0.55029296875,
-1.052734375,
-0.7666015625,
0.73046875,
0.04656982421875,
0.03582763671875,
0.71533203125,
-0.09442138671875,
-0.5791015625,
0.177978515625,
0.28759765625,
-0.54150390625,
0.381591796875,
-0.309326171875,
0.2142333984375,
-0.45166015625,
-0.367431640625,
-0.07562255859375,
-0.392333984375,
0.701171875,
0.23486328125,
-0.78125,
-0.47119140625,
-0.99169921875,
0.0298309326171875,
-0.198974609375,
-0.61328125,
0.31201171875,
-0.1644287109375,
-0.27587890625,
-0.340576171875,
-0.3232421875,
-0.69677734375,
-0.032562255859375,
-0.5908203125,
-0.318115234375,
0.194580078125,
0.346435546875,
0.57861328125,
0.1263427734375,
-0.31396484375,
0.0266571044921875,
-0.302490234375,
-0.039031982421875,
-0.316162109375,
-0.1630859375,
-0.071044921875,
-0.378173828125,
-0.295166015625,
-0.03021240234375,
0.368896484375,
0.278564453125,
0.2978515625,
0.2476806640625,
0.421142578125,
0.51513671875,
-0.56494140625,
0.74169921875,
-0.037933349609375,
-0.79541015625,
-0.45361328125,
0.497314453125,
-0.1021728515625,
0.96435546875,
0.2607421875,
-1.2275390625,
-0.810546875,
-1.314453125,
0.03350830078125,
-0.3173828125,
-0.240478515625,
-0.87158203125,
0.031585693359375,
-0.51904296875,
0.2286376953125,
-0.204833984375,
-0.498779296875,
0.10089111328125,
-1.380859375,
0.1082763671875,
-0.71875,
-0.56005859375,
-0.398681640625,
-0.48828125,
-0.186767578125,
0.97705078125,
0.34423828125,
0.280029296875,
0.1612548828125,
0.11712646484375,
-0.06292724609375,
-0.272216796875,
-0.91162109375,
-0.5078125,
0.0543212890625,
0.2105712890625,
0.0626220703125,
-0.06036376953125,
-0.452880859375,
0.84765625,
-0.9482421875,
-0.0338134765625,
-0.1798095703125,
-0.276611328125,
-0.07379150390625,
-0.281005859375,
1.1865234375,
-0.40576171875,
-0.01451873779296875,
-0.08367919921875,
0.455322265625,
0.52392578125,
-0.37548828125,
-0.349365234375,
-0.60888671875,
-0.3623046875,
-1.0009765625,
0.68359375,
-0.7119140625,
0.15576171875,
-0.64794921875,
-0.271728515625,
1.23828125,
-0.90673828125,
0.51220703125,
0.859375,
0.0194549560546875,
0.132080078125,
-0.8154296875,
0.5771484375,
0.51220703125,
-0.484130859375,
-0.08782958984375,
0.1629638671875,
-0.55126953125,
0.29931640625,
0.07061767578125,
-1.0341796875,
-0.708984375,
0.61279296875,
1.251953125,
-0.1591796875,
0.6845703125,
-0.143310546875,
-0.449951171875,
-0.4365234375,
1.0234375,
-0.150634765625,
0.057861328125,
1.015625,
-0.5234375,
-0.38232421875,
0.18212890625,
-0.0287628173828125,
-0.51123046875,
-0.406494140625,
1.56640625,
-0.1943359375,
-0.287841796875,
1.056640625,
0.796875,
-0.7216796875,
-0.5615234375,
-0.3134765625,
0.3525390625,
0.0262908935546875,
-0.74658203125,
0.30029296875,
0.59326171875,
-0.7353515625,
-0.152099609375,
0.473876953125,
-0.1927490234375,
0.356201171875,
0.0732421875,
0.4794921875,
-0.3798828125,
0.2337646484375,
0.6982421875,
-0.7197265625,
-0.1160888671875,
-1.0859375,
0.3134765625,
-0.2076416015625,
-0.43994140625,
0.76123046875,
-0.26611328125,
0.483642578125,
0.91552734375,
-0.238037109375,
0.52880859375,
-0.69873046875,
-0.486083984375,
0.1827392578125,
-0.95947265625,
-0.68896484375,
-0.452392578125,
0.51953125,
-0.1358642578125,
0.23046875,
-1.0888671875,
0.2171630859375,
0.50537109375,
0.361572265625,
-0.52783203125,
-0.7109375,
-0.037384033203125,
-0.865234375,
-0.486572265625,
-0.490966796875,
-0.56640625,
-0.2578125,
-0.034515380859375,
0.02105712890625,
-0.53369140625,
0.334228515625,
0.41796875,
-0.264404296875,
0.791015625,
-0.5283203125,
0.43017578125,
-0.73876953125,
-0.2301025390625,
-0.59326171875,
0.0404052734375,
-0.332763671875,
-0.0394287109375,
-0.432861328125,
0.2071533203125,
0.449462890625,
0.25146484375,
-0.028594970703125,
-0.207275390625,
-0.481201171875,
-0.59912109375,
-0.1201171875,
0.2060546875,
-0.5302734375,
0.75,
0.39697265625,
0.2132568359375,
0.74365234375,
-0.2147216796875,
-0.4775390625,
0.1177978515625,
0.7197265625,
0.63671875,
-0.300048828125,
-0.09552001953125,
-0.1646728515625,
-0.037109375,
-0.79638671875,
0.08660888671875,
-0.0290985107421875,
0.256103515625,
0.021881103515625,
-0.2841796875,
0.364501953125,
1.13671875,
0.02264404296875,
0.7099609375,
0.2415771484375,
0.25830078125,
0.29345703125,
-0.48291015625,
-0.062286376953125,
0.467041015625,
0.1373291015625,
-0.357666015625,
-0.0178680419921875,
0.513671875,
-0.0211944580078125,
0.326171875,
0.06488037109375,
-0.95849609375,
-1.220703125,
-0.366943359375,
0.11962890625,
0.49560546875,
0.65234375,
-0.442626953125,
-0.2205810546875,
-0.455810546875,
-0.85595703125,
0.5966796875,
-1.1982421875,
-0.71875,
0.55078125,
-0.25830078125,
-0.72607421875,
-0.08673095703125,
-0.53369140625,
0.1290283203125,
0.1365966796875,
0.3681640625,
-0.66845703125,
0.044677734375,
0.2607421875,
0.461669921875,
-0.27685546875,
-0.2449951171875,
-0.055389404296875,
0.309814453125,
-0.364501953125,
-0.2120361328125,
0.37353515625,
1.0380859375,
0.1441650390625,
-0.05743408203125,
-0.79736328125,
0.149658203125,
0.49462890625,
0.01013946533203125,
-0.342041015625,
-0.0168914794921875,
-0.63525390625,
0.68359375,
-0.67919921875,
-0.0321044921875,
-0.01690673828125,
0.163818359375,
0.0740966796875,
-0.428955078125,
-0.556640625,
0.84375,
1.130859375,
-0.25537109375,
0.462158203125,
0.053863525390625,
0.2186279296875,
-0.258544921875,
-0.1513671875,
-0.42822265625,
0.464599609375,
0.1737060546875,
0.4736328125,
-0.0316162109375,
0.77392578125,
0.798828125,
-0.12152099609375,
0.279296875,
0.365234375,
0.0596923828125,
-0.0328369140625,
0.006931304931640625,
-0.064208984375,
0.2724609375,
0.466796875,
-0.6240234375,
0.369384765625,
-0.80517578125,
-0.2286376953125,
-0.08624267578125,
-0.61474609375,
0.82861328125,
-0.9697265625,
-0.061187744140625,
-0.1759033203125,
-0.48291015625,
0.31689453125,
0.74951171875,
0.483154296875,
-0.0011968612670898438,
0.62646484375,
0.888671875,
0.313232421875,
1.044921875,
0.61962890625,
0.2783203125,
-0.79931640625,
0.163330078125,
0.2626953125,
-0.252685546875,
-0.37841796875,
-0.195556640625,
-0.8193359375,
0.53125,
-0.014739990234375,
-0.44091796875,
0.388916015625,
-0.7919921875,
-0.24755859375,
0.09814453125,
0.84033203125,
-0.413330078125,
0.4462890625,
0.0875244140625,
-0.393798828125,
-0.7783203125,
0.939453125,
-0.049560546875,
0.325927734375,
0.23974609375,
0.83349609375,
-0.01030731201171875,
1.1455078125,
0.4306640625,
-0.251220703125,
0.0626220703125,
0.1103515625,
-0.3310546875,
-0.92236328125,
-0.2548828125,
-0.572265625,
0.16552734375,
-0.368408203125,
-0.08172607421875,
-0.0230712890625,
0.64111328125,
0.0033283233642578125,
-0.9306640625,
-0.33203125,
0.059844970703125,
-0.62109375,
0.55859375,
0.283447265625,
0.223388671875,
0.332763671875,
0.03179931640625,
-0.318603515625,
-0.6591796875,
-0.025115966796875,
-0.67236328125,
0.38427734375,
-0.337158203125,
-0.2408447265625,
-0.79150390625,
-0.79345703125,
-0.266845703125,
0.163818359375,
-0.3154296875,
-0.810546875,
0.310791015625,
0.1622314453125,
0.47265625,
0.08843994140625,
-0.40625,
0.5888671875,
0.84912109375,
0.9580078125,
0.0152435302734375,
0.81982421875,
0.408203125,
-0.312255859375,
0.1485595703125,
-0.271728515625,
0.358154296875,
-0.5556640625,
0.149169921875,
-0.275634765625,
0.392333984375,
-0.5654296875,
-1.25390625,
-0.107177734375,
0.6513671875,
0.2200927734375,
-0.71142578125,
-1.11328125,
-0.6953125,
-0.607421875,
0.359130859375,
-0.74853515625,
0.427734375,
-0.0263824462890625,
0.252197265625,
-0.1943359375,
-0.9189453125,
4.4453125,
1.0087890625,
1.166015625,
0.458984375,
0.09454345703125,
0.88427734375,
0.421875,
-0.26220703125,
-0.05169677734375,
-0.72802734375,
0.3623046875,
-0.2822265625,
-0.154296875,
0.96875,
0.345947265625,
0.7490234375,
-0.841796875,
-0.316162109375,
0.10302734375,
-0.63720703125,
-0.794921875,
0.1328125,
-0.464111328125,
0.1409912109375,
-0.187255859375,
0.43017578125,
0.75146484375,
-0.95458984375,
-0.39990234375,
-0.2744140625,
0.203857421875,
-0.6953125,
1.15234375,
-0.324951171875,
-0.2197265625,
0.415283203125,
-0.16748046875,
-0.5595703125,
-0.1197509765625,
0.4921875,
0.155029296875,
0.45947265625,
0.9970703125,
-0.2244873046875,
0.50732421875,
0.5732421875,
-0.54248046875,
0.0748291015625,
-0.23388671875,
-0.8701171875,
1.0458984375,
-0.338134765625,
0.357177734375,
-0.411865234375,
-0.91259765625,
0.2447509765625,
-0.08502197265625,
-0.2978515625,
-0.12646484375,
0.2333984375,
0.1697998046875,
0.053192138671875,
-0.09320068359375,
0.373291015625,
-1.048828125,
0.62451171875,
0.0439453125,
0.2122802734375,
-0.60546875,
-0.3583984375,
-0.23388671875,
-0.214599609375,
-0.2108154296875,
-0.455810546875,
0.42333984375,
0.2183837890625,
0.004878997802734375,
0.308349609375,
0.68896484375,
-0.78076171875,
-0.036346435546875,
-0.252685546875,
-0.53564453125,
-0.67138671875,
0.7421875,
0.98193359375,
-0.69970703125,
-0.53759765625,
-0.2410888671875,
0.37255859375,
0.615234375,
0.449951171875,
0.404052734375,
-0.1142578125,
-0.255859375
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Submitted Solution:
```
import queue
def topologicalSort(graph, result, V):
indegree = [0] * V
zero_indegree = queue.PriorityQueue()
for u in range (V):
for v in graph[u]:
indegree[v] += 1
for i in range (V):
if indegree[i] == 0:
zero_indegree.put(i)
cnt = 0
while not zero_indegree.empty():
u = zero_indegree.get()
result.append(u)
for v in graph[u]:
indegree[v] -= 1
if indegree[v] == 0:
zero_indegree.put(v)
cnt+=1
if (cnt != V):
return False
return True
n = int(input())
graph = [[]for i in range (26)]
result = []
strings = []
for i in range (n):
strings.append(input())
check = True
for i in range (1,n):
flag = False
_len = min(len(strings[i]),len(strings[i-1]))
for j in range (_len):
if strings[i][j] != strings[i-1][j]:
flag = True
graph[ord(strings[i-1][j]) - ord('a')].append(ord(strings[i][j])-ord('a'))
break
if (len(strings[i]) < len(strings[i-1]) and not flag):
print('Impossible')
check = False
break
if check:
not_cycle = topologicalSort(graph,result,26)
if not not_cycle:
print('Impossible')
else:
for i in result:
print(chr(i+ord('a')),end = '')
print()
```
Yes
| 72,049 | [
-0.0347900390625,
-0.2958984375,
0.419677734375,
-0.2406005859375,
-0.400634765625,
-0.288330078125,
-0.093994140625,
0.26318359375,
0.09747314453125,
0.603515625,
0.6552734375,
0.0177154541015625,
0.22216796875,
-0.8720703125,
-0.8095703125,
0.137939453125,
-0.180419921875,
-0.413330078125,
-0.04302978515625,
-0.1639404296875,
0.428955078125,
0.2188720703125,
-1.6826171875,
0.10687255859375,
-0.583984375,
0.9892578125,
0.53173828125,
0.1768798828125,
1.2421875,
0.92578125,
-0.077880859375,
-0.40576171875,
0.5224609375,
-0.82763671875,
-0.211181640625,
-0.303955078125,
0.67822265625,
-0.51220703125,
-0.1773681640625,
-0.7197265625,
0.421875,
-0.67822265625,
0.406494140625,
-0.81591796875,
-0.89697265625,
-0.347412109375,
-0.1845703125,
-0.2103271484375,
-0.45263671875,
-1.2236328125,
0.2249755859375,
-0.2197265625,
0.62353515625,
-0.499755859375,
-0.10601806640625,
0.102294921875,
0.341796875,
0.0197296142578125,
-0.495849609375,
0.3818359375,
0.015960693359375,
0.351806640625,
-0.383056640625,
-0.63330078125,
-0.33447265625,
0.253662109375,
0.141357421875,
-0.1221923828125,
0.1630859375,
-0.49853515625,
-0.2242431640625,
0.312255859375,
-0.34765625,
0.06622314453125,
-0.51171875,
0.08294677734375,
-0.1854248046875,
-0.1673583984375,
-0.484375,
0.59765625,
0.26416015625,
0.6728515625,
0.1380615234375,
0.366943359375,
-0.2724609375,
-0.30517578125,
-0.006076812744140625,
0.1400146484375,
0.26123046875,
0.1253662109375,
0.2259521484375,
0.359619140625,
-0.7763671875,
-0.284912109375,
0.472900390625,
0.53271484375,
-0.0203857421875,
0.252685546875,
0.10882568359375,
0.1519775390625,
0.96142578125,
1.19140625,
-0.1544189453125,
0.98291015625,
-0.75439453125,
0.12274169921875,
-0.11260986328125,
-0.2318115234375,
0.11370849609375,
-0.34033203125,
-0.1241455078125,
-0.289794921875,
0.1488037109375,
0.22802734375,
0.0005865097045898438,
0.6865234375,
-0.423828125,
0.428466796875,
-0.86962890625,
-0.1019287109375,
0.497802734375,
0.043243408203125,
0.01403045654296875,
0.06243896484375,
0.39111328125,
-0.266845703125,
-0.266357421875,
0.90380859375,
-0.435302734375,
-0.08660888671875,
0.474609375,
-0.10601806640625,
-0.5556640625,
0.2481689453125,
-0.1397705078125,
0.74560546875,
-0.03253173828125,
0.476318359375,
0.5791015625,
-0.498291015625,
0.63916015625,
-0.0911865234375,
0.0460205078125,
1.5751953125,
-0.060333251953125,
-0.2724609375,
0.298828125,
0.2093505859375,
-0.7548828125,
0.517578125,
-0.99755859375,
0.78271484375,
0.2447509765625,
0.2386474609375,
-0.53271484375,
0.419677734375,
-0.1954345703125,
0.382568359375,
0.615234375,
0.56591796875,
-0.33203125,
-0.1103515625,
-0.212890625,
0.98828125,
-0.3076171875,
1.0341796875,
-0.5234375,
-0.0975341796875,
0.04864501953125,
-0.1348876953125,
0.066162109375,
0.0762939453125,
-0.367431640625,
1.046875,
0.307373046875,
0.83642578125,
0.416015625,
-0.378662109375,
0.12127685546875,
0.1669921875,
-0.359130859375,
0.42822265625,
0.0236053466796875,
0.8271484375,
0.1929931640625,
0.2078857421875,
0.2841796875,
-0.72216796875,
-0.30908203125,
-0.6884765625,
-0.222900390625,
0.79443359375,
-0.5009765625,
0.408447265625,
-0.0689697265625,
-0.1278076171875,
-0.62451171875,
0.1302490234375,
0.8681640625,
-0.947265625,
-0.2325439453125,
0.5703125,
-0.183837890625,
0.6025390625,
-0.71337890625,
-0.53662109375,
0.371337890625,
1.0849609375,
0.0574951171875,
0.037017822265625,
0.238037109375,
0.23828125,
-0.48828125,
0.0780029296875,
0.31982421875,
-0.036865234375,
-0.427734375,
0.59814453125,
-0.425048828125,
-0.15380859375,
0.268310546875,
0.908203125,
0.802734375,
0.25146484375,
-0.27685546875,
-0.0227203369140625,
1.01171875,
1.3388671875,
-0.326171875,
0.07818603515625,
0.09735107421875,
1.0947265625,
0.3623046875,
0.6923828125,
0.56103515625,
-0.0753173828125,
0.80615234375,
0.58447265625,
-0.391845703125,
0.0987548828125,
0.03424072265625,
0.587890625,
0.70751953125,
0.65625,
-0.1058349609375,
0.45849609375,
-0.1751708984375,
0.1563720703125,
-0.281005859375,
0.6513671875,
0.18505859375,
0.85546875,
0.06396484375,
0.31494140625,
-0.479736328125,
-0.525390625,
-0.2001953125,
0.51318359375,
-0.96630859375,
-0.70166015625,
-0.32763671875,
-0.1954345703125,
0.07611083984375,
0.033935546875,
0.1790771484375,
0.19189453125,
0.347412109375,
0.30322265625,
-0.24755859375,
-0.6416015625,
-0.984375,
-0.869140625,
-1.2646484375,
-0.343505859375,
-0.73193359375,
-0.023162841796875,
0.32080078125,
-0.472412109375,
0.419189453125,
-0.2568359375,
-0.1495361328125,
0.34375,
-0.458740234375,
0.6435546875,
0.09197998046875,
0.83642578125,
-0.55419921875,
0.164306640625,
-0.199462890625,
1.1845703125,
-0.64404296875,
-0.1546630859375,
-0.50927734375,
-0.6962890625,
0.458740234375,
0.442138671875,
0.57861328125,
0.06024169921875,
-0.59033203125,
-1.15625,
-0.54052734375,
0.06304931640625,
-0.8876953125,
0.2490234375,
-0.73681640625,
1.0263671875,
0.10906982421875,
-0.681640625,
0.40771484375,
0.76171875,
-0.7451171875,
0.84716796875,
0.471435546875,
0.188232421875,
-0.87548828125,
1.49609375,
0.07525634765625,
0.47998046875,
-0.4697265625,
-0.484130859375,
-0.428955078125,
0.29638671875,
0.7529296875,
-1.0107421875,
-0.09112548828125,
0.78759765625,
-0.0080413818359375,
-1.1474609375,
0.7333984375,
-0.8271484375,
-0.7119140625,
-0.0684814453125,
-0.6455078125,
0.68212890625,
0.83837890625,
0.5908203125,
0.1959228515625,
-0.37451171875,
-0.2025146484375,
0.56884765625,
-0.033966064453125,
-0.6259765625,
-0.2252197265625,
0.428955078125,
-0.1868896484375,
-0.156982421875,
0.162353515625,
-0.39208984375,
-0.08416748046875,
-0.05023193359375,
-0.174560546875,
0.9970703125,
0.1295166015625,
0.18603515625,
-0.054168701171875,
0.87060546875,
-0.74365234375,
-0.496337890625,
-0.52685546875,
0.7265625,
0.6279296875,
0.425537109375,
0.455810546875,
-0.12109375,
-0.43212890625,
-0.81884765625,
0.277099609375,
-0.003963470458984375,
0.63134765625,
-0.67041015625,
0.830078125,
0.2017822265625,
-0.56103515625,
0.431884765625,
-0.80517578125,
-0.25146484375,
1.33203125,
-0.298828125,
0.83251953125,
-0.626953125,
0.09320068359375,
-0.3017578125,
0.359619140625,
0.44775390625,
0.2314453125,
0.67333984375,
-0.413330078125,
0.00014770030975341797,
-0.391357421875,
-0.499755859375,
0.15283203125,
-0.75048828125,
0.084228515625,
-0.105224609375,
-0.440185546875,
-0.8916015625,
0.72119140625,
0.5283203125,
0.1832275390625,
0.1519775390625,
0.70068359375,
0.1890869140625,
0.293701171875,
1.01171875,
-0.34521484375,
0.1781005859375,
-0.65087890625,
0.8720703125,
0.26416015625,
-0.153076171875,
-0.0038909912109375,
-0.01934814453125,
-0.12060546875,
0.153564453125,
-0.1595458984375,
-0.150634765625,
-0.7548828125,
0.236083984375,
0.2239990234375,
0.71484375,
-0.54150390625,
-0.5712890625,
-0.1719970703125,
0.58251953125,
0.318115234375,
-0.5927734375,
0.1116943359375,
-0.69970703125,
0.308349609375,
0.5927734375,
-0.124267578125,
-0.521484375,
-0.57763671875,
-1.318359375,
-0.450927734375,
0.60546875,
0.4013671875,
0.08184814453125,
-0.11737060546875,
-0.8779296875,
0.716796875,
0.10693359375,
-0.291259765625,
0.1651611328125,
-0.293701171875,
-0.0293426513671875,
-0.1441650390625,
0.55908203125,
0.035247802734375,
-0.72265625,
0.326171875,
-1.095703125,
0.6103515625,
-0.8203125,
0.54931640625,
0.056121826171875,
0.1942138671875,
-0.1727294921875,
0.38037109375,
-0.487548828125,
-0.05755615234375,
-0.306396484375,
0.55029296875,
-1.052734375,
-0.7666015625,
0.73046875,
0.04656982421875,
0.03582763671875,
0.71533203125,
-0.09442138671875,
-0.5791015625,
0.177978515625,
0.28759765625,
-0.54150390625,
0.381591796875,
-0.309326171875,
0.2142333984375,
-0.45166015625,
-0.367431640625,
-0.07562255859375,
-0.392333984375,
0.701171875,
0.23486328125,
-0.78125,
-0.47119140625,
-0.99169921875,
0.0298309326171875,
-0.198974609375,
-0.61328125,
0.31201171875,
-0.1644287109375,
-0.27587890625,
-0.340576171875,
-0.3232421875,
-0.69677734375,
-0.032562255859375,
-0.5908203125,
-0.318115234375,
0.194580078125,
0.346435546875,
0.57861328125,
0.1263427734375,
-0.31396484375,
0.0266571044921875,
-0.302490234375,
-0.039031982421875,
-0.316162109375,
-0.1630859375,
-0.071044921875,
-0.378173828125,
-0.295166015625,
-0.03021240234375,
0.368896484375,
0.278564453125,
0.2978515625,
0.2476806640625,
0.421142578125,
0.51513671875,
-0.56494140625,
0.74169921875,
-0.037933349609375,
-0.79541015625,
-0.45361328125,
0.497314453125,
-0.1021728515625,
0.96435546875,
0.2607421875,
-1.2275390625,
-0.810546875,
-1.314453125,
0.03350830078125,
-0.3173828125,
-0.240478515625,
-0.87158203125,
0.031585693359375,
-0.51904296875,
0.2286376953125,
-0.204833984375,
-0.498779296875,
0.10089111328125,
-1.380859375,
0.1082763671875,
-0.71875,
-0.56005859375,
-0.398681640625,
-0.48828125,
-0.186767578125,
0.97705078125,
0.34423828125,
0.280029296875,
0.1612548828125,
0.11712646484375,
-0.06292724609375,
-0.272216796875,
-0.91162109375,
-0.5078125,
0.0543212890625,
0.2105712890625,
0.0626220703125,
-0.06036376953125,
-0.452880859375,
0.84765625,
-0.9482421875,
-0.0338134765625,
-0.1798095703125,
-0.276611328125,
-0.07379150390625,
-0.281005859375,
1.1865234375,
-0.40576171875,
-0.01451873779296875,
-0.08367919921875,
0.455322265625,
0.52392578125,
-0.37548828125,
-0.349365234375,
-0.60888671875,
-0.3623046875,
-1.0009765625,
0.68359375,
-0.7119140625,
0.15576171875,
-0.64794921875,
-0.271728515625,
1.23828125,
-0.90673828125,
0.51220703125,
0.859375,
0.0194549560546875,
0.132080078125,
-0.8154296875,
0.5771484375,
0.51220703125,
-0.484130859375,
-0.08782958984375,
0.1629638671875,
-0.55126953125,
0.29931640625,
0.07061767578125,
-1.0341796875,
-0.708984375,
0.61279296875,
1.251953125,
-0.1591796875,
0.6845703125,
-0.143310546875,
-0.449951171875,
-0.4365234375,
1.0234375,
-0.150634765625,
0.057861328125,
1.015625,
-0.5234375,
-0.38232421875,
0.18212890625,
-0.0287628173828125,
-0.51123046875,
-0.406494140625,
1.56640625,
-0.1943359375,
-0.287841796875,
1.056640625,
0.796875,
-0.7216796875,
-0.5615234375,
-0.3134765625,
0.3525390625,
0.0262908935546875,
-0.74658203125,
0.30029296875,
0.59326171875,
-0.7353515625,
-0.152099609375,
0.473876953125,
-0.1927490234375,
0.356201171875,
0.0732421875,
0.4794921875,
-0.3798828125,
0.2337646484375,
0.6982421875,
-0.7197265625,
-0.1160888671875,
-1.0859375,
0.3134765625,
-0.2076416015625,
-0.43994140625,
0.76123046875,
-0.26611328125,
0.483642578125,
0.91552734375,
-0.238037109375,
0.52880859375,
-0.69873046875,
-0.486083984375,
0.1827392578125,
-0.95947265625,
-0.68896484375,
-0.452392578125,
0.51953125,
-0.1358642578125,
0.23046875,
-1.0888671875,
0.2171630859375,
0.50537109375,
0.361572265625,
-0.52783203125,
-0.7109375,
-0.037384033203125,
-0.865234375,
-0.486572265625,
-0.490966796875,
-0.56640625,
-0.2578125,
-0.034515380859375,
0.02105712890625,
-0.53369140625,
0.334228515625,
0.41796875,
-0.264404296875,
0.791015625,
-0.5283203125,
0.43017578125,
-0.73876953125,
-0.2301025390625,
-0.59326171875,
0.0404052734375,
-0.332763671875,
-0.0394287109375,
-0.432861328125,
0.2071533203125,
0.449462890625,
0.25146484375,
-0.028594970703125,
-0.207275390625,
-0.481201171875,
-0.59912109375,
-0.1201171875,
0.2060546875,
-0.5302734375,
0.75,
0.39697265625,
0.2132568359375,
0.74365234375,
-0.2147216796875,
-0.4775390625,
0.1177978515625,
0.7197265625,
0.63671875,
-0.300048828125,
-0.09552001953125,
-0.1646728515625,
-0.037109375,
-0.79638671875,
0.08660888671875,
-0.0290985107421875,
0.256103515625,
0.021881103515625,
-0.2841796875,
0.364501953125,
1.13671875,
0.02264404296875,
0.7099609375,
0.2415771484375,
0.25830078125,
0.29345703125,
-0.48291015625,
-0.062286376953125,
0.467041015625,
0.1373291015625,
-0.357666015625,
-0.0178680419921875,
0.513671875,
-0.0211944580078125,
0.326171875,
0.06488037109375,
-0.95849609375,
-1.220703125,
-0.366943359375,
0.11962890625,
0.49560546875,
0.65234375,
-0.442626953125,
-0.2205810546875,
-0.455810546875,
-0.85595703125,
0.5966796875,
-1.1982421875,
-0.71875,
0.55078125,
-0.25830078125,
-0.72607421875,
-0.08673095703125,
-0.53369140625,
0.1290283203125,
0.1365966796875,
0.3681640625,
-0.66845703125,
0.044677734375,
0.2607421875,
0.461669921875,
-0.27685546875,
-0.2449951171875,
-0.055389404296875,
0.309814453125,
-0.364501953125,
-0.2120361328125,
0.37353515625,
1.0380859375,
0.1441650390625,
-0.05743408203125,
-0.79736328125,
0.149658203125,
0.49462890625,
0.01013946533203125,
-0.342041015625,
-0.0168914794921875,
-0.63525390625,
0.68359375,
-0.67919921875,
-0.0321044921875,
-0.01690673828125,
0.163818359375,
0.0740966796875,
-0.428955078125,
-0.556640625,
0.84375,
1.130859375,
-0.25537109375,
0.462158203125,
0.053863525390625,
0.2186279296875,
-0.258544921875,
-0.1513671875,
-0.42822265625,
0.464599609375,
0.1737060546875,
0.4736328125,
-0.0316162109375,
0.77392578125,
0.798828125,
-0.12152099609375,
0.279296875,
0.365234375,
0.0596923828125,
-0.0328369140625,
0.006931304931640625,
-0.064208984375,
0.2724609375,
0.466796875,
-0.6240234375,
0.369384765625,
-0.80517578125,
-0.2286376953125,
-0.08624267578125,
-0.61474609375,
0.82861328125,
-0.9697265625,
-0.061187744140625,
-0.1759033203125,
-0.48291015625,
0.31689453125,
0.74951171875,
0.483154296875,
-0.0011968612670898438,
0.62646484375,
0.888671875,
0.313232421875,
1.044921875,
0.61962890625,
0.2783203125,
-0.79931640625,
0.163330078125,
0.2626953125,
-0.252685546875,
-0.37841796875,
-0.195556640625,
-0.8193359375,
0.53125,
-0.014739990234375,
-0.44091796875,
0.388916015625,
-0.7919921875,
-0.24755859375,
0.09814453125,
0.84033203125,
-0.413330078125,
0.4462890625,
0.0875244140625,
-0.393798828125,
-0.7783203125,
0.939453125,
-0.049560546875,
0.325927734375,
0.23974609375,
0.83349609375,
-0.01030731201171875,
1.1455078125,
0.4306640625,
-0.251220703125,
0.0626220703125,
0.1103515625,
-0.3310546875,
-0.92236328125,
-0.2548828125,
-0.572265625,
0.16552734375,
-0.368408203125,
-0.08172607421875,
-0.0230712890625,
0.64111328125,
0.0033283233642578125,
-0.9306640625,
-0.33203125,
0.059844970703125,
-0.62109375,
0.55859375,
0.283447265625,
0.223388671875,
0.332763671875,
0.03179931640625,
-0.318603515625,
-0.6591796875,
-0.025115966796875,
-0.67236328125,
0.38427734375,
-0.337158203125,
-0.2408447265625,
-0.79150390625,
-0.79345703125,
-0.266845703125,
0.163818359375,
-0.3154296875,
-0.810546875,
0.310791015625,
0.1622314453125,
0.47265625,
0.08843994140625,
-0.40625,
0.5888671875,
0.84912109375,
0.9580078125,
0.0152435302734375,
0.81982421875,
0.408203125,
-0.312255859375,
0.1485595703125,
-0.271728515625,
0.358154296875,
-0.5556640625,
0.149169921875,
-0.275634765625,
0.392333984375,
-0.5654296875,
-1.25390625,
-0.107177734375,
0.6513671875,
0.2200927734375,
-0.71142578125,
-1.11328125,
-0.6953125,
-0.607421875,
0.359130859375,
-0.74853515625,
0.427734375,
-0.0263824462890625,
0.252197265625,
-0.1943359375,
-0.9189453125,
4.4453125,
1.0087890625,
1.166015625,
0.458984375,
0.09454345703125,
0.88427734375,
0.421875,
-0.26220703125,
-0.05169677734375,
-0.72802734375,
0.3623046875,
-0.2822265625,
-0.154296875,
0.96875,
0.345947265625,
0.7490234375,
-0.841796875,
-0.316162109375,
0.10302734375,
-0.63720703125,
-0.794921875,
0.1328125,
-0.464111328125,
0.1409912109375,
-0.187255859375,
0.43017578125,
0.75146484375,
-0.95458984375,
-0.39990234375,
-0.2744140625,
0.203857421875,
-0.6953125,
1.15234375,
-0.324951171875,
-0.2197265625,
0.415283203125,
-0.16748046875,
-0.5595703125,
-0.1197509765625,
0.4921875,
0.155029296875,
0.45947265625,
0.9970703125,
-0.2244873046875,
0.50732421875,
0.5732421875,
-0.54248046875,
0.0748291015625,
-0.23388671875,
-0.8701171875,
1.0458984375,
-0.338134765625,
0.357177734375,
-0.411865234375,
-0.91259765625,
0.2447509765625,
-0.08502197265625,
-0.2978515625,
-0.12646484375,
0.2333984375,
0.1697998046875,
0.053192138671875,
-0.09320068359375,
0.373291015625,
-1.048828125,
0.62451171875,
0.0439453125,
0.2122802734375,
-0.60546875,
-0.3583984375,
-0.23388671875,
-0.214599609375,
-0.2108154296875,
-0.455810546875,
0.42333984375,
0.2183837890625,
0.004878997802734375,
0.308349609375,
0.68896484375,
-0.78076171875,
-0.036346435546875,
-0.252685546875,
-0.53564453125,
-0.67138671875,
0.7421875,
0.98193359375,
-0.69970703125,
-0.53759765625,
-0.2410888671875,
0.37255859375,
0.615234375,
0.449951171875,
0.404052734375,
-0.1142578125,
-0.255859375
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Submitted Solution:
```
###### ### ####### ####### ## # ##### ### #####
# # # # # # # # # # # # # ###
# # # # # # # # # # # # # ###
###### ######### # # # # # # ######### #
###### ######### # # # # # # ######### #
# # # # # # # # # # #### # # #
# # # # # # # ## # # # # #
###### # # ####### ####### # # ##### # # # #
from __future__ import print_function # for PyPy2
from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1e9)+7
inf = float("inf")
# range = xrange
def topologicalSort(adj, n):
'''
Nodes are based on 1-based Indexing [1, n]
return's Empty array if topological sort not possible
'''
ans = []
isExplored = [0]*(n+1)
vis = [0]*(n+1)
for i in range(1, n+1):
if isExplored[i]:
continue
stack = [i]
while stack:
p = stack[-1]
if vis[p] or isExplored[p]:
if not isExplored[p]:
isExplored[p] = 1
ans.append(stack.pop())
else:
stack.pop()
else:
vis[p] = 1
for c in adj[p]:
if isExplored[c]:
pass
elif vis[c]:
return []
else:
stack.append(c)
return ans
def getNode(ch):
return ord(ch)-96
def getDiffChar(sx, sy):
for i in range(min(len(sx), len(sy))):
if sx[i] != sy[i]:
# print(sx[i], sy[i])
return (getNode(sx[i]), getNode(sy[i]))
return (0, 0)
n, = gil()
words = []
adj = [[] for _ in range(27)]
for _ in range(n):
words.append(g())
for i in range(n):
for j in range(i+1, n):
x, y = getDiffChar(words[i], words[j])
# print(x, y)
if x!=y:
adj[y].append(x)
elif len(words[i]) > len(words[j]):
print("Impossible")
exit()
# print(adj)
ans = topologicalSort(adj, 26)
if len(ans) != 26:
print("Impossible")
else:
for i in ans:
print(chr(i+96), end="")
print()
```
Yes
| 72,050 | [
-0.0347900390625,
-0.2958984375,
0.419677734375,
-0.2406005859375,
-0.400634765625,
-0.288330078125,
-0.093994140625,
0.26318359375,
0.09747314453125,
0.603515625,
0.6552734375,
0.0177154541015625,
0.22216796875,
-0.8720703125,
-0.8095703125,
0.137939453125,
-0.180419921875,
-0.413330078125,
-0.04302978515625,
-0.1639404296875,
0.428955078125,
0.2188720703125,
-1.6826171875,
0.10687255859375,
-0.583984375,
0.9892578125,
0.53173828125,
0.1768798828125,
1.2421875,
0.92578125,
-0.077880859375,
-0.40576171875,
0.5224609375,
-0.82763671875,
-0.211181640625,
-0.303955078125,
0.67822265625,
-0.51220703125,
-0.1773681640625,
-0.7197265625,
0.421875,
-0.67822265625,
0.406494140625,
-0.81591796875,
-0.89697265625,
-0.347412109375,
-0.1845703125,
-0.2103271484375,
-0.45263671875,
-1.2236328125,
0.2249755859375,
-0.2197265625,
0.62353515625,
-0.499755859375,
-0.10601806640625,
0.102294921875,
0.341796875,
0.0197296142578125,
-0.495849609375,
0.3818359375,
0.015960693359375,
0.351806640625,
-0.383056640625,
-0.63330078125,
-0.33447265625,
0.253662109375,
0.141357421875,
-0.1221923828125,
0.1630859375,
-0.49853515625,
-0.2242431640625,
0.312255859375,
-0.34765625,
0.06622314453125,
-0.51171875,
0.08294677734375,
-0.1854248046875,
-0.1673583984375,
-0.484375,
0.59765625,
0.26416015625,
0.6728515625,
0.1380615234375,
0.366943359375,
-0.2724609375,
-0.30517578125,
-0.006076812744140625,
0.1400146484375,
0.26123046875,
0.1253662109375,
0.2259521484375,
0.359619140625,
-0.7763671875,
-0.284912109375,
0.472900390625,
0.53271484375,
-0.0203857421875,
0.252685546875,
0.10882568359375,
0.1519775390625,
0.96142578125,
1.19140625,
-0.1544189453125,
0.98291015625,
-0.75439453125,
0.12274169921875,
-0.11260986328125,
-0.2318115234375,
0.11370849609375,
-0.34033203125,
-0.1241455078125,
-0.289794921875,
0.1488037109375,
0.22802734375,
0.0005865097045898438,
0.6865234375,
-0.423828125,
0.428466796875,
-0.86962890625,
-0.1019287109375,
0.497802734375,
0.043243408203125,
0.01403045654296875,
0.06243896484375,
0.39111328125,
-0.266845703125,
-0.266357421875,
0.90380859375,
-0.435302734375,
-0.08660888671875,
0.474609375,
-0.10601806640625,
-0.5556640625,
0.2481689453125,
-0.1397705078125,
0.74560546875,
-0.03253173828125,
0.476318359375,
0.5791015625,
-0.498291015625,
0.63916015625,
-0.0911865234375,
0.0460205078125,
1.5751953125,
-0.060333251953125,
-0.2724609375,
0.298828125,
0.2093505859375,
-0.7548828125,
0.517578125,
-0.99755859375,
0.78271484375,
0.2447509765625,
0.2386474609375,
-0.53271484375,
0.419677734375,
-0.1954345703125,
0.382568359375,
0.615234375,
0.56591796875,
-0.33203125,
-0.1103515625,
-0.212890625,
0.98828125,
-0.3076171875,
1.0341796875,
-0.5234375,
-0.0975341796875,
0.04864501953125,
-0.1348876953125,
0.066162109375,
0.0762939453125,
-0.367431640625,
1.046875,
0.307373046875,
0.83642578125,
0.416015625,
-0.378662109375,
0.12127685546875,
0.1669921875,
-0.359130859375,
0.42822265625,
0.0236053466796875,
0.8271484375,
0.1929931640625,
0.2078857421875,
0.2841796875,
-0.72216796875,
-0.30908203125,
-0.6884765625,
-0.222900390625,
0.79443359375,
-0.5009765625,
0.408447265625,
-0.0689697265625,
-0.1278076171875,
-0.62451171875,
0.1302490234375,
0.8681640625,
-0.947265625,
-0.2325439453125,
0.5703125,
-0.183837890625,
0.6025390625,
-0.71337890625,
-0.53662109375,
0.371337890625,
1.0849609375,
0.0574951171875,
0.037017822265625,
0.238037109375,
0.23828125,
-0.48828125,
0.0780029296875,
0.31982421875,
-0.036865234375,
-0.427734375,
0.59814453125,
-0.425048828125,
-0.15380859375,
0.268310546875,
0.908203125,
0.802734375,
0.25146484375,
-0.27685546875,
-0.0227203369140625,
1.01171875,
1.3388671875,
-0.326171875,
0.07818603515625,
0.09735107421875,
1.0947265625,
0.3623046875,
0.6923828125,
0.56103515625,
-0.0753173828125,
0.80615234375,
0.58447265625,
-0.391845703125,
0.0987548828125,
0.03424072265625,
0.587890625,
0.70751953125,
0.65625,
-0.1058349609375,
0.45849609375,
-0.1751708984375,
0.1563720703125,
-0.281005859375,
0.6513671875,
0.18505859375,
0.85546875,
0.06396484375,
0.31494140625,
-0.479736328125,
-0.525390625,
-0.2001953125,
0.51318359375,
-0.96630859375,
-0.70166015625,
-0.32763671875,
-0.1954345703125,
0.07611083984375,
0.033935546875,
0.1790771484375,
0.19189453125,
0.347412109375,
0.30322265625,
-0.24755859375,
-0.6416015625,
-0.984375,
-0.869140625,
-1.2646484375,
-0.343505859375,
-0.73193359375,
-0.023162841796875,
0.32080078125,
-0.472412109375,
0.419189453125,
-0.2568359375,
-0.1495361328125,
0.34375,
-0.458740234375,
0.6435546875,
0.09197998046875,
0.83642578125,
-0.55419921875,
0.164306640625,
-0.199462890625,
1.1845703125,
-0.64404296875,
-0.1546630859375,
-0.50927734375,
-0.6962890625,
0.458740234375,
0.442138671875,
0.57861328125,
0.06024169921875,
-0.59033203125,
-1.15625,
-0.54052734375,
0.06304931640625,
-0.8876953125,
0.2490234375,
-0.73681640625,
1.0263671875,
0.10906982421875,
-0.681640625,
0.40771484375,
0.76171875,
-0.7451171875,
0.84716796875,
0.471435546875,
0.188232421875,
-0.87548828125,
1.49609375,
0.07525634765625,
0.47998046875,
-0.4697265625,
-0.484130859375,
-0.428955078125,
0.29638671875,
0.7529296875,
-1.0107421875,
-0.09112548828125,
0.78759765625,
-0.0080413818359375,
-1.1474609375,
0.7333984375,
-0.8271484375,
-0.7119140625,
-0.0684814453125,
-0.6455078125,
0.68212890625,
0.83837890625,
0.5908203125,
0.1959228515625,
-0.37451171875,
-0.2025146484375,
0.56884765625,
-0.033966064453125,
-0.6259765625,
-0.2252197265625,
0.428955078125,
-0.1868896484375,
-0.156982421875,
0.162353515625,
-0.39208984375,
-0.08416748046875,
-0.05023193359375,
-0.174560546875,
0.9970703125,
0.1295166015625,
0.18603515625,
-0.054168701171875,
0.87060546875,
-0.74365234375,
-0.496337890625,
-0.52685546875,
0.7265625,
0.6279296875,
0.425537109375,
0.455810546875,
-0.12109375,
-0.43212890625,
-0.81884765625,
0.277099609375,
-0.003963470458984375,
0.63134765625,
-0.67041015625,
0.830078125,
0.2017822265625,
-0.56103515625,
0.431884765625,
-0.80517578125,
-0.25146484375,
1.33203125,
-0.298828125,
0.83251953125,
-0.626953125,
0.09320068359375,
-0.3017578125,
0.359619140625,
0.44775390625,
0.2314453125,
0.67333984375,
-0.413330078125,
0.00014770030975341797,
-0.391357421875,
-0.499755859375,
0.15283203125,
-0.75048828125,
0.084228515625,
-0.105224609375,
-0.440185546875,
-0.8916015625,
0.72119140625,
0.5283203125,
0.1832275390625,
0.1519775390625,
0.70068359375,
0.1890869140625,
0.293701171875,
1.01171875,
-0.34521484375,
0.1781005859375,
-0.65087890625,
0.8720703125,
0.26416015625,
-0.153076171875,
-0.0038909912109375,
-0.01934814453125,
-0.12060546875,
0.153564453125,
-0.1595458984375,
-0.150634765625,
-0.7548828125,
0.236083984375,
0.2239990234375,
0.71484375,
-0.54150390625,
-0.5712890625,
-0.1719970703125,
0.58251953125,
0.318115234375,
-0.5927734375,
0.1116943359375,
-0.69970703125,
0.308349609375,
0.5927734375,
-0.124267578125,
-0.521484375,
-0.57763671875,
-1.318359375,
-0.450927734375,
0.60546875,
0.4013671875,
0.08184814453125,
-0.11737060546875,
-0.8779296875,
0.716796875,
0.10693359375,
-0.291259765625,
0.1651611328125,
-0.293701171875,
-0.0293426513671875,
-0.1441650390625,
0.55908203125,
0.035247802734375,
-0.72265625,
0.326171875,
-1.095703125,
0.6103515625,
-0.8203125,
0.54931640625,
0.056121826171875,
0.1942138671875,
-0.1727294921875,
0.38037109375,
-0.487548828125,
-0.05755615234375,
-0.306396484375,
0.55029296875,
-1.052734375,
-0.7666015625,
0.73046875,
0.04656982421875,
0.03582763671875,
0.71533203125,
-0.09442138671875,
-0.5791015625,
0.177978515625,
0.28759765625,
-0.54150390625,
0.381591796875,
-0.309326171875,
0.2142333984375,
-0.45166015625,
-0.367431640625,
-0.07562255859375,
-0.392333984375,
0.701171875,
0.23486328125,
-0.78125,
-0.47119140625,
-0.99169921875,
0.0298309326171875,
-0.198974609375,
-0.61328125,
0.31201171875,
-0.1644287109375,
-0.27587890625,
-0.340576171875,
-0.3232421875,
-0.69677734375,
-0.032562255859375,
-0.5908203125,
-0.318115234375,
0.194580078125,
0.346435546875,
0.57861328125,
0.1263427734375,
-0.31396484375,
0.0266571044921875,
-0.302490234375,
-0.039031982421875,
-0.316162109375,
-0.1630859375,
-0.071044921875,
-0.378173828125,
-0.295166015625,
-0.03021240234375,
0.368896484375,
0.278564453125,
0.2978515625,
0.2476806640625,
0.421142578125,
0.51513671875,
-0.56494140625,
0.74169921875,
-0.037933349609375,
-0.79541015625,
-0.45361328125,
0.497314453125,
-0.1021728515625,
0.96435546875,
0.2607421875,
-1.2275390625,
-0.810546875,
-1.314453125,
0.03350830078125,
-0.3173828125,
-0.240478515625,
-0.87158203125,
0.031585693359375,
-0.51904296875,
0.2286376953125,
-0.204833984375,
-0.498779296875,
0.10089111328125,
-1.380859375,
0.1082763671875,
-0.71875,
-0.56005859375,
-0.398681640625,
-0.48828125,
-0.186767578125,
0.97705078125,
0.34423828125,
0.280029296875,
0.1612548828125,
0.11712646484375,
-0.06292724609375,
-0.272216796875,
-0.91162109375,
-0.5078125,
0.0543212890625,
0.2105712890625,
0.0626220703125,
-0.06036376953125,
-0.452880859375,
0.84765625,
-0.9482421875,
-0.0338134765625,
-0.1798095703125,
-0.276611328125,
-0.07379150390625,
-0.281005859375,
1.1865234375,
-0.40576171875,
-0.01451873779296875,
-0.08367919921875,
0.455322265625,
0.52392578125,
-0.37548828125,
-0.349365234375,
-0.60888671875,
-0.3623046875,
-1.0009765625,
0.68359375,
-0.7119140625,
0.15576171875,
-0.64794921875,
-0.271728515625,
1.23828125,
-0.90673828125,
0.51220703125,
0.859375,
0.0194549560546875,
0.132080078125,
-0.8154296875,
0.5771484375,
0.51220703125,
-0.484130859375,
-0.08782958984375,
0.1629638671875,
-0.55126953125,
0.29931640625,
0.07061767578125,
-1.0341796875,
-0.708984375,
0.61279296875,
1.251953125,
-0.1591796875,
0.6845703125,
-0.143310546875,
-0.449951171875,
-0.4365234375,
1.0234375,
-0.150634765625,
0.057861328125,
1.015625,
-0.5234375,
-0.38232421875,
0.18212890625,
-0.0287628173828125,
-0.51123046875,
-0.406494140625,
1.56640625,
-0.1943359375,
-0.287841796875,
1.056640625,
0.796875,
-0.7216796875,
-0.5615234375,
-0.3134765625,
0.3525390625,
0.0262908935546875,
-0.74658203125,
0.30029296875,
0.59326171875,
-0.7353515625,
-0.152099609375,
0.473876953125,
-0.1927490234375,
0.356201171875,
0.0732421875,
0.4794921875,
-0.3798828125,
0.2337646484375,
0.6982421875,
-0.7197265625,
-0.1160888671875,
-1.0859375,
0.3134765625,
-0.2076416015625,
-0.43994140625,
0.76123046875,
-0.26611328125,
0.483642578125,
0.91552734375,
-0.238037109375,
0.52880859375,
-0.69873046875,
-0.486083984375,
0.1827392578125,
-0.95947265625,
-0.68896484375,
-0.452392578125,
0.51953125,
-0.1358642578125,
0.23046875,
-1.0888671875,
0.2171630859375,
0.50537109375,
0.361572265625,
-0.52783203125,
-0.7109375,
-0.037384033203125,
-0.865234375,
-0.486572265625,
-0.490966796875,
-0.56640625,
-0.2578125,
-0.034515380859375,
0.02105712890625,
-0.53369140625,
0.334228515625,
0.41796875,
-0.264404296875,
0.791015625,
-0.5283203125,
0.43017578125,
-0.73876953125,
-0.2301025390625,
-0.59326171875,
0.0404052734375,
-0.332763671875,
-0.0394287109375,
-0.432861328125,
0.2071533203125,
0.449462890625,
0.25146484375,
-0.028594970703125,
-0.207275390625,
-0.481201171875,
-0.59912109375,
-0.1201171875,
0.2060546875,
-0.5302734375,
0.75,
0.39697265625,
0.2132568359375,
0.74365234375,
-0.2147216796875,
-0.4775390625,
0.1177978515625,
0.7197265625,
0.63671875,
-0.300048828125,
-0.09552001953125,
-0.1646728515625,
-0.037109375,
-0.79638671875,
0.08660888671875,
-0.0290985107421875,
0.256103515625,
0.021881103515625,
-0.2841796875,
0.364501953125,
1.13671875,
0.02264404296875,
0.7099609375,
0.2415771484375,
0.25830078125,
0.29345703125,
-0.48291015625,
-0.062286376953125,
0.467041015625,
0.1373291015625,
-0.357666015625,
-0.0178680419921875,
0.513671875,
-0.0211944580078125,
0.326171875,
0.06488037109375,
-0.95849609375,
-1.220703125,
-0.366943359375,
0.11962890625,
0.49560546875,
0.65234375,
-0.442626953125,
-0.2205810546875,
-0.455810546875,
-0.85595703125,
0.5966796875,
-1.1982421875,
-0.71875,
0.55078125,
-0.25830078125,
-0.72607421875,
-0.08673095703125,
-0.53369140625,
0.1290283203125,
0.1365966796875,
0.3681640625,
-0.66845703125,
0.044677734375,
0.2607421875,
0.461669921875,
-0.27685546875,
-0.2449951171875,
-0.055389404296875,
0.309814453125,
-0.364501953125,
-0.2120361328125,
0.37353515625,
1.0380859375,
0.1441650390625,
-0.05743408203125,
-0.79736328125,
0.149658203125,
0.49462890625,
0.01013946533203125,
-0.342041015625,
-0.0168914794921875,
-0.63525390625,
0.68359375,
-0.67919921875,
-0.0321044921875,
-0.01690673828125,
0.163818359375,
0.0740966796875,
-0.428955078125,
-0.556640625,
0.84375,
1.130859375,
-0.25537109375,
0.462158203125,
0.053863525390625,
0.2186279296875,
-0.258544921875,
-0.1513671875,
-0.42822265625,
0.464599609375,
0.1737060546875,
0.4736328125,
-0.0316162109375,
0.77392578125,
0.798828125,
-0.12152099609375,
0.279296875,
0.365234375,
0.0596923828125,
-0.0328369140625,
0.006931304931640625,
-0.064208984375,
0.2724609375,
0.466796875,
-0.6240234375,
0.369384765625,
-0.80517578125,
-0.2286376953125,
-0.08624267578125,
-0.61474609375,
0.82861328125,
-0.9697265625,
-0.061187744140625,
-0.1759033203125,
-0.48291015625,
0.31689453125,
0.74951171875,
0.483154296875,
-0.0011968612670898438,
0.62646484375,
0.888671875,
0.313232421875,
1.044921875,
0.61962890625,
0.2783203125,
-0.79931640625,
0.163330078125,
0.2626953125,
-0.252685546875,
-0.37841796875,
-0.195556640625,
-0.8193359375,
0.53125,
-0.014739990234375,
-0.44091796875,
0.388916015625,
-0.7919921875,
-0.24755859375,
0.09814453125,
0.84033203125,
-0.413330078125,
0.4462890625,
0.0875244140625,
-0.393798828125,
-0.7783203125,
0.939453125,
-0.049560546875,
0.325927734375,
0.23974609375,
0.83349609375,
-0.01030731201171875,
1.1455078125,
0.4306640625,
-0.251220703125,
0.0626220703125,
0.1103515625,
-0.3310546875,
-0.92236328125,
-0.2548828125,
-0.572265625,
0.16552734375,
-0.368408203125,
-0.08172607421875,
-0.0230712890625,
0.64111328125,
0.0033283233642578125,
-0.9306640625,
-0.33203125,
0.059844970703125,
-0.62109375,
0.55859375,
0.283447265625,
0.223388671875,
0.332763671875,
0.03179931640625,
-0.318603515625,
-0.6591796875,
-0.025115966796875,
-0.67236328125,
0.38427734375,
-0.337158203125,
-0.2408447265625,
-0.79150390625,
-0.79345703125,
-0.266845703125,
0.163818359375,
-0.3154296875,
-0.810546875,
0.310791015625,
0.1622314453125,
0.47265625,
0.08843994140625,
-0.40625,
0.5888671875,
0.84912109375,
0.9580078125,
0.0152435302734375,
0.81982421875,
0.408203125,
-0.312255859375,
0.1485595703125,
-0.271728515625,
0.358154296875,
-0.5556640625,
0.149169921875,
-0.275634765625,
0.392333984375,
-0.5654296875,
-1.25390625,
-0.107177734375,
0.6513671875,
0.2200927734375,
-0.71142578125,
-1.11328125,
-0.6953125,
-0.607421875,
0.359130859375,
-0.74853515625,
0.427734375,
-0.0263824462890625,
0.252197265625,
-0.1943359375,
-0.9189453125,
4.4453125,
1.0087890625,
1.166015625,
0.458984375,
0.09454345703125,
0.88427734375,
0.421875,
-0.26220703125,
-0.05169677734375,
-0.72802734375,
0.3623046875,
-0.2822265625,
-0.154296875,
0.96875,
0.345947265625,
0.7490234375,
-0.841796875,
-0.316162109375,
0.10302734375,
-0.63720703125,
-0.794921875,
0.1328125,
-0.464111328125,
0.1409912109375,
-0.187255859375,
0.43017578125,
0.75146484375,
-0.95458984375,
-0.39990234375,
-0.2744140625,
0.203857421875,
-0.6953125,
1.15234375,
-0.324951171875,
-0.2197265625,
0.415283203125,
-0.16748046875,
-0.5595703125,
-0.1197509765625,
0.4921875,
0.155029296875,
0.45947265625,
0.9970703125,
-0.2244873046875,
0.50732421875,
0.5732421875,
-0.54248046875,
0.0748291015625,
-0.23388671875,
-0.8701171875,
1.0458984375,
-0.338134765625,
0.357177734375,
-0.411865234375,
-0.91259765625,
0.2447509765625,
-0.08502197265625,
-0.2978515625,
-0.12646484375,
0.2333984375,
0.1697998046875,
0.053192138671875,
-0.09320068359375,
0.373291015625,
-1.048828125,
0.62451171875,
0.0439453125,
0.2122802734375,
-0.60546875,
-0.3583984375,
-0.23388671875,
-0.214599609375,
-0.2108154296875,
-0.455810546875,
0.42333984375,
0.2183837890625,
0.004878997802734375,
0.308349609375,
0.68896484375,
-0.78076171875,
-0.036346435546875,
-0.252685546875,
-0.53564453125,
-0.67138671875,
0.7421875,
0.98193359375,
-0.69970703125,
-0.53759765625,
-0.2410888671875,
0.37255859375,
0.615234375,
0.449951171875,
0.404052734375,
-0.1142578125,
-0.255859375
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Submitted Solution:
```
import string
import sys
from collections import defaultdict
num_names = int(input())
names = [input() for _ in range(num_names)]
adj_list = {c: [] for c in string.ascii_lowercase}
in_degree = {c: 0 for c in string.ascii_lowercase}
for a, b in zip(names[:-1], names[1:]):
have_prefix = True
for i, j in zip(a, b):
if i != j:
adj_list[i].append(j)
in_degree[j] += 1
have_prefix = False
break
if have_prefix and len(b) < len(a):
print('Impossible')
sys.exit(0)
alphabet = ''
zeros = [u for u in in_degree if in_degree[u] == 0]
while zeros:
u = zeros.pop()
alphabet += u
for v in adj_list[u]:
in_degree[v] -= 1
if in_degree[v] == 0:
zeros.append(v)
if len(alphabet) == 26:
print(alphabet)
else:
print('Impossible')
```
Yes
| 72,051 | [
-0.0347900390625,
-0.2958984375,
0.419677734375,
-0.2406005859375,
-0.400634765625,
-0.288330078125,
-0.093994140625,
0.26318359375,
0.09747314453125,
0.603515625,
0.6552734375,
0.0177154541015625,
0.22216796875,
-0.8720703125,
-0.8095703125,
0.137939453125,
-0.180419921875,
-0.413330078125,
-0.04302978515625,
-0.1639404296875,
0.428955078125,
0.2188720703125,
-1.6826171875,
0.10687255859375,
-0.583984375,
0.9892578125,
0.53173828125,
0.1768798828125,
1.2421875,
0.92578125,
-0.077880859375,
-0.40576171875,
0.5224609375,
-0.82763671875,
-0.211181640625,
-0.303955078125,
0.67822265625,
-0.51220703125,
-0.1773681640625,
-0.7197265625,
0.421875,
-0.67822265625,
0.406494140625,
-0.81591796875,
-0.89697265625,
-0.347412109375,
-0.1845703125,
-0.2103271484375,
-0.45263671875,
-1.2236328125,
0.2249755859375,
-0.2197265625,
0.62353515625,
-0.499755859375,
-0.10601806640625,
0.102294921875,
0.341796875,
0.0197296142578125,
-0.495849609375,
0.3818359375,
0.015960693359375,
0.351806640625,
-0.383056640625,
-0.63330078125,
-0.33447265625,
0.253662109375,
0.141357421875,
-0.1221923828125,
0.1630859375,
-0.49853515625,
-0.2242431640625,
0.312255859375,
-0.34765625,
0.06622314453125,
-0.51171875,
0.08294677734375,
-0.1854248046875,
-0.1673583984375,
-0.484375,
0.59765625,
0.26416015625,
0.6728515625,
0.1380615234375,
0.366943359375,
-0.2724609375,
-0.30517578125,
-0.006076812744140625,
0.1400146484375,
0.26123046875,
0.1253662109375,
0.2259521484375,
0.359619140625,
-0.7763671875,
-0.284912109375,
0.472900390625,
0.53271484375,
-0.0203857421875,
0.252685546875,
0.10882568359375,
0.1519775390625,
0.96142578125,
1.19140625,
-0.1544189453125,
0.98291015625,
-0.75439453125,
0.12274169921875,
-0.11260986328125,
-0.2318115234375,
0.11370849609375,
-0.34033203125,
-0.1241455078125,
-0.289794921875,
0.1488037109375,
0.22802734375,
0.0005865097045898438,
0.6865234375,
-0.423828125,
0.428466796875,
-0.86962890625,
-0.1019287109375,
0.497802734375,
0.043243408203125,
0.01403045654296875,
0.06243896484375,
0.39111328125,
-0.266845703125,
-0.266357421875,
0.90380859375,
-0.435302734375,
-0.08660888671875,
0.474609375,
-0.10601806640625,
-0.5556640625,
0.2481689453125,
-0.1397705078125,
0.74560546875,
-0.03253173828125,
0.476318359375,
0.5791015625,
-0.498291015625,
0.63916015625,
-0.0911865234375,
0.0460205078125,
1.5751953125,
-0.060333251953125,
-0.2724609375,
0.298828125,
0.2093505859375,
-0.7548828125,
0.517578125,
-0.99755859375,
0.78271484375,
0.2447509765625,
0.2386474609375,
-0.53271484375,
0.419677734375,
-0.1954345703125,
0.382568359375,
0.615234375,
0.56591796875,
-0.33203125,
-0.1103515625,
-0.212890625,
0.98828125,
-0.3076171875,
1.0341796875,
-0.5234375,
-0.0975341796875,
0.04864501953125,
-0.1348876953125,
0.066162109375,
0.0762939453125,
-0.367431640625,
1.046875,
0.307373046875,
0.83642578125,
0.416015625,
-0.378662109375,
0.12127685546875,
0.1669921875,
-0.359130859375,
0.42822265625,
0.0236053466796875,
0.8271484375,
0.1929931640625,
0.2078857421875,
0.2841796875,
-0.72216796875,
-0.30908203125,
-0.6884765625,
-0.222900390625,
0.79443359375,
-0.5009765625,
0.408447265625,
-0.0689697265625,
-0.1278076171875,
-0.62451171875,
0.1302490234375,
0.8681640625,
-0.947265625,
-0.2325439453125,
0.5703125,
-0.183837890625,
0.6025390625,
-0.71337890625,
-0.53662109375,
0.371337890625,
1.0849609375,
0.0574951171875,
0.037017822265625,
0.238037109375,
0.23828125,
-0.48828125,
0.0780029296875,
0.31982421875,
-0.036865234375,
-0.427734375,
0.59814453125,
-0.425048828125,
-0.15380859375,
0.268310546875,
0.908203125,
0.802734375,
0.25146484375,
-0.27685546875,
-0.0227203369140625,
1.01171875,
1.3388671875,
-0.326171875,
0.07818603515625,
0.09735107421875,
1.0947265625,
0.3623046875,
0.6923828125,
0.56103515625,
-0.0753173828125,
0.80615234375,
0.58447265625,
-0.391845703125,
0.0987548828125,
0.03424072265625,
0.587890625,
0.70751953125,
0.65625,
-0.1058349609375,
0.45849609375,
-0.1751708984375,
0.1563720703125,
-0.281005859375,
0.6513671875,
0.18505859375,
0.85546875,
0.06396484375,
0.31494140625,
-0.479736328125,
-0.525390625,
-0.2001953125,
0.51318359375,
-0.96630859375,
-0.70166015625,
-0.32763671875,
-0.1954345703125,
0.07611083984375,
0.033935546875,
0.1790771484375,
0.19189453125,
0.347412109375,
0.30322265625,
-0.24755859375,
-0.6416015625,
-0.984375,
-0.869140625,
-1.2646484375,
-0.343505859375,
-0.73193359375,
-0.023162841796875,
0.32080078125,
-0.472412109375,
0.419189453125,
-0.2568359375,
-0.1495361328125,
0.34375,
-0.458740234375,
0.6435546875,
0.09197998046875,
0.83642578125,
-0.55419921875,
0.164306640625,
-0.199462890625,
1.1845703125,
-0.64404296875,
-0.1546630859375,
-0.50927734375,
-0.6962890625,
0.458740234375,
0.442138671875,
0.57861328125,
0.06024169921875,
-0.59033203125,
-1.15625,
-0.54052734375,
0.06304931640625,
-0.8876953125,
0.2490234375,
-0.73681640625,
1.0263671875,
0.10906982421875,
-0.681640625,
0.40771484375,
0.76171875,
-0.7451171875,
0.84716796875,
0.471435546875,
0.188232421875,
-0.87548828125,
1.49609375,
0.07525634765625,
0.47998046875,
-0.4697265625,
-0.484130859375,
-0.428955078125,
0.29638671875,
0.7529296875,
-1.0107421875,
-0.09112548828125,
0.78759765625,
-0.0080413818359375,
-1.1474609375,
0.7333984375,
-0.8271484375,
-0.7119140625,
-0.0684814453125,
-0.6455078125,
0.68212890625,
0.83837890625,
0.5908203125,
0.1959228515625,
-0.37451171875,
-0.2025146484375,
0.56884765625,
-0.033966064453125,
-0.6259765625,
-0.2252197265625,
0.428955078125,
-0.1868896484375,
-0.156982421875,
0.162353515625,
-0.39208984375,
-0.08416748046875,
-0.05023193359375,
-0.174560546875,
0.9970703125,
0.1295166015625,
0.18603515625,
-0.054168701171875,
0.87060546875,
-0.74365234375,
-0.496337890625,
-0.52685546875,
0.7265625,
0.6279296875,
0.425537109375,
0.455810546875,
-0.12109375,
-0.43212890625,
-0.81884765625,
0.277099609375,
-0.003963470458984375,
0.63134765625,
-0.67041015625,
0.830078125,
0.2017822265625,
-0.56103515625,
0.431884765625,
-0.80517578125,
-0.25146484375,
1.33203125,
-0.298828125,
0.83251953125,
-0.626953125,
0.09320068359375,
-0.3017578125,
0.359619140625,
0.44775390625,
0.2314453125,
0.67333984375,
-0.413330078125,
0.00014770030975341797,
-0.391357421875,
-0.499755859375,
0.15283203125,
-0.75048828125,
0.084228515625,
-0.105224609375,
-0.440185546875,
-0.8916015625,
0.72119140625,
0.5283203125,
0.1832275390625,
0.1519775390625,
0.70068359375,
0.1890869140625,
0.293701171875,
1.01171875,
-0.34521484375,
0.1781005859375,
-0.65087890625,
0.8720703125,
0.26416015625,
-0.153076171875,
-0.0038909912109375,
-0.01934814453125,
-0.12060546875,
0.153564453125,
-0.1595458984375,
-0.150634765625,
-0.7548828125,
0.236083984375,
0.2239990234375,
0.71484375,
-0.54150390625,
-0.5712890625,
-0.1719970703125,
0.58251953125,
0.318115234375,
-0.5927734375,
0.1116943359375,
-0.69970703125,
0.308349609375,
0.5927734375,
-0.124267578125,
-0.521484375,
-0.57763671875,
-1.318359375,
-0.450927734375,
0.60546875,
0.4013671875,
0.08184814453125,
-0.11737060546875,
-0.8779296875,
0.716796875,
0.10693359375,
-0.291259765625,
0.1651611328125,
-0.293701171875,
-0.0293426513671875,
-0.1441650390625,
0.55908203125,
0.035247802734375,
-0.72265625,
0.326171875,
-1.095703125,
0.6103515625,
-0.8203125,
0.54931640625,
0.056121826171875,
0.1942138671875,
-0.1727294921875,
0.38037109375,
-0.487548828125,
-0.05755615234375,
-0.306396484375,
0.55029296875,
-1.052734375,
-0.7666015625,
0.73046875,
0.04656982421875,
0.03582763671875,
0.71533203125,
-0.09442138671875,
-0.5791015625,
0.177978515625,
0.28759765625,
-0.54150390625,
0.381591796875,
-0.309326171875,
0.2142333984375,
-0.45166015625,
-0.367431640625,
-0.07562255859375,
-0.392333984375,
0.701171875,
0.23486328125,
-0.78125,
-0.47119140625,
-0.99169921875,
0.0298309326171875,
-0.198974609375,
-0.61328125,
0.31201171875,
-0.1644287109375,
-0.27587890625,
-0.340576171875,
-0.3232421875,
-0.69677734375,
-0.032562255859375,
-0.5908203125,
-0.318115234375,
0.194580078125,
0.346435546875,
0.57861328125,
0.1263427734375,
-0.31396484375,
0.0266571044921875,
-0.302490234375,
-0.039031982421875,
-0.316162109375,
-0.1630859375,
-0.071044921875,
-0.378173828125,
-0.295166015625,
-0.03021240234375,
0.368896484375,
0.278564453125,
0.2978515625,
0.2476806640625,
0.421142578125,
0.51513671875,
-0.56494140625,
0.74169921875,
-0.037933349609375,
-0.79541015625,
-0.45361328125,
0.497314453125,
-0.1021728515625,
0.96435546875,
0.2607421875,
-1.2275390625,
-0.810546875,
-1.314453125,
0.03350830078125,
-0.3173828125,
-0.240478515625,
-0.87158203125,
0.031585693359375,
-0.51904296875,
0.2286376953125,
-0.204833984375,
-0.498779296875,
0.10089111328125,
-1.380859375,
0.1082763671875,
-0.71875,
-0.56005859375,
-0.398681640625,
-0.48828125,
-0.186767578125,
0.97705078125,
0.34423828125,
0.280029296875,
0.1612548828125,
0.11712646484375,
-0.06292724609375,
-0.272216796875,
-0.91162109375,
-0.5078125,
0.0543212890625,
0.2105712890625,
0.0626220703125,
-0.06036376953125,
-0.452880859375,
0.84765625,
-0.9482421875,
-0.0338134765625,
-0.1798095703125,
-0.276611328125,
-0.07379150390625,
-0.281005859375,
1.1865234375,
-0.40576171875,
-0.01451873779296875,
-0.08367919921875,
0.455322265625,
0.52392578125,
-0.37548828125,
-0.349365234375,
-0.60888671875,
-0.3623046875,
-1.0009765625,
0.68359375,
-0.7119140625,
0.15576171875,
-0.64794921875,
-0.271728515625,
1.23828125,
-0.90673828125,
0.51220703125,
0.859375,
0.0194549560546875,
0.132080078125,
-0.8154296875,
0.5771484375,
0.51220703125,
-0.484130859375,
-0.08782958984375,
0.1629638671875,
-0.55126953125,
0.29931640625,
0.07061767578125,
-1.0341796875,
-0.708984375,
0.61279296875,
1.251953125,
-0.1591796875,
0.6845703125,
-0.143310546875,
-0.449951171875,
-0.4365234375,
1.0234375,
-0.150634765625,
0.057861328125,
1.015625,
-0.5234375,
-0.38232421875,
0.18212890625,
-0.0287628173828125,
-0.51123046875,
-0.406494140625,
1.56640625,
-0.1943359375,
-0.287841796875,
1.056640625,
0.796875,
-0.7216796875,
-0.5615234375,
-0.3134765625,
0.3525390625,
0.0262908935546875,
-0.74658203125,
0.30029296875,
0.59326171875,
-0.7353515625,
-0.152099609375,
0.473876953125,
-0.1927490234375,
0.356201171875,
0.0732421875,
0.4794921875,
-0.3798828125,
0.2337646484375,
0.6982421875,
-0.7197265625,
-0.1160888671875,
-1.0859375,
0.3134765625,
-0.2076416015625,
-0.43994140625,
0.76123046875,
-0.26611328125,
0.483642578125,
0.91552734375,
-0.238037109375,
0.52880859375,
-0.69873046875,
-0.486083984375,
0.1827392578125,
-0.95947265625,
-0.68896484375,
-0.452392578125,
0.51953125,
-0.1358642578125,
0.23046875,
-1.0888671875,
0.2171630859375,
0.50537109375,
0.361572265625,
-0.52783203125,
-0.7109375,
-0.037384033203125,
-0.865234375,
-0.486572265625,
-0.490966796875,
-0.56640625,
-0.2578125,
-0.034515380859375,
0.02105712890625,
-0.53369140625,
0.334228515625,
0.41796875,
-0.264404296875,
0.791015625,
-0.5283203125,
0.43017578125,
-0.73876953125,
-0.2301025390625,
-0.59326171875,
0.0404052734375,
-0.332763671875,
-0.0394287109375,
-0.432861328125,
0.2071533203125,
0.449462890625,
0.25146484375,
-0.028594970703125,
-0.207275390625,
-0.481201171875,
-0.59912109375,
-0.1201171875,
0.2060546875,
-0.5302734375,
0.75,
0.39697265625,
0.2132568359375,
0.74365234375,
-0.2147216796875,
-0.4775390625,
0.1177978515625,
0.7197265625,
0.63671875,
-0.300048828125,
-0.09552001953125,
-0.1646728515625,
-0.037109375,
-0.79638671875,
0.08660888671875,
-0.0290985107421875,
0.256103515625,
0.021881103515625,
-0.2841796875,
0.364501953125,
1.13671875,
0.02264404296875,
0.7099609375,
0.2415771484375,
0.25830078125,
0.29345703125,
-0.48291015625,
-0.062286376953125,
0.467041015625,
0.1373291015625,
-0.357666015625,
-0.0178680419921875,
0.513671875,
-0.0211944580078125,
0.326171875,
0.06488037109375,
-0.95849609375,
-1.220703125,
-0.366943359375,
0.11962890625,
0.49560546875,
0.65234375,
-0.442626953125,
-0.2205810546875,
-0.455810546875,
-0.85595703125,
0.5966796875,
-1.1982421875,
-0.71875,
0.55078125,
-0.25830078125,
-0.72607421875,
-0.08673095703125,
-0.53369140625,
0.1290283203125,
0.1365966796875,
0.3681640625,
-0.66845703125,
0.044677734375,
0.2607421875,
0.461669921875,
-0.27685546875,
-0.2449951171875,
-0.055389404296875,
0.309814453125,
-0.364501953125,
-0.2120361328125,
0.37353515625,
1.0380859375,
0.1441650390625,
-0.05743408203125,
-0.79736328125,
0.149658203125,
0.49462890625,
0.01013946533203125,
-0.342041015625,
-0.0168914794921875,
-0.63525390625,
0.68359375,
-0.67919921875,
-0.0321044921875,
-0.01690673828125,
0.163818359375,
0.0740966796875,
-0.428955078125,
-0.556640625,
0.84375,
1.130859375,
-0.25537109375,
0.462158203125,
0.053863525390625,
0.2186279296875,
-0.258544921875,
-0.1513671875,
-0.42822265625,
0.464599609375,
0.1737060546875,
0.4736328125,
-0.0316162109375,
0.77392578125,
0.798828125,
-0.12152099609375,
0.279296875,
0.365234375,
0.0596923828125,
-0.0328369140625,
0.006931304931640625,
-0.064208984375,
0.2724609375,
0.466796875,
-0.6240234375,
0.369384765625,
-0.80517578125,
-0.2286376953125,
-0.08624267578125,
-0.61474609375,
0.82861328125,
-0.9697265625,
-0.061187744140625,
-0.1759033203125,
-0.48291015625,
0.31689453125,
0.74951171875,
0.483154296875,
-0.0011968612670898438,
0.62646484375,
0.888671875,
0.313232421875,
1.044921875,
0.61962890625,
0.2783203125,
-0.79931640625,
0.163330078125,
0.2626953125,
-0.252685546875,
-0.37841796875,
-0.195556640625,
-0.8193359375,
0.53125,
-0.014739990234375,
-0.44091796875,
0.388916015625,
-0.7919921875,
-0.24755859375,
0.09814453125,
0.84033203125,
-0.413330078125,
0.4462890625,
0.0875244140625,
-0.393798828125,
-0.7783203125,
0.939453125,
-0.049560546875,
0.325927734375,
0.23974609375,
0.83349609375,
-0.01030731201171875,
1.1455078125,
0.4306640625,
-0.251220703125,
0.0626220703125,
0.1103515625,
-0.3310546875,
-0.92236328125,
-0.2548828125,
-0.572265625,
0.16552734375,
-0.368408203125,
-0.08172607421875,
-0.0230712890625,
0.64111328125,
0.0033283233642578125,
-0.9306640625,
-0.33203125,
0.059844970703125,
-0.62109375,
0.55859375,
0.283447265625,
0.223388671875,
0.332763671875,
0.03179931640625,
-0.318603515625,
-0.6591796875,
-0.025115966796875,
-0.67236328125,
0.38427734375,
-0.337158203125,
-0.2408447265625,
-0.79150390625,
-0.79345703125,
-0.266845703125,
0.163818359375,
-0.3154296875,
-0.810546875,
0.310791015625,
0.1622314453125,
0.47265625,
0.08843994140625,
-0.40625,
0.5888671875,
0.84912109375,
0.9580078125,
0.0152435302734375,
0.81982421875,
0.408203125,
-0.312255859375,
0.1485595703125,
-0.271728515625,
0.358154296875,
-0.5556640625,
0.149169921875,
-0.275634765625,
0.392333984375,
-0.5654296875,
-1.25390625,
-0.107177734375,
0.6513671875,
0.2200927734375,
-0.71142578125,
-1.11328125,
-0.6953125,
-0.607421875,
0.359130859375,
-0.74853515625,
0.427734375,
-0.0263824462890625,
0.252197265625,
-0.1943359375,
-0.9189453125,
4.4453125,
1.0087890625,
1.166015625,
0.458984375,
0.09454345703125,
0.88427734375,
0.421875,
-0.26220703125,
-0.05169677734375,
-0.72802734375,
0.3623046875,
-0.2822265625,
-0.154296875,
0.96875,
0.345947265625,
0.7490234375,
-0.841796875,
-0.316162109375,
0.10302734375,
-0.63720703125,
-0.794921875,
0.1328125,
-0.464111328125,
0.1409912109375,
-0.187255859375,
0.43017578125,
0.75146484375,
-0.95458984375,
-0.39990234375,
-0.2744140625,
0.203857421875,
-0.6953125,
1.15234375,
-0.324951171875,
-0.2197265625,
0.415283203125,
-0.16748046875,
-0.5595703125,
-0.1197509765625,
0.4921875,
0.155029296875,
0.45947265625,
0.9970703125,
-0.2244873046875,
0.50732421875,
0.5732421875,
-0.54248046875,
0.0748291015625,
-0.23388671875,
-0.8701171875,
1.0458984375,
-0.338134765625,
0.357177734375,
-0.411865234375,
-0.91259765625,
0.2447509765625,
-0.08502197265625,
-0.2978515625,
-0.12646484375,
0.2333984375,
0.1697998046875,
0.053192138671875,
-0.09320068359375,
0.373291015625,
-1.048828125,
0.62451171875,
0.0439453125,
0.2122802734375,
-0.60546875,
-0.3583984375,
-0.23388671875,
-0.214599609375,
-0.2108154296875,
-0.455810546875,
0.42333984375,
0.2183837890625,
0.004878997802734375,
0.308349609375,
0.68896484375,
-0.78076171875,
-0.036346435546875,
-0.252685546875,
-0.53564453125,
-0.67138671875,
0.7421875,
0.98193359375,
-0.69970703125,
-0.53759765625,
-0.2410888671875,
0.37255859375,
0.615234375,
0.449951171875,
0.404052734375,
-0.1142578125,
-0.255859375
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Submitted Solution:
```
n = int(input())
G = [input() for _ in range(n)]
print("cbdefghijklmnopqrsatuvwxyz")
```
No
| 72,052 | [
-0.0347900390625,
-0.2958984375,
0.419677734375,
-0.2406005859375,
-0.400634765625,
-0.288330078125,
-0.093994140625,
0.26318359375,
0.09747314453125,
0.603515625,
0.6552734375,
0.0177154541015625,
0.22216796875,
-0.8720703125,
-0.8095703125,
0.137939453125,
-0.180419921875,
-0.413330078125,
-0.04302978515625,
-0.1639404296875,
0.428955078125,
0.2188720703125,
-1.6826171875,
0.10687255859375,
-0.583984375,
0.9892578125,
0.53173828125,
0.1768798828125,
1.2421875,
0.92578125,
-0.077880859375,
-0.40576171875,
0.5224609375,
-0.82763671875,
-0.211181640625,
-0.303955078125,
0.67822265625,
-0.51220703125,
-0.1773681640625,
-0.7197265625,
0.421875,
-0.67822265625,
0.406494140625,
-0.81591796875,
-0.89697265625,
-0.347412109375,
-0.1845703125,
-0.2103271484375,
-0.45263671875,
-1.2236328125,
0.2249755859375,
-0.2197265625,
0.62353515625,
-0.499755859375,
-0.10601806640625,
0.102294921875,
0.341796875,
0.0197296142578125,
-0.495849609375,
0.3818359375,
0.015960693359375,
0.351806640625,
-0.383056640625,
-0.63330078125,
-0.33447265625,
0.253662109375,
0.141357421875,
-0.1221923828125,
0.1630859375,
-0.49853515625,
-0.2242431640625,
0.312255859375,
-0.34765625,
0.06622314453125,
-0.51171875,
0.08294677734375,
-0.1854248046875,
-0.1673583984375,
-0.484375,
0.59765625,
0.26416015625,
0.6728515625,
0.1380615234375,
0.366943359375,
-0.2724609375,
-0.30517578125,
-0.006076812744140625,
0.1400146484375,
0.26123046875,
0.1253662109375,
0.2259521484375,
0.359619140625,
-0.7763671875,
-0.284912109375,
0.472900390625,
0.53271484375,
-0.0203857421875,
0.252685546875,
0.10882568359375,
0.1519775390625,
0.96142578125,
1.19140625,
-0.1544189453125,
0.98291015625,
-0.75439453125,
0.12274169921875,
-0.11260986328125,
-0.2318115234375,
0.11370849609375,
-0.34033203125,
-0.1241455078125,
-0.289794921875,
0.1488037109375,
0.22802734375,
0.0005865097045898438,
0.6865234375,
-0.423828125,
0.428466796875,
-0.86962890625,
-0.1019287109375,
0.497802734375,
0.043243408203125,
0.01403045654296875,
0.06243896484375,
0.39111328125,
-0.266845703125,
-0.266357421875,
0.90380859375,
-0.435302734375,
-0.08660888671875,
0.474609375,
-0.10601806640625,
-0.5556640625,
0.2481689453125,
-0.1397705078125,
0.74560546875,
-0.03253173828125,
0.476318359375,
0.5791015625,
-0.498291015625,
0.63916015625,
-0.0911865234375,
0.0460205078125,
1.5751953125,
-0.060333251953125,
-0.2724609375,
0.298828125,
0.2093505859375,
-0.7548828125,
0.517578125,
-0.99755859375,
0.78271484375,
0.2447509765625,
0.2386474609375,
-0.53271484375,
0.419677734375,
-0.1954345703125,
0.382568359375,
0.615234375,
0.56591796875,
-0.33203125,
-0.1103515625,
-0.212890625,
0.98828125,
-0.3076171875,
1.0341796875,
-0.5234375,
-0.0975341796875,
0.04864501953125,
-0.1348876953125,
0.066162109375,
0.0762939453125,
-0.367431640625,
1.046875,
0.307373046875,
0.83642578125,
0.416015625,
-0.378662109375,
0.12127685546875,
0.1669921875,
-0.359130859375,
0.42822265625,
0.0236053466796875,
0.8271484375,
0.1929931640625,
0.2078857421875,
0.2841796875,
-0.72216796875,
-0.30908203125,
-0.6884765625,
-0.222900390625,
0.79443359375,
-0.5009765625,
0.408447265625,
-0.0689697265625,
-0.1278076171875,
-0.62451171875,
0.1302490234375,
0.8681640625,
-0.947265625,
-0.2325439453125,
0.5703125,
-0.183837890625,
0.6025390625,
-0.71337890625,
-0.53662109375,
0.371337890625,
1.0849609375,
0.0574951171875,
0.037017822265625,
0.238037109375,
0.23828125,
-0.48828125,
0.0780029296875,
0.31982421875,
-0.036865234375,
-0.427734375,
0.59814453125,
-0.425048828125,
-0.15380859375,
0.268310546875,
0.908203125,
0.802734375,
0.25146484375,
-0.27685546875,
-0.0227203369140625,
1.01171875,
1.3388671875,
-0.326171875,
0.07818603515625,
0.09735107421875,
1.0947265625,
0.3623046875,
0.6923828125,
0.56103515625,
-0.0753173828125,
0.80615234375,
0.58447265625,
-0.391845703125,
0.0987548828125,
0.03424072265625,
0.587890625,
0.70751953125,
0.65625,
-0.1058349609375,
0.45849609375,
-0.1751708984375,
0.1563720703125,
-0.281005859375,
0.6513671875,
0.18505859375,
0.85546875,
0.06396484375,
0.31494140625,
-0.479736328125,
-0.525390625,
-0.2001953125,
0.51318359375,
-0.96630859375,
-0.70166015625,
-0.32763671875,
-0.1954345703125,
0.07611083984375,
0.033935546875,
0.1790771484375,
0.19189453125,
0.347412109375,
0.30322265625,
-0.24755859375,
-0.6416015625,
-0.984375,
-0.869140625,
-1.2646484375,
-0.343505859375,
-0.73193359375,
-0.023162841796875,
0.32080078125,
-0.472412109375,
0.419189453125,
-0.2568359375,
-0.1495361328125,
0.34375,
-0.458740234375,
0.6435546875,
0.09197998046875,
0.83642578125,
-0.55419921875,
0.164306640625,
-0.199462890625,
1.1845703125,
-0.64404296875,
-0.1546630859375,
-0.50927734375,
-0.6962890625,
0.458740234375,
0.442138671875,
0.57861328125,
0.06024169921875,
-0.59033203125,
-1.15625,
-0.54052734375,
0.06304931640625,
-0.8876953125,
0.2490234375,
-0.73681640625,
1.0263671875,
0.10906982421875,
-0.681640625,
0.40771484375,
0.76171875,
-0.7451171875,
0.84716796875,
0.471435546875,
0.188232421875,
-0.87548828125,
1.49609375,
0.07525634765625,
0.47998046875,
-0.4697265625,
-0.484130859375,
-0.428955078125,
0.29638671875,
0.7529296875,
-1.0107421875,
-0.09112548828125,
0.78759765625,
-0.0080413818359375,
-1.1474609375,
0.7333984375,
-0.8271484375,
-0.7119140625,
-0.0684814453125,
-0.6455078125,
0.68212890625,
0.83837890625,
0.5908203125,
0.1959228515625,
-0.37451171875,
-0.2025146484375,
0.56884765625,
-0.033966064453125,
-0.6259765625,
-0.2252197265625,
0.428955078125,
-0.1868896484375,
-0.156982421875,
0.162353515625,
-0.39208984375,
-0.08416748046875,
-0.05023193359375,
-0.174560546875,
0.9970703125,
0.1295166015625,
0.18603515625,
-0.054168701171875,
0.87060546875,
-0.74365234375,
-0.496337890625,
-0.52685546875,
0.7265625,
0.6279296875,
0.425537109375,
0.455810546875,
-0.12109375,
-0.43212890625,
-0.81884765625,
0.277099609375,
-0.003963470458984375,
0.63134765625,
-0.67041015625,
0.830078125,
0.2017822265625,
-0.56103515625,
0.431884765625,
-0.80517578125,
-0.25146484375,
1.33203125,
-0.298828125,
0.83251953125,
-0.626953125,
0.09320068359375,
-0.3017578125,
0.359619140625,
0.44775390625,
0.2314453125,
0.67333984375,
-0.413330078125,
0.00014770030975341797,
-0.391357421875,
-0.499755859375,
0.15283203125,
-0.75048828125,
0.084228515625,
-0.105224609375,
-0.440185546875,
-0.8916015625,
0.72119140625,
0.5283203125,
0.1832275390625,
0.1519775390625,
0.70068359375,
0.1890869140625,
0.293701171875,
1.01171875,
-0.34521484375,
0.1781005859375,
-0.65087890625,
0.8720703125,
0.26416015625,
-0.153076171875,
-0.0038909912109375,
-0.01934814453125,
-0.12060546875,
0.153564453125,
-0.1595458984375,
-0.150634765625,
-0.7548828125,
0.236083984375,
0.2239990234375,
0.71484375,
-0.54150390625,
-0.5712890625,
-0.1719970703125,
0.58251953125,
0.318115234375,
-0.5927734375,
0.1116943359375,
-0.69970703125,
0.308349609375,
0.5927734375,
-0.124267578125,
-0.521484375,
-0.57763671875,
-1.318359375,
-0.450927734375,
0.60546875,
0.4013671875,
0.08184814453125,
-0.11737060546875,
-0.8779296875,
0.716796875,
0.10693359375,
-0.291259765625,
0.1651611328125,
-0.293701171875,
-0.0293426513671875,
-0.1441650390625,
0.55908203125,
0.035247802734375,
-0.72265625,
0.326171875,
-1.095703125,
0.6103515625,
-0.8203125,
0.54931640625,
0.056121826171875,
0.1942138671875,
-0.1727294921875,
0.38037109375,
-0.487548828125,
-0.05755615234375,
-0.306396484375,
0.55029296875,
-1.052734375,
-0.7666015625,
0.73046875,
0.04656982421875,
0.03582763671875,
0.71533203125,
-0.09442138671875,
-0.5791015625,
0.177978515625,
0.28759765625,
-0.54150390625,
0.381591796875,
-0.309326171875,
0.2142333984375,
-0.45166015625,
-0.367431640625,
-0.07562255859375,
-0.392333984375,
0.701171875,
0.23486328125,
-0.78125,
-0.47119140625,
-0.99169921875,
0.0298309326171875,
-0.198974609375,
-0.61328125,
0.31201171875,
-0.1644287109375,
-0.27587890625,
-0.340576171875,
-0.3232421875,
-0.69677734375,
-0.032562255859375,
-0.5908203125,
-0.318115234375,
0.194580078125,
0.346435546875,
0.57861328125,
0.1263427734375,
-0.31396484375,
0.0266571044921875,
-0.302490234375,
-0.039031982421875,
-0.316162109375,
-0.1630859375,
-0.071044921875,
-0.378173828125,
-0.295166015625,
-0.03021240234375,
0.368896484375,
0.278564453125,
0.2978515625,
0.2476806640625,
0.421142578125,
0.51513671875,
-0.56494140625,
0.74169921875,
-0.037933349609375,
-0.79541015625,
-0.45361328125,
0.497314453125,
-0.1021728515625,
0.96435546875,
0.2607421875,
-1.2275390625,
-0.810546875,
-1.314453125,
0.03350830078125,
-0.3173828125,
-0.240478515625,
-0.87158203125,
0.031585693359375,
-0.51904296875,
0.2286376953125,
-0.204833984375,
-0.498779296875,
0.10089111328125,
-1.380859375,
0.1082763671875,
-0.71875,
-0.56005859375,
-0.398681640625,
-0.48828125,
-0.186767578125,
0.97705078125,
0.34423828125,
0.280029296875,
0.1612548828125,
0.11712646484375,
-0.06292724609375,
-0.272216796875,
-0.91162109375,
-0.5078125,
0.0543212890625,
0.2105712890625,
0.0626220703125,
-0.06036376953125,
-0.452880859375,
0.84765625,
-0.9482421875,
-0.0338134765625,
-0.1798095703125,
-0.276611328125,
-0.07379150390625,
-0.281005859375,
1.1865234375,
-0.40576171875,
-0.01451873779296875,
-0.08367919921875,
0.455322265625,
0.52392578125,
-0.37548828125,
-0.349365234375,
-0.60888671875,
-0.3623046875,
-1.0009765625,
0.68359375,
-0.7119140625,
0.15576171875,
-0.64794921875,
-0.271728515625,
1.23828125,
-0.90673828125,
0.51220703125,
0.859375,
0.0194549560546875,
0.132080078125,
-0.8154296875,
0.5771484375,
0.51220703125,
-0.484130859375,
-0.08782958984375,
0.1629638671875,
-0.55126953125,
0.29931640625,
0.07061767578125,
-1.0341796875,
-0.708984375,
0.61279296875,
1.251953125,
-0.1591796875,
0.6845703125,
-0.143310546875,
-0.449951171875,
-0.4365234375,
1.0234375,
-0.150634765625,
0.057861328125,
1.015625,
-0.5234375,
-0.38232421875,
0.18212890625,
-0.0287628173828125,
-0.51123046875,
-0.406494140625,
1.56640625,
-0.1943359375,
-0.287841796875,
1.056640625,
0.796875,
-0.7216796875,
-0.5615234375,
-0.3134765625,
0.3525390625,
0.0262908935546875,
-0.74658203125,
0.30029296875,
0.59326171875,
-0.7353515625,
-0.152099609375,
0.473876953125,
-0.1927490234375,
0.356201171875,
0.0732421875,
0.4794921875,
-0.3798828125,
0.2337646484375,
0.6982421875,
-0.7197265625,
-0.1160888671875,
-1.0859375,
0.3134765625,
-0.2076416015625,
-0.43994140625,
0.76123046875,
-0.26611328125,
0.483642578125,
0.91552734375,
-0.238037109375,
0.52880859375,
-0.69873046875,
-0.486083984375,
0.1827392578125,
-0.95947265625,
-0.68896484375,
-0.452392578125,
0.51953125,
-0.1358642578125,
0.23046875,
-1.0888671875,
0.2171630859375,
0.50537109375,
0.361572265625,
-0.52783203125,
-0.7109375,
-0.037384033203125,
-0.865234375,
-0.486572265625,
-0.490966796875,
-0.56640625,
-0.2578125,
-0.034515380859375,
0.02105712890625,
-0.53369140625,
0.334228515625,
0.41796875,
-0.264404296875,
0.791015625,
-0.5283203125,
0.43017578125,
-0.73876953125,
-0.2301025390625,
-0.59326171875,
0.0404052734375,
-0.332763671875,
-0.0394287109375,
-0.432861328125,
0.2071533203125,
0.449462890625,
0.25146484375,
-0.028594970703125,
-0.207275390625,
-0.481201171875,
-0.59912109375,
-0.1201171875,
0.2060546875,
-0.5302734375,
0.75,
0.39697265625,
0.2132568359375,
0.74365234375,
-0.2147216796875,
-0.4775390625,
0.1177978515625,
0.7197265625,
0.63671875,
-0.300048828125,
-0.09552001953125,
-0.1646728515625,
-0.037109375,
-0.79638671875,
0.08660888671875,
-0.0290985107421875,
0.256103515625,
0.021881103515625,
-0.2841796875,
0.364501953125,
1.13671875,
0.02264404296875,
0.7099609375,
0.2415771484375,
0.25830078125,
0.29345703125,
-0.48291015625,
-0.062286376953125,
0.467041015625,
0.1373291015625,
-0.357666015625,
-0.0178680419921875,
0.513671875,
-0.0211944580078125,
0.326171875,
0.06488037109375,
-0.95849609375,
-1.220703125,
-0.366943359375,
0.11962890625,
0.49560546875,
0.65234375,
-0.442626953125,
-0.2205810546875,
-0.455810546875,
-0.85595703125,
0.5966796875,
-1.1982421875,
-0.71875,
0.55078125,
-0.25830078125,
-0.72607421875,
-0.08673095703125,
-0.53369140625,
0.1290283203125,
0.1365966796875,
0.3681640625,
-0.66845703125,
0.044677734375,
0.2607421875,
0.461669921875,
-0.27685546875,
-0.2449951171875,
-0.055389404296875,
0.309814453125,
-0.364501953125,
-0.2120361328125,
0.37353515625,
1.0380859375,
0.1441650390625,
-0.05743408203125,
-0.79736328125,
0.149658203125,
0.49462890625,
0.01013946533203125,
-0.342041015625,
-0.0168914794921875,
-0.63525390625,
0.68359375,
-0.67919921875,
-0.0321044921875,
-0.01690673828125,
0.163818359375,
0.0740966796875,
-0.428955078125,
-0.556640625,
0.84375,
1.130859375,
-0.25537109375,
0.462158203125,
0.053863525390625,
0.2186279296875,
-0.258544921875,
-0.1513671875,
-0.42822265625,
0.464599609375,
0.1737060546875,
0.4736328125,
-0.0316162109375,
0.77392578125,
0.798828125,
-0.12152099609375,
0.279296875,
0.365234375,
0.0596923828125,
-0.0328369140625,
0.006931304931640625,
-0.064208984375,
0.2724609375,
0.466796875,
-0.6240234375,
0.369384765625,
-0.80517578125,
-0.2286376953125,
-0.08624267578125,
-0.61474609375,
0.82861328125,
-0.9697265625,
-0.061187744140625,
-0.1759033203125,
-0.48291015625,
0.31689453125,
0.74951171875,
0.483154296875,
-0.0011968612670898438,
0.62646484375,
0.888671875,
0.313232421875,
1.044921875,
0.61962890625,
0.2783203125,
-0.79931640625,
0.163330078125,
0.2626953125,
-0.252685546875,
-0.37841796875,
-0.195556640625,
-0.8193359375,
0.53125,
-0.014739990234375,
-0.44091796875,
0.388916015625,
-0.7919921875,
-0.24755859375,
0.09814453125,
0.84033203125,
-0.413330078125,
0.4462890625,
0.0875244140625,
-0.393798828125,
-0.7783203125,
0.939453125,
-0.049560546875,
0.325927734375,
0.23974609375,
0.83349609375,
-0.01030731201171875,
1.1455078125,
0.4306640625,
-0.251220703125,
0.0626220703125,
0.1103515625,
-0.3310546875,
-0.92236328125,
-0.2548828125,
-0.572265625,
0.16552734375,
-0.368408203125,
-0.08172607421875,
-0.0230712890625,
0.64111328125,
0.0033283233642578125,
-0.9306640625,
-0.33203125,
0.059844970703125,
-0.62109375,
0.55859375,
0.283447265625,
0.223388671875,
0.332763671875,
0.03179931640625,
-0.318603515625,
-0.6591796875,
-0.025115966796875,
-0.67236328125,
0.38427734375,
-0.337158203125,
-0.2408447265625,
-0.79150390625,
-0.79345703125,
-0.266845703125,
0.163818359375,
-0.3154296875,
-0.810546875,
0.310791015625,
0.1622314453125,
0.47265625,
0.08843994140625,
-0.40625,
0.5888671875,
0.84912109375,
0.9580078125,
0.0152435302734375,
0.81982421875,
0.408203125,
-0.312255859375,
0.1485595703125,
-0.271728515625,
0.358154296875,
-0.5556640625,
0.149169921875,
-0.275634765625,
0.392333984375,
-0.5654296875,
-1.25390625,
-0.107177734375,
0.6513671875,
0.2200927734375,
-0.71142578125,
-1.11328125,
-0.6953125,
-0.607421875,
0.359130859375,
-0.74853515625,
0.427734375,
-0.0263824462890625,
0.252197265625,
-0.1943359375,
-0.9189453125,
4.4453125,
1.0087890625,
1.166015625,
0.458984375,
0.09454345703125,
0.88427734375,
0.421875,
-0.26220703125,
-0.05169677734375,
-0.72802734375,
0.3623046875,
-0.2822265625,
-0.154296875,
0.96875,
0.345947265625,
0.7490234375,
-0.841796875,
-0.316162109375,
0.10302734375,
-0.63720703125,
-0.794921875,
0.1328125,
-0.464111328125,
0.1409912109375,
-0.187255859375,
0.43017578125,
0.75146484375,
-0.95458984375,
-0.39990234375,
-0.2744140625,
0.203857421875,
-0.6953125,
1.15234375,
-0.324951171875,
-0.2197265625,
0.415283203125,
-0.16748046875,
-0.5595703125,
-0.1197509765625,
0.4921875,
0.155029296875,
0.45947265625,
0.9970703125,
-0.2244873046875,
0.50732421875,
0.5732421875,
-0.54248046875,
0.0748291015625,
-0.23388671875,
-0.8701171875,
1.0458984375,
-0.338134765625,
0.357177734375,
-0.411865234375,
-0.91259765625,
0.2447509765625,
-0.08502197265625,
-0.2978515625,
-0.12646484375,
0.2333984375,
0.1697998046875,
0.053192138671875,
-0.09320068359375,
0.373291015625,
-1.048828125,
0.62451171875,
0.0439453125,
0.2122802734375,
-0.60546875,
-0.3583984375,
-0.23388671875,
-0.214599609375,
-0.2108154296875,
-0.455810546875,
0.42333984375,
0.2183837890625,
0.004878997802734375,
0.308349609375,
0.68896484375,
-0.78076171875,
-0.036346435546875,
-0.252685546875,
-0.53564453125,
-0.67138671875,
0.7421875,
0.98193359375,
-0.69970703125,
-0.53759765625,
-0.2410888671875,
0.37255859375,
0.615234375,
0.449951171875,
0.404052734375,
-0.1142578125,
-0.255859375
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Submitted Solution:
```
n = int(input())
s = [input() for i in range(n)]
f = [[0 for i in range(26)] for j in range(26)]
for i in range(n):
for k in range(i + 1, n):
for j in range(min(len(s[k]), len(s[i]))):
if s[k][j] != s[i][j]:
if f[ord(s[k][j]) - ord('a')][ord(s[i][j]) - ord('a')] == 1:
print('Impossible')
exit(0)
f[ord(s[k][j]) - ord('a')][ord(s[i][j]) - ord('a')] = -1
f[ord(s[i][j]) - ord('a')][ord(s[k][j]) - ord('a')] = 1
break
def dfs(k, used, f, res):
if used[k] == 1:
print('Impossible')
exit(0)
used[k] = 1
for i in range(26):
if used[i] == 0 and f[k][i] == 1:
dfs(i, used, f, res)
used[k] = 2
res.append(k)
used = [0 for i in range(26)]
res = []
for i in range(25, -1, -1):
if used[i] == 0:
dfs(i, used, f, res)
for i in range(26):
print(chr(res[25 - i] + ord('a')), end='')
```
No
| 72,053 | [
-0.0347900390625,
-0.2958984375,
0.419677734375,
-0.2406005859375,
-0.400634765625,
-0.288330078125,
-0.093994140625,
0.26318359375,
0.09747314453125,
0.603515625,
0.6552734375,
0.0177154541015625,
0.22216796875,
-0.8720703125,
-0.8095703125,
0.137939453125,
-0.180419921875,
-0.413330078125,
-0.04302978515625,
-0.1639404296875,
0.428955078125,
0.2188720703125,
-1.6826171875,
0.10687255859375,
-0.583984375,
0.9892578125,
0.53173828125,
0.1768798828125,
1.2421875,
0.92578125,
-0.077880859375,
-0.40576171875,
0.5224609375,
-0.82763671875,
-0.211181640625,
-0.303955078125,
0.67822265625,
-0.51220703125,
-0.1773681640625,
-0.7197265625,
0.421875,
-0.67822265625,
0.406494140625,
-0.81591796875,
-0.89697265625,
-0.347412109375,
-0.1845703125,
-0.2103271484375,
-0.45263671875,
-1.2236328125,
0.2249755859375,
-0.2197265625,
0.62353515625,
-0.499755859375,
-0.10601806640625,
0.102294921875,
0.341796875,
0.0197296142578125,
-0.495849609375,
0.3818359375,
0.015960693359375,
0.351806640625,
-0.383056640625,
-0.63330078125,
-0.33447265625,
0.253662109375,
0.141357421875,
-0.1221923828125,
0.1630859375,
-0.49853515625,
-0.2242431640625,
0.312255859375,
-0.34765625,
0.06622314453125,
-0.51171875,
0.08294677734375,
-0.1854248046875,
-0.1673583984375,
-0.484375,
0.59765625,
0.26416015625,
0.6728515625,
0.1380615234375,
0.366943359375,
-0.2724609375,
-0.30517578125,
-0.006076812744140625,
0.1400146484375,
0.26123046875,
0.1253662109375,
0.2259521484375,
0.359619140625,
-0.7763671875,
-0.284912109375,
0.472900390625,
0.53271484375,
-0.0203857421875,
0.252685546875,
0.10882568359375,
0.1519775390625,
0.96142578125,
1.19140625,
-0.1544189453125,
0.98291015625,
-0.75439453125,
0.12274169921875,
-0.11260986328125,
-0.2318115234375,
0.11370849609375,
-0.34033203125,
-0.1241455078125,
-0.289794921875,
0.1488037109375,
0.22802734375,
0.0005865097045898438,
0.6865234375,
-0.423828125,
0.428466796875,
-0.86962890625,
-0.1019287109375,
0.497802734375,
0.043243408203125,
0.01403045654296875,
0.06243896484375,
0.39111328125,
-0.266845703125,
-0.266357421875,
0.90380859375,
-0.435302734375,
-0.08660888671875,
0.474609375,
-0.10601806640625,
-0.5556640625,
0.2481689453125,
-0.1397705078125,
0.74560546875,
-0.03253173828125,
0.476318359375,
0.5791015625,
-0.498291015625,
0.63916015625,
-0.0911865234375,
0.0460205078125,
1.5751953125,
-0.060333251953125,
-0.2724609375,
0.298828125,
0.2093505859375,
-0.7548828125,
0.517578125,
-0.99755859375,
0.78271484375,
0.2447509765625,
0.2386474609375,
-0.53271484375,
0.419677734375,
-0.1954345703125,
0.382568359375,
0.615234375,
0.56591796875,
-0.33203125,
-0.1103515625,
-0.212890625,
0.98828125,
-0.3076171875,
1.0341796875,
-0.5234375,
-0.0975341796875,
0.04864501953125,
-0.1348876953125,
0.066162109375,
0.0762939453125,
-0.367431640625,
1.046875,
0.307373046875,
0.83642578125,
0.416015625,
-0.378662109375,
0.12127685546875,
0.1669921875,
-0.359130859375,
0.42822265625,
0.0236053466796875,
0.8271484375,
0.1929931640625,
0.2078857421875,
0.2841796875,
-0.72216796875,
-0.30908203125,
-0.6884765625,
-0.222900390625,
0.79443359375,
-0.5009765625,
0.408447265625,
-0.0689697265625,
-0.1278076171875,
-0.62451171875,
0.1302490234375,
0.8681640625,
-0.947265625,
-0.2325439453125,
0.5703125,
-0.183837890625,
0.6025390625,
-0.71337890625,
-0.53662109375,
0.371337890625,
1.0849609375,
0.0574951171875,
0.037017822265625,
0.238037109375,
0.23828125,
-0.48828125,
0.0780029296875,
0.31982421875,
-0.036865234375,
-0.427734375,
0.59814453125,
-0.425048828125,
-0.15380859375,
0.268310546875,
0.908203125,
0.802734375,
0.25146484375,
-0.27685546875,
-0.0227203369140625,
1.01171875,
1.3388671875,
-0.326171875,
0.07818603515625,
0.09735107421875,
1.0947265625,
0.3623046875,
0.6923828125,
0.56103515625,
-0.0753173828125,
0.80615234375,
0.58447265625,
-0.391845703125,
0.0987548828125,
0.03424072265625,
0.587890625,
0.70751953125,
0.65625,
-0.1058349609375,
0.45849609375,
-0.1751708984375,
0.1563720703125,
-0.281005859375,
0.6513671875,
0.18505859375,
0.85546875,
0.06396484375,
0.31494140625,
-0.479736328125,
-0.525390625,
-0.2001953125,
0.51318359375,
-0.96630859375,
-0.70166015625,
-0.32763671875,
-0.1954345703125,
0.07611083984375,
0.033935546875,
0.1790771484375,
0.19189453125,
0.347412109375,
0.30322265625,
-0.24755859375,
-0.6416015625,
-0.984375,
-0.869140625,
-1.2646484375,
-0.343505859375,
-0.73193359375,
-0.023162841796875,
0.32080078125,
-0.472412109375,
0.419189453125,
-0.2568359375,
-0.1495361328125,
0.34375,
-0.458740234375,
0.6435546875,
0.09197998046875,
0.83642578125,
-0.55419921875,
0.164306640625,
-0.199462890625,
1.1845703125,
-0.64404296875,
-0.1546630859375,
-0.50927734375,
-0.6962890625,
0.458740234375,
0.442138671875,
0.57861328125,
0.06024169921875,
-0.59033203125,
-1.15625,
-0.54052734375,
0.06304931640625,
-0.8876953125,
0.2490234375,
-0.73681640625,
1.0263671875,
0.10906982421875,
-0.681640625,
0.40771484375,
0.76171875,
-0.7451171875,
0.84716796875,
0.471435546875,
0.188232421875,
-0.87548828125,
1.49609375,
0.07525634765625,
0.47998046875,
-0.4697265625,
-0.484130859375,
-0.428955078125,
0.29638671875,
0.7529296875,
-1.0107421875,
-0.09112548828125,
0.78759765625,
-0.0080413818359375,
-1.1474609375,
0.7333984375,
-0.8271484375,
-0.7119140625,
-0.0684814453125,
-0.6455078125,
0.68212890625,
0.83837890625,
0.5908203125,
0.1959228515625,
-0.37451171875,
-0.2025146484375,
0.56884765625,
-0.033966064453125,
-0.6259765625,
-0.2252197265625,
0.428955078125,
-0.1868896484375,
-0.156982421875,
0.162353515625,
-0.39208984375,
-0.08416748046875,
-0.05023193359375,
-0.174560546875,
0.9970703125,
0.1295166015625,
0.18603515625,
-0.054168701171875,
0.87060546875,
-0.74365234375,
-0.496337890625,
-0.52685546875,
0.7265625,
0.6279296875,
0.425537109375,
0.455810546875,
-0.12109375,
-0.43212890625,
-0.81884765625,
0.277099609375,
-0.003963470458984375,
0.63134765625,
-0.67041015625,
0.830078125,
0.2017822265625,
-0.56103515625,
0.431884765625,
-0.80517578125,
-0.25146484375,
1.33203125,
-0.298828125,
0.83251953125,
-0.626953125,
0.09320068359375,
-0.3017578125,
0.359619140625,
0.44775390625,
0.2314453125,
0.67333984375,
-0.413330078125,
0.00014770030975341797,
-0.391357421875,
-0.499755859375,
0.15283203125,
-0.75048828125,
0.084228515625,
-0.105224609375,
-0.440185546875,
-0.8916015625,
0.72119140625,
0.5283203125,
0.1832275390625,
0.1519775390625,
0.70068359375,
0.1890869140625,
0.293701171875,
1.01171875,
-0.34521484375,
0.1781005859375,
-0.65087890625,
0.8720703125,
0.26416015625,
-0.153076171875,
-0.0038909912109375,
-0.01934814453125,
-0.12060546875,
0.153564453125,
-0.1595458984375,
-0.150634765625,
-0.7548828125,
0.236083984375,
0.2239990234375,
0.71484375,
-0.54150390625,
-0.5712890625,
-0.1719970703125,
0.58251953125,
0.318115234375,
-0.5927734375,
0.1116943359375,
-0.69970703125,
0.308349609375,
0.5927734375,
-0.124267578125,
-0.521484375,
-0.57763671875,
-1.318359375,
-0.450927734375,
0.60546875,
0.4013671875,
0.08184814453125,
-0.11737060546875,
-0.8779296875,
0.716796875,
0.10693359375,
-0.291259765625,
0.1651611328125,
-0.293701171875,
-0.0293426513671875,
-0.1441650390625,
0.55908203125,
0.035247802734375,
-0.72265625,
0.326171875,
-1.095703125,
0.6103515625,
-0.8203125,
0.54931640625,
0.056121826171875,
0.1942138671875,
-0.1727294921875,
0.38037109375,
-0.487548828125,
-0.05755615234375,
-0.306396484375,
0.55029296875,
-1.052734375,
-0.7666015625,
0.73046875,
0.04656982421875,
0.03582763671875,
0.71533203125,
-0.09442138671875,
-0.5791015625,
0.177978515625,
0.28759765625,
-0.54150390625,
0.381591796875,
-0.309326171875,
0.2142333984375,
-0.45166015625,
-0.367431640625,
-0.07562255859375,
-0.392333984375,
0.701171875,
0.23486328125,
-0.78125,
-0.47119140625,
-0.99169921875,
0.0298309326171875,
-0.198974609375,
-0.61328125,
0.31201171875,
-0.1644287109375,
-0.27587890625,
-0.340576171875,
-0.3232421875,
-0.69677734375,
-0.032562255859375,
-0.5908203125,
-0.318115234375,
0.194580078125,
0.346435546875,
0.57861328125,
0.1263427734375,
-0.31396484375,
0.0266571044921875,
-0.302490234375,
-0.039031982421875,
-0.316162109375,
-0.1630859375,
-0.071044921875,
-0.378173828125,
-0.295166015625,
-0.03021240234375,
0.368896484375,
0.278564453125,
0.2978515625,
0.2476806640625,
0.421142578125,
0.51513671875,
-0.56494140625,
0.74169921875,
-0.037933349609375,
-0.79541015625,
-0.45361328125,
0.497314453125,
-0.1021728515625,
0.96435546875,
0.2607421875,
-1.2275390625,
-0.810546875,
-1.314453125,
0.03350830078125,
-0.3173828125,
-0.240478515625,
-0.87158203125,
0.031585693359375,
-0.51904296875,
0.2286376953125,
-0.204833984375,
-0.498779296875,
0.10089111328125,
-1.380859375,
0.1082763671875,
-0.71875,
-0.56005859375,
-0.398681640625,
-0.48828125,
-0.186767578125,
0.97705078125,
0.34423828125,
0.280029296875,
0.1612548828125,
0.11712646484375,
-0.06292724609375,
-0.272216796875,
-0.91162109375,
-0.5078125,
0.0543212890625,
0.2105712890625,
0.0626220703125,
-0.06036376953125,
-0.452880859375,
0.84765625,
-0.9482421875,
-0.0338134765625,
-0.1798095703125,
-0.276611328125,
-0.07379150390625,
-0.281005859375,
1.1865234375,
-0.40576171875,
-0.01451873779296875,
-0.08367919921875,
0.455322265625,
0.52392578125,
-0.37548828125,
-0.349365234375,
-0.60888671875,
-0.3623046875,
-1.0009765625,
0.68359375,
-0.7119140625,
0.15576171875,
-0.64794921875,
-0.271728515625,
1.23828125,
-0.90673828125,
0.51220703125,
0.859375,
0.0194549560546875,
0.132080078125,
-0.8154296875,
0.5771484375,
0.51220703125,
-0.484130859375,
-0.08782958984375,
0.1629638671875,
-0.55126953125,
0.29931640625,
0.07061767578125,
-1.0341796875,
-0.708984375,
0.61279296875,
1.251953125,
-0.1591796875,
0.6845703125,
-0.143310546875,
-0.449951171875,
-0.4365234375,
1.0234375,
-0.150634765625,
0.057861328125,
1.015625,
-0.5234375,
-0.38232421875,
0.18212890625,
-0.0287628173828125,
-0.51123046875,
-0.406494140625,
1.56640625,
-0.1943359375,
-0.287841796875,
1.056640625,
0.796875,
-0.7216796875,
-0.5615234375,
-0.3134765625,
0.3525390625,
0.0262908935546875,
-0.74658203125,
0.30029296875,
0.59326171875,
-0.7353515625,
-0.152099609375,
0.473876953125,
-0.1927490234375,
0.356201171875,
0.0732421875,
0.4794921875,
-0.3798828125,
0.2337646484375,
0.6982421875,
-0.7197265625,
-0.1160888671875,
-1.0859375,
0.3134765625,
-0.2076416015625,
-0.43994140625,
0.76123046875,
-0.26611328125,
0.483642578125,
0.91552734375,
-0.238037109375,
0.52880859375,
-0.69873046875,
-0.486083984375,
0.1827392578125,
-0.95947265625,
-0.68896484375,
-0.452392578125,
0.51953125,
-0.1358642578125,
0.23046875,
-1.0888671875,
0.2171630859375,
0.50537109375,
0.361572265625,
-0.52783203125,
-0.7109375,
-0.037384033203125,
-0.865234375,
-0.486572265625,
-0.490966796875,
-0.56640625,
-0.2578125,
-0.034515380859375,
0.02105712890625,
-0.53369140625,
0.334228515625,
0.41796875,
-0.264404296875,
0.791015625,
-0.5283203125,
0.43017578125,
-0.73876953125,
-0.2301025390625,
-0.59326171875,
0.0404052734375,
-0.332763671875,
-0.0394287109375,
-0.432861328125,
0.2071533203125,
0.449462890625,
0.25146484375,
-0.028594970703125,
-0.207275390625,
-0.481201171875,
-0.59912109375,
-0.1201171875,
0.2060546875,
-0.5302734375,
0.75,
0.39697265625,
0.2132568359375,
0.74365234375,
-0.2147216796875,
-0.4775390625,
0.1177978515625,
0.7197265625,
0.63671875,
-0.300048828125,
-0.09552001953125,
-0.1646728515625,
-0.037109375,
-0.79638671875,
0.08660888671875,
-0.0290985107421875,
0.256103515625,
0.021881103515625,
-0.2841796875,
0.364501953125,
1.13671875,
0.02264404296875,
0.7099609375,
0.2415771484375,
0.25830078125,
0.29345703125,
-0.48291015625,
-0.062286376953125,
0.467041015625,
0.1373291015625,
-0.357666015625,
-0.0178680419921875,
0.513671875,
-0.0211944580078125,
0.326171875,
0.06488037109375,
-0.95849609375,
-1.220703125,
-0.366943359375,
0.11962890625,
0.49560546875,
0.65234375,
-0.442626953125,
-0.2205810546875,
-0.455810546875,
-0.85595703125,
0.5966796875,
-1.1982421875,
-0.71875,
0.55078125,
-0.25830078125,
-0.72607421875,
-0.08673095703125,
-0.53369140625,
0.1290283203125,
0.1365966796875,
0.3681640625,
-0.66845703125,
0.044677734375,
0.2607421875,
0.461669921875,
-0.27685546875,
-0.2449951171875,
-0.055389404296875,
0.309814453125,
-0.364501953125,
-0.2120361328125,
0.37353515625,
1.0380859375,
0.1441650390625,
-0.05743408203125,
-0.79736328125,
0.149658203125,
0.49462890625,
0.01013946533203125,
-0.342041015625,
-0.0168914794921875,
-0.63525390625,
0.68359375,
-0.67919921875,
-0.0321044921875,
-0.01690673828125,
0.163818359375,
0.0740966796875,
-0.428955078125,
-0.556640625,
0.84375,
1.130859375,
-0.25537109375,
0.462158203125,
0.053863525390625,
0.2186279296875,
-0.258544921875,
-0.1513671875,
-0.42822265625,
0.464599609375,
0.1737060546875,
0.4736328125,
-0.0316162109375,
0.77392578125,
0.798828125,
-0.12152099609375,
0.279296875,
0.365234375,
0.0596923828125,
-0.0328369140625,
0.006931304931640625,
-0.064208984375,
0.2724609375,
0.466796875,
-0.6240234375,
0.369384765625,
-0.80517578125,
-0.2286376953125,
-0.08624267578125,
-0.61474609375,
0.82861328125,
-0.9697265625,
-0.061187744140625,
-0.1759033203125,
-0.48291015625,
0.31689453125,
0.74951171875,
0.483154296875,
-0.0011968612670898438,
0.62646484375,
0.888671875,
0.313232421875,
1.044921875,
0.61962890625,
0.2783203125,
-0.79931640625,
0.163330078125,
0.2626953125,
-0.252685546875,
-0.37841796875,
-0.195556640625,
-0.8193359375,
0.53125,
-0.014739990234375,
-0.44091796875,
0.388916015625,
-0.7919921875,
-0.24755859375,
0.09814453125,
0.84033203125,
-0.413330078125,
0.4462890625,
0.0875244140625,
-0.393798828125,
-0.7783203125,
0.939453125,
-0.049560546875,
0.325927734375,
0.23974609375,
0.83349609375,
-0.01030731201171875,
1.1455078125,
0.4306640625,
-0.251220703125,
0.0626220703125,
0.1103515625,
-0.3310546875,
-0.92236328125,
-0.2548828125,
-0.572265625,
0.16552734375,
-0.368408203125,
-0.08172607421875,
-0.0230712890625,
0.64111328125,
0.0033283233642578125,
-0.9306640625,
-0.33203125,
0.059844970703125,
-0.62109375,
0.55859375,
0.283447265625,
0.223388671875,
0.332763671875,
0.03179931640625,
-0.318603515625,
-0.6591796875,
-0.025115966796875,
-0.67236328125,
0.38427734375,
-0.337158203125,
-0.2408447265625,
-0.79150390625,
-0.79345703125,
-0.266845703125,
0.163818359375,
-0.3154296875,
-0.810546875,
0.310791015625,
0.1622314453125,
0.47265625,
0.08843994140625,
-0.40625,
0.5888671875,
0.84912109375,
0.9580078125,
0.0152435302734375,
0.81982421875,
0.408203125,
-0.312255859375,
0.1485595703125,
-0.271728515625,
0.358154296875,
-0.5556640625,
0.149169921875,
-0.275634765625,
0.392333984375,
-0.5654296875,
-1.25390625,
-0.107177734375,
0.6513671875,
0.2200927734375,
-0.71142578125,
-1.11328125,
-0.6953125,
-0.607421875,
0.359130859375,
-0.74853515625,
0.427734375,
-0.0263824462890625,
0.252197265625,
-0.1943359375,
-0.9189453125,
4.4453125,
1.0087890625,
1.166015625,
0.458984375,
0.09454345703125,
0.88427734375,
0.421875,
-0.26220703125,
-0.05169677734375,
-0.72802734375,
0.3623046875,
-0.2822265625,
-0.154296875,
0.96875,
0.345947265625,
0.7490234375,
-0.841796875,
-0.316162109375,
0.10302734375,
-0.63720703125,
-0.794921875,
0.1328125,
-0.464111328125,
0.1409912109375,
-0.187255859375,
0.43017578125,
0.75146484375,
-0.95458984375,
-0.39990234375,
-0.2744140625,
0.203857421875,
-0.6953125,
1.15234375,
-0.324951171875,
-0.2197265625,
0.415283203125,
-0.16748046875,
-0.5595703125,
-0.1197509765625,
0.4921875,
0.155029296875,
0.45947265625,
0.9970703125,
-0.2244873046875,
0.50732421875,
0.5732421875,
-0.54248046875,
0.0748291015625,
-0.23388671875,
-0.8701171875,
1.0458984375,
-0.338134765625,
0.357177734375,
-0.411865234375,
-0.91259765625,
0.2447509765625,
-0.08502197265625,
-0.2978515625,
-0.12646484375,
0.2333984375,
0.1697998046875,
0.053192138671875,
-0.09320068359375,
0.373291015625,
-1.048828125,
0.62451171875,
0.0439453125,
0.2122802734375,
-0.60546875,
-0.3583984375,
-0.23388671875,
-0.214599609375,
-0.2108154296875,
-0.455810546875,
0.42333984375,
0.2183837890625,
0.004878997802734375,
0.308349609375,
0.68896484375,
-0.78076171875,
-0.036346435546875,
-0.252685546875,
-0.53564453125,
-0.67138671875,
0.7421875,
0.98193359375,
-0.69970703125,
-0.53759765625,
-0.2410888671875,
0.37255859375,
0.615234375,
0.449951171875,
0.404052734375,
-0.1142578125,
-0.255859375
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Submitted Solution:
```
from sys import stdin,stdout
inp=stdin.readline
op=stdout.write
n=int(inp())
st=[]
for i in range(n):
temp=list(inp()[:-1])
st.append(temp)
alph=list("abcdefghijklmnopqrstuvwxyz")
g={alph[i]:[] for i in range(26)}
pos=0
flag=1
while(len(st)>0):
m=len(st)
while(m>1):
x=st.pop(0)
y=st[0]
if(pos<len(x) and pos<len(y)):
if(x[pos]==y[pos] ):
st.append(x)
st.append(y)
else:
if(x[pos] in g[y[pos]]):
break
else:
g[x[pos]].append(y[pos])
m=m-1
else:
st.pop(0)
pos=pos+1
continue
break
else:
flag=0
# print(g)
if(flag==0):
st=[]
vis={i:0 for i in list(g.keys())}
q=[]
indeg={i:0 for i in list(g.keys())}
for i in alph[1:27]:
for j in g[i]:
if not(j==0):
indeg[j]+=1
for j in list(indeg.keys()):
if(indeg[j]==0):
q.append(j)
vis[j]=1
# print(q)
ans=[]
while(len(q)>0):
temp=q.pop(0)
ans.append(temp)
for j in g[temp]:
if not(j==0) and vis[j]==0:
indeg[j]-=1
for j in list(indeg.keys()):
if(indeg[j]==0 and vis[j]==0):
q.append(j)
vis[j]=1
if(len(ans)==26):
op(''.join(ans))
else:
op("Impossible\n")
# op(str(vis)+"\n")
else:
op("Impossible\n")
```
No
| 72,054 | [
-0.0347900390625,
-0.2958984375,
0.419677734375,
-0.2406005859375,
-0.400634765625,
-0.288330078125,
-0.093994140625,
0.26318359375,
0.09747314453125,
0.603515625,
0.6552734375,
0.0177154541015625,
0.22216796875,
-0.8720703125,
-0.8095703125,
0.137939453125,
-0.180419921875,
-0.413330078125,
-0.04302978515625,
-0.1639404296875,
0.428955078125,
0.2188720703125,
-1.6826171875,
0.10687255859375,
-0.583984375,
0.9892578125,
0.53173828125,
0.1768798828125,
1.2421875,
0.92578125,
-0.077880859375,
-0.40576171875,
0.5224609375,
-0.82763671875,
-0.211181640625,
-0.303955078125,
0.67822265625,
-0.51220703125,
-0.1773681640625,
-0.7197265625,
0.421875,
-0.67822265625,
0.406494140625,
-0.81591796875,
-0.89697265625,
-0.347412109375,
-0.1845703125,
-0.2103271484375,
-0.45263671875,
-1.2236328125,
0.2249755859375,
-0.2197265625,
0.62353515625,
-0.499755859375,
-0.10601806640625,
0.102294921875,
0.341796875,
0.0197296142578125,
-0.495849609375,
0.3818359375,
0.015960693359375,
0.351806640625,
-0.383056640625,
-0.63330078125,
-0.33447265625,
0.253662109375,
0.141357421875,
-0.1221923828125,
0.1630859375,
-0.49853515625,
-0.2242431640625,
0.312255859375,
-0.34765625,
0.06622314453125,
-0.51171875,
0.08294677734375,
-0.1854248046875,
-0.1673583984375,
-0.484375,
0.59765625,
0.26416015625,
0.6728515625,
0.1380615234375,
0.366943359375,
-0.2724609375,
-0.30517578125,
-0.006076812744140625,
0.1400146484375,
0.26123046875,
0.1253662109375,
0.2259521484375,
0.359619140625,
-0.7763671875,
-0.284912109375,
0.472900390625,
0.53271484375,
-0.0203857421875,
0.252685546875,
0.10882568359375,
0.1519775390625,
0.96142578125,
1.19140625,
-0.1544189453125,
0.98291015625,
-0.75439453125,
0.12274169921875,
-0.11260986328125,
-0.2318115234375,
0.11370849609375,
-0.34033203125,
-0.1241455078125,
-0.289794921875,
0.1488037109375,
0.22802734375,
0.0005865097045898438,
0.6865234375,
-0.423828125,
0.428466796875,
-0.86962890625,
-0.1019287109375,
0.497802734375,
0.043243408203125,
0.01403045654296875,
0.06243896484375,
0.39111328125,
-0.266845703125,
-0.266357421875,
0.90380859375,
-0.435302734375,
-0.08660888671875,
0.474609375,
-0.10601806640625,
-0.5556640625,
0.2481689453125,
-0.1397705078125,
0.74560546875,
-0.03253173828125,
0.476318359375,
0.5791015625,
-0.498291015625,
0.63916015625,
-0.0911865234375,
0.0460205078125,
1.5751953125,
-0.060333251953125,
-0.2724609375,
0.298828125,
0.2093505859375,
-0.7548828125,
0.517578125,
-0.99755859375,
0.78271484375,
0.2447509765625,
0.2386474609375,
-0.53271484375,
0.419677734375,
-0.1954345703125,
0.382568359375,
0.615234375,
0.56591796875,
-0.33203125,
-0.1103515625,
-0.212890625,
0.98828125,
-0.3076171875,
1.0341796875,
-0.5234375,
-0.0975341796875,
0.04864501953125,
-0.1348876953125,
0.066162109375,
0.0762939453125,
-0.367431640625,
1.046875,
0.307373046875,
0.83642578125,
0.416015625,
-0.378662109375,
0.12127685546875,
0.1669921875,
-0.359130859375,
0.42822265625,
0.0236053466796875,
0.8271484375,
0.1929931640625,
0.2078857421875,
0.2841796875,
-0.72216796875,
-0.30908203125,
-0.6884765625,
-0.222900390625,
0.79443359375,
-0.5009765625,
0.408447265625,
-0.0689697265625,
-0.1278076171875,
-0.62451171875,
0.1302490234375,
0.8681640625,
-0.947265625,
-0.2325439453125,
0.5703125,
-0.183837890625,
0.6025390625,
-0.71337890625,
-0.53662109375,
0.371337890625,
1.0849609375,
0.0574951171875,
0.037017822265625,
0.238037109375,
0.23828125,
-0.48828125,
0.0780029296875,
0.31982421875,
-0.036865234375,
-0.427734375,
0.59814453125,
-0.425048828125,
-0.15380859375,
0.268310546875,
0.908203125,
0.802734375,
0.25146484375,
-0.27685546875,
-0.0227203369140625,
1.01171875,
1.3388671875,
-0.326171875,
0.07818603515625,
0.09735107421875,
1.0947265625,
0.3623046875,
0.6923828125,
0.56103515625,
-0.0753173828125,
0.80615234375,
0.58447265625,
-0.391845703125,
0.0987548828125,
0.03424072265625,
0.587890625,
0.70751953125,
0.65625,
-0.1058349609375,
0.45849609375,
-0.1751708984375,
0.1563720703125,
-0.281005859375,
0.6513671875,
0.18505859375,
0.85546875,
0.06396484375,
0.31494140625,
-0.479736328125,
-0.525390625,
-0.2001953125,
0.51318359375,
-0.96630859375,
-0.70166015625,
-0.32763671875,
-0.1954345703125,
0.07611083984375,
0.033935546875,
0.1790771484375,
0.19189453125,
0.347412109375,
0.30322265625,
-0.24755859375,
-0.6416015625,
-0.984375,
-0.869140625,
-1.2646484375,
-0.343505859375,
-0.73193359375,
-0.023162841796875,
0.32080078125,
-0.472412109375,
0.419189453125,
-0.2568359375,
-0.1495361328125,
0.34375,
-0.458740234375,
0.6435546875,
0.09197998046875,
0.83642578125,
-0.55419921875,
0.164306640625,
-0.199462890625,
1.1845703125,
-0.64404296875,
-0.1546630859375,
-0.50927734375,
-0.6962890625,
0.458740234375,
0.442138671875,
0.57861328125,
0.06024169921875,
-0.59033203125,
-1.15625,
-0.54052734375,
0.06304931640625,
-0.8876953125,
0.2490234375,
-0.73681640625,
1.0263671875,
0.10906982421875,
-0.681640625,
0.40771484375,
0.76171875,
-0.7451171875,
0.84716796875,
0.471435546875,
0.188232421875,
-0.87548828125,
1.49609375,
0.07525634765625,
0.47998046875,
-0.4697265625,
-0.484130859375,
-0.428955078125,
0.29638671875,
0.7529296875,
-1.0107421875,
-0.09112548828125,
0.78759765625,
-0.0080413818359375,
-1.1474609375,
0.7333984375,
-0.8271484375,
-0.7119140625,
-0.0684814453125,
-0.6455078125,
0.68212890625,
0.83837890625,
0.5908203125,
0.1959228515625,
-0.37451171875,
-0.2025146484375,
0.56884765625,
-0.033966064453125,
-0.6259765625,
-0.2252197265625,
0.428955078125,
-0.1868896484375,
-0.156982421875,
0.162353515625,
-0.39208984375,
-0.08416748046875,
-0.05023193359375,
-0.174560546875,
0.9970703125,
0.1295166015625,
0.18603515625,
-0.054168701171875,
0.87060546875,
-0.74365234375,
-0.496337890625,
-0.52685546875,
0.7265625,
0.6279296875,
0.425537109375,
0.455810546875,
-0.12109375,
-0.43212890625,
-0.81884765625,
0.277099609375,
-0.003963470458984375,
0.63134765625,
-0.67041015625,
0.830078125,
0.2017822265625,
-0.56103515625,
0.431884765625,
-0.80517578125,
-0.25146484375,
1.33203125,
-0.298828125,
0.83251953125,
-0.626953125,
0.09320068359375,
-0.3017578125,
0.359619140625,
0.44775390625,
0.2314453125,
0.67333984375,
-0.413330078125,
0.00014770030975341797,
-0.391357421875,
-0.499755859375,
0.15283203125,
-0.75048828125,
0.084228515625,
-0.105224609375,
-0.440185546875,
-0.8916015625,
0.72119140625,
0.5283203125,
0.1832275390625,
0.1519775390625,
0.70068359375,
0.1890869140625,
0.293701171875,
1.01171875,
-0.34521484375,
0.1781005859375,
-0.65087890625,
0.8720703125,
0.26416015625,
-0.153076171875,
-0.0038909912109375,
-0.01934814453125,
-0.12060546875,
0.153564453125,
-0.1595458984375,
-0.150634765625,
-0.7548828125,
0.236083984375,
0.2239990234375,
0.71484375,
-0.54150390625,
-0.5712890625,
-0.1719970703125,
0.58251953125,
0.318115234375,
-0.5927734375,
0.1116943359375,
-0.69970703125,
0.308349609375,
0.5927734375,
-0.124267578125,
-0.521484375,
-0.57763671875,
-1.318359375,
-0.450927734375,
0.60546875,
0.4013671875,
0.08184814453125,
-0.11737060546875,
-0.8779296875,
0.716796875,
0.10693359375,
-0.291259765625,
0.1651611328125,
-0.293701171875,
-0.0293426513671875,
-0.1441650390625,
0.55908203125,
0.035247802734375,
-0.72265625,
0.326171875,
-1.095703125,
0.6103515625,
-0.8203125,
0.54931640625,
0.056121826171875,
0.1942138671875,
-0.1727294921875,
0.38037109375,
-0.487548828125,
-0.05755615234375,
-0.306396484375,
0.55029296875,
-1.052734375,
-0.7666015625,
0.73046875,
0.04656982421875,
0.03582763671875,
0.71533203125,
-0.09442138671875,
-0.5791015625,
0.177978515625,
0.28759765625,
-0.54150390625,
0.381591796875,
-0.309326171875,
0.2142333984375,
-0.45166015625,
-0.367431640625,
-0.07562255859375,
-0.392333984375,
0.701171875,
0.23486328125,
-0.78125,
-0.47119140625,
-0.99169921875,
0.0298309326171875,
-0.198974609375,
-0.61328125,
0.31201171875,
-0.1644287109375,
-0.27587890625,
-0.340576171875,
-0.3232421875,
-0.69677734375,
-0.032562255859375,
-0.5908203125,
-0.318115234375,
0.194580078125,
0.346435546875,
0.57861328125,
0.1263427734375,
-0.31396484375,
0.0266571044921875,
-0.302490234375,
-0.039031982421875,
-0.316162109375,
-0.1630859375,
-0.071044921875,
-0.378173828125,
-0.295166015625,
-0.03021240234375,
0.368896484375,
0.278564453125,
0.2978515625,
0.2476806640625,
0.421142578125,
0.51513671875,
-0.56494140625,
0.74169921875,
-0.037933349609375,
-0.79541015625,
-0.45361328125,
0.497314453125,
-0.1021728515625,
0.96435546875,
0.2607421875,
-1.2275390625,
-0.810546875,
-1.314453125,
0.03350830078125,
-0.3173828125,
-0.240478515625,
-0.87158203125,
0.031585693359375,
-0.51904296875,
0.2286376953125,
-0.204833984375,
-0.498779296875,
0.10089111328125,
-1.380859375,
0.1082763671875,
-0.71875,
-0.56005859375,
-0.398681640625,
-0.48828125,
-0.186767578125,
0.97705078125,
0.34423828125,
0.280029296875,
0.1612548828125,
0.11712646484375,
-0.06292724609375,
-0.272216796875,
-0.91162109375,
-0.5078125,
0.0543212890625,
0.2105712890625,
0.0626220703125,
-0.06036376953125,
-0.452880859375,
0.84765625,
-0.9482421875,
-0.0338134765625,
-0.1798095703125,
-0.276611328125,
-0.07379150390625,
-0.281005859375,
1.1865234375,
-0.40576171875,
-0.01451873779296875,
-0.08367919921875,
0.455322265625,
0.52392578125,
-0.37548828125,
-0.349365234375,
-0.60888671875,
-0.3623046875,
-1.0009765625,
0.68359375,
-0.7119140625,
0.15576171875,
-0.64794921875,
-0.271728515625,
1.23828125,
-0.90673828125,
0.51220703125,
0.859375,
0.0194549560546875,
0.132080078125,
-0.8154296875,
0.5771484375,
0.51220703125,
-0.484130859375,
-0.08782958984375,
0.1629638671875,
-0.55126953125,
0.29931640625,
0.07061767578125,
-1.0341796875,
-0.708984375,
0.61279296875,
1.251953125,
-0.1591796875,
0.6845703125,
-0.143310546875,
-0.449951171875,
-0.4365234375,
1.0234375,
-0.150634765625,
0.057861328125,
1.015625,
-0.5234375,
-0.38232421875,
0.18212890625,
-0.0287628173828125,
-0.51123046875,
-0.406494140625,
1.56640625,
-0.1943359375,
-0.287841796875,
1.056640625,
0.796875,
-0.7216796875,
-0.5615234375,
-0.3134765625,
0.3525390625,
0.0262908935546875,
-0.74658203125,
0.30029296875,
0.59326171875,
-0.7353515625,
-0.152099609375,
0.473876953125,
-0.1927490234375,
0.356201171875,
0.0732421875,
0.4794921875,
-0.3798828125,
0.2337646484375,
0.6982421875,
-0.7197265625,
-0.1160888671875,
-1.0859375,
0.3134765625,
-0.2076416015625,
-0.43994140625,
0.76123046875,
-0.26611328125,
0.483642578125,
0.91552734375,
-0.238037109375,
0.52880859375,
-0.69873046875,
-0.486083984375,
0.1827392578125,
-0.95947265625,
-0.68896484375,
-0.452392578125,
0.51953125,
-0.1358642578125,
0.23046875,
-1.0888671875,
0.2171630859375,
0.50537109375,
0.361572265625,
-0.52783203125,
-0.7109375,
-0.037384033203125,
-0.865234375,
-0.486572265625,
-0.490966796875,
-0.56640625,
-0.2578125,
-0.034515380859375,
0.02105712890625,
-0.53369140625,
0.334228515625,
0.41796875,
-0.264404296875,
0.791015625,
-0.5283203125,
0.43017578125,
-0.73876953125,
-0.2301025390625,
-0.59326171875,
0.0404052734375,
-0.332763671875,
-0.0394287109375,
-0.432861328125,
0.2071533203125,
0.449462890625,
0.25146484375,
-0.028594970703125,
-0.207275390625,
-0.481201171875,
-0.59912109375,
-0.1201171875,
0.2060546875,
-0.5302734375,
0.75,
0.39697265625,
0.2132568359375,
0.74365234375,
-0.2147216796875,
-0.4775390625,
0.1177978515625,
0.7197265625,
0.63671875,
-0.300048828125,
-0.09552001953125,
-0.1646728515625,
-0.037109375,
-0.79638671875,
0.08660888671875,
-0.0290985107421875,
0.256103515625,
0.021881103515625,
-0.2841796875,
0.364501953125,
1.13671875,
0.02264404296875,
0.7099609375,
0.2415771484375,
0.25830078125,
0.29345703125,
-0.48291015625,
-0.062286376953125,
0.467041015625,
0.1373291015625,
-0.357666015625,
-0.0178680419921875,
0.513671875,
-0.0211944580078125,
0.326171875,
0.06488037109375,
-0.95849609375,
-1.220703125,
-0.366943359375,
0.11962890625,
0.49560546875,
0.65234375,
-0.442626953125,
-0.2205810546875,
-0.455810546875,
-0.85595703125,
0.5966796875,
-1.1982421875,
-0.71875,
0.55078125,
-0.25830078125,
-0.72607421875,
-0.08673095703125,
-0.53369140625,
0.1290283203125,
0.1365966796875,
0.3681640625,
-0.66845703125,
0.044677734375,
0.2607421875,
0.461669921875,
-0.27685546875,
-0.2449951171875,
-0.055389404296875,
0.309814453125,
-0.364501953125,
-0.2120361328125,
0.37353515625,
1.0380859375,
0.1441650390625,
-0.05743408203125,
-0.79736328125,
0.149658203125,
0.49462890625,
0.01013946533203125,
-0.342041015625,
-0.0168914794921875,
-0.63525390625,
0.68359375,
-0.67919921875,
-0.0321044921875,
-0.01690673828125,
0.163818359375,
0.0740966796875,
-0.428955078125,
-0.556640625,
0.84375,
1.130859375,
-0.25537109375,
0.462158203125,
0.053863525390625,
0.2186279296875,
-0.258544921875,
-0.1513671875,
-0.42822265625,
0.464599609375,
0.1737060546875,
0.4736328125,
-0.0316162109375,
0.77392578125,
0.798828125,
-0.12152099609375,
0.279296875,
0.365234375,
0.0596923828125,
-0.0328369140625,
0.006931304931640625,
-0.064208984375,
0.2724609375,
0.466796875,
-0.6240234375,
0.369384765625,
-0.80517578125,
-0.2286376953125,
-0.08624267578125,
-0.61474609375,
0.82861328125,
-0.9697265625,
-0.061187744140625,
-0.1759033203125,
-0.48291015625,
0.31689453125,
0.74951171875,
0.483154296875,
-0.0011968612670898438,
0.62646484375,
0.888671875,
0.313232421875,
1.044921875,
0.61962890625,
0.2783203125,
-0.79931640625,
0.163330078125,
0.2626953125,
-0.252685546875,
-0.37841796875,
-0.195556640625,
-0.8193359375,
0.53125,
-0.014739990234375,
-0.44091796875,
0.388916015625,
-0.7919921875,
-0.24755859375,
0.09814453125,
0.84033203125,
-0.413330078125,
0.4462890625,
0.0875244140625,
-0.393798828125,
-0.7783203125,
0.939453125,
-0.049560546875,
0.325927734375,
0.23974609375,
0.83349609375,
-0.01030731201171875,
1.1455078125,
0.4306640625,
-0.251220703125,
0.0626220703125,
0.1103515625,
-0.3310546875,
-0.92236328125,
-0.2548828125,
-0.572265625,
0.16552734375,
-0.368408203125,
-0.08172607421875,
-0.0230712890625,
0.64111328125,
0.0033283233642578125,
-0.9306640625,
-0.33203125,
0.059844970703125,
-0.62109375,
0.55859375,
0.283447265625,
0.223388671875,
0.332763671875,
0.03179931640625,
-0.318603515625,
-0.6591796875,
-0.025115966796875,
-0.67236328125,
0.38427734375,
-0.337158203125,
-0.2408447265625,
-0.79150390625,
-0.79345703125,
-0.266845703125,
0.163818359375,
-0.3154296875,
-0.810546875,
0.310791015625,
0.1622314453125,
0.47265625,
0.08843994140625,
-0.40625,
0.5888671875,
0.84912109375,
0.9580078125,
0.0152435302734375,
0.81982421875,
0.408203125,
-0.312255859375,
0.1485595703125,
-0.271728515625,
0.358154296875,
-0.5556640625,
0.149169921875,
-0.275634765625,
0.392333984375,
-0.5654296875,
-1.25390625,
-0.107177734375,
0.6513671875,
0.2200927734375,
-0.71142578125,
-1.11328125,
-0.6953125,
-0.607421875,
0.359130859375,
-0.74853515625,
0.427734375,
-0.0263824462890625,
0.252197265625,
-0.1943359375,
-0.9189453125,
4.4453125,
1.0087890625,
1.166015625,
0.458984375,
0.09454345703125,
0.88427734375,
0.421875,
-0.26220703125,
-0.05169677734375,
-0.72802734375,
0.3623046875,
-0.2822265625,
-0.154296875,
0.96875,
0.345947265625,
0.7490234375,
-0.841796875,
-0.316162109375,
0.10302734375,
-0.63720703125,
-0.794921875,
0.1328125,
-0.464111328125,
0.1409912109375,
-0.187255859375,
0.43017578125,
0.75146484375,
-0.95458984375,
-0.39990234375,
-0.2744140625,
0.203857421875,
-0.6953125,
1.15234375,
-0.324951171875,
-0.2197265625,
0.415283203125,
-0.16748046875,
-0.5595703125,
-0.1197509765625,
0.4921875,
0.155029296875,
0.45947265625,
0.9970703125,
-0.2244873046875,
0.50732421875,
0.5732421875,
-0.54248046875,
0.0748291015625,
-0.23388671875,
-0.8701171875,
1.0458984375,
-0.338134765625,
0.357177734375,
-0.411865234375,
-0.91259765625,
0.2447509765625,
-0.08502197265625,
-0.2978515625,
-0.12646484375,
0.2333984375,
0.1697998046875,
0.053192138671875,
-0.09320068359375,
0.373291015625,
-1.048828125,
0.62451171875,
0.0439453125,
0.2122802734375,
-0.60546875,
-0.3583984375,
-0.23388671875,
-0.214599609375,
-0.2108154296875,
-0.455810546875,
0.42333984375,
0.2183837890625,
0.004878997802734375,
0.308349609375,
0.68896484375,
-0.78076171875,
-0.036346435546875,
-0.252685546875,
-0.53564453125,
-0.67138671875,
0.7421875,
0.98193359375,
-0.69970703125,
-0.53759765625,
-0.2410888671875,
0.37255859375,
0.615234375,
0.449951171875,
0.404052734375,
-0.1142578125,
-0.255859375
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!
She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.
Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.
Input
The first line contains an integer n (1 ≤ n ≤ 100): number of names.
Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.
Output
If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).
Otherwise output a single word "Impossible" (without quotes).
Examples
Input
3
rivest
shamir
adleman
Output
bcdefghijklmnopqrsatuvwxyz
Input
10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer
Output
Impossible
Input
10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever
Output
aghjlnopefikdmbcqrstuvwxyz
Input
7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck
Output
acbdefhijklmnogpqrstuvwxyz
Submitted Solution:
```
from heapq import heappop, heappush
n = int(input())
a = []
first = ord('a')
for i in range(n):
a.append(input())
graph = [[] for x in range(27)]
for i in range(int(n-1)):
for j in range(i+1, n, 1):
pre = a[i]
suf = a[j]
if len(pre) <= len(suf):
index = 0
while index < len(pre):
if pre[index] == suf[index]:
index += 1
else:
graph[ord(pre[index])-first].append(ord(suf[index])-first)
index = -1
break
else:
index = 0
while index < len(suf):
if pre[index] == suf[index]:
index += 1
else:
graph[ord(pre[index])-first].append(ord(suf[index])-first)
index = -1
break
if index!=-1:
print("Imposible")
exit(0)
isContructors = True
def dfs(u, stack, vis):
vis[u] = 2
#print("dfs in ",u,end=" ")
global isContructors, graph
for v in graph[u]:
if vis[v] == 0:
dfs(v, stack, vis)
elif vis[v] == 2:
# print("false in vetex ",v,end=" ")
isContructors = False
# print("")
vis[u] = 1
stack.append(u)
def roolback(u, vis):
vis[u] = 1
global graph
print(str(chr(u+first)), end="")
for v in graph[u]:
if vis[v] == 0:
roolback(v, vis)
stack, vis = [], [0]*26
for i in range(26):
if vis[i] == 0:
dfs(i, stack, vis)
if isContructors == False:
print("Impossible")
else:
vis = [0]*26
while stack:
u = stack[-1]
stack.pop()
print(chr(u+first),end="")
```
No
| 72,055 | [
-0.0347900390625,
-0.2958984375,
0.419677734375,
-0.2406005859375,
-0.400634765625,
-0.288330078125,
-0.093994140625,
0.26318359375,
0.09747314453125,
0.603515625,
0.6552734375,
0.0177154541015625,
0.22216796875,
-0.8720703125,
-0.8095703125,
0.137939453125,
-0.180419921875,
-0.413330078125,
-0.04302978515625,
-0.1639404296875,
0.428955078125,
0.2188720703125,
-1.6826171875,
0.10687255859375,
-0.583984375,
0.9892578125,
0.53173828125,
0.1768798828125,
1.2421875,
0.92578125,
-0.077880859375,
-0.40576171875,
0.5224609375,
-0.82763671875,
-0.211181640625,
-0.303955078125,
0.67822265625,
-0.51220703125,
-0.1773681640625,
-0.7197265625,
0.421875,
-0.67822265625,
0.406494140625,
-0.81591796875,
-0.89697265625,
-0.347412109375,
-0.1845703125,
-0.2103271484375,
-0.45263671875,
-1.2236328125,
0.2249755859375,
-0.2197265625,
0.62353515625,
-0.499755859375,
-0.10601806640625,
0.102294921875,
0.341796875,
0.0197296142578125,
-0.495849609375,
0.3818359375,
0.015960693359375,
0.351806640625,
-0.383056640625,
-0.63330078125,
-0.33447265625,
0.253662109375,
0.141357421875,
-0.1221923828125,
0.1630859375,
-0.49853515625,
-0.2242431640625,
0.312255859375,
-0.34765625,
0.06622314453125,
-0.51171875,
0.08294677734375,
-0.1854248046875,
-0.1673583984375,
-0.484375,
0.59765625,
0.26416015625,
0.6728515625,
0.1380615234375,
0.366943359375,
-0.2724609375,
-0.30517578125,
-0.006076812744140625,
0.1400146484375,
0.26123046875,
0.1253662109375,
0.2259521484375,
0.359619140625,
-0.7763671875,
-0.284912109375,
0.472900390625,
0.53271484375,
-0.0203857421875,
0.252685546875,
0.10882568359375,
0.1519775390625,
0.96142578125,
1.19140625,
-0.1544189453125,
0.98291015625,
-0.75439453125,
0.12274169921875,
-0.11260986328125,
-0.2318115234375,
0.11370849609375,
-0.34033203125,
-0.1241455078125,
-0.289794921875,
0.1488037109375,
0.22802734375,
0.0005865097045898438,
0.6865234375,
-0.423828125,
0.428466796875,
-0.86962890625,
-0.1019287109375,
0.497802734375,
0.043243408203125,
0.01403045654296875,
0.06243896484375,
0.39111328125,
-0.266845703125,
-0.266357421875,
0.90380859375,
-0.435302734375,
-0.08660888671875,
0.474609375,
-0.10601806640625,
-0.5556640625,
0.2481689453125,
-0.1397705078125,
0.74560546875,
-0.03253173828125,
0.476318359375,
0.5791015625,
-0.498291015625,
0.63916015625,
-0.0911865234375,
0.0460205078125,
1.5751953125,
-0.060333251953125,
-0.2724609375,
0.298828125,
0.2093505859375,
-0.7548828125,
0.517578125,
-0.99755859375,
0.78271484375,
0.2447509765625,
0.2386474609375,
-0.53271484375,
0.419677734375,
-0.1954345703125,
0.382568359375,
0.615234375,
0.56591796875,
-0.33203125,
-0.1103515625,
-0.212890625,
0.98828125,
-0.3076171875,
1.0341796875,
-0.5234375,
-0.0975341796875,
0.04864501953125,
-0.1348876953125,
0.066162109375,
0.0762939453125,
-0.367431640625,
1.046875,
0.307373046875,
0.83642578125,
0.416015625,
-0.378662109375,
0.12127685546875,
0.1669921875,
-0.359130859375,
0.42822265625,
0.0236053466796875,
0.8271484375,
0.1929931640625,
0.2078857421875,
0.2841796875,
-0.72216796875,
-0.30908203125,
-0.6884765625,
-0.222900390625,
0.79443359375,
-0.5009765625,
0.408447265625,
-0.0689697265625,
-0.1278076171875,
-0.62451171875,
0.1302490234375,
0.8681640625,
-0.947265625,
-0.2325439453125,
0.5703125,
-0.183837890625,
0.6025390625,
-0.71337890625,
-0.53662109375,
0.371337890625,
1.0849609375,
0.0574951171875,
0.037017822265625,
0.238037109375,
0.23828125,
-0.48828125,
0.0780029296875,
0.31982421875,
-0.036865234375,
-0.427734375,
0.59814453125,
-0.425048828125,
-0.15380859375,
0.268310546875,
0.908203125,
0.802734375,
0.25146484375,
-0.27685546875,
-0.0227203369140625,
1.01171875,
1.3388671875,
-0.326171875,
0.07818603515625,
0.09735107421875,
1.0947265625,
0.3623046875,
0.6923828125,
0.56103515625,
-0.0753173828125,
0.80615234375,
0.58447265625,
-0.391845703125,
0.0987548828125,
0.03424072265625,
0.587890625,
0.70751953125,
0.65625,
-0.1058349609375,
0.45849609375,
-0.1751708984375,
0.1563720703125,
-0.281005859375,
0.6513671875,
0.18505859375,
0.85546875,
0.06396484375,
0.31494140625,
-0.479736328125,
-0.525390625,
-0.2001953125,
0.51318359375,
-0.96630859375,
-0.70166015625,
-0.32763671875,
-0.1954345703125,
0.07611083984375,
0.033935546875,
0.1790771484375,
0.19189453125,
0.347412109375,
0.30322265625,
-0.24755859375,
-0.6416015625,
-0.984375,
-0.869140625,
-1.2646484375,
-0.343505859375,
-0.73193359375,
-0.023162841796875,
0.32080078125,
-0.472412109375,
0.419189453125,
-0.2568359375,
-0.1495361328125,
0.34375,
-0.458740234375,
0.6435546875,
0.09197998046875,
0.83642578125,
-0.55419921875,
0.164306640625,
-0.199462890625,
1.1845703125,
-0.64404296875,
-0.1546630859375,
-0.50927734375,
-0.6962890625,
0.458740234375,
0.442138671875,
0.57861328125,
0.06024169921875,
-0.59033203125,
-1.15625,
-0.54052734375,
0.06304931640625,
-0.8876953125,
0.2490234375,
-0.73681640625,
1.0263671875,
0.10906982421875,
-0.681640625,
0.40771484375,
0.76171875,
-0.7451171875,
0.84716796875,
0.471435546875,
0.188232421875,
-0.87548828125,
1.49609375,
0.07525634765625,
0.47998046875,
-0.4697265625,
-0.484130859375,
-0.428955078125,
0.29638671875,
0.7529296875,
-1.0107421875,
-0.09112548828125,
0.78759765625,
-0.0080413818359375,
-1.1474609375,
0.7333984375,
-0.8271484375,
-0.7119140625,
-0.0684814453125,
-0.6455078125,
0.68212890625,
0.83837890625,
0.5908203125,
0.1959228515625,
-0.37451171875,
-0.2025146484375,
0.56884765625,
-0.033966064453125,
-0.6259765625,
-0.2252197265625,
0.428955078125,
-0.1868896484375,
-0.156982421875,
0.162353515625,
-0.39208984375,
-0.08416748046875,
-0.05023193359375,
-0.174560546875,
0.9970703125,
0.1295166015625,
0.18603515625,
-0.054168701171875,
0.87060546875,
-0.74365234375,
-0.496337890625,
-0.52685546875,
0.7265625,
0.6279296875,
0.425537109375,
0.455810546875,
-0.12109375,
-0.43212890625,
-0.81884765625,
0.277099609375,
-0.003963470458984375,
0.63134765625,
-0.67041015625,
0.830078125,
0.2017822265625,
-0.56103515625,
0.431884765625,
-0.80517578125,
-0.25146484375,
1.33203125,
-0.298828125,
0.83251953125,
-0.626953125,
0.09320068359375,
-0.3017578125,
0.359619140625,
0.44775390625,
0.2314453125,
0.67333984375,
-0.413330078125,
0.00014770030975341797,
-0.391357421875,
-0.499755859375,
0.15283203125,
-0.75048828125,
0.084228515625,
-0.105224609375,
-0.440185546875,
-0.8916015625,
0.72119140625,
0.5283203125,
0.1832275390625,
0.1519775390625,
0.70068359375,
0.1890869140625,
0.293701171875,
1.01171875,
-0.34521484375,
0.1781005859375,
-0.65087890625,
0.8720703125,
0.26416015625,
-0.153076171875,
-0.0038909912109375,
-0.01934814453125,
-0.12060546875,
0.153564453125,
-0.1595458984375,
-0.150634765625,
-0.7548828125,
0.236083984375,
0.2239990234375,
0.71484375,
-0.54150390625,
-0.5712890625,
-0.1719970703125,
0.58251953125,
0.318115234375,
-0.5927734375,
0.1116943359375,
-0.69970703125,
0.308349609375,
0.5927734375,
-0.124267578125,
-0.521484375,
-0.57763671875,
-1.318359375,
-0.450927734375,
0.60546875,
0.4013671875,
0.08184814453125,
-0.11737060546875,
-0.8779296875,
0.716796875,
0.10693359375,
-0.291259765625,
0.1651611328125,
-0.293701171875,
-0.0293426513671875,
-0.1441650390625,
0.55908203125,
0.035247802734375,
-0.72265625,
0.326171875,
-1.095703125,
0.6103515625,
-0.8203125,
0.54931640625,
0.056121826171875,
0.1942138671875,
-0.1727294921875,
0.38037109375,
-0.487548828125,
-0.05755615234375,
-0.306396484375,
0.55029296875,
-1.052734375,
-0.7666015625,
0.73046875,
0.04656982421875,
0.03582763671875,
0.71533203125,
-0.09442138671875,
-0.5791015625,
0.177978515625,
0.28759765625,
-0.54150390625,
0.381591796875,
-0.309326171875,
0.2142333984375,
-0.45166015625,
-0.367431640625,
-0.07562255859375,
-0.392333984375,
0.701171875,
0.23486328125,
-0.78125,
-0.47119140625,
-0.99169921875,
0.0298309326171875,
-0.198974609375,
-0.61328125,
0.31201171875,
-0.1644287109375,
-0.27587890625,
-0.340576171875,
-0.3232421875,
-0.69677734375,
-0.032562255859375,
-0.5908203125,
-0.318115234375,
0.194580078125,
0.346435546875,
0.57861328125,
0.1263427734375,
-0.31396484375,
0.0266571044921875,
-0.302490234375,
-0.039031982421875,
-0.316162109375,
-0.1630859375,
-0.071044921875,
-0.378173828125,
-0.295166015625,
-0.03021240234375,
0.368896484375,
0.278564453125,
0.2978515625,
0.2476806640625,
0.421142578125,
0.51513671875,
-0.56494140625,
0.74169921875,
-0.037933349609375,
-0.79541015625,
-0.45361328125,
0.497314453125,
-0.1021728515625,
0.96435546875,
0.2607421875,
-1.2275390625,
-0.810546875,
-1.314453125,
0.03350830078125,
-0.3173828125,
-0.240478515625,
-0.87158203125,
0.031585693359375,
-0.51904296875,
0.2286376953125,
-0.204833984375,
-0.498779296875,
0.10089111328125,
-1.380859375,
0.1082763671875,
-0.71875,
-0.56005859375,
-0.398681640625,
-0.48828125,
-0.186767578125,
0.97705078125,
0.34423828125,
0.280029296875,
0.1612548828125,
0.11712646484375,
-0.06292724609375,
-0.272216796875,
-0.91162109375,
-0.5078125,
0.0543212890625,
0.2105712890625,
0.0626220703125,
-0.06036376953125,
-0.452880859375,
0.84765625,
-0.9482421875,
-0.0338134765625,
-0.1798095703125,
-0.276611328125,
-0.07379150390625,
-0.281005859375,
1.1865234375,
-0.40576171875,
-0.01451873779296875,
-0.08367919921875,
0.455322265625,
0.52392578125,
-0.37548828125,
-0.349365234375,
-0.60888671875,
-0.3623046875,
-1.0009765625,
0.68359375,
-0.7119140625,
0.15576171875,
-0.64794921875,
-0.271728515625,
1.23828125,
-0.90673828125,
0.51220703125,
0.859375,
0.0194549560546875,
0.132080078125,
-0.8154296875,
0.5771484375,
0.51220703125,
-0.484130859375,
-0.08782958984375,
0.1629638671875,
-0.55126953125,
0.29931640625,
0.07061767578125,
-1.0341796875,
-0.708984375,
0.61279296875,
1.251953125,
-0.1591796875,
0.6845703125,
-0.143310546875,
-0.449951171875,
-0.4365234375,
1.0234375,
-0.150634765625,
0.057861328125,
1.015625,
-0.5234375,
-0.38232421875,
0.18212890625,
-0.0287628173828125,
-0.51123046875,
-0.406494140625,
1.56640625,
-0.1943359375,
-0.287841796875,
1.056640625,
0.796875,
-0.7216796875,
-0.5615234375,
-0.3134765625,
0.3525390625,
0.0262908935546875,
-0.74658203125,
0.30029296875,
0.59326171875,
-0.7353515625,
-0.152099609375,
0.473876953125,
-0.1927490234375,
0.356201171875,
0.0732421875,
0.4794921875,
-0.3798828125,
0.2337646484375,
0.6982421875,
-0.7197265625,
-0.1160888671875,
-1.0859375,
0.3134765625,
-0.2076416015625,
-0.43994140625,
0.76123046875,
-0.26611328125,
0.483642578125,
0.91552734375,
-0.238037109375,
0.52880859375,
-0.69873046875,
-0.486083984375,
0.1827392578125,
-0.95947265625,
-0.68896484375,
-0.452392578125,
0.51953125,
-0.1358642578125,
0.23046875,
-1.0888671875,
0.2171630859375,
0.50537109375,
0.361572265625,
-0.52783203125,
-0.7109375,
-0.037384033203125,
-0.865234375,
-0.486572265625,
-0.490966796875,
-0.56640625,
-0.2578125,
-0.034515380859375,
0.02105712890625,
-0.53369140625,
0.334228515625,
0.41796875,
-0.264404296875,
0.791015625,
-0.5283203125,
0.43017578125,
-0.73876953125,
-0.2301025390625,
-0.59326171875,
0.0404052734375,
-0.332763671875,
-0.0394287109375,
-0.432861328125,
0.2071533203125,
0.449462890625,
0.25146484375,
-0.028594970703125,
-0.207275390625,
-0.481201171875,
-0.59912109375,
-0.1201171875,
0.2060546875,
-0.5302734375,
0.75,
0.39697265625,
0.2132568359375,
0.74365234375,
-0.2147216796875,
-0.4775390625,
0.1177978515625,
0.7197265625,
0.63671875,
-0.300048828125,
-0.09552001953125,
-0.1646728515625,
-0.037109375,
-0.79638671875,
0.08660888671875,
-0.0290985107421875,
0.256103515625,
0.021881103515625,
-0.2841796875,
0.364501953125,
1.13671875,
0.02264404296875,
0.7099609375,
0.2415771484375,
0.25830078125,
0.29345703125,
-0.48291015625,
-0.062286376953125,
0.467041015625,
0.1373291015625,
-0.357666015625,
-0.0178680419921875,
0.513671875,
-0.0211944580078125,
0.326171875,
0.06488037109375,
-0.95849609375,
-1.220703125,
-0.366943359375,
0.11962890625,
0.49560546875,
0.65234375,
-0.442626953125,
-0.2205810546875,
-0.455810546875,
-0.85595703125,
0.5966796875,
-1.1982421875,
-0.71875,
0.55078125,
-0.25830078125,
-0.72607421875,
-0.08673095703125,
-0.53369140625,
0.1290283203125,
0.1365966796875,
0.3681640625,
-0.66845703125,
0.044677734375,
0.2607421875,
0.461669921875,
-0.27685546875,
-0.2449951171875,
-0.055389404296875,
0.309814453125,
-0.364501953125,
-0.2120361328125,
0.37353515625,
1.0380859375,
0.1441650390625,
-0.05743408203125,
-0.79736328125,
0.149658203125,
0.49462890625,
0.01013946533203125,
-0.342041015625,
-0.0168914794921875,
-0.63525390625,
0.68359375,
-0.67919921875,
-0.0321044921875,
-0.01690673828125,
0.163818359375,
0.0740966796875,
-0.428955078125,
-0.556640625,
0.84375,
1.130859375,
-0.25537109375,
0.462158203125,
0.053863525390625,
0.2186279296875,
-0.258544921875,
-0.1513671875,
-0.42822265625,
0.464599609375,
0.1737060546875,
0.4736328125,
-0.0316162109375,
0.77392578125,
0.798828125,
-0.12152099609375,
0.279296875,
0.365234375,
0.0596923828125,
-0.0328369140625,
0.006931304931640625,
-0.064208984375,
0.2724609375,
0.466796875,
-0.6240234375,
0.369384765625,
-0.80517578125,
-0.2286376953125,
-0.08624267578125,
-0.61474609375,
0.82861328125,
-0.9697265625,
-0.061187744140625,
-0.1759033203125,
-0.48291015625,
0.31689453125,
0.74951171875,
0.483154296875,
-0.0011968612670898438,
0.62646484375,
0.888671875,
0.313232421875,
1.044921875,
0.61962890625,
0.2783203125,
-0.79931640625,
0.163330078125,
0.2626953125,
-0.252685546875,
-0.37841796875,
-0.195556640625,
-0.8193359375,
0.53125,
-0.014739990234375,
-0.44091796875,
0.388916015625,
-0.7919921875,
-0.24755859375,
0.09814453125,
0.84033203125,
-0.413330078125,
0.4462890625,
0.0875244140625,
-0.393798828125,
-0.7783203125,
0.939453125,
-0.049560546875,
0.325927734375,
0.23974609375,
0.83349609375,
-0.01030731201171875,
1.1455078125,
0.4306640625,
-0.251220703125,
0.0626220703125,
0.1103515625,
-0.3310546875,
-0.92236328125,
-0.2548828125,
-0.572265625,
0.16552734375,
-0.368408203125,
-0.08172607421875,
-0.0230712890625,
0.64111328125,
0.0033283233642578125,
-0.9306640625,
-0.33203125,
0.059844970703125,
-0.62109375,
0.55859375,
0.283447265625,
0.223388671875,
0.332763671875,
0.03179931640625,
-0.318603515625,
-0.6591796875,
-0.025115966796875,
-0.67236328125,
0.38427734375,
-0.337158203125,
-0.2408447265625,
-0.79150390625,
-0.79345703125,
-0.266845703125,
0.163818359375,
-0.3154296875,
-0.810546875,
0.310791015625,
0.1622314453125,
0.47265625,
0.08843994140625,
-0.40625,
0.5888671875,
0.84912109375,
0.9580078125,
0.0152435302734375,
0.81982421875,
0.408203125,
-0.312255859375,
0.1485595703125,
-0.271728515625,
0.358154296875,
-0.5556640625,
0.149169921875,
-0.275634765625,
0.392333984375,
-0.5654296875,
-1.25390625,
-0.107177734375,
0.6513671875,
0.2200927734375,
-0.71142578125,
-1.11328125,
-0.6953125,
-0.607421875,
0.359130859375,
-0.74853515625,
0.427734375,
-0.0263824462890625,
0.252197265625,
-0.1943359375,
-0.9189453125,
4.4453125,
1.0087890625,
1.166015625,
0.458984375,
0.09454345703125,
0.88427734375,
0.421875,
-0.26220703125,
-0.05169677734375,
-0.72802734375,
0.3623046875,
-0.2822265625,
-0.154296875,
0.96875,
0.345947265625,
0.7490234375,
-0.841796875,
-0.316162109375,
0.10302734375,
-0.63720703125,
-0.794921875,
0.1328125,
-0.464111328125,
0.1409912109375,
-0.187255859375,
0.43017578125,
0.75146484375,
-0.95458984375,
-0.39990234375,
-0.2744140625,
0.203857421875,
-0.6953125,
1.15234375,
-0.324951171875,
-0.2197265625,
0.415283203125,
-0.16748046875,
-0.5595703125,
-0.1197509765625,
0.4921875,
0.155029296875,
0.45947265625,
0.9970703125,
-0.2244873046875,
0.50732421875,
0.5732421875,
-0.54248046875,
0.0748291015625,
-0.23388671875,
-0.8701171875,
1.0458984375,
-0.338134765625,
0.357177734375,
-0.411865234375,
-0.91259765625,
0.2447509765625,
-0.08502197265625,
-0.2978515625,
-0.12646484375,
0.2333984375,
0.1697998046875,
0.053192138671875,
-0.09320068359375,
0.373291015625,
-1.048828125,
0.62451171875,
0.0439453125,
0.2122802734375,
-0.60546875,
-0.3583984375,
-0.23388671875,
-0.214599609375,
-0.2108154296875,
-0.455810546875,
0.42333984375,
0.2183837890625,
0.004878997802734375,
0.308349609375,
0.68896484375,
-0.78076171875,
-0.036346435546875,
-0.252685546875,
-0.53564453125,
-0.67138671875,
0.7421875,
0.98193359375,
-0.69970703125,
-0.53759765625,
-0.2410888671875,
0.37255859375,
0.615234375,
0.449951171875,
0.404052734375,
-0.1142578125,
-0.255859375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!
The popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Tyndex.Bar automatically fills the glass with the finest 1664 cognac after you buy Tyndex.Bottles and insert in into a USB port). It is highly popular due to the well-thought interaction with the user.
Let us take, for example, the system of automatic address correction. Have you entered codehorses instead of codeforces? The gloomy Zoozle Chrome will sadly say that the address does not exist. Tyndex.Brome at the same time will automatically find the closest address and sent you there. That's brilliant!
How does this splendid function work? That's simple! For each potential address a function of the F error is calculated by the following rules:
* for every letter ci from the potential address c the closest position j of the letter ci in the address (s) entered by the user is found. The absolute difference |i - j| of these positions is added to F. So for every i (1 ≤ i ≤ |c|) the position j is chosen such, that ci = sj, and |i - j| is minimal possible.
* if no such letter ci exists in the address entered by the user, then the length of the potential address |c| is added to F.
After the values of the error function have been calculated for all the potential addresses the most suitable one is found.
To understand the special features of the above described method better, it is recommended to realize the algorithm of calculating the F function for an address given by the user and some set of potential addresses. Good luck!
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105). They are the number of potential addresses and the length of the address entered by the user. The next line contains k lowercase Latin letters. They are the address entered by the user (s). Each next i-th (1 ≤ i ≤ n) line contains a non-empty sequence of lowercase Latin letters. They are the potential address. It is guaranteed that the total length of all the lines does not exceed 2·105.
Output
On each n line of the output file print a single number: the value of the error function when the current potential address is chosen.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).
Examples
Input
2 10
codeforces
codeforces
codehorses
Output
0
12
Input
9 9
vkontakte
vcontacte
vkontrakte
vkollapse
vkrokodile
vtopke
vkapuste
vpechke
vk
vcodeforcese
Output
18
14
36
47
14
29
30
0
84
Tags: binary search, implementation
Correct Solution:
```
from bisect import bisect_left
n, k = map(int, input().split())
q = 'abcdefghijklmnopqrstuvwxyz'
a = {i: [] for i in q}
for i, j in enumerate(input()): a[j].append(i)
def g(t): return [(t[i] + t[i - 1]) // 2 for i in range(1, len(t))]
c = {i: g(a[i]) for i in q}
def f():
global a, c
s, t = 0, input()
d = len(t)
for i, j in enumerate(t):
if a[j]:
if c[j]: s += abs(i - a[j][bisect_left(c[j], i)])
else: s += abs(i - a[j][0])
else: s += d
return str(s)
print('\n'.join(f() for i in range(n)))
```
| 72,099 | [
0.08807373046875,
-0.013092041015625,
0.03485107421875,
0.2880859375,
-0.71435546875,
-0.1817626953125,
0.2098388671875,
0.287841796875,
0.2978515625,
0.7138671875,
0.437255859375,
-0.02587890625,
-0.1748046875,
-0.428466796875,
-0.5693359375,
0.166015625,
-0.50634765625,
-0.5341796875,
-0.32568359375,
0.02001953125,
0.316162109375,
-0.154296875,
-1.5400390625,
0.1527099609375,
-0.14599609375,
0.310791015625,
0.724609375,
-0.31591796875,
1.2880859375,
1.1826171875,
-0.18017578125,
-0.73681640625,
0.304443359375,
-0.52490234375,
-0.3095703125,
-0.412841796875,
0.2374267578125,
-0.861328125,
-0.0181884765625,
-0.79736328125,
0.040496826171875,
-0.420654296875,
0.1533203125,
-0.859375,
-0.78564453125,
-0.1715087890625,
-0.71337890625,
-0.548828125,
-0.2244873046875,
-0.73193359375,
0.37646484375,
0.112060546875,
0.046722412109375,
-0.481689453125,
-0.1365966796875,
-0.0806884765625,
-0.174072265625,
-0.0216064453125,
-0.84423828125,
0.09185791015625,
0.1903076171875,
0.237060546875,
-0.30224609375,
-0.68994140625,
0.416015625,
0.49853515625,
-0.17626953125,
-0.118408203125,
0.02410888671875,
0.02679443359375,
-0.2125244140625,
0.2122802734375,
-0.4140625,
-0.69091796875,
-0.2315673828125,
-0.115966796875,
0.036712646484375,
-0.06134033203125,
-0.88134765625,
0.446533203125,
0.2265625,
0.66162109375,
0.2890625,
0.6513671875,
-0.1798095703125,
0.0567626953125,
0.335693359375,
0.152099609375,
-0.451416015625,
0.09521484375,
0.038970947265625,
0.1593017578125,
0.055328369140625,
-0.06658935546875,
0.4990234375,
0.420654296875,
-0.447509765625,
0.54443359375,
0.2578125,
-0.0770263671875,
0.7265625,
0.9111328125,
-0.82763671875,
1.029296875,
-0.053070068359375,
0.286865234375,
0.0445556640625,
-0.54052734375,
-0.27734375,
-0.61181640625,
-0.25927734375,
-0.33984375,
0.197021484375,
0.24853515625,
-0.1651611328125,
0.67333984375,
-0.494384765625,
0.306640625,
-0.463134765625,
-0.26806640625,
-0.1844482421875,
0.06121826171875,
0.33251953125,
-0.272705078125,
-0.2430419921875,
-0.37744140625,
-0.5400390625,
0.77001953125,
-0.65087890625,
-0.34765625,
-0.29931640625,
-0.53173828125,
-0.1514892578125,
0.226806640625,
-0.1456298828125,
0.79443359375,
-0.302734375,
0.55859375,
0.75341796875,
-1.2509765625,
1.126953125,
0.08575439453125,
0.0200958251953125,
1.6025390625,
0.453369140625,
0.11328125,
0.18896484375,
-0.023040771484375,
-0.439208984375,
0.39599609375,
-0.53173828125,
0.85205078125,
0.14599609375,
0.06561279296875,
0.077880859375,
0.319091796875,
-0.2208251953125,
0.352783203125,
0.444580078125,
0.464599609375,
-0.10467529296875,
0.72705078125,
-0.46826171875,
0.8740234375,
-0.73974609375,
0.67724609375,
-0.666015625,
-0.2049560546875,
-0.0767822265625,
-0.62890625,
0.10064697265625,
0.0125885009765625,
-0.1971435546875,
0.57275390625,
0.85498046875,
0.51953125,
0.74072265625,
-0.341796875,
0.416015625,
0.29736328125,
-0.39794921875,
0.22607421875,
0.70068359375,
1.095703125,
0.382568359375,
-0.0035037994384765625,
0.039825439453125,
-0.48583984375,
-0.6982421875,
-0.60400390625,
0.04241943359375,
0.51416015625,
-0.56201171875,
0.1492919921875,
0.1544189453125,
-0.1529541015625,
-0.75390625,
-0.4296875,
0.479736328125,
-1.19140625,
-0.505859375,
0.85546875,
-0.338134765625,
0.342041015625,
-0.163330078125,
-0.298583984375,
0.19873046875,
1.1162109375,
-0.6015625,
0.2274169921875,
0.330322265625,
0.0811767578125,
-0.39111328125,
-0.1485595703125,
0.35400390625,
-0.0645751953125,
-0.13427734375,
0.59033203125,
0.0279083251953125,
0.08050537109375,
0.368896484375,
0.49267578125,
0.251953125,
0.393798828125,
-0.40966796875,
0.1563720703125,
-0.174560546875,
0.98193359375,
-0.24658203125,
0.376708984375,
-0.32421875,
0.921875,
0.09625244140625,
0.82763671875,
0.160888671875,
0.0180816650390625,
1.1533203125,
0.97314453125,
-0.62646484375,
0.5830078125,
0.0279388427734375,
0.6884765625,
0.299560546875,
0.52587890625,
-0.116943359375,
0.45458984375,
0.041259765625,
0.012542724609375,
-0.339111328125,
0.7431640625,
0.08746337890625,
1.02734375,
0.14794921875,
0.03277587890625,
-0.59716796875,
-0.421875,
0.17138671875,
0.572265625,
-0.697265625,
-0.533203125,
0.311767578125,
-0.1663818359375,
0.325927734375,
-0.16259765625,
0.254638671875,
0.95654296875,
-0.08685302734375,
0.6357421875,
-0.291259765625,
-0.70703125,
-0.7373046875,
-0.7685546875,
-1.12890625,
-0.373779296875,
-0.712890625,
-0.457275390625,
0.320556640625,
-0.55126953125,
0.2218017578125,
0.1478271484375,
0.349853515625,
0.332275390625,
-0.489013671875,
0.72021484375,
0.23583984375,
0.6796875,
-0.52783203125,
0.6220703125,
0.01200103759765625,
0.94775390625,
-0.52099609375,
-0.11566162109375,
-0.07342529296875,
-0.53271484375,
0.55029296875,
0.185546875,
0.451171875,
-0.0572509765625,
-0.427978515625,
-0.64501953125,
-0.48681640625,
0.212646484375,
-0.390869140625,
-0.1781005859375,
-0.292724609375,
0.57763671875,
0.66455078125,
-0.33203125,
0.90087890625,
0.501953125,
-0.74951171875,
0.418701171875,
0.58251953125,
-0.273193359375,
-0.814453125,
1.3896484375,
0.6044921875,
0.336669921875,
-0.591796875,
-0.34521484375,
-0.77490234375,
0.1470947265625,
0.08905029296875,
-0.60400390625,
-0.497314453125,
0.7158203125,
-0.2403564453125,
-1.083984375,
0.416259765625,
-1.228515625,
-0.6318359375,
-0.235595703125,
-0.132568359375,
0.734375,
0.61376953125,
-0.02972412109375,
0.47802734375,
-0.2435302734375,
-0.0406494140625,
0.460205078125,
0.3505859375,
-0.607421875,
0.11029052734375,
0.78125,
0.125,
0.1387939453125,
0.166748046875,
-0.91064453125,
-0.2364501953125,
-0.1683349609375,
-0.1810302734375,
0.73779296875,
0.48486328125,
0.2374267578125,
-0.132080078125,
0.9931640625,
-0.80029296875,
-0.2034912109375,
-0.3798828125,
0.5546875,
0.232177734375,
0.241455078125,
0.07470703125,
-0.1907958984375,
-0.3857421875,
-0.66455078125,
0.303466796875,
0.1326904296875,
0.43310546875,
-0.80517578125,
0.28173828125,
0.2056884765625,
-0.541015625,
0.54052734375,
-0.29736328125,
-0.29052734375,
0.904296875,
-0.055694580078125,
0.77783203125,
-0.712890625,
0.1300048828125,
-0.404541015625,
0.007671356201171875,
1.03515625,
0.1302490234375,
0.322021484375,
-0.339599609375,
-0.5458984375,
-0.2705078125,
-0.54638671875,
-0.07391357421875,
0.243896484375,
0.2578125,
0.05816650390625,
-0.51513671875,
-0.92236328125,
0.5107421875,
0.265380859375,
0.427490234375,
-0.08221435546875,
0.37109375,
0.212158203125,
0.736328125,
0.22021484375,
-0.154541015625,
0.56787109375,
-0.5302734375,
0.6298828125,
0.213623046875,
-0.453369140625,
-0.1982421875,
-0.39208984375,
0.11773681640625,
0.32275390625,
-0.06121826171875,
-0.0701904296875,
-0.79150390625,
0.472900390625,
-0.0186767578125,
0.57421875,
-0.1629638671875,
-0.345947265625,
-0.53466796875,
-0.00014257431030273438,
0.2037353515625,
-0.85498046875,
0.434814453125,
-0.471435546875,
0.330322265625,
0.623046875,
0.32666015625,
-0.36181640625,
-0.94970703125,
-0.40283203125,
-0.716796875,
0.23388671875,
0.712890625,
-0.178955078125,
0.060302734375,
-0.806640625,
0.36083984375,
0.19482421875,
-0.413818359375,
0.1297607421875,
0.041015625,
0.2259521484375,
0.23876953125,
0.8662109375,
-0.294189453125,
-0.46044921875,
0.3994140625,
-0.92724609375,
0.9951171875,
-0.32275390625,
-0.149169921875,
-0.136474609375,
0.054656982421875,
-0.06304931640625,
0.396484375,
-0.72265625,
0.06878662109375,
-0.340576171875,
0.1441650390625,
-1.1083984375,
-1.056640625,
0.7099609375,
0.2403564453125,
0.0699462890625,
0.4091796875,
0.1727294921875,
-0.83154296875,
0.53466796875,
0.4833984375,
-0.43505859375,
0.34521484375,
-0.08367919921875,
0.5771484375,
-0.256591796875,
-0.7998046875,
0.09381103515625,
-0.67822265625,
0.9248046875,
0.26025390625,
-0.69873046875,
-0.52294921875,
-0.8486328125,
-0.007778167724609375,
-0.2666015625,
-0.51171875,
0.66064453125,
-0.1280517578125,
0.0262298583984375,
-0.258056640625,
-0.1318359375,
-1.01171875,
-0.08258056640625,
-0.56201171875,
0.2132568359375,
0.2200927734375,
0.55029296875,
0.88134765625,
-0.260498046875,
-0.5771484375,
0.11749267578125,
-0.06298828125,
-0.11651611328125,
-0.5830078125,
0.12481689453125,
0.036834716796875,
-0.27001953125,
-0.724609375,
0.1541748046875,
0.0287017822265625,
0.580078125,
0.91259765625,
0.3740234375,
0.3173828125,
0.01885986328125,
-0.62158203125,
0.472412109375,
0.142822265625,
-0.8486328125,
-0.337646484375,
0.47509765625,
-0.06298828125,
0.9111328125,
0.381591796875,
-0.71337890625,
-0.4375,
-0.7607421875,
-0.0997314453125,
-1.0478515625,
-0.1934814453125,
-0.978515625,
-0.6005859375,
-0.047607421875,
0.537109375,
0.384521484375,
-0.62548828125,
0.029998779296875,
-1.005859375,
-0.154296875,
-0.7958984375,
-0.47265625,
-0.4111328125,
-0.67578125,
0.002269744873046875,
0.8662109375,
-0.07855224609375,
0.1461181640625,
-0.44189453125,
0.35107421875,
0.1370849609375,
0.08563232421875,
-0.85595703125,
-0.90625,
-0.3330078125,
-0.228271484375,
-0.135009765625,
-0.07843017578125,
-0.5380859375,
0.90869140625,
-0.60888671875,
-0.06854248046875,
-0.74267578125,
-0.029022216796875,
-0.11383056640625,
-0.1309814453125,
0.33447265625,
-0.418212890625,
-0.1385498046875,
-0.34228515625,
0.6171875,
0.53759765625,
-0.10443115234375,
-0.78857421875,
-0.771484375,
-0.962890625,
-1.3984375,
0.35107421875,
-0.41259765625,
0.212646484375,
-0.215087890625,
-0.56689453125,
1.064453125,
-0.424072265625,
0.09344482421875,
0.9248046875,
-0.16455078125,
0.1824951171875,
-0.49755859375,
1.00390625,
0.90234375,
-0.1318359375,
0.0389404296875,
0.18603515625,
-0.411865234375,
0.105224609375,
-0.53271484375,
-0.58447265625,
-0.80419921875,
0.285400390625,
1.0107421875,
-0.10455322265625,
1.0771484375,
-0.6796875,
-0.91162109375,
-0.1571044921875,
0.80712890625,
0.307861328125,
0.392578125,
0.92431640625,
-0.04486083984375,
0.1025390625,
0.374755859375,
0.0009670257568359375,
-0.05938720703125,
-0.669921875,
1.095703125,
-0.470458984375,
-1.0400390625,
0.77587890625,
0.80322265625,
-0.7890625,
-1.1806640625,
-0.1983642578125,
0.253173828125,
-0.154052734375,
-0.6220703125,
0.51123046875,
0.49169921875,
-0.76708984375,
0.42626953125,
0.58740234375,
-0.365234375,
0.287353515625,
0.21826171875,
0.441650390625,
-0.439697265625,
-0.0877685546875,
0.7197265625,
-0.29443359375,
-0.78466796875,
-0.83251953125,
0.27978515625,
0.1453857421875,
-0.051727294921875,
0.80126953125,
0.07940673828125,
0.1983642578125,
0.50439453125,
0.2020263671875,
0.74658203125,
-0.216552734375,
-0.0731201171875,
0.2705078125,
-0.5205078125,
-0.82080078125,
-0.305419921875,
0.939453125,
-0.140380859375,
0.06695556640625,
-0.5048828125,
0.53173828125,
0.40234375,
0.260009765625,
-0.8427734375,
-0.9482421875,
-0.09619140625,
-0.98779296875,
-0.51025390625,
-0.263427734375,
-0.6826171875,
0.1051025390625,
0.142578125,
-0.12646484375,
-0.6162109375,
0.12457275390625,
0.85009765625,
-0.39306640625,
0.2078857421875,
-0.73974609375,
0.283203125,
-0.431640625,
-0.162353515625,
-0.80126953125,
-0.006603240966796875,
-0.2176513671875,
-0.270751953125,
-0.65869140625,
-0.230224609375,
0.390380859375,
0.1446533203125,
-0.271484375,
0.07562255859375,
-0.3017578125,
-1.0615234375,
-0.40966796875,
-0.0181121826171875,
-0.2015380859375,
0.97900390625,
0.39111328125,
-0.056549072265625,
0.336181640625,
-0.70263671875,
-0.2373046875,
0.316650390625,
0.5546875,
0.57421875,
-0.427490234375,
-0.021453857421875,
-0.2169189453125,
-0.050048828125,
-0.84912109375,
0.302490234375,
-0.85693359375,
0.3701171875,
0.26611328125,
-0.0941162109375,
0.49951171875,
0.71728515625,
-0.24560546875,
0.07647705078125,
0.05352783203125,
0.156494140625,
0.51953125,
0.276123046875,
0.03314208984375,
0.075439453125,
0.474609375,
-0.299072265625,
-0.0792236328125,
-0.038177490234375,
0.1611328125,
-0.093505859375,
-0.054962158203125,
-0.615234375,
-1.072265625,
-0.29248046875,
-0.06585693359375,
0.3193359375,
0.308837890625,
-0.2445068359375,
0.1363525390625,
0.30859375,
-0.7919921875,
0.5009765625,
-1.0771484375,
-0.76123046875,
0.58642578125,
-0.16259765625,
-0.580078125,
-0.1273193359375,
-0.198486328125,
0.007732391357421875,
0.0836181640625,
0.0699462890625,
-0.61279296875,
0.427490234375,
0.294677734375,
0.46923828125,
-0.1522216796875,
0.11358642578125,
0.43212890625,
0.609375,
-0.568359375,
-0.6650390625,
-0.0841064453125,
0.97607421875,
0.25341796875,
-0.63134765625,
-0.449951171875,
0.041961669921875,
0.492919921875,
0.225830078125,
-0.54150390625,
0.305419921875,
-0.5546875,
1.2060546875,
-0.90087890625,
0.04974365234375,
0.28466796875,
0.39697265625,
0.06488037109375,
-0.24853515625,
-0.1383056640625,
0.7822265625,
0.72998046875,
-0.334228515625,
0.75146484375,
0.412109375,
0.276611328125,
-0.5986328125,
-0.288330078125,
-0.28662109375,
0.90380859375,
0.8173828125,
0.4833984375,
-0.0021820068359375,
0.2158203125,
0.79443359375,
-0.44921875,
-0.375,
0.66259765625,
0.139404296875,
-0.305419921875,
0.31640625,
0.08697509765625,
0.410888671875,
0.1162109375,
-0.45849609375,
0.1361083984375,
-0.437255859375,
-0.1405029296875,
-0.369140625,
-0.52001953125,
0.95654296875,
-0.734375,
-0.0782470703125,
0.1177978515625,
-0.5400390625,
0.5439453125,
0.603515625,
0.09185791015625,
-0.69091796875,
0.896484375,
0.382568359375,
0.44775390625,
0.77001953125,
0.339599609375,
0.110595703125,
-0.62841796875,
0.360595703125,
0.0008306503295898438,
-0.1737060546875,
-0.1409912109375,
-0.35546875,
-0.994140625,
0.44775390625,
-0.3701171875,
-0.62158203125,
0.38623046875,
-0.459716796875,
-0.1871337890625,
-0.25634765625,
0.96875,
-0.80712890625,
0.3876953125,
0.0018796920776367188,
-0.1533203125,
-0.48388671875,
0.66162109375,
-0.228271484375,
0.2464599609375,
0.07012939453125,
0.97802734375,
-0.1568603515625,
1.662109375,
0.2435302734375,
-0.1341552734375,
0.04779052734375,
0.2301025390625,
-0.389404296875,
-0.6416015625,
-0.428955078125,
-0.57080078125,
0.0377197265625,
-0.321044921875,
-0.50146484375,
-0.09954833984375,
0.492919921875,
0.067138671875,
-0.64892578125,
-0.29052734375,
0.64208984375,
-0.406494140625,
0.35009765625,
0.57080078125,
0.45458984375,
-0.00360870361328125,
-0.370849609375,
-0.4208984375,
-0.41845703125,
0.10821533203125,
-0.48681640625,
0.51953125,
-0.57763671875,
-0.139404296875,
-0.560546875,
-0.1146240234375,
-0.2159423828125,
0.0538330078125,
-0.62255859375,
-0.5751953125,
0.826171875,
0.492919921875,
-0.197998046875,
0.8779296875,
-0.42138671875,
0.095947265625,
0.9453125,
1.166015625,
0.0239715576171875,
0.634765625,
0.361083984375,
0.0635986328125,
-0.0297088623046875,
-0.2225341796875,
0.395751953125,
-0.422607421875,
0.06341552734375,
-0.576171875,
0.2171630859375,
-0.5341796875,
-0.90380859375,
-0.059783935546875,
0.501953125,
0.2470703125,
-0.7607421875,
-1.0498046875,
-0.32568359375,
-1.349609375,
0.129638671875,
-0.50146484375,
0.39697265625,
0.2156982421875,
-0.1513671875,
0.228515625,
-1.048828125,
4.53515625,
1.2255859375,
0.8076171875,
0.168701171875,
0.258544921875,
0.39599609375,
0.2235107421875,
-0.6728515625,
-0.0084991455078125,
-0.5947265625,
0.0396728515625,
-0.408203125,
0.3193359375,
0.8212890625,
0.48828125,
0.405517578125,
-0.7666015625,
-0.43798828125,
0.1983642578125,
-1.013671875,
-0.796875,
0.142333984375,
0.065673828125,
0.828125,
0.09649658203125,
0.81298828125,
0.6953125,
-0.564453125,
-0.282470703125,
-0.572265625,
0.140869140625,
-0.495361328125,
0.837890625,
0.1251220703125,
-0.2037353515625,
0.8935546875,
0.0012226104736328125,
-0.0316162109375,
-0.1689453125,
-0.14306640625,
-0.1724853515625,
0.01093292236328125,
0.541015625,
-0.458740234375,
0.65283203125,
0.2509765625,
-0.5087890625,
-0.036712646484375,
0.1961669921875,
-0.93017578125,
0.87841796875,
-0.25634765625,
0.46044921875,
-0.1553955078125,
-0.437744140625,
0.10675048828125,
0.357177734375,
-0.0498046875,
-0.280029296875,
0.2978515625,
0.55517578125,
0.069091796875,
-0.19775390625,
0.69580078125,
-0.9365234375,
0.57666015625,
-0.175537109375,
0.77001953125,
-0.1622314453125,
-0.1453857421875,
-0.43896484375,
-0.1282958984375,
-0.286865234375,
-0.82373046875,
0.97509765625,
0.2412109375,
-0.1732177734375,
0.363037109375,
0.463623046875,
-0.496337890625,
0.29248046875,
-0.2880859375,
-0.453857421875,
-0.44189453125,
0.75927734375,
1.029296875,
-0.4462890625,
-0.367919921875,
0.26123046875,
1.0673828125,
0.41015625,
0.360107421875,
-0.07958984375,
-0.833984375,
-0.11273193359375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!
The popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Tyndex.Bar automatically fills the glass with the finest 1664 cognac after you buy Tyndex.Bottles and insert in into a USB port). It is highly popular due to the well-thought interaction with the user.
Let us take, for example, the system of automatic address correction. Have you entered codehorses instead of codeforces? The gloomy Zoozle Chrome will sadly say that the address does not exist. Tyndex.Brome at the same time will automatically find the closest address and sent you there. That's brilliant!
How does this splendid function work? That's simple! For each potential address a function of the F error is calculated by the following rules:
* for every letter ci from the potential address c the closest position j of the letter ci in the address (s) entered by the user is found. The absolute difference |i - j| of these positions is added to F. So for every i (1 ≤ i ≤ |c|) the position j is chosen such, that ci = sj, and |i - j| is minimal possible.
* if no such letter ci exists in the address entered by the user, then the length of the potential address |c| is added to F.
After the values of the error function have been calculated for all the potential addresses the most suitable one is found.
To understand the special features of the above described method better, it is recommended to realize the algorithm of calculating the F function for an address given by the user and some set of potential addresses. Good luck!
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105). They are the number of potential addresses and the length of the address entered by the user. The next line contains k lowercase Latin letters. They are the address entered by the user (s). Each next i-th (1 ≤ i ≤ n) line contains a non-empty sequence of lowercase Latin letters. They are the potential address. It is guaranteed that the total length of all the lines does not exceed 2·105.
Output
On each n line of the output file print a single number: the value of the error function when the current potential address is chosen.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).
Examples
Input
2 10
codeforces
codeforces
codehorses
Output
0
12
Input
9 9
vkontakte
vcontacte
vkontrakte
vkollapse
vkrokodile
vtopke
vkapuste
vpechke
vk
vcodeforcese
Output
18
14
36
47
14
29
30
0
84
Tags: binary search, implementation
Correct Solution:
```
# https://codeforces.com/problemset/problem/62/B
# bin search
def search(val):
l = 0
r = 1
while l <= r:
pass
def calc_f(arr, val):
n = len(arr)
l = 0
r = n - 1
last_less = False
while l <= r:
m = l + (r - l) // 2
if arr[m] < val:
l = m + 1
last_less = True
elif arr[m] > val:
r = m - 1
last_less = False
else:
return abs(val - arr[m])
if last_less:
nearest = l, l - 1
else:
nearest = r, r + 1
min_diff = 10**6
for v in nearest:
if 0 <= v < n:
min_diff = min(min_diff, abs(val - arr[v]))
return min_diff
def main():
n = int(input().split()[0])
s = input()
d = {}
for i, char in enumerate(s):
arr = d.get(char, [])
arr.append(i)
d[char] = arr
for i in range(n): # 2 * 10^5 max str length for all potential strings
c = input()
nc = len(c)
f = 0
for j, char in enumerate(c):
if char not in d:
f += nc
else:
f += calc_f(d[char], j)
print(f)
if __name__ == '__main__':
main()
```
| 72,100 | [
0.08807373046875,
-0.013092041015625,
0.03485107421875,
0.2880859375,
-0.71435546875,
-0.1817626953125,
0.2098388671875,
0.287841796875,
0.2978515625,
0.7138671875,
0.437255859375,
-0.02587890625,
-0.1748046875,
-0.428466796875,
-0.5693359375,
0.166015625,
-0.50634765625,
-0.5341796875,
-0.32568359375,
0.02001953125,
0.316162109375,
-0.154296875,
-1.5400390625,
0.1527099609375,
-0.14599609375,
0.310791015625,
0.724609375,
-0.31591796875,
1.2880859375,
1.1826171875,
-0.18017578125,
-0.73681640625,
0.304443359375,
-0.52490234375,
-0.3095703125,
-0.412841796875,
0.2374267578125,
-0.861328125,
-0.0181884765625,
-0.79736328125,
0.040496826171875,
-0.420654296875,
0.1533203125,
-0.859375,
-0.78564453125,
-0.1715087890625,
-0.71337890625,
-0.548828125,
-0.2244873046875,
-0.73193359375,
0.37646484375,
0.112060546875,
0.046722412109375,
-0.481689453125,
-0.1365966796875,
-0.0806884765625,
-0.174072265625,
-0.0216064453125,
-0.84423828125,
0.09185791015625,
0.1903076171875,
0.237060546875,
-0.30224609375,
-0.68994140625,
0.416015625,
0.49853515625,
-0.17626953125,
-0.118408203125,
0.02410888671875,
0.02679443359375,
-0.2125244140625,
0.2122802734375,
-0.4140625,
-0.69091796875,
-0.2315673828125,
-0.115966796875,
0.036712646484375,
-0.06134033203125,
-0.88134765625,
0.446533203125,
0.2265625,
0.66162109375,
0.2890625,
0.6513671875,
-0.1798095703125,
0.0567626953125,
0.335693359375,
0.152099609375,
-0.451416015625,
0.09521484375,
0.038970947265625,
0.1593017578125,
0.055328369140625,
-0.06658935546875,
0.4990234375,
0.420654296875,
-0.447509765625,
0.54443359375,
0.2578125,
-0.0770263671875,
0.7265625,
0.9111328125,
-0.82763671875,
1.029296875,
-0.053070068359375,
0.286865234375,
0.0445556640625,
-0.54052734375,
-0.27734375,
-0.61181640625,
-0.25927734375,
-0.33984375,
0.197021484375,
0.24853515625,
-0.1651611328125,
0.67333984375,
-0.494384765625,
0.306640625,
-0.463134765625,
-0.26806640625,
-0.1844482421875,
0.06121826171875,
0.33251953125,
-0.272705078125,
-0.2430419921875,
-0.37744140625,
-0.5400390625,
0.77001953125,
-0.65087890625,
-0.34765625,
-0.29931640625,
-0.53173828125,
-0.1514892578125,
0.226806640625,
-0.1456298828125,
0.79443359375,
-0.302734375,
0.55859375,
0.75341796875,
-1.2509765625,
1.126953125,
0.08575439453125,
0.0200958251953125,
1.6025390625,
0.453369140625,
0.11328125,
0.18896484375,
-0.023040771484375,
-0.439208984375,
0.39599609375,
-0.53173828125,
0.85205078125,
0.14599609375,
0.06561279296875,
0.077880859375,
0.319091796875,
-0.2208251953125,
0.352783203125,
0.444580078125,
0.464599609375,
-0.10467529296875,
0.72705078125,
-0.46826171875,
0.8740234375,
-0.73974609375,
0.67724609375,
-0.666015625,
-0.2049560546875,
-0.0767822265625,
-0.62890625,
0.10064697265625,
0.0125885009765625,
-0.1971435546875,
0.57275390625,
0.85498046875,
0.51953125,
0.74072265625,
-0.341796875,
0.416015625,
0.29736328125,
-0.39794921875,
0.22607421875,
0.70068359375,
1.095703125,
0.382568359375,
-0.0035037994384765625,
0.039825439453125,
-0.48583984375,
-0.6982421875,
-0.60400390625,
0.04241943359375,
0.51416015625,
-0.56201171875,
0.1492919921875,
0.1544189453125,
-0.1529541015625,
-0.75390625,
-0.4296875,
0.479736328125,
-1.19140625,
-0.505859375,
0.85546875,
-0.338134765625,
0.342041015625,
-0.163330078125,
-0.298583984375,
0.19873046875,
1.1162109375,
-0.6015625,
0.2274169921875,
0.330322265625,
0.0811767578125,
-0.39111328125,
-0.1485595703125,
0.35400390625,
-0.0645751953125,
-0.13427734375,
0.59033203125,
0.0279083251953125,
0.08050537109375,
0.368896484375,
0.49267578125,
0.251953125,
0.393798828125,
-0.40966796875,
0.1563720703125,
-0.174560546875,
0.98193359375,
-0.24658203125,
0.376708984375,
-0.32421875,
0.921875,
0.09625244140625,
0.82763671875,
0.160888671875,
0.0180816650390625,
1.1533203125,
0.97314453125,
-0.62646484375,
0.5830078125,
0.0279388427734375,
0.6884765625,
0.299560546875,
0.52587890625,
-0.116943359375,
0.45458984375,
0.041259765625,
0.012542724609375,
-0.339111328125,
0.7431640625,
0.08746337890625,
1.02734375,
0.14794921875,
0.03277587890625,
-0.59716796875,
-0.421875,
0.17138671875,
0.572265625,
-0.697265625,
-0.533203125,
0.311767578125,
-0.1663818359375,
0.325927734375,
-0.16259765625,
0.254638671875,
0.95654296875,
-0.08685302734375,
0.6357421875,
-0.291259765625,
-0.70703125,
-0.7373046875,
-0.7685546875,
-1.12890625,
-0.373779296875,
-0.712890625,
-0.457275390625,
0.320556640625,
-0.55126953125,
0.2218017578125,
0.1478271484375,
0.349853515625,
0.332275390625,
-0.489013671875,
0.72021484375,
0.23583984375,
0.6796875,
-0.52783203125,
0.6220703125,
0.01200103759765625,
0.94775390625,
-0.52099609375,
-0.11566162109375,
-0.07342529296875,
-0.53271484375,
0.55029296875,
0.185546875,
0.451171875,
-0.0572509765625,
-0.427978515625,
-0.64501953125,
-0.48681640625,
0.212646484375,
-0.390869140625,
-0.1781005859375,
-0.292724609375,
0.57763671875,
0.66455078125,
-0.33203125,
0.90087890625,
0.501953125,
-0.74951171875,
0.418701171875,
0.58251953125,
-0.273193359375,
-0.814453125,
1.3896484375,
0.6044921875,
0.336669921875,
-0.591796875,
-0.34521484375,
-0.77490234375,
0.1470947265625,
0.08905029296875,
-0.60400390625,
-0.497314453125,
0.7158203125,
-0.2403564453125,
-1.083984375,
0.416259765625,
-1.228515625,
-0.6318359375,
-0.235595703125,
-0.132568359375,
0.734375,
0.61376953125,
-0.02972412109375,
0.47802734375,
-0.2435302734375,
-0.0406494140625,
0.460205078125,
0.3505859375,
-0.607421875,
0.11029052734375,
0.78125,
0.125,
0.1387939453125,
0.166748046875,
-0.91064453125,
-0.2364501953125,
-0.1683349609375,
-0.1810302734375,
0.73779296875,
0.48486328125,
0.2374267578125,
-0.132080078125,
0.9931640625,
-0.80029296875,
-0.2034912109375,
-0.3798828125,
0.5546875,
0.232177734375,
0.241455078125,
0.07470703125,
-0.1907958984375,
-0.3857421875,
-0.66455078125,
0.303466796875,
0.1326904296875,
0.43310546875,
-0.80517578125,
0.28173828125,
0.2056884765625,
-0.541015625,
0.54052734375,
-0.29736328125,
-0.29052734375,
0.904296875,
-0.055694580078125,
0.77783203125,
-0.712890625,
0.1300048828125,
-0.404541015625,
0.007671356201171875,
1.03515625,
0.1302490234375,
0.322021484375,
-0.339599609375,
-0.5458984375,
-0.2705078125,
-0.54638671875,
-0.07391357421875,
0.243896484375,
0.2578125,
0.05816650390625,
-0.51513671875,
-0.92236328125,
0.5107421875,
0.265380859375,
0.427490234375,
-0.08221435546875,
0.37109375,
0.212158203125,
0.736328125,
0.22021484375,
-0.154541015625,
0.56787109375,
-0.5302734375,
0.6298828125,
0.213623046875,
-0.453369140625,
-0.1982421875,
-0.39208984375,
0.11773681640625,
0.32275390625,
-0.06121826171875,
-0.0701904296875,
-0.79150390625,
0.472900390625,
-0.0186767578125,
0.57421875,
-0.1629638671875,
-0.345947265625,
-0.53466796875,
-0.00014257431030273438,
0.2037353515625,
-0.85498046875,
0.434814453125,
-0.471435546875,
0.330322265625,
0.623046875,
0.32666015625,
-0.36181640625,
-0.94970703125,
-0.40283203125,
-0.716796875,
0.23388671875,
0.712890625,
-0.178955078125,
0.060302734375,
-0.806640625,
0.36083984375,
0.19482421875,
-0.413818359375,
0.1297607421875,
0.041015625,
0.2259521484375,
0.23876953125,
0.8662109375,
-0.294189453125,
-0.46044921875,
0.3994140625,
-0.92724609375,
0.9951171875,
-0.32275390625,
-0.149169921875,
-0.136474609375,
0.054656982421875,
-0.06304931640625,
0.396484375,
-0.72265625,
0.06878662109375,
-0.340576171875,
0.1441650390625,
-1.1083984375,
-1.056640625,
0.7099609375,
0.2403564453125,
0.0699462890625,
0.4091796875,
0.1727294921875,
-0.83154296875,
0.53466796875,
0.4833984375,
-0.43505859375,
0.34521484375,
-0.08367919921875,
0.5771484375,
-0.256591796875,
-0.7998046875,
0.09381103515625,
-0.67822265625,
0.9248046875,
0.26025390625,
-0.69873046875,
-0.52294921875,
-0.8486328125,
-0.007778167724609375,
-0.2666015625,
-0.51171875,
0.66064453125,
-0.1280517578125,
0.0262298583984375,
-0.258056640625,
-0.1318359375,
-1.01171875,
-0.08258056640625,
-0.56201171875,
0.2132568359375,
0.2200927734375,
0.55029296875,
0.88134765625,
-0.260498046875,
-0.5771484375,
0.11749267578125,
-0.06298828125,
-0.11651611328125,
-0.5830078125,
0.12481689453125,
0.036834716796875,
-0.27001953125,
-0.724609375,
0.1541748046875,
0.0287017822265625,
0.580078125,
0.91259765625,
0.3740234375,
0.3173828125,
0.01885986328125,
-0.62158203125,
0.472412109375,
0.142822265625,
-0.8486328125,
-0.337646484375,
0.47509765625,
-0.06298828125,
0.9111328125,
0.381591796875,
-0.71337890625,
-0.4375,
-0.7607421875,
-0.0997314453125,
-1.0478515625,
-0.1934814453125,
-0.978515625,
-0.6005859375,
-0.047607421875,
0.537109375,
0.384521484375,
-0.62548828125,
0.029998779296875,
-1.005859375,
-0.154296875,
-0.7958984375,
-0.47265625,
-0.4111328125,
-0.67578125,
0.002269744873046875,
0.8662109375,
-0.07855224609375,
0.1461181640625,
-0.44189453125,
0.35107421875,
0.1370849609375,
0.08563232421875,
-0.85595703125,
-0.90625,
-0.3330078125,
-0.228271484375,
-0.135009765625,
-0.07843017578125,
-0.5380859375,
0.90869140625,
-0.60888671875,
-0.06854248046875,
-0.74267578125,
-0.029022216796875,
-0.11383056640625,
-0.1309814453125,
0.33447265625,
-0.418212890625,
-0.1385498046875,
-0.34228515625,
0.6171875,
0.53759765625,
-0.10443115234375,
-0.78857421875,
-0.771484375,
-0.962890625,
-1.3984375,
0.35107421875,
-0.41259765625,
0.212646484375,
-0.215087890625,
-0.56689453125,
1.064453125,
-0.424072265625,
0.09344482421875,
0.9248046875,
-0.16455078125,
0.1824951171875,
-0.49755859375,
1.00390625,
0.90234375,
-0.1318359375,
0.0389404296875,
0.18603515625,
-0.411865234375,
0.105224609375,
-0.53271484375,
-0.58447265625,
-0.80419921875,
0.285400390625,
1.0107421875,
-0.10455322265625,
1.0771484375,
-0.6796875,
-0.91162109375,
-0.1571044921875,
0.80712890625,
0.307861328125,
0.392578125,
0.92431640625,
-0.04486083984375,
0.1025390625,
0.374755859375,
0.0009670257568359375,
-0.05938720703125,
-0.669921875,
1.095703125,
-0.470458984375,
-1.0400390625,
0.77587890625,
0.80322265625,
-0.7890625,
-1.1806640625,
-0.1983642578125,
0.253173828125,
-0.154052734375,
-0.6220703125,
0.51123046875,
0.49169921875,
-0.76708984375,
0.42626953125,
0.58740234375,
-0.365234375,
0.287353515625,
0.21826171875,
0.441650390625,
-0.439697265625,
-0.0877685546875,
0.7197265625,
-0.29443359375,
-0.78466796875,
-0.83251953125,
0.27978515625,
0.1453857421875,
-0.051727294921875,
0.80126953125,
0.07940673828125,
0.1983642578125,
0.50439453125,
0.2020263671875,
0.74658203125,
-0.216552734375,
-0.0731201171875,
0.2705078125,
-0.5205078125,
-0.82080078125,
-0.305419921875,
0.939453125,
-0.140380859375,
0.06695556640625,
-0.5048828125,
0.53173828125,
0.40234375,
0.260009765625,
-0.8427734375,
-0.9482421875,
-0.09619140625,
-0.98779296875,
-0.51025390625,
-0.263427734375,
-0.6826171875,
0.1051025390625,
0.142578125,
-0.12646484375,
-0.6162109375,
0.12457275390625,
0.85009765625,
-0.39306640625,
0.2078857421875,
-0.73974609375,
0.283203125,
-0.431640625,
-0.162353515625,
-0.80126953125,
-0.006603240966796875,
-0.2176513671875,
-0.270751953125,
-0.65869140625,
-0.230224609375,
0.390380859375,
0.1446533203125,
-0.271484375,
0.07562255859375,
-0.3017578125,
-1.0615234375,
-0.40966796875,
-0.0181121826171875,
-0.2015380859375,
0.97900390625,
0.39111328125,
-0.056549072265625,
0.336181640625,
-0.70263671875,
-0.2373046875,
0.316650390625,
0.5546875,
0.57421875,
-0.427490234375,
-0.021453857421875,
-0.2169189453125,
-0.050048828125,
-0.84912109375,
0.302490234375,
-0.85693359375,
0.3701171875,
0.26611328125,
-0.0941162109375,
0.49951171875,
0.71728515625,
-0.24560546875,
0.07647705078125,
0.05352783203125,
0.156494140625,
0.51953125,
0.276123046875,
0.03314208984375,
0.075439453125,
0.474609375,
-0.299072265625,
-0.0792236328125,
-0.038177490234375,
0.1611328125,
-0.093505859375,
-0.054962158203125,
-0.615234375,
-1.072265625,
-0.29248046875,
-0.06585693359375,
0.3193359375,
0.308837890625,
-0.2445068359375,
0.1363525390625,
0.30859375,
-0.7919921875,
0.5009765625,
-1.0771484375,
-0.76123046875,
0.58642578125,
-0.16259765625,
-0.580078125,
-0.1273193359375,
-0.198486328125,
0.007732391357421875,
0.0836181640625,
0.0699462890625,
-0.61279296875,
0.427490234375,
0.294677734375,
0.46923828125,
-0.1522216796875,
0.11358642578125,
0.43212890625,
0.609375,
-0.568359375,
-0.6650390625,
-0.0841064453125,
0.97607421875,
0.25341796875,
-0.63134765625,
-0.449951171875,
0.041961669921875,
0.492919921875,
0.225830078125,
-0.54150390625,
0.305419921875,
-0.5546875,
1.2060546875,
-0.90087890625,
0.04974365234375,
0.28466796875,
0.39697265625,
0.06488037109375,
-0.24853515625,
-0.1383056640625,
0.7822265625,
0.72998046875,
-0.334228515625,
0.75146484375,
0.412109375,
0.276611328125,
-0.5986328125,
-0.288330078125,
-0.28662109375,
0.90380859375,
0.8173828125,
0.4833984375,
-0.0021820068359375,
0.2158203125,
0.79443359375,
-0.44921875,
-0.375,
0.66259765625,
0.139404296875,
-0.305419921875,
0.31640625,
0.08697509765625,
0.410888671875,
0.1162109375,
-0.45849609375,
0.1361083984375,
-0.437255859375,
-0.1405029296875,
-0.369140625,
-0.52001953125,
0.95654296875,
-0.734375,
-0.0782470703125,
0.1177978515625,
-0.5400390625,
0.5439453125,
0.603515625,
0.09185791015625,
-0.69091796875,
0.896484375,
0.382568359375,
0.44775390625,
0.77001953125,
0.339599609375,
0.110595703125,
-0.62841796875,
0.360595703125,
0.0008306503295898438,
-0.1737060546875,
-0.1409912109375,
-0.35546875,
-0.994140625,
0.44775390625,
-0.3701171875,
-0.62158203125,
0.38623046875,
-0.459716796875,
-0.1871337890625,
-0.25634765625,
0.96875,
-0.80712890625,
0.3876953125,
0.0018796920776367188,
-0.1533203125,
-0.48388671875,
0.66162109375,
-0.228271484375,
0.2464599609375,
0.07012939453125,
0.97802734375,
-0.1568603515625,
1.662109375,
0.2435302734375,
-0.1341552734375,
0.04779052734375,
0.2301025390625,
-0.389404296875,
-0.6416015625,
-0.428955078125,
-0.57080078125,
0.0377197265625,
-0.321044921875,
-0.50146484375,
-0.09954833984375,
0.492919921875,
0.067138671875,
-0.64892578125,
-0.29052734375,
0.64208984375,
-0.406494140625,
0.35009765625,
0.57080078125,
0.45458984375,
-0.00360870361328125,
-0.370849609375,
-0.4208984375,
-0.41845703125,
0.10821533203125,
-0.48681640625,
0.51953125,
-0.57763671875,
-0.139404296875,
-0.560546875,
-0.1146240234375,
-0.2159423828125,
0.0538330078125,
-0.62255859375,
-0.5751953125,
0.826171875,
0.492919921875,
-0.197998046875,
0.8779296875,
-0.42138671875,
0.095947265625,
0.9453125,
1.166015625,
0.0239715576171875,
0.634765625,
0.361083984375,
0.0635986328125,
-0.0297088623046875,
-0.2225341796875,
0.395751953125,
-0.422607421875,
0.06341552734375,
-0.576171875,
0.2171630859375,
-0.5341796875,
-0.90380859375,
-0.059783935546875,
0.501953125,
0.2470703125,
-0.7607421875,
-1.0498046875,
-0.32568359375,
-1.349609375,
0.129638671875,
-0.50146484375,
0.39697265625,
0.2156982421875,
-0.1513671875,
0.228515625,
-1.048828125,
4.53515625,
1.2255859375,
0.8076171875,
0.168701171875,
0.258544921875,
0.39599609375,
0.2235107421875,
-0.6728515625,
-0.0084991455078125,
-0.5947265625,
0.0396728515625,
-0.408203125,
0.3193359375,
0.8212890625,
0.48828125,
0.405517578125,
-0.7666015625,
-0.43798828125,
0.1983642578125,
-1.013671875,
-0.796875,
0.142333984375,
0.065673828125,
0.828125,
0.09649658203125,
0.81298828125,
0.6953125,
-0.564453125,
-0.282470703125,
-0.572265625,
0.140869140625,
-0.495361328125,
0.837890625,
0.1251220703125,
-0.2037353515625,
0.8935546875,
0.0012226104736328125,
-0.0316162109375,
-0.1689453125,
-0.14306640625,
-0.1724853515625,
0.01093292236328125,
0.541015625,
-0.458740234375,
0.65283203125,
0.2509765625,
-0.5087890625,
-0.036712646484375,
0.1961669921875,
-0.93017578125,
0.87841796875,
-0.25634765625,
0.46044921875,
-0.1553955078125,
-0.437744140625,
0.10675048828125,
0.357177734375,
-0.0498046875,
-0.280029296875,
0.2978515625,
0.55517578125,
0.069091796875,
-0.19775390625,
0.69580078125,
-0.9365234375,
0.57666015625,
-0.175537109375,
0.77001953125,
-0.1622314453125,
-0.1453857421875,
-0.43896484375,
-0.1282958984375,
-0.286865234375,
-0.82373046875,
0.97509765625,
0.2412109375,
-0.1732177734375,
0.363037109375,
0.463623046875,
-0.496337890625,
0.29248046875,
-0.2880859375,
-0.453857421875,
-0.44189453125,
0.75927734375,
1.029296875,
-0.4462890625,
-0.367919921875,
0.26123046875,
1.0673828125,
0.41015625,
0.360107421875,
-0.07958984375,
-0.833984375,
-0.11273193359375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!
The popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Tyndex.Bar automatically fills the glass with the finest 1664 cognac after you buy Tyndex.Bottles and insert in into a USB port). It is highly popular due to the well-thought interaction with the user.
Let us take, for example, the system of automatic address correction. Have you entered codehorses instead of codeforces? The gloomy Zoozle Chrome will sadly say that the address does not exist. Tyndex.Brome at the same time will automatically find the closest address and sent you there. That's brilliant!
How does this splendid function work? That's simple! For each potential address a function of the F error is calculated by the following rules:
* for every letter ci from the potential address c the closest position j of the letter ci in the address (s) entered by the user is found. The absolute difference |i - j| of these positions is added to F. So for every i (1 ≤ i ≤ |c|) the position j is chosen such, that ci = sj, and |i - j| is minimal possible.
* if no such letter ci exists in the address entered by the user, then the length of the potential address |c| is added to F.
After the values of the error function have been calculated for all the potential addresses the most suitable one is found.
To understand the special features of the above described method better, it is recommended to realize the algorithm of calculating the F function for an address given by the user and some set of potential addresses. Good luck!
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105). They are the number of potential addresses and the length of the address entered by the user. The next line contains k lowercase Latin letters. They are the address entered by the user (s). Each next i-th (1 ≤ i ≤ n) line contains a non-empty sequence of lowercase Latin letters. They are the potential address. It is guaranteed that the total length of all the lines does not exceed 2·105.
Output
On each n line of the output file print a single number: the value of the error function when the current potential address is chosen.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).
Examples
Input
2 10
codeforces
codeforces
codehorses
Output
0
12
Input
9 9
vkontakte
vcontacte
vkontrakte
vkollapse
vkrokodile
vtopke
vkapuste
vpechke
vk
vcodeforcese
Output
18
14
36
47
14
29
30
0
84
Tags: binary search, implementation
Correct Solution:
```
from bisect import bisect_left
n,k=map(int,input().split())
q="abcdefghijklmnopqrstuvwxyz"
a={i:[] for i in q}
for key,value in enumerate(input()):a[value].append(key)
#print(a)
def g(t):return [(t[i]+t[i-1])//2 for i in range(1,len(t))] #类似于二分查找的思路 //便于快速确定位置
c={i:g(a[i]) for i in q}
#print(c)
for _ in range(n):
s,t=0,input()
lt=len(t)
for key,value in enumerate(t):
if a[value]:
if c[value]:s+=abs(key-a[value][bisect_left(c[value],key)])
else:s+=abs(key-a[value][0])
else:
s+=lt
print(s)
```
| 72,101 | [
0.08807373046875,
-0.013092041015625,
0.03485107421875,
0.2880859375,
-0.71435546875,
-0.1817626953125,
0.2098388671875,
0.287841796875,
0.2978515625,
0.7138671875,
0.437255859375,
-0.02587890625,
-0.1748046875,
-0.428466796875,
-0.5693359375,
0.166015625,
-0.50634765625,
-0.5341796875,
-0.32568359375,
0.02001953125,
0.316162109375,
-0.154296875,
-1.5400390625,
0.1527099609375,
-0.14599609375,
0.310791015625,
0.724609375,
-0.31591796875,
1.2880859375,
1.1826171875,
-0.18017578125,
-0.73681640625,
0.304443359375,
-0.52490234375,
-0.3095703125,
-0.412841796875,
0.2374267578125,
-0.861328125,
-0.0181884765625,
-0.79736328125,
0.040496826171875,
-0.420654296875,
0.1533203125,
-0.859375,
-0.78564453125,
-0.1715087890625,
-0.71337890625,
-0.548828125,
-0.2244873046875,
-0.73193359375,
0.37646484375,
0.112060546875,
0.046722412109375,
-0.481689453125,
-0.1365966796875,
-0.0806884765625,
-0.174072265625,
-0.0216064453125,
-0.84423828125,
0.09185791015625,
0.1903076171875,
0.237060546875,
-0.30224609375,
-0.68994140625,
0.416015625,
0.49853515625,
-0.17626953125,
-0.118408203125,
0.02410888671875,
0.02679443359375,
-0.2125244140625,
0.2122802734375,
-0.4140625,
-0.69091796875,
-0.2315673828125,
-0.115966796875,
0.036712646484375,
-0.06134033203125,
-0.88134765625,
0.446533203125,
0.2265625,
0.66162109375,
0.2890625,
0.6513671875,
-0.1798095703125,
0.0567626953125,
0.335693359375,
0.152099609375,
-0.451416015625,
0.09521484375,
0.038970947265625,
0.1593017578125,
0.055328369140625,
-0.06658935546875,
0.4990234375,
0.420654296875,
-0.447509765625,
0.54443359375,
0.2578125,
-0.0770263671875,
0.7265625,
0.9111328125,
-0.82763671875,
1.029296875,
-0.053070068359375,
0.286865234375,
0.0445556640625,
-0.54052734375,
-0.27734375,
-0.61181640625,
-0.25927734375,
-0.33984375,
0.197021484375,
0.24853515625,
-0.1651611328125,
0.67333984375,
-0.494384765625,
0.306640625,
-0.463134765625,
-0.26806640625,
-0.1844482421875,
0.06121826171875,
0.33251953125,
-0.272705078125,
-0.2430419921875,
-0.37744140625,
-0.5400390625,
0.77001953125,
-0.65087890625,
-0.34765625,
-0.29931640625,
-0.53173828125,
-0.1514892578125,
0.226806640625,
-0.1456298828125,
0.79443359375,
-0.302734375,
0.55859375,
0.75341796875,
-1.2509765625,
1.126953125,
0.08575439453125,
0.0200958251953125,
1.6025390625,
0.453369140625,
0.11328125,
0.18896484375,
-0.023040771484375,
-0.439208984375,
0.39599609375,
-0.53173828125,
0.85205078125,
0.14599609375,
0.06561279296875,
0.077880859375,
0.319091796875,
-0.2208251953125,
0.352783203125,
0.444580078125,
0.464599609375,
-0.10467529296875,
0.72705078125,
-0.46826171875,
0.8740234375,
-0.73974609375,
0.67724609375,
-0.666015625,
-0.2049560546875,
-0.0767822265625,
-0.62890625,
0.10064697265625,
0.0125885009765625,
-0.1971435546875,
0.57275390625,
0.85498046875,
0.51953125,
0.74072265625,
-0.341796875,
0.416015625,
0.29736328125,
-0.39794921875,
0.22607421875,
0.70068359375,
1.095703125,
0.382568359375,
-0.0035037994384765625,
0.039825439453125,
-0.48583984375,
-0.6982421875,
-0.60400390625,
0.04241943359375,
0.51416015625,
-0.56201171875,
0.1492919921875,
0.1544189453125,
-0.1529541015625,
-0.75390625,
-0.4296875,
0.479736328125,
-1.19140625,
-0.505859375,
0.85546875,
-0.338134765625,
0.342041015625,
-0.163330078125,
-0.298583984375,
0.19873046875,
1.1162109375,
-0.6015625,
0.2274169921875,
0.330322265625,
0.0811767578125,
-0.39111328125,
-0.1485595703125,
0.35400390625,
-0.0645751953125,
-0.13427734375,
0.59033203125,
0.0279083251953125,
0.08050537109375,
0.368896484375,
0.49267578125,
0.251953125,
0.393798828125,
-0.40966796875,
0.1563720703125,
-0.174560546875,
0.98193359375,
-0.24658203125,
0.376708984375,
-0.32421875,
0.921875,
0.09625244140625,
0.82763671875,
0.160888671875,
0.0180816650390625,
1.1533203125,
0.97314453125,
-0.62646484375,
0.5830078125,
0.0279388427734375,
0.6884765625,
0.299560546875,
0.52587890625,
-0.116943359375,
0.45458984375,
0.041259765625,
0.012542724609375,
-0.339111328125,
0.7431640625,
0.08746337890625,
1.02734375,
0.14794921875,
0.03277587890625,
-0.59716796875,
-0.421875,
0.17138671875,
0.572265625,
-0.697265625,
-0.533203125,
0.311767578125,
-0.1663818359375,
0.325927734375,
-0.16259765625,
0.254638671875,
0.95654296875,
-0.08685302734375,
0.6357421875,
-0.291259765625,
-0.70703125,
-0.7373046875,
-0.7685546875,
-1.12890625,
-0.373779296875,
-0.712890625,
-0.457275390625,
0.320556640625,
-0.55126953125,
0.2218017578125,
0.1478271484375,
0.349853515625,
0.332275390625,
-0.489013671875,
0.72021484375,
0.23583984375,
0.6796875,
-0.52783203125,
0.6220703125,
0.01200103759765625,
0.94775390625,
-0.52099609375,
-0.11566162109375,
-0.07342529296875,
-0.53271484375,
0.55029296875,
0.185546875,
0.451171875,
-0.0572509765625,
-0.427978515625,
-0.64501953125,
-0.48681640625,
0.212646484375,
-0.390869140625,
-0.1781005859375,
-0.292724609375,
0.57763671875,
0.66455078125,
-0.33203125,
0.90087890625,
0.501953125,
-0.74951171875,
0.418701171875,
0.58251953125,
-0.273193359375,
-0.814453125,
1.3896484375,
0.6044921875,
0.336669921875,
-0.591796875,
-0.34521484375,
-0.77490234375,
0.1470947265625,
0.08905029296875,
-0.60400390625,
-0.497314453125,
0.7158203125,
-0.2403564453125,
-1.083984375,
0.416259765625,
-1.228515625,
-0.6318359375,
-0.235595703125,
-0.132568359375,
0.734375,
0.61376953125,
-0.02972412109375,
0.47802734375,
-0.2435302734375,
-0.0406494140625,
0.460205078125,
0.3505859375,
-0.607421875,
0.11029052734375,
0.78125,
0.125,
0.1387939453125,
0.166748046875,
-0.91064453125,
-0.2364501953125,
-0.1683349609375,
-0.1810302734375,
0.73779296875,
0.48486328125,
0.2374267578125,
-0.132080078125,
0.9931640625,
-0.80029296875,
-0.2034912109375,
-0.3798828125,
0.5546875,
0.232177734375,
0.241455078125,
0.07470703125,
-0.1907958984375,
-0.3857421875,
-0.66455078125,
0.303466796875,
0.1326904296875,
0.43310546875,
-0.80517578125,
0.28173828125,
0.2056884765625,
-0.541015625,
0.54052734375,
-0.29736328125,
-0.29052734375,
0.904296875,
-0.055694580078125,
0.77783203125,
-0.712890625,
0.1300048828125,
-0.404541015625,
0.007671356201171875,
1.03515625,
0.1302490234375,
0.322021484375,
-0.339599609375,
-0.5458984375,
-0.2705078125,
-0.54638671875,
-0.07391357421875,
0.243896484375,
0.2578125,
0.05816650390625,
-0.51513671875,
-0.92236328125,
0.5107421875,
0.265380859375,
0.427490234375,
-0.08221435546875,
0.37109375,
0.212158203125,
0.736328125,
0.22021484375,
-0.154541015625,
0.56787109375,
-0.5302734375,
0.6298828125,
0.213623046875,
-0.453369140625,
-0.1982421875,
-0.39208984375,
0.11773681640625,
0.32275390625,
-0.06121826171875,
-0.0701904296875,
-0.79150390625,
0.472900390625,
-0.0186767578125,
0.57421875,
-0.1629638671875,
-0.345947265625,
-0.53466796875,
-0.00014257431030273438,
0.2037353515625,
-0.85498046875,
0.434814453125,
-0.471435546875,
0.330322265625,
0.623046875,
0.32666015625,
-0.36181640625,
-0.94970703125,
-0.40283203125,
-0.716796875,
0.23388671875,
0.712890625,
-0.178955078125,
0.060302734375,
-0.806640625,
0.36083984375,
0.19482421875,
-0.413818359375,
0.1297607421875,
0.041015625,
0.2259521484375,
0.23876953125,
0.8662109375,
-0.294189453125,
-0.46044921875,
0.3994140625,
-0.92724609375,
0.9951171875,
-0.32275390625,
-0.149169921875,
-0.136474609375,
0.054656982421875,
-0.06304931640625,
0.396484375,
-0.72265625,
0.06878662109375,
-0.340576171875,
0.1441650390625,
-1.1083984375,
-1.056640625,
0.7099609375,
0.2403564453125,
0.0699462890625,
0.4091796875,
0.1727294921875,
-0.83154296875,
0.53466796875,
0.4833984375,
-0.43505859375,
0.34521484375,
-0.08367919921875,
0.5771484375,
-0.256591796875,
-0.7998046875,
0.09381103515625,
-0.67822265625,
0.9248046875,
0.26025390625,
-0.69873046875,
-0.52294921875,
-0.8486328125,
-0.007778167724609375,
-0.2666015625,
-0.51171875,
0.66064453125,
-0.1280517578125,
0.0262298583984375,
-0.258056640625,
-0.1318359375,
-1.01171875,
-0.08258056640625,
-0.56201171875,
0.2132568359375,
0.2200927734375,
0.55029296875,
0.88134765625,
-0.260498046875,
-0.5771484375,
0.11749267578125,
-0.06298828125,
-0.11651611328125,
-0.5830078125,
0.12481689453125,
0.036834716796875,
-0.27001953125,
-0.724609375,
0.1541748046875,
0.0287017822265625,
0.580078125,
0.91259765625,
0.3740234375,
0.3173828125,
0.01885986328125,
-0.62158203125,
0.472412109375,
0.142822265625,
-0.8486328125,
-0.337646484375,
0.47509765625,
-0.06298828125,
0.9111328125,
0.381591796875,
-0.71337890625,
-0.4375,
-0.7607421875,
-0.0997314453125,
-1.0478515625,
-0.1934814453125,
-0.978515625,
-0.6005859375,
-0.047607421875,
0.537109375,
0.384521484375,
-0.62548828125,
0.029998779296875,
-1.005859375,
-0.154296875,
-0.7958984375,
-0.47265625,
-0.4111328125,
-0.67578125,
0.002269744873046875,
0.8662109375,
-0.07855224609375,
0.1461181640625,
-0.44189453125,
0.35107421875,
0.1370849609375,
0.08563232421875,
-0.85595703125,
-0.90625,
-0.3330078125,
-0.228271484375,
-0.135009765625,
-0.07843017578125,
-0.5380859375,
0.90869140625,
-0.60888671875,
-0.06854248046875,
-0.74267578125,
-0.029022216796875,
-0.11383056640625,
-0.1309814453125,
0.33447265625,
-0.418212890625,
-0.1385498046875,
-0.34228515625,
0.6171875,
0.53759765625,
-0.10443115234375,
-0.78857421875,
-0.771484375,
-0.962890625,
-1.3984375,
0.35107421875,
-0.41259765625,
0.212646484375,
-0.215087890625,
-0.56689453125,
1.064453125,
-0.424072265625,
0.09344482421875,
0.9248046875,
-0.16455078125,
0.1824951171875,
-0.49755859375,
1.00390625,
0.90234375,
-0.1318359375,
0.0389404296875,
0.18603515625,
-0.411865234375,
0.105224609375,
-0.53271484375,
-0.58447265625,
-0.80419921875,
0.285400390625,
1.0107421875,
-0.10455322265625,
1.0771484375,
-0.6796875,
-0.91162109375,
-0.1571044921875,
0.80712890625,
0.307861328125,
0.392578125,
0.92431640625,
-0.04486083984375,
0.1025390625,
0.374755859375,
0.0009670257568359375,
-0.05938720703125,
-0.669921875,
1.095703125,
-0.470458984375,
-1.0400390625,
0.77587890625,
0.80322265625,
-0.7890625,
-1.1806640625,
-0.1983642578125,
0.253173828125,
-0.154052734375,
-0.6220703125,
0.51123046875,
0.49169921875,
-0.76708984375,
0.42626953125,
0.58740234375,
-0.365234375,
0.287353515625,
0.21826171875,
0.441650390625,
-0.439697265625,
-0.0877685546875,
0.7197265625,
-0.29443359375,
-0.78466796875,
-0.83251953125,
0.27978515625,
0.1453857421875,
-0.051727294921875,
0.80126953125,
0.07940673828125,
0.1983642578125,
0.50439453125,
0.2020263671875,
0.74658203125,
-0.216552734375,
-0.0731201171875,
0.2705078125,
-0.5205078125,
-0.82080078125,
-0.305419921875,
0.939453125,
-0.140380859375,
0.06695556640625,
-0.5048828125,
0.53173828125,
0.40234375,
0.260009765625,
-0.8427734375,
-0.9482421875,
-0.09619140625,
-0.98779296875,
-0.51025390625,
-0.263427734375,
-0.6826171875,
0.1051025390625,
0.142578125,
-0.12646484375,
-0.6162109375,
0.12457275390625,
0.85009765625,
-0.39306640625,
0.2078857421875,
-0.73974609375,
0.283203125,
-0.431640625,
-0.162353515625,
-0.80126953125,
-0.006603240966796875,
-0.2176513671875,
-0.270751953125,
-0.65869140625,
-0.230224609375,
0.390380859375,
0.1446533203125,
-0.271484375,
0.07562255859375,
-0.3017578125,
-1.0615234375,
-0.40966796875,
-0.0181121826171875,
-0.2015380859375,
0.97900390625,
0.39111328125,
-0.056549072265625,
0.336181640625,
-0.70263671875,
-0.2373046875,
0.316650390625,
0.5546875,
0.57421875,
-0.427490234375,
-0.021453857421875,
-0.2169189453125,
-0.050048828125,
-0.84912109375,
0.302490234375,
-0.85693359375,
0.3701171875,
0.26611328125,
-0.0941162109375,
0.49951171875,
0.71728515625,
-0.24560546875,
0.07647705078125,
0.05352783203125,
0.156494140625,
0.51953125,
0.276123046875,
0.03314208984375,
0.075439453125,
0.474609375,
-0.299072265625,
-0.0792236328125,
-0.038177490234375,
0.1611328125,
-0.093505859375,
-0.054962158203125,
-0.615234375,
-1.072265625,
-0.29248046875,
-0.06585693359375,
0.3193359375,
0.308837890625,
-0.2445068359375,
0.1363525390625,
0.30859375,
-0.7919921875,
0.5009765625,
-1.0771484375,
-0.76123046875,
0.58642578125,
-0.16259765625,
-0.580078125,
-0.1273193359375,
-0.198486328125,
0.007732391357421875,
0.0836181640625,
0.0699462890625,
-0.61279296875,
0.427490234375,
0.294677734375,
0.46923828125,
-0.1522216796875,
0.11358642578125,
0.43212890625,
0.609375,
-0.568359375,
-0.6650390625,
-0.0841064453125,
0.97607421875,
0.25341796875,
-0.63134765625,
-0.449951171875,
0.041961669921875,
0.492919921875,
0.225830078125,
-0.54150390625,
0.305419921875,
-0.5546875,
1.2060546875,
-0.90087890625,
0.04974365234375,
0.28466796875,
0.39697265625,
0.06488037109375,
-0.24853515625,
-0.1383056640625,
0.7822265625,
0.72998046875,
-0.334228515625,
0.75146484375,
0.412109375,
0.276611328125,
-0.5986328125,
-0.288330078125,
-0.28662109375,
0.90380859375,
0.8173828125,
0.4833984375,
-0.0021820068359375,
0.2158203125,
0.79443359375,
-0.44921875,
-0.375,
0.66259765625,
0.139404296875,
-0.305419921875,
0.31640625,
0.08697509765625,
0.410888671875,
0.1162109375,
-0.45849609375,
0.1361083984375,
-0.437255859375,
-0.1405029296875,
-0.369140625,
-0.52001953125,
0.95654296875,
-0.734375,
-0.0782470703125,
0.1177978515625,
-0.5400390625,
0.5439453125,
0.603515625,
0.09185791015625,
-0.69091796875,
0.896484375,
0.382568359375,
0.44775390625,
0.77001953125,
0.339599609375,
0.110595703125,
-0.62841796875,
0.360595703125,
0.0008306503295898438,
-0.1737060546875,
-0.1409912109375,
-0.35546875,
-0.994140625,
0.44775390625,
-0.3701171875,
-0.62158203125,
0.38623046875,
-0.459716796875,
-0.1871337890625,
-0.25634765625,
0.96875,
-0.80712890625,
0.3876953125,
0.0018796920776367188,
-0.1533203125,
-0.48388671875,
0.66162109375,
-0.228271484375,
0.2464599609375,
0.07012939453125,
0.97802734375,
-0.1568603515625,
1.662109375,
0.2435302734375,
-0.1341552734375,
0.04779052734375,
0.2301025390625,
-0.389404296875,
-0.6416015625,
-0.428955078125,
-0.57080078125,
0.0377197265625,
-0.321044921875,
-0.50146484375,
-0.09954833984375,
0.492919921875,
0.067138671875,
-0.64892578125,
-0.29052734375,
0.64208984375,
-0.406494140625,
0.35009765625,
0.57080078125,
0.45458984375,
-0.00360870361328125,
-0.370849609375,
-0.4208984375,
-0.41845703125,
0.10821533203125,
-0.48681640625,
0.51953125,
-0.57763671875,
-0.139404296875,
-0.560546875,
-0.1146240234375,
-0.2159423828125,
0.0538330078125,
-0.62255859375,
-0.5751953125,
0.826171875,
0.492919921875,
-0.197998046875,
0.8779296875,
-0.42138671875,
0.095947265625,
0.9453125,
1.166015625,
0.0239715576171875,
0.634765625,
0.361083984375,
0.0635986328125,
-0.0297088623046875,
-0.2225341796875,
0.395751953125,
-0.422607421875,
0.06341552734375,
-0.576171875,
0.2171630859375,
-0.5341796875,
-0.90380859375,
-0.059783935546875,
0.501953125,
0.2470703125,
-0.7607421875,
-1.0498046875,
-0.32568359375,
-1.349609375,
0.129638671875,
-0.50146484375,
0.39697265625,
0.2156982421875,
-0.1513671875,
0.228515625,
-1.048828125,
4.53515625,
1.2255859375,
0.8076171875,
0.168701171875,
0.258544921875,
0.39599609375,
0.2235107421875,
-0.6728515625,
-0.0084991455078125,
-0.5947265625,
0.0396728515625,
-0.408203125,
0.3193359375,
0.8212890625,
0.48828125,
0.405517578125,
-0.7666015625,
-0.43798828125,
0.1983642578125,
-1.013671875,
-0.796875,
0.142333984375,
0.065673828125,
0.828125,
0.09649658203125,
0.81298828125,
0.6953125,
-0.564453125,
-0.282470703125,
-0.572265625,
0.140869140625,
-0.495361328125,
0.837890625,
0.1251220703125,
-0.2037353515625,
0.8935546875,
0.0012226104736328125,
-0.0316162109375,
-0.1689453125,
-0.14306640625,
-0.1724853515625,
0.01093292236328125,
0.541015625,
-0.458740234375,
0.65283203125,
0.2509765625,
-0.5087890625,
-0.036712646484375,
0.1961669921875,
-0.93017578125,
0.87841796875,
-0.25634765625,
0.46044921875,
-0.1553955078125,
-0.437744140625,
0.10675048828125,
0.357177734375,
-0.0498046875,
-0.280029296875,
0.2978515625,
0.55517578125,
0.069091796875,
-0.19775390625,
0.69580078125,
-0.9365234375,
0.57666015625,
-0.175537109375,
0.77001953125,
-0.1622314453125,
-0.1453857421875,
-0.43896484375,
-0.1282958984375,
-0.286865234375,
-0.82373046875,
0.97509765625,
0.2412109375,
-0.1732177734375,
0.363037109375,
0.463623046875,
-0.496337890625,
0.29248046875,
-0.2880859375,
-0.453857421875,
-0.44189453125,
0.75927734375,
1.029296875,
-0.4462890625,
-0.367919921875,
0.26123046875,
1.0673828125,
0.41015625,
0.360107421875,
-0.07958984375,
-0.833984375,
-0.11273193359375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!
The popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Tyndex.Bar automatically fills the glass with the finest 1664 cognac after you buy Tyndex.Bottles and insert in into a USB port). It is highly popular due to the well-thought interaction with the user.
Let us take, for example, the system of automatic address correction. Have you entered codehorses instead of codeforces? The gloomy Zoozle Chrome will sadly say that the address does not exist. Tyndex.Brome at the same time will automatically find the closest address and sent you there. That's brilliant!
How does this splendid function work? That's simple! For each potential address a function of the F error is calculated by the following rules:
* for every letter ci from the potential address c the closest position j of the letter ci in the address (s) entered by the user is found. The absolute difference |i - j| of these positions is added to F. So for every i (1 ≤ i ≤ |c|) the position j is chosen such, that ci = sj, and |i - j| is minimal possible.
* if no such letter ci exists in the address entered by the user, then the length of the potential address |c| is added to F.
After the values of the error function have been calculated for all the potential addresses the most suitable one is found.
To understand the special features of the above described method better, it is recommended to realize the algorithm of calculating the F function for an address given by the user and some set of potential addresses. Good luck!
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105). They are the number of potential addresses and the length of the address entered by the user. The next line contains k lowercase Latin letters. They are the address entered by the user (s). Each next i-th (1 ≤ i ≤ n) line contains a non-empty sequence of lowercase Latin letters. They are the potential address. It is guaranteed that the total length of all the lines does not exceed 2·105.
Output
On each n line of the output file print a single number: the value of the error function when the current potential address is chosen.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).
Examples
Input
2 10
codeforces
codeforces
codehorses
Output
0
12
Input
9 9
vkontakte
vcontacte
vkontrakte
vkollapse
vkrokodile
vtopke
vkapuste
vpechke
vk
vcodeforcese
Output
18
14
36
47
14
29
30
0
84
Tags: binary search, implementation
Correct Solution:
```
def g(t): return [(t[i] + t[i - 1]) // 2 for i in range(1, len(t))] + [1000000]
def h(a, b, c):
j = s = 0
for i in b:
while i > c[j]: j += 1
s += abs(i - a[j])
return s
n, k = map(int, input().split())
q = 'abcdefghijklmnopqrstuvwxyz'
s, a = 0, {i: [] for i in q}
for i, j in enumerate(input()): a[j].append(i)
c = {i: g(a[i]) for i in q}
def f():
s, b = 0, {i: [] for i in q}
t = input()
for i, j in enumerate(t): b[j].append(i)
for i in q:
if b[i]:
if a[i]: s += h(a[i], b[i], c[i])
else: s += len(t) * len(b[i])
return str(s)
print('\n'.join(f() for i in range(n)))
```
| 72,102 | [
0.08807373046875,
-0.013092041015625,
0.03485107421875,
0.2880859375,
-0.71435546875,
-0.1817626953125,
0.2098388671875,
0.287841796875,
0.2978515625,
0.7138671875,
0.437255859375,
-0.02587890625,
-0.1748046875,
-0.428466796875,
-0.5693359375,
0.166015625,
-0.50634765625,
-0.5341796875,
-0.32568359375,
0.02001953125,
0.316162109375,
-0.154296875,
-1.5400390625,
0.1527099609375,
-0.14599609375,
0.310791015625,
0.724609375,
-0.31591796875,
1.2880859375,
1.1826171875,
-0.18017578125,
-0.73681640625,
0.304443359375,
-0.52490234375,
-0.3095703125,
-0.412841796875,
0.2374267578125,
-0.861328125,
-0.0181884765625,
-0.79736328125,
0.040496826171875,
-0.420654296875,
0.1533203125,
-0.859375,
-0.78564453125,
-0.1715087890625,
-0.71337890625,
-0.548828125,
-0.2244873046875,
-0.73193359375,
0.37646484375,
0.112060546875,
0.046722412109375,
-0.481689453125,
-0.1365966796875,
-0.0806884765625,
-0.174072265625,
-0.0216064453125,
-0.84423828125,
0.09185791015625,
0.1903076171875,
0.237060546875,
-0.30224609375,
-0.68994140625,
0.416015625,
0.49853515625,
-0.17626953125,
-0.118408203125,
0.02410888671875,
0.02679443359375,
-0.2125244140625,
0.2122802734375,
-0.4140625,
-0.69091796875,
-0.2315673828125,
-0.115966796875,
0.036712646484375,
-0.06134033203125,
-0.88134765625,
0.446533203125,
0.2265625,
0.66162109375,
0.2890625,
0.6513671875,
-0.1798095703125,
0.0567626953125,
0.335693359375,
0.152099609375,
-0.451416015625,
0.09521484375,
0.038970947265625,
0.1593017578125,
0.055328369140625,
-0.06658935546875,
0.4990234375,
0.420654296875,
-0.447509765625,
0.54443359375,
0.2578125,
-0.0770263671875,
0.7265625,
0.9111328125,
-0.82763671875,
1.029296875,
-0.053070068359375,
0.286865234375,
0.0445556640625,
-0.54052734375,
-0.27734375,
-0.61181640625,
-0.25927734375,
-0.33984375,
0.197021484375,
0.24853515625,
-0.1651611328125,
0.67333984375,
-0.494384765625,
0.306640625,
-0.463134765625,
-0.26806640625,
-0.1844482421875,
0.06121826171875,
0.33251953125,
-0.272705078125,
-0.2430419921875,
-0.37744140625,
-0.5400390625,
0.77001953125,
-0.65087890625,
-0.34765625,
-0.29931640625,
-0.53173828125,
-0.1514892578125,
0.226806640625,
-0.1456298828125,
0.79443359375,
-0.302734375,
0.55859375,
0.75341796875,
-1.2509765625,
1.126953125,
0.08575439453125,
0.0200958251953125,
1.6025390625,
0.453369140625,
0.11328125,
0.18896484375,
-0.023040771484375,
-0.439208984375,
0.39599609375,
-0.53173828125,
0.85205078125,
0.14599609375,
0.06561279296875,
0.077880859375,
0.319091796875,
-0.2208251953125,
0.352783203125,
0.444580078125,
0.464599609375,
-0.10467529296875,
0.72705078125,
-0.46826171875,
0.8740234375,
-0.73974609375,
0.67724609375,
-0.666015625,
-0.2049560546875,
-0.0767822265625,
-0.62890625,
0.10064697265625,
0.0125885009765625,
-0.1971435546875,
0.57275390625,
0.85498046875,
0.51953125,
0.74072265625,
-0.341796875,
0.416015625,
0.29736328125,
-0.39794921875,
0.22607421875,
0.70068359375,
1.095703125,
0.382568359375,
-0.0035037994384765625,
0.039825439453125,
-0.48583984375,
-0.6982421875,
-0.60400390625,
0.04241943359375,
0.51416015625,
-0.56201171875,
0.1492919921875,
0.1544189453125,
-0.1529541015625,
-0.75390625,
-0.4296875,
0.479736328125,
-1.19140625,
-0.505859375,
0.85546875,
-0.338134765625,
0.342041015625,
-0.163330078125,
-0.298583984375,
0.19873046875,
1.1162109375,
-0.6015625,
0.2274169921875,
0.330322265625,
0.0811767578125,
-0.39111328125,
-0.1485595703125,
0.35400390625,
-0.0645751953125,
-0.13427734375,
0.59033203125,
0.0279083251953125,
0.08050537109375,
0.368896484375,
0.49267578125,
0.251953125,
0.393798828125,
-0.40966796875,
0.1563720703125,
-0.174560546875,
0.98193359375,
-0.24658203125,
0.376708984375,
-0.32421875,
0.921875,
0.09625244140625,
0.82763671875,
0.160888671875,
0.0180816650390625,
1.1533203125,
0.97314453125,
-0.62646484375,
0.5830078125,
0.0279388427734375,
0.6884765625,
0.299560546875,
0.52587890625,
-0.116943359375,
0.45458984375,
0.041259765625,
0.012542724609375,
-0.339111328125,
0.7431640625,
0.08746337890625,
1.02734375,
0.14794921875,
0.03277587890625,
-0.59716796875,
-0.421875,
0.17138671875,
0.572265625,
-0.697265625,
-0.533203125,
0.311767578125,
-0.1663818359375,
0.325927734375,
-0.16259765625,
0.254638671875,
0.95654296875,
-0.08685302734375,
0.6357421875,
-0.291259765625,
-0.70703125,
-0.7373046875,
-0.7685546875,
-1.12890625,
-0.373779296875,
-0.712890625,
-0.457275390625,
0.320556640625,
-0.55126953125,
0.2218017578125,
0.1478271484375,
0.349853515625,
0.332275390625,
-0.489013671875,
0.72021484375,
0.23583984375,
0.6796875,
-0.52783203125,
0.6220703125,
0.01200103759765625,
0.94775390625,
-0.52099609375,
-0.11566162109375,
-0.07342529296875,
-0.53271484375,
0.55029296875,
0.185546875,
0.451171875,
-0.0572509765625,
-0.427978515625,
-0.64501953125,
-0.48681640625,
0.212646484375,
-0.390869140625,
-0.1781005859375,
-0.292724609375,
0.57763671875,
0.66455078125,
-0.33203125,
0.90087890625,
0.501953125,
-0.74951171875,
0.418701171875,
0.58251953125,
-0.273193359375,
-0.814453125,
1.3896484375,
0.6044921875,
0.336669921875,
-0.591796875,
-0.34521484375,
-0.77490234375,
0.1470947265625,
0.08905029296875,
-0.60400390625,
-0.497314453125,
0.7158203125,
-0.2403564453125,
-1.083984375,
0.416259765625,
-1.228515625,
-0.6318359375,
-0.235595703125,
-0.132568359375,
0.734375,
0.61376953125,
-0.02972412109375,
0.47802734375,
-0.2435302734375,
-0.0406494140625,
0.460205078125,
0.3505859375,
-0.607421875,
0.11029052734375,
0.78125,
0.125,
0.1387939453125,
0.166748046875,
-0.91064453125,
-0.2364501953125,
-0.1683349609375,
-0.1810302734375,
0.73779296875,
0.48486328125,
0.2374267578125,
-0.132080078125,
0.9931640625,
-0.80029296875,
-0.2034912109375,
-0.3798828125,
0.5546875,
0.232177734375,
0.241455078125,
0.07470703125,
-0.1907958984375,
-0.3857421875,
-0.66455078125,
0.303466796875,
0.1326904296875,
0.43310546875,
-0.80517578125,
0.28173828125,
0.2056884765625,
-0.541015625,
0.54052734375,
-0.29736328125,
-0.29052734375,
0.904296875,
-0.055694580078125,
0.77783203125,
-0.712890625,
0.1300048828125,
-0.404541015625,
0.007671356201171875,
1.03515625,
0.1302490234375,
0.322021484375,
-0.339599609375,
-0.5458984375,
-0.2705078125,
-0.54638671875,
-0.07391357421875,
0.243896484375,
0.2578125,
0.05816650390625,
-0.51513671875,
-0.92236328125,
0.5107421875,
0.265380859375,
0.427490234375,
-0.08221435546875,
0.37109375,
0.212158203125,
0.736328125,
0.22021484375,
-0.154541015625,
0.56787109375,
-0.5302734375,
0.6298828125,
0.213623046875,
-0.453369140625,
-0.1982421875,
-0.39208984375,
0.11773681640625,
0.32275390625,
-0.06121826171875,
-0.0701904296875,
-0.79150390625,
0.472900390625,
-0.0186767578125,
0.57421875,
-0.1629638671875,
-0.345947265625,
-0.53466796875,
-0.00014257431030273438,
0.2037353515625,
-0.85498046875,
0.434814453125,
-0.471435546875,
0.330322265625,
0.623046875,
0.32666015625,
-0.36181640625,
-0.94970703125,
-0.40283203125,
-0.716796875,
0.23388671875,
0.712890625,
-0.178955078125,
0.060302734375,
-0.806640625,
0.36083984375,
0.19482421875,
-0.413818359375,
0.1297607421875,
0.041015625,
0.2259521484375,
0.23876953125,
0.8662109375,
-0.294189453125,
-0.46044921875,
0.3994140625,
-0.92724609375,
0.9951171875,
-0.32275390625,
-0.149169921875,
-0.136474609375,
0.054656982421875,
-0.06304931640625,
0.396484375,
-0.72265625,
0.06878662109375,
-0.340576171875,
0.1441650390625,
-1.1083984375,
-1.056640625,
0.7099609375,
0.2403564453125,
0.0699462890625,
0.4091796875,
0.1727294921875,
-0.83154296875,
0.53466796875,
0.4833984375,
-0.43505859375,
0.34521484375,
-0.08367919921875,
0.5771484375,
-0.256591796875,
-0.7998046875,
0.09381103515625,
-0.67822265625,
0.9248046875,
0.26025390625,
-0.69873046875,
-0.52294921875,
-0.8486328125,
-0.007778167724609375,
-0.2666015625,
-0.51171875,
0.66064453125,
-0.1280517578125,
0.0262298583984375,
-0.258056640625,
-0.1318359375,
-1.01171875,
-0.08258056640625,
-0.56201171875,
0.2132568359375,
0.2200927734375,
0.55029296875,
0.88134765625,
-0.260498046875,
-0.5771484375,
0.11749267578125,
-0.06298828125,
-0.11651611328125,
-0.5830078125,
0.12481689453125,
0.036834716796875,
-0.27001953125,
-0.724609375,
0.1541748046875,
0.0287017822265625,
0.580078125,
0.91259765625,
0.3740234375,
0.3173828125,
0.01885986328125,
-0.62158203125,
0.472412109375,
0.142822265625,
-0.8486328125,
-0.337646484375,
0.47509765625,
-0.06298828125,
0.9111328125,
0.381591796875,
-0.71337890625,
-0.4375,
-0.7607421875,
-0.0997314453125,
-1.0478515625,
-0.1934814453125,
-0.978515625,
-0.6005859375,
-0.047607421875,
0.537109375,
0.384521484375,
-0.62548828125,
0.029998779296875,
-1.005859375,
-0.154296875,
-0.7958984375,
-0.47265625,
-0.4111328125,
-0.67578125,
0.002269744873046875,
0.8662109375,
-0.07855224609375,
0.1461181640625,
-0.44189453125,
0.35107421875,
0.1370849609375,
0.08563232421875,
-0.85595703125,
-0.90625,
-0.3330078125,
-0.228271484375,
-0.135009765625,
-0.07843017578125,
-0.5380859375,
0.90869140625,
-0.60888671875,
-0.06854248046875,
-0.74267578125,
-0.029022216796875,
-0.11383056640625,
-0.1309814453125,
0.33447265625,
-0.418212890625,
-0.1385498046875,
-0.34228515625,
0.6171875,
0.53759765625,
-0.10443115234375,
-0.78857421875,
-0.771484375,
-0.962890625,
-1.3984375,
0.35107421875,
-0.41259765625,
0.212646484375,
-0.215087890625,
-0.56689453125,
1.064453125,
-0.424072265625,
0.09344482421875,
0.9248046875,
-0.16455078125,
0.1824951171875,
-0.49755859375,
1.00390625,
0.90234375,
-0.1318359375,
0.0389404296875,
0.18603515625,
-0.411865234375,
0.105224609375,
-0.53271484375,
-0.58447265625,
-0.80419921875,
0.285400390625,
1.0107421875,
-0.10455322265625,
1.0771484375,
-0.6796875,
-0.91162109375,
-0.1571044921875,
0.80712890625,
0.307861328125,
0.392578125,
0.92431640625,
-0.04486083984375,
0.1025390625,
0.374755859375,
0.0009670257568359375,
-0.05938720703125,
-0.669921875,
1.095703125,
-0.470458984375,
-1.0400390625,
0.77587890625,
0.80322265625,
-0.7890625,
-1.1806640625,
-0.1983642578125,
0.253173828125,
-0.154052734375,
-0.6220703125,
0.51123046875,
0.49169921875,
-0.76708984375,
0.42626953125,
0.58740234375,
-0.365234375,
0.287353515625,
0.21826171875,
0.441650390625,
-0.439697265625,
-0.0877685546875,
0.7197265625,
-0.29443359375,
-0.78466796875,
-0.83251953125,
0.27978515625,
0.1453857421875,
-0.051727294921875,
0.80126953125,
0.07940673828125,
0.1983642578125,
0.50439453125,
0.2020263671875,
0.74658203125,
-0.216552734375,
-0.0731201171875,
0.2705078125,
-0.5205078125,
-0.82080078125,
-0.305419921875,
0.939453125,
-0.140380859375,
0.06695556640625,
-0.5048828125,
0.53173828125,
0.40234375,
0.260009765625,
-0.8427734375,
-0.9482421875,
-0.09619140625,
-0.98779296875,
-0.51025390625,
-0.263427734375,
-0.6826171875,
0.1051025390625,
0.142578125,
-0.12646484375,
-0.6162109375,
0.12457275390625,
0.85009765625,
-0.39306640625,
0.2078857421875,
-0.73974609375,
0.283203125,
-0.431640625,
-0.162353515625,
-0.80126953125,
-0.006603240966796875,
-0.2176513671875,
-0.270751953125,
-0.65869140625,
-0.230224609375,
0.390380859375,
0.1446533203125,
-0.271484375,
0.07562255859375,
-0.3017578125,
-1.0615234375,
-0.40966796875,
-0.0181121826171875,
-0.2015380859375,
0.97900390625,
0.39111328125,
-0.056549072265625,
0.336181640625,
-0.70263671875,
-0.2373046875,
0.316650390625,
0.5546875,
0.57421875,
-0.427490234375,
-0.021453857421875,
-0.2169189453125,
-0.050048828125,
-0.84912109375,
0.302490234375,
-0.85693359375,
0.3701171875,
0.26611328125,
-0.0941162109375,
0.49951171875,
0.71728515625,
-0.24560546875,
0.07647705078125,
0.05352783203125,
0.156494140625,
0.51953125,
0.276123046875,
0.03314208984375,
0.075439453125,
0.474609375,
-0.299072265625,
-0.0792236328125,
-0.038177490234375,
0.1611328125,
-0.093505859375,
-0.054962158203125,
-0.615234375,
-1.072265625,
-0.29248046875,
-0.06585693359375,
0.3193359375,
0.308837890625,
-0.2445068359375,
0.1363525390625,
0.30859375,
-0.7919921875,
0.5009765625,
-1.0771484375,
-0.76123046875,
0.58642578125,
-0.16259765625,
-0.580078125,
-0.1273193359375,
-0.198486328125,
0.007732391357421875,
0.0836181640625,
0.0699462890625,
-0.61279296875,
0.427490234375,
0.294677734375,
0.46923828125,
-0.1522216796875,
0.11358642578125,
0.43212890625,
0.609375,
-0.568359375,
-0.6650390625,
-0.0841064453125,
0.97607421875,
0.25341796875,
-0.63134765625,
-0.449951171875,
0.041961669921875,
0.492919921875,
0.225830078125,
-0.54150390625,
0.305419921875,
-0.5546875,
1.2060546875,
-0.90087890625,
0.04974365234375,
0.28466796875,
0.39697265625,
0.06488037109375,
-0.24853515625,
-0.1383056640625,
0.7822265625,
0.72998046875,
-0.334228515625,
0.75146484375,
0.412109375,
0.276611328125,
-0.5986328125,
-0.288330078125,
-0.28662109375,
0.90380859375,
0.8173828125,
0.4833984375,
-0.0021820068359375,
0.2158203125,
0.79443359375,
-0.44921875,
-0.375,
0.66259765625,
0.139404296875,
-0.305419921875,
0.31640625,
0.08697509765625,
0.410888671875,
0.1162109375,
-0.45849609375,
0.1361083984375,
-0.437255859375,
-0.1405029296875,
-0.369140625,
-0.52001953125,
0.95654296875,
-0.734375,
-0.0782470703125,
0.1177978515625,
-0.5400390625,
0.5439453125,
0.603515625,
0.09185791015625,
-0.69091796875,
0.896484375,
0.382568359375,
0.44775390625,
0.77001953125,
0.339599609375,
0.110595703125,
-0.62841796875,
0.360595703125,
0.0008306503295898438,
-0.1737060546875,
-0.1409912109375,
-0.35546875,
-0.994140625,
0.44775390625,
-0.3701171875,
-0.62158203125,
0.38623046875,
-0.459716796875,
-0.1871337890625,
-0.25634765625,
0.96875,
-0.80712890625,
0.3876953125,
0.0018796920776367188,
-0.1533203125,
-0.48388671875,
0.66162109375,
-0.228271484375,
0.2464599609375,
0.07012939453125,
0.97802734375,
-0.1568603515625,
1.662109375,
0.2435302734375,
-0.1341552734375,
0.04779052734375,
0.2301025390625,
-0.389404296875,
-0.6416015625,
-0.428955078125,
-0.57080078125,
0.0377197265625,
-0.321044921875,
-0.50146484375,
-0.09954833984375,
0.492919921875,
0.067138671875,
-0.64892578125,
-0.29052734375,
0.64208984375,
-0.406494140625,
0.35009765625,
0.57080078125,
0.45458984375,
-0.00360870361328125,
-0.370849609375,
-0.4208984375,
-0.41845703125,
0.10821533203125,
-0.48681640625,
0.51953125,
-0.57763671875,
-0.139404296875,
-0.560546875,
-0.1146240234375,
-0.2159423828125,
0.0538330078125,
-0.62255859375,
-0.5751953125,
0.826171875,
0.492919921875,
-0.197998046875,
0.8779296875,
-0.42138671875,
0.095947265625,
0.9453125,
1.166015625,
0.0239715576171875,
0.634765625,
0.361083984375,
0.0635986328125,
-0.0297088623046875,
-0.2225341796875,
0.395751953125,
-0.422607421875,
0.06341552734375,
-0.576171875,
0.2171630859375,
-0.5341796875,
-0.90380859375,
-0.059783935546875,
0.501953125,
0.2470703125,
-0.7607421875,
-1.0498046875,
-0.32568359375,
-1.349609375,
0.129638671875,
-0.50146484375,
0.39697265625,
0.2156982421875,
-0.1513671875,
0.228515625,
-1.048828125,
4.53515625,
1.2255859375,
0.8076171875,
0.168701171875,
0.258544921875,
0.39599609375,
0.2235107421875,
-0.6728515625,
-0.0084991455078125,
-0.5947265625,
0.0396728515625,
-0.408203125,
0.3193359375,
0.8212890625,
0.48828125,
0.405517578125,
-0.7666015625,
-0.43798828125,
0.1983642578125,
-1.013671875,
-0.796875,
0.142333984375,
0.065673828125,
0.828125,
0.09649658203125,
0.81298828125,
0.6953125,
-0.564453125,
-0.282470703125,
-0.572265625,
0.140869140625,
-0.495361328125,
0.837890625,
0.1251220703125,
-0.2037353515625,
0.8935546875,
0.0012226104736328125,
-0.0316162109375,
-0.1689453125,
-0.14306640625,
-0.1724853515625,
0.01093292236328125,
0.541015625,
-0.458740234375,
0.65283203125,
0.2509765625,
-0.5087890625,
-0.036712646484375,
0.1961669921875,
-0.93017578125,
0.87841796875,
-0.25634765625,
0.46044921875,
-0.1553955078125,
-0.437744140625,
0.10675048828125,
0.357177734375,
-0.0498046875,
-0.280029296875,
0.2978515625,
0.55517578125,
0.069091796875,
-0.19775390625,
0.69580078125,
-0.9365234375,
0.57666015625,
-0.175537109375,
0.77001953125,
-0.1622314453125,
-0.1453857421875,
-0.43896484375,
-0.1282958984375,
-0.286865234375,
-0.82373046875,
0.97509765625,
0.2412109375,
-0.1732177734375,
0.363037109375,
0.463623046875,
-0.496337890625,
0.29248046875,
-0.2880859375,
-0.453857421875,
-0.44189453125,
0.75927734375,
1.029296875,
-0.4462890625,
-0.367919921875,
0.26123046875,
1.0673828125,
0.41015625,
0.360107421875,
-0.07958984375,
-0.833984375,
-0.11273193359375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!
The popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Tyndex.Bar automatically fills the glass with the finest 1664 cognac after you buy Tyndex.Bottles and insert in into a USB port). It is highly popular due to the well-thought interaction with the user.
Let us take, for example, the system of automatic address correction. Have you entered codehorses instead of codeforces? The gloomy Zoozle Chrome will sadly say that the address does not exist. Tyndex.Brome at the same time will automatically find the closest address and sent you there. That's brilliant!
How does this splendid function work? That's simple! For each potential address a function of the F error is calculated by the following rules:
* for every letter ci from the potential address c the closest position j of the letter ci in the address (s) entered by the user is found. The absolute difference |i - j| of these positions is added to F. So for every i (1 ≤ i ≤ |c|) the position j is chosen such, that ci = sj, and |i - j| is minimal possible.
* if no such letter ci exists in the address entered by the user, then the length of the potential address |c| is added to F.
After the values of the error function have been calculated for all the potential addresses the most suitable one is found.
To understand the special features of the above described method better, it is recommended to realize the algorithm of calculating the F function for an address given by the user and some set of potential addresses. Good luck!
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105). They are the number of potential addresses and the length of the address entered by the user. The next line contains k lowercase Latin letters. They are the address entered by the user (s). Each next i-th (1 ≤ i ≤ n) line contains a non-empty sequence of lowercase Latin letters. They are the potential address. It is guaranteed that the total length of all the lines does not exceed 2·105.
Output
On each n line of the output file print a single number: the value of the error function when the current potential address is chosen.
Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).
Examples
Input
2 10
codeforces
codeforces
codehorses
Output
0
12
Input
9 9
vkontakte
vcontacte
vkontrakte
vkollapse
vkrokodile
vtopke
vkapuste
vpechke
vk
vcodeforcese
Output
18
14
36
47
14
29
30
0
84
Tags: binary search, implementation
Correct Solution:
```
def g(t): return [(t[i] + t[i - 1]) // 2 for i in range(1, len(t))] + [1000000]
def h(a, b, c):
j = s = 0
for i in b:
while i > c[j]: j += 1
s += abs(i - a[j])
return s
n, k = map(int, input().split())
q = 'abcdefghijklmnopqrstuvwxyz'
s, a = 0, {i: [] for i in q}
for i, j in enumerate(input()): a[j].append(i)
c = {i: g(a[i]) for i in q}
def f():
s, b = 0, {i: [] for i in q}
t = input()
for i, j in enumerate(t): b[j].append(i)
for i in q:
if b[i]:
if a[i]: s += h(a[i], b[i], c[i])
else: s += len(t) * len(b[i])
return str(s)
print('\n'.join(f() for i in range(n)))
# Made By Mostafa_Khaled
```
| 72,103 | [
0.08807373046875,
-0.013092041015625,
0.03485107421875,
0.2880859375,
-0.71435546875,
-0.1817626953125,
0.2098388671875,
0.287841796875,
0.2978515625,
0.7138671875,
0.437255859375,
-0.02587890625,
-0.1748046875,
-0.428466796875,
-0.5693359375,
0.166015625,
-0.50634765625,
-0.5341796875,
-0.32568359375,
0.02001953125,
0.316162109375,
-0.154296875,
-1.5400390625,
0.1527099609375,
-0.14599609375,
0.310791015625,
0.724609375,
-0.31591796875,
1.2880859375,
1.1826171875,
-0.18017578125,
-0.73681640625,
0.304443359375,
-0.52490234375,
-0.3095703125,
-0.412841796875,
0.2374267578125,
-0.861328125,
-0.0181884765625,
-0.79736328125,
0.040496826171875,
-0.420654296875,
0.1533203125,
-0.859375,
-0.78564453125,
-0.1715087890625,
-0.71337890625,
-0.548828125,
-0.2244873046875,
-0.73193359375,
0.37646484375,
0.112060546875,
0.046722412109375,
-0.481689453125,
-0.1365966796875,
-0.0806884765625,
-0.174072265625,
-0.0216064453125,
-0.84423828125,
0.09185791015625,
0.1903076171875,
0.237060546875,
-0.30224609375,
-0.68994140625,
0.416015625,
0.49853515625,
-0.17626953125,
-0.118408203125,
0.02410888671875,
0.02679443359375,
-0.2125244140625,
0.2122802734375,
-0.4140625,
-0.69091796875,
-0.2315673828125,
-0.115966796875,
0.036712646484375,
-0.06134033203125,
-0.88134765625,
0.446533203125,
0.2265625,
0.66162109375,
0.2890625,
0.6513671875,
-0.1798095703125,
0.0567626953125,
0.335693359375,
0.152099609375,
-0.451416015625,
0.09521484375,
0.038970947265625,
0.1593017578125,
0.055328369140625,
-0.06658935546875,
0.4990234375,
0.420654296875,
-0.447509765625,
0.54443359375,
0.2578125,
-0.0770263671875,
0.7265625,
0.9111328125,
-0.82763671875,
1.029296875,
-0.053070068359375,
0.286865234375,
0.0445556640625,
-0.54052734375,
-0.27734375,
-0.61181640625,
-0.25927734375,
-0.33984375,
0.197021484375,
0.24853515625,
-0.1651611328125,
0.67333984375,
-0.494384765625,
0.306640625,
-0.463134765625,
-0.26806640625,
-0.1844482421875,
0.06121826171875,
0.33251953125,
-0.272705078125,
-0.2430419921875,
-0.37744140625,
-0.5400390625,
0.77001953125,
-0.65087890625,
-0.34765625,
-0.29931640625,
-0.53173828125,
-0.1514892578125,
0.226806640625,
-0.1456298828125,
0.79443359375,
-0.302734375,
0.55859375,
0.75341796875,
-1.2509765625,
1.126953125,
0.08575439453125,
0.0200958251953125,
1.6025390625,
0.453369140625,
0.11328125,
0.18896484375,
-0.023040771484375,
-0.439208984375,
0.39599609375,
-0.53173828125,
0.85205078125,
0.14599609375,
0.06561279296875,
0.077880859375,
0.319091796875,
-0.2208251953125,
0.352783203125,
0.444580078125,
0.464599609375,
-0.10467529296875,
0.72705078125,
-0.46826171875,
0.8740234375,
-0.73974609375,
0.67724609375,
-0.666015625,
-0.2049560546875,
-0.0767822265625,
-0.62890625,
0.10064697265625,
0.0125885009765625,
-0.1971435546875,
0.57275390625,
0.85498046875,
0.51953125,
0.74072265625,
-0.341796875,
0.416015625,
0.29736328125,
-0.39794921875,
0.22607421875,
0.70068359375,
1.095703125,
0.382568359375,
-0.0035037994384765625,
0.039825439453125,
-0.48583984375,
-0.6982421875,
-0.60400390625,
0.04241943359375,
0.51416015625,
-0.56201171875,
0.1492919921875,
0.1544189453125,
-0.1529541015625,
-0.75390625,
-0.4296875,
0.479736328125,
-1.19140625,
-0.505859375,
0.85546875,
-0.338134765625,
0.342041015625,
-0.163330078125,
-0.298583984375,
0.19873046875,
1.1162109375,
-0.6015625,
0.2274169921875,
0.330322265625,
0.0811767578125,
-0.39111328125,
-0.1485595703125,
0.35400390625,
-0.0645751953125,
-0.13427734375,
0.59033203125,
0.0279083251953125,
0.08050537109375,
0.368896484375,
0.49267578125,
0.251953125,
0.393798828125,
-0.40966796875,
0.1563720703125,
-0.174560546875,
0.98193359375,
-0.24658203125,
0.376708984375,
-0.32421875,
0.921875,
0.09625244140625,
0.82763671875,
0.160888671875,
0.0180816650390625,
1.1533203125,
0.97314453125,
-0.62646484375,
0.5830078125,
0.0279388427734375,
0.6884765625,
0.299560546875,
0.52587890625,
-0.116943359375,
0.45458984375,
0.041259765625,
0.012542724609375,
-0.339111328125,
0.7431640625,
0.08746337890625,
1.02734375,
0.14794921875,
0.03277587890625,
-0.59716796875,
-0.421875,
0.17138671875,
0.572265625,
-0.697265625,
-0.533203125,
0.311767578125,
-0.1663818359375,
0.325927734375,
-0.16259765625,
0.254638671875,
0.95654296875,
-0.08685302734375,
0.6357421875,
-0.291259765625,
-0.70703125,
-0.7373046875,
-0.7685546875,
-1.12890625,
-0.373779296875,
-0.712890625,
-0.457275390625,
0.320556640625,
-0.55126953125,
0.2218017578125,
0.1478271484375,
0.349853515625,
0.332275390625,
-0.489013671875,
0.72021484375,
0.23583984375,
0.6796875,
-0.52783203125,
0.6220703125,
0.01200103759765625,
0.94775390625,
-0.52099609375,
-0.11566162109375,
-0.07342529296875,
-0.53271484375,
0.55029296875,
0.185546875,
0.451171875,
-0.0572509765625,
-0.427978515625,
-0.64501953125,
-0.48681640625,
0.212646484375,
-0.390869140625,
-0.1781005859375,
-0.292724609375,
0.57763671875,
0.66455078125,
-0.33203125,
0.90087890625,
0.501953125,
-0.74951171875,
0.418701171875,
0.58251953125,
-0.273193359375,
-0.814453125,
1.3896484375,
0.6044921875,
0.336669921875,
-0.591796875,
-0.34521484375,
-0.77490234375,
0.1470947265625,
0.08905029296875,
-0.60400390625,
-0.497314453125,
0.7158203125,
-0.2403564453125,
-1.083984375,
0.416259765625,
-1.228515625,
-0.6318359375,
-0.235595703125,
-0.132568359375,
0.734375,
0.61376953125,
-0.02972412109375,
0.47802734375,
-0.2435302734375,
-0.0406494140625,
0.460205078125,
0.3505859375,
-0.607421875,
0.11029052734375,
0.78125,
0.125,
0.1387939453125,
0.166748046875,
-0.91064453125,
-0.2364501953125,
-0.1683349609375,
-0.1810302734375,
0.73779296875,
0.48486328125,
0.2374267578125,
-0.132080078125,
0.9931640625,
-0.80029296875,
-0.2034912109375,
-0.3798828125,
0.5546875,
0.232177734375,
0.241455078125,
0.07470703125,
-0.1907958984375,
-0.3857421875,
-0.66455078125,
0.303466796875,
0.1326904296875,
0.43310546875,
-0.80517578125,
0.28173828125,
0.2056884765625,
-0.541015625,
0.54052734375,
-0.29736328125,
-0.29052734375,
0.904296875,
-0.055694580078125,
0.77783203125,
-0.712890625,
0.1300048828125,
-0.404541015625,
0.007671356201171875,
1.03515625,
0.1302490234375,
0.322021484375,
-0.339599609375,
-0.5458984375,
-0.2705078125,
-0.54638671875,
-0.07391357421875,
0.243896484375,
0.2578125,
0.05816650390625,
-0.51513671875,
-0.92236328125,
0.5107421875,
0.265380859375,
0.427490234375,
-0.08221435546875,
0.37109375,
0.212158203125,
0.736328125,
0.22021484375,
-0.154541015625,
0.56787109375,
-0.5302734375,
0.6298828125,
0.213623046875,
-0.453369140625,
-0.1982421875,
-0.39208984375,
0.11773681640625,
0.32275390625,
-0.06121826171875,
-0.0701904296875,
-0.79150390625,
0.472900390625,
-0.0186767578125,
0.57421875,
-0.1629638671875,
-0.345947265625,
-0.53466796875,
-0.00014257431030273438,
0.2037353515625,
-0.85498046875,
0.434814453125,
-0.471435546875,
0.330322265625,
0.623046875,
0.32666015625,
-0.36181640625,
-0.94970703125,
-0.40283203125,
-0.716796875,
0.23388671875,
0.712890625,
-0.178955078125,
0.060302734375,
-0.806640625,
0.36083984375,
0.19482421875,
-0.413818359375,
0.1297607421875,
0.041015625,
0.2259521484375,
0.23876953125,
0.8662109375,
-0.294189453125,
-0.46044921875,
0.3994140625,
-0.92724609375,
0.9951171875,
-0.32275390625,
-0.149169921875,
-0.136474609375,
0.054656982421875,
-0.06304931640625,
0.396484375,
-0.72265625,
0.06878662109375,
-0.340576171875,
0.1441650390625,
-1.1083984375,
-1.056640625,
0.7099609375,
0.2403564453125,
0.0699462890625,
0.4091796875,
0.1727294921875,
-0.83154296875,
0.53466796875,
0.4833984375,
-0.43505859375,
0.34521484375,
-0.08367919921875,
0.5771484375,
-0.256591796875,
-0.7998046875,
0.09381103515625,
-0.67822265625,
0.9248046875,
0.26025390625,
-0.69873046875,
-0.52294921875,
-0.8486328125,
-0.007778167724609375,
-0.2666015625,
-0.51171875,
0.66064453125,
-0.1280517578125,
0.0262298583984375,
-0.258056640625,
-0.1318359375,
-1.01171875,
-0.08258056640625,
-0.56201171875,
0.2132568359375,
0.2200927734375,
0.55029296875,
0.88134765625,
-0.260498046875,
-0.5771484375,
0.11749267578125,
-0.06298828125,
-0.11651611328125,
-0.5830078125,
0.12481689453125,
0.036834716796875,
-0.27001953125,
-0.724609375,
0.1541748046875,
0.0287017822265625,
0.580078125,
0.91259765625,
0.3740234375,
0.3173828125,
0.01885986328125,
-0.62158203125,
0.472412109375,
0.142822265625,
-0.8486328125,
-0.337646484375,
0.47509765625,
-0.06298828125,
0.9111328125,
0.381591796875,
-0.71337890625,
-0.4375,
-0.7607421875,
-0.0997314453125,
-1.0478515625,
-0.1934814453125,
-0.978515625,
-0.6005859375,
-0.047607421875,
0.537109375,
0.384521484375,
-0.62548828125,
0.029998779296875,
-1.005859375,
-0.154296875,
-0.7958984375,
-0.47265625,
-0.4111328125,
-0.67578125,
0.002269744873046875,
0.8662109375,
-0.07855224609375,
0.1461181640625,
-0.44189453125,
0.35107421875,
0.1370849609375,
0.08563232421875,
-0.85595703125,
-0.90625,
-0.3330078125,
-0.228271484375,
-0.135009765625,
-0.07843017578125,
-0.5380859375,
0.90869140625,
-0.60888671875,
-0.06854248046875,
-0.74267578125,
-0.029022216796875,
-0.11383056640625,
-0.1309814453125,
0.33447265625,
-0.418212890625,
-0.1385498046875,
-0.34228515625,
0.6171875,
0.53759765625,
-0.10443115234375,
-0.78857421875,
-0.771484375,
-0.962890625,
-1.3984375,
0.35107421875,
-0.41259765625,
0.212646484375,
-0.215087890625,
-0.56689453125,
1.064453125,
-0.424072265625,
0.09344482421875,
0.9248046875,
-0.16455078125,
0.1824951171875,
-0.49755859375,
1.00390625,
0.90234375,
-0.1318359375,
0.0389404296875,
0.18603515625,
-0.411865234375,
0.105224609375,
-0.53271484375,
-0.58447265625,
-0.80419921875,
0.285400390625,
1.0107421875,
-0.10455322265625,
1.0771484375,
-0.6796875,
-0.91162109375,
-0.1571044921875,
0.80712890625,
0.307861328125,
0.392578125,
0.92431640625,
-0.04486083984375,
0.1025390625,
0.374755859375,
0.0009670257568359375,
-0.05938720703125,
-0.669921875,
1.095703125,
-0.470458984375,
-1.0400390625,
0.77587890625,
0.80322265625,
-0.7890625,
-1.1806640625,
-0.1983642578125,
0.253173828125,
-0.154052734375,
-0.6220703125,
0.51123046875,
0.49169921875,
-0.76708984375,
0.42626953125,
0.58740234375,
-0.365234375,
0.287353515625,
0.21826171875,
0.441650390625,
-0.439697265625,
-0.0877685546875,
0.7197265625,
-0.29443359375,
-0.78466796875,
-0.83251953125,
0.27978515625,
0.1453857421875,
-0.051727294921875,
0.80126953125,
0.07940673828125,
0.1983642578125,
0.50439453125,
0.2020263671875,
0.74658203125,
-0.216552734375,
-0.0731201171875,
0.2705078125,
-0.5205078125,
-0.82080078125,
-0.305419921875,
0.939453125,
-0.140380859375,
0.06695556640625,
-0.5048828125,
0.53173828125,
0.40234375,
0.260009765625,
-0.8427734375,
-0.9482421875,
-0.09619140625,
-0.98779296875,
-0.51025390625,
-0.263427734375,
-0.6826171875,
0.1051025390625,
0.142578125,
-0.12646484375,
-0.6162109375,
0.12457275390625,
0.85009765625,
-0.39306640625,
0.2078857421875,
-0.73974609375,
0.283203125,
-0.431640625,
-0.162353515625,
-0.80126953125,
-0.006603240966796875,
-0.2176513671875,
-0.270751953125,
-0.65869140625,
-0.230224609375,
0.390380859375,
0.1446533203125,
-0.271484375,
0.07562255859375,
-0.3017578125,
-1.0615234375,
-0.40966796875,
-0.0181121826171875,
-0.2015380859375,
0.97900390625,
0.39111328125,
-0.056549072265625,
0.336181640625,
-0.70263671875,
-0.2373046875,
0.316650390625,
0.5546875,
0.57421875,
-0.427490234375,
-0.021453857421875,
-0.2169189453125,
-0.050048828125,
-0.84912109375,
0.302490234375,
-0.85693359375,
0.3701171875,
0.26611328125,
-0.0941162109375,
0.49951171875,
0.71728515625,
-0.24560546875,
0.07647705078125,
0.05352783203125,
0.156494140625,
0.51953125,
0.276123046875,
0.03314208984375,
0.075439453125,
0.474609375,
-0.299072265625,
-0.0792236328125,
-0.038177490234375,
0.1611328125,
-0.093505859375,
-0.054962158203125,
-0.615234375,
-1.072265625,
-0.29248046875,
-0.06585693359375,
0.3193359375,
0.308837890625,
-0.2445068359375,
0.1363525390625,
0.30859375,
-0.7919921875,
0.5009765625,
-1.0771484375,
-0.76123046875,
0.58642578125,
-0.16259765625,
-0.580078125,
-0.1273193359375,
-0.198486328125,
0.007732391357421875,
0.0836181640625,
0.0699462890625,
-0.61279296875,
0.427490234375,
0.294677734375,
0.46923828125,
-0.1522216796875,
0.11358642578125,
0.43212890625,
0.609375,
-0.568359375,
-0.6650390625,
-0.0841064453125,
0.97607421875,
0.25341796875,
-0.63134765625,
-0.449951171875,
0.041961669921875,
0.492919921875,
0.225830078125,
-0.54150390625,
0.305419921875,
-0.5546875,
1.2060546875,
-0.90087890625,
0.04974365234375,
0.28466796875,
0.39697265625,
0.06488037109375,
-0.24853515625,
-0.1383056640625,
0.7822265625,
0.72998046875,
-0.334228515625,
0.75146484375,
0.412109375,
0.276611328125,
-0.5986328125,
-0.288330078125,
-0.28662109375,
0.90380859375,
0.8173828125,
0.4833984375,
-0.0021820068359375,
0.2158203125,
0.79443359375,
-0.44921875,
-0.375,
0.66259765625,
0.139404296875,
-0.305419921875,
0.31640625,
0.08697509765625,
0.410888671875,
0.1162109375,
-0.45849609375,
0.1361083984375,
-0.437255859375,
-0.1405029296875,
-0.369140625,
-0.52001953125,
0.95654296875,
-0.734375,
-0.0782470703125,
0.1177978515625,
-0.5400390625,
0.5439453125,
0.603515625,
0.09185791015625,
-0.69091796875,
0.896484375,
0.382568359375,
0.44775390625,
0.77001953125,
0.339599609375,
0.110595703125,
-0.62841796875,
0.360595703125,
0.0008306503295898438,
-0.1737060546875,
-0.1409912109375,
-0.35546875,
-0.994140625,
0.44775390625,
-0.3701171875,
-0.62158203125,
0.38623046875,
-0.459716796875,
-0.1871337890625,
-0.25634765625,
0.96875,
-0.80712890625,
0.3876953125,
0.0018796920776367188,
-0.1533203125,
-0.48388671875,
0.66162109375,
-0.228271484375,
0.2464599609375,
0.07012939453125,
0.97802734375,
-0.1568603515625,
1.662109375,
0.2435302734375,
-0.1341552734375,
0.04779052734375,
0.2301025390625,
-0.389404296875,
-0.6416015625,
-0.428955078125,
-0.57080078125,
0.0377197265625,
-0.321044921875,
-0.50146484375,
-0.09954833984375,
0.492919921875,
0.067138671875,
-0.64892578125,
-0.29052734375,
0.64208984375,
-0.406494140625,
0.35009765625,
0.57080078125,
0.45458984375,
-0.00360870361328125,
-0.370849609375,
-0.4208984375,
-0.41845703125,
0.10821533203125,
-0.48681640625,
0.51953125,
-0.57763671875,
-0.139404296875,
-0.560546875,
-0.1146240234375,
-0.2159423828125,
0.0538330078125,
-0.62255859375,
-0.5751953125,
0.826171875,
0.492919921875,
-0.197998046875,
0.8779296875,
-0.42138671875,
0.095947265625,
0.9453125,
1.166015625,
0.0239715576171875,
0.634765625,
0.361083984375,
0.0635986328125,
-0.0297088623046875,
-0.2225341796875,
0.395751953125,
-0.422607421875,
0.06341552734375,
-0.576171875,
0.2171630859375,
-0.5341796875,
-0.90380859375,
-0.059783935546875,
0.501953125,
0.2470703125,
-0.7607421875,
-1.0498046875,
-0.32568359375,
-1.349609375,
0.129638671875,
-0.50146484375,
0.39697265625,
0.2156982421875,
-0.1513671875,
0.228515625,
-1.048828125,
4.53515625,
1.2255859375,
0.8076171875,
0.168701171875,
0.258544921875,
0.39599609375,
0.2235107421875,
-0.6728515625,
-0.0084991455078125,
-0.5947265625,
0.0396728515625,
-0.408203125,
0.3193359375,
0.8212890625,
0.48828125,
0.405517578125,
-0.7666015625,
-0.43798828125,
0.1983642578125,
-1.013671875,
-0.796875,
0.142333984375,
0.065673828125,
0.828125,
0.09649658203125,
0.81298828125,
0.6953125,
-0.564453125,
-0.282470703125,
-0.572265625,
0.140869140625,
-0.495361328125,
0.837890625,
0.1251220703125,
-0.2037353515625,
0.8935546875,
0.0012226104736328125,
-0.0316162109375,
-0.1689453125,
-0.14306640625,
-0.1724853515625,
0.01093292236328125,
0.541015625,
-0.458740234375,
0.65283203125,
0.2509765625,
-0.5087890625,
-0.036712646484375,
0.1961669921875,
-0.93017578125,
0.87841796875,
-0.25634765625,
0.46044921875,
-0.1553955078125,
-0.437744140625,
0.10675048828125,
0.357177734375,
-0.0498046875,
-0.280029296875,
0.2978515625,
0.55517578125,
0.069091796875,
-0.19775390625,
0.69580078125,
-0.9365234375,
0.57666015625,
-0.175537109375,
0.77001953125,
-0.1622314453125,
-0.1453857421875,
-0.43896484375,
-0.1282958984375,
-0.286865234375,
-0.82373046875,
0.97509765625,
0.2412109375,
-0.1732177734375,
0.363037109375,
0.463623046875,
-0.496337890625,
0.29248046875,
-0.2880859375,
-0.453857421875,
-0.44189453125,
0.75927734375,
1.029296875,
-0.4462890625,
-0.367919921875,
0.26123046875,
1.0673828125,
0.41015625,
0.360107421875,
-0.07958984375,
-0.833984375,
-0.11273193359375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Input
The input contains a single integer a (0 ≤ a ≤ 35).
Output
Output a single integer.
Examples
Input
3
Output
8
Input
10
Output
1024
Tags: *special
Correct Solution:
```
i = int(input())
stringarrPresidents = ["Washington", "Adams", "Jefferson", "Madison", "Monroe", "Adams", "Jackson", "Van Buren", "Harrison", "Tyler", "Polk", "Taylor", "Fillmore", "Pierce", "Buchanan", "Lincoln", "Johnson", "Grant", "Hayes", "Garfield", "Arthur", "Cleveland", "Harrison", "Cleveland", "McKinley", "Roosevelt", "Taft", "Wilson", "Harding", "Coolidge", "Hoover", "Roosevelt", "Truman", "Eisenhower", "Kennedy", "Johnson", "Nixon", "Ford", "Carter", "Reagan"]
print(stringarrPresidents[i-1])
```
| 72,108 | [
0.5048828125,
0.1656494140625,
0.212158203125,
0.281494140625,
-0.7109375,
-0.426513671875,
-0.193603515625,
0.1597900390625,
0.375244140625,
0.10406494140625,
0.96826171875,
-0.412841796875,
-0.30029296875,
-0.5107421875,
-0.488525390625,
0.30078125,
-0.63623046875,
-0.5615234375,
-0.03857421875,
-0.36669921875,
0.2445068359375,
0.1502685546875,
-1.8154296875,
-0.1492919921875,
-0.6435546875,
1.080078125,
0.474609375,
0.426025390625,
0.5087890625,
1.08203125,
-0.383056640625,
-0.740234375,
0.62353515625,
-0.91845703125,
-0.625,
-0.468994140625,
0.58349609375,
-0.70361328125,
-0.367919921875,
-0.26318359375,
0.158447265625,
-0.58154296875,
0.16748046875,
-0.826171875,
-1.2412109375,
0.476806640625,
-0.345703125,
-0.32080078125,
-0.228515625,
-1.09375,
-0.1336669921875,
-0.1981201171875,
0.6923828125,
0.291015625,
0.040802001953125,
-0.23779296875,
-0.221435546875,
-0.407470703125,
-0.82861328125,
0.1600341796875,
-0.07281494140625,
0.35400390625,
-0.037689208984375,
-1.0009765625,
-0.178955078125,
0.07232666015625,
-0.0655517578125,
-0.4921875,
0.3515625,
-0.72412109375,
-0.09722900390625,
-0.0271759033203125,
-0.458740234375,
-0.6513671875,
-0.155517578125,
-0.022369384765625,
0.412109375,
-0.3525390625,
-0.5283203125,
0.5068359375,
0.025909423828125,
1.1103515625,
-0.014190673828125,
0.33935546875,
-0.287841796875,
-0.6123046875,
-0.08624267578125,
0.57568359375,
0.42919921875,
0.246826171875,
-0.468017578125,
0.568359375,
-0.409912109375,
0.08465576171875,
0.69384765625,
0.326904296875,
-0.1304931640625,
0.380859375,
0.3408203125,
-0.1214599609375,
0.94677734375,
0.76318359375,
-0.14111328125,
0.98974609375,
-0.46044921875,
-0.056121826171875,
0.192626953125,
-0.07818603515625,
0.05657958984375,
-0.04229736328125,
-0.039459228515625,
-0.52587890625,
0.55224609375,
0.03564453125,
-0.515625,
0.87939453125,
0.2646484375,
0.07489013671875,
-1.02734375,
0.37548828125,
0.498291015625,
-0.154296875,
0.55615234375,
-0.3173828125,
-0.1475830078125,
-0.264404296875,
-0.35888671875,
1.0712890625,
-0.78271484375,
0.4306640625,
0.375,
0.08221435546875,
0.14306640625,
0.040863037109375,
-0.059417724609375,
0.556640625,
-0.45361328125,
0.7099609375,
0.875,
-0.7412109375,
0.92578125,
-0.224853515625,
-0.2027587890625,
1.3671875,
0.46533203125,
0.3076171875,
0.56103515625,
0.44189453125,
-0.625,
0.10791015625,
-0.75634765625,
0.96923828125,
0.272216796875,
0.2705078125,
-0.20654296875,
0.18994140625,
0.2109375,
0.312255859375,
0.1253662109375,
0.384521484375,
-0.438232421875,
0.03173828125,
0.0150299072265625,
0.8935546875,
-0.51708984375,
0.923828125,
-0.88916015625,
-0.218017578125,
-0.48193359375,
-0.60302734375,
0.21875,
-0.19189453125,
-0.07647705078125,
0.77587890625,
0.55419921875,
1.1953125,
0.88037109375,
-0.12200927734375,
0.64599609375,
0.33154296875,
-0.529296875,
0.2384033203125,
0.69970703125,
0.61962890625,
0.234130859375,
0.3125,
0.137939453125,
-0.1956787109375,
-1.208984375,
-0.53125,
-0.053955078125,
0.55029296875,
-0.1966552734375,
0.27685546875,
0.1939697265625,
0.160400390625,
-0.90234375,
-0.2186279296875,
-0.31494140625,
-0.279541015625,
-0.2568359375,
0.2188720703125,
-0.1568603515625,
0.244873046875,
-0.09307861328125,
-0.437255859375,
0.48291015625,
1.193359375,
-0.426513671875,
-0.1512451171875,
0.404296875,
-0.03460693359375,
0.2298583984375,
0.1824951171875,
0.068359375,
-0.03814697265625,
-0.724609375,
0.81591796875,
-0.2039794921875,
0.11920166015625,
0.367431640625,
0.83251953125,
0.29150390625,
0.86865234375,
-0.0791015625,
-0.55126953125,
0.548828125,
0.919921875,
-0.1519775390625,
0.841796875,
0.385498046875,
0.896484375,
0.49072265625,
0.8447265625,
0.8310546875,
0.218994140625,
0.323974609375,
0.5166015625,
0.1292724609375,
0.13525390625,
0.0487060546875,
0.408447265625,
0.71240234375,
0.1280517578125,
0.1051025390625,
0.71728515625,
-0.20263671875,
0.31591796875,
-0.18408203125,
0.57568359375,
-0.1197509765625,
0.81201171875,
0.13525390625,
0.59375,
-0.7548828125,
-0.26123046875,
0.77001953125,
0.8056640625,
-0.448486328125,
-0.492919921875,
-0.1505126953125,
-0.07366943359375,
-0.051177978515625,
-0.134033203125,
0.02587890625,
0.74755859375,
0.48779296875,
0.6337890625,
-0.0667724609375,
-0.5107421875,
-1.01171875,
-0.77001953125,
-0.80712890625,
-0.5361328125,
-0.43603515625,
0.191162109375,
0.385009765625,
-0.7197265625,
0.028472900390625,
-0.6083984375,
-0.453369140625,
-0.06341552734375,
-0.51904296875,
0.68994140625,
-0.0198211669921875,
0.6904296875,
-0.8046875,
0.339111328125,
0.299560546875,
0.71875,
-0.1917724609375,
-0.50634765625,
0.0201416015625,
-0.5966796875,
0.0455322265625,
0.14892578125,
0.41845703125,
-0.168701171875,
-0.666015625,
-0.90478515625,
-0.64794921875,
0.5517578125,
-0.2352294921875,
-0.01195526123046875,
-0.556640625,
0.68896484375,
0.47509765625,
-0.57373046875,
0.537109375,
1.0302734375,
-0.6201171875,
0.74951171875,
0.52783203125,
0.386962890625,
-0.92236328125,
1.0869140625,
0.46875,
0.48779296875,
-0.6708984375,
-0.412109375,
-1.025390625,
0.2464599609375,
-0.10302734375,
-1.015625,
-0.343994140625,
0.52978515625,
-0.315673828125,
-1.0283203125,
0.2178955078125,
-1.3115234375,
-0.69140625,
-0.51318359375,
-0.52880859375,
0.76708984375,
0.7724609375,
-0.09716796875,
-0.0211181640625,
-0.40673828125,
0.09722900390625,
0.8056640625,
0.55078125,
-0.50537109375,
-0.01885986328125,
0.5654296875,
-0.293701171875,
-0.281982421875,
-0.11053466796875,
-0.314453125,
0.07611083984375,
0.24365234375,
0.404052734375,
0.425048828125,
0.262451171875,
-0.0975341796875,
0.53466796875,
0.81396484375,
-0.84716796875,
-0.27783203125,
-0.0209197998046875,
0.1160888671875,
0.249267578125,
0.454833984375,
0.09320068359375,
-0.237548828125,
-0.4189453125,
-1.1845703125,
0.325927734375,
0.349365234375,
0.822265625,
-1.0146484375,
0.77490234375,
0.60107421875,
-0.4365234375,
0.63134765625,
-0.6708984375,
-0.206298828125,
0.90478515625,
0.189208984375,
0.68896484375,
-0.544921875,
0.1473388671875,
0.2066650390625,
0.097900390625,
0.5458984375,
0.049041748046875,
0.64697265625,
-0.416748046875,
-0.51318359375,
-0.419189453125,
-0.04486083984375,
-0.10791015625,
-0.74267578125,
-0.334716796875,
-0.2724609375,
-0.385986328125,
-0.61181640625,
0.736328125,
0.5888671875,
0.2083740234375,
0.318603515625,
0.53369140625,
0.35009765625,
0.53466796875,
0.491455078125,
-0.308837890625,
0.02386474609375,
-0.8359375,
0.84765625,
0.182861328125,
-0.66943359375,
-0.27197265625,
-0.50244140625,
-0.186279296875,
0.055389404296875,
0.1932373046875,
-0.47412109375,
-0.7626953125,
0.387451171875,
-0.192138671875,
0.97802734375,
-0.49072265625,
-0.383544921875,
-0.236572265625,
0.5302734375,
0.402099609375,
-0.68212890625,
0.349609375,
-0.2298583984375,
0.8720703125,
0.355224609375,
-0.15576171875,
-0.9501953125,
-0.7890625,
-1.0810546875,
-0.728515625,
0.1007080078125,
0.6640625,
-0.55419921875,
0.1385498046875,
-1.1669921875,
0.324951171875,
0.76416015625,
-0.205078125,
0.07452392578125,
-0.10693359375,
-0.06884765625,
0.07623291015625,
0.7529296875,
-0.304931640625,
-0.5361328125,
0.2318115234375,
-1.0166015625,
0.3125,
-0.73486328125,
0.197021484375,
-0.08056640625,
-0.01806640625,
-0.401611328125,
0.04254150390625,
-0.29638671875,
0.333740234375,
-0.048980712890625,
0.212646484375,
-0.65234375,
-0.7841796875,
0.86474609375,
-0.446533203125,
-0.30419921875,
0.8369140625,
0.07470703125,
-0.29296875,
0.225830078125,
0.5458984375,
-0.423095703125,
0.004062652587890625,
-0.421630859375,
0.91455078125,
-0.4873046875,
-0.2490234375,
-0.220458984375,
-0.95068359375,
0.56201171875,
0.0399169921875,
-0.86181640625,
-0.5068359375,
-1.3359375,
-0.35302734375,
0.130126953125,
-0.56201171875,
0.1322021484375,
-0.0088653564453125,
-0.1956787109375,
-0.09454345703125,
-0.67578125,
-0.21728515625,
0.0276641845703125,
-0.6162109375,
0.06756591796875,
0.427490234375,
0.1917724609375,
0.91357421875,
0.208251953125,
-0.43701171875,
0.1572265625,
0.009857177734375,
-0.055908203125,
-0.60595703125,
-0.09564208984375,
-0.481201171875,
0.0489501953125,
-0.340576171875,
-0.329833984375,
-0.262451171875,
0.98681640625,
0.76513671875,
-0.359130859375,
0.59375,
0.2335205078125,
-0.68359375,
0.7822265625,
0.408447265625,
-0.6865234375,
-0.232421875,
0.65087890625,
0.0233306884765625,
0.6875,
0.299560546875,
-0.7509765625,
-0.62646484375,
-0.99169921875,
0.077392578125,
-0.01264190673828125,
-0.343017578125,
-0.796875,
-0.64892578125,
-0.10955810546875,
0.48876953125,
-0.017364501953125,
-0.5390625,
0.019439697265625,
-0.272216796875,
-0.0037403106689453125,
-0.8408203125,
-0.202880859375,
-0.72265625,
-0.83984375,
-0.2286376953125,
0.61669921875,
0.053558349609375,
-0.025421142578125,
0.12237548828125,
-0.374267578125,
0.1846923828125,
-0.41162109375,
-0.7646484375,
-0.50146484375,
-0.250732421875,
0.0255889892578125,
-0.0499267578125,
0.07257080078125,
-0.456787109375,
0.2998046875,
-0.52294921875,
0.063720703125,
-0.03717041015625,
-0.35546875,
-0.439208984375,
-0.64453125,
1.1787109375,
-0.5087890625,
0.0416259765625,
-0.386474609375,
0.369140625,
0.49365234375,
-0.1441650390625,
-0.54052734375,
-0.9833984375,
-0.415771484375,
-0.9189453125,
0.6845703125,
-0.4052734375,
-0.0234222412109375,
-0.6572265625,
-0.189453125,
0.7919921875,
-0.6845703125,
0.314697265625,
1.5302734375,
-0.273681640625,
0.3095703125,
-0.80712890625,
0.345703125,
0.34765625,
-0.58154296875,
0.2135009765625,
0.263427734375,
-0.83984375,
0.2401123046875,
-0.04510498046875,
-0.99658203125,
-0.64306640625,
-0.0225372314453125,
1.5771484375,
0.2015380859375,
0.935546875,
0.311767578125,
-1.427734375,
-0.57666015625,
0.76953125,
-0.1243896484375,
0.7060546875,
0.716796875,
0.1849365234375,
0.030517578125,
-0.0003864765167236328,
0.043609619140625,
-0.1572265625,
-0.3193359375,
0.966796875,
-0.373779296875,
-0.5625,
0.64404296875,
1.0849609375,
-1.1943359375,
-0.51904296875,
0.09759521484375,
-0.36865234375,
-0.406494140625,
-0.58642578125,
0.23974609375,
0.8173828125,
-1.048828125,
-0.465576171875,
0.54296875,
-0.1439208984375,
0.1929931640625,
0.0047607421875,
0.433837890625,
-0.1552734375,
0.671875,
0.53564453125,
-0.2486572265625,
-0.195556640625,
-0.71435546875,
-0.097900390625,
-0.045623779296875,
-0.05084228515625,
0.6962890625,
-0.400634765625,
-0.053375244140625,
0.413818359375,
-0.373779296875,
0.6259765625,
-0.30517578125,
-0.56396484375,
0.32958984375,
-0.3505859375,
-0.467041015625,
-0.020660400390625,
0.390380859375,
0.156494140625,
0.489501953125,
-0.11004638671875,
0.4228515625,
0.3447265625,
0.57275390625,
-0.1328125,
-1.2529296875,
-0.2230224609375,
-0.890625,
-0.2587890625,
-0.50146484375,
-0.54345703125,
-0.388916015625,
0.07208251953125,
0.299072265625,
-0.677734375,
-0.00994873046875,
0.09271240234375,
-0.50537109375,
1.009765625,
-0.51904296875,
0.352783203125,
-0.51806640625,
-0.370849609375,
-0.896484375,
0.1455078125,
-0.201171875,
-0.21533203125,
-0.5048828125,
0.5810546875,
-0.086669921875,
0.4873046875,
-0.131591796875,
0.34228515625,
-0.2178955078125,
-0.48095703125,
-0.042388916015625,
-0.2178955078125,
-0.1141357421875,
0.69384765625,
0.5537109375,
-0.60888671875,
0.41748046875,
-0.36572265625,
-0.34814453125,
-0.50927734375,
0.6455078125,
0.53564453125,
-0.5888671875,
-0.406494140625,
-0.466796875,
0.0477294921875,
-1.03125,
0.364501953125,
-0.0069580078125,
0.26953125,
0.242919921875,
-0.265869140625,
0.55908203125,
0.826171875,
0.1654052734375,
0.07110595703125,
-0.1514892578125,
0.370361328125,
0.451171875,
-0.231689453125,
-0.0838623046875,
0.28271484375,
0.359130859375,
-0.44775390625,
-0.1624755859375,
0.3876953125,
-0.06561279296875,
0.436767578125,
0.03411865234375,
-0.607421875,
-0.7021484375,
-0.41162109375,
-0.1630859375,
0.71337890625,
0.6708984375,
-0.479248046875,
0.062103271484375,
0.146484375,
-0.2744140625,
0.0288848876953125,
-1.328125,
-0.85400390625,
0.94921875,
-0.125,
-0.3310546875,
-0.467041015625,
-0.33056640625,
-0.65478515625,
0.2880859375,
0.388916015625,
-0.432861328125,
0.8466796875,
-0.361328125,
0.498779296875,
-0.5751953125,
-0.0626220703125,
0.494873046875,
0.57080078125,
-0.70556640625,
-0.56591796875,
0.474365234375,
0.97216796875,
0.448974609375,
0.0982666015625,
-0.56689453125,
0.285400390625,
0.12127685546875,
0.00678253173828125,
-0.38134765625,
0.183349609375,
-0.08837890625,
0.51416015625,
-0.71923828125,
0.369873046875,
-0.69970703125,
0.281494140625,
0.25927734375,
-0.352294921875,
-0.45947265625,
0.7197265625,
0.6142578125,
-0.2137451171875,
0.474853515625,
0.37060546875,
0.15234375,
-0.1666259765625,
-0.322509765625,
-0.1278076171875,
0.76904296875,
1.076171875,
0.53955078125,
0.038970947265625,
0.453857421875,
0.54833984375,
0.07513427734375,
-0.04876708984375,
0.384033203125,
0.357177734375,
-0.369140625,
-0.02947998046875,
-0.15380859375,
-0.08966064453125,
0.324951171875,
-0.468994140625,
0.0570068359375,
-0.3984375,
-0.31298828125,
-0.1558837890625,
-0.63916015625,
1.05078125,
-0.034210205078125,
-0.59130859375,
0.383056640625,
-0.60205078125,
0.1356201171875,
0.974609375,
0.20361328125,
-0.232666015625,
1.1494140625,
0.63330078125,
1.013671875,
0.9208984375,
0.451171875,
0.393798828125,
-0.52490234375,
-0.003971099853515625,
-0.412353515625,
0.253173828125,
-0.27978515625,
-0.52880859375,
-0.654296875,
0.432861328125,
-0.260009765625,
-0.383056640625,
0.861328125,
-0.58984375,
-0.274658203125,
-0.513671875,
0.89453125,
-0.59375,
0.226318359375,
0.453125,
-0.57568359375,
-0.56689453125,
1.279296875,
-0.0279998779296875,
0.2626953125,
-0.0599365234375,
1.3251953125,
0.43701171875,
1.396484375,
0.73876953125,
-0.12261962890625,
-0.11602783203125,
0.5478515625,
-0.3916015625,
-0.640625,
-0.50341796875,
-0.59033203125,
0.2452392578125,
-0.75732421875,
0.07501220703125,
0.2137451171875,
0.81298828125,
0.481689453125,
-1.076171875,
-0.474853515625,
0.29052734375,
-0.79931640625,
0.380615234375,
0.316162109375,
-0.008392333984375,
-0.034698486328125,
-0.261962890625,
0.0196075439453125,
-0.471923828125,
0.6455078125,
-0.320068359375,
0.767578125,
-0.469482421875,
-0.9326171875,
-0.223388671875,
-0.67138671875,
-0.028533935546875,
-0.10357666015625,
-0.6552734375,
-0.302734375,
0.279541015625,
0.468505859375,
0.36376953125,
0.24365234375,
0.49462890625,
-0.1505126953125,
1.0400390625,
1.0634765625,
0.10015869140625,
0.292236328125,
0.182373046875,
-0.331787109375,
0.58642578125,
-0.400634765625,
0.4228515625,
-0.32177734375,
0.231201171875,
-0.437744140625,
0.59716796875,
-0.7841796875,
-1.4931640625,
0.302490234375,
0.404296875,
0.357421875,
-0.42626953125,
-0.8037109375,
-0.12359619140625,
-1.1806640625,
-0.15625,
-0.2340087890625,
0.483154296875,
-0.732421875,
0.1531982421875,
-0.1015625,
-1.1865234375,
4.359375,
1.0419921875,
0.73193359375,
0.3232421875,
0.277099609375,
0.7216796875,
0.619140625,
-0.2958984375,
-0.3125,
-0.5400390625,
0.25439453125,
-0.33544921875,
-0.09783935546875,
0.666015625,
0.358642578125,
0.10748291015625,
-0.6083984375,
0.267822265625,
-0.060516357421875,
-0.8544921875,
-0.481201171875,
0.39453125,
-0.1756591796875,
0.72998046875,
-0.369140625,
0.14404296875,
0.355224609375,
-0.6689453125,
-0.266357421875,
-0.383056640625,
0.5302734375,
-0.68310546875,
1.0185546875,
0.08355712890625,
-0.382568359375,
0.09906005859375,
-0.224853515625,
-0.55322265625,
-0.114501953125,
0.1270751953125,
-0.35693359375,
0.1446533203125,
0.82373046875,
-0.90771484375,
-0.023468017578125,
0.357666015625,
-0.60986328125,
0.6416015625,
0.362548828125,
-1.08984375,
0.76904296875,
-0.477783203125,
0.37841796875,
-0.74365234375,
-0.68994140625,
0.308837890625,
-0.00579071044921875,
0.1055908203125,
-0.474365234375,
0.197509765625,
0.6259765625,
0.48046875,
0.07427978515625,
0.39111328125,
-1.1328125,
1.029296875,
0.0281219482421875,
0.465087890625,
-0.60400390625,
-0.2471923828125,
-0.308837890625,
-0.1737060546875,
-0.58544921875,
-0.27685546875,
0.607421875,
0.0146942138671875,
-0.379150390625,
0.2763671875,
0.310791015625,
-0.83154296875,
-0.042694091796875,
-0.427978515625,
-0.626953125,
-0.482666015625,
0.458740234375,
1.1865234375,
-0.88916015625,
0.016082763671875,
-0.27490234375,
0.94482421875,
-0.2344970703125,
0.451416015625,
-0.0302581787109375,
-0.24560546875,
-0.290283203125
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Tags: implementation, strings
Correct Solution:
```
n = int(input())
encoded = list(input())
left, right = '', ''
while True:
try:
right = encoded[-1] + right
encoded.pop()
left += encoded[-1]
encoded.pop()
except:
break
print(left + right)
```
| 72,169 | [
0.61865234375,
-0.290771484375,
0.251708984375,
0.384765625,
-0.54052734375,
-0.62548828125,
0.1298828125,
-0.0924072265625,
-0.399658203125,
0.7626953125,
0.9833984375,
-0.2122802734375,
-0.045806884765625,
-0.63720703125,
-0.9208984375,
-0.54443359375,
-0.3759765625,
-0.54296875,
-0.7021484375,
0.1636962890625,
0.2398681640625,
0.03802490234375,
-1.1875,
-0.1519775390625,
-0.3759765625,
1.12890625,
0.61376953125,
-0.2332763671875,
1.2353515625,
0.97314453125,
0.0190277099609375,
0.07330322265625,
0.75634765625,
-1.1962890625,
-0.330322265625,
-0.2467041015625,
0.69189453125,
-0.34716796875,
-0.28125,
-0.375244140625,
0.26171875,
-0.347900390625,
0.4130859375,
-0.6376953125,
-0.86669921875,
-0.07098388671875,
-0.284912109375,
-0.8935546875,
-0.370849609375,
-0.91650390625,
0.129638671875,
-0.360107421875,
0.57421875,
-0.283935546875,
-0.17919921875,
-0.2841796875,
-0.1402587890625,
-0.006084442138671875,
-0.34423828125,
0.325439453125,
0.376220703125,
0.40869140625,
0.1448974609375,
-1.03125,
-0.30859375,
-0.32763671875,
-0.0987548828125,
-0.12109375,
0.010009765625,
-0.6982421875,
-0.164306640625,
0.4912109375,
-0.173095703125,
-0.693359375,
-0.346923828125,
0.10955810546875,
0.2880859375,
0.21240234375,
-0.75341796875,
0.94189453125,
0.1226806640625,
0.87353515625,
0.66259765625,
0.4287109375,
-0.51708984375,
-0.235107421875,
0.0594482421875,
0.368408203125,
0.100830078125,
-0.005970001220703125,
0.06585693359375,
0.51171875,
-0.263427734375,
0.189208984375,
0.494384765625,
0.60302734375,
0.010528564453125,
0.333251953125,
0.033447265625,
0.61083984375,
0.791015625,
1.3896484375,
-0.279296875,
1.0791015625,
-0.436767578125,
0.57958984375,
0.1746826171875,
0.274169921875,
-0.330810546875,
0.11328125,
-0.470458984375,
-0.1163330078125,
0.0014638900756835938,
-0.340087890625,
-0.218017578125,
0.97607421875,
-0.1153564453125,
0.210693359375,
-0.91259765625,
0.419921875,
0.3466796875,
0.266845703125,
0.427734375,
-0.336181640625,
0.2371826171875,
-0.38232421875,
-0.6572265625,
1.0947265625,
-0.472900390625,
-0.427001953125,
0.1854248046875,
0.3369140625,
-0.366943359375,
0.1915283203125,
0.326171875,
0.71484375,
0.1455078125,
0.45654296875,
0.81298828125,
-0.278564453125,
0.317138671875,
0.1837158203125,
-0.33740234375,
1.4521484375,
-0.150390625,
-0.2763671875,
0.451416015625,
0.28955078125,
-0.859375,
0.615234375,
-0.79052734375,
0.41943359375,
-0.1746826171875,
0.297607421875,
-0.302490234375,
0.05035400390625,
-0.267578125,
0.67138671875,
-0.0272064208984375,
0.075439453125,
-0.366455078125,
-0.235595703125,
-0.360595703125,
0.86669921875,
-0.6201171875,
1.33203125,
-0.96435546875,
-0.6259765625,
-0.47900390625,
-0.2479248046875,
0.42529296875,
-0.11395263671875,
-0.092041015625,
0.6826171875,
0.39990234375,
0.845703125,
0.671875,
-0.41162109375,
0.3642578125,
0.0731201171875,
0.1085205078125,
0.294189453125,
0.309326171875,
0.69189453125,
0.1771240234375,
-0.026824951171875,
0.1103515625,
-0.498046875,
-0.67822265625,
-0.3056640625,
-0.144287109375,
0.82080078125,
-0.354248046875,
-0.1839599609375,
-0.34130859375,
-0.322998046875,
-0.7314453125,
-0.376708984375,
-0.070068359375,
-1.017578125,
-0.2958984375,
0.8369140625,
-0.2841796875,
0.52490234375,
-0.448486328125,
-0.63818359375,
0.332763671875,
1.173828125,
-0.233154296875,
-0.264892578125,
0.986328125,
0.25146484375,
-0.46728515625,
0.329833984375,
0.171142578125,
0.1641845703125,
-0.8046875,
0.6806640625,
-0.46630859375,
0.07659912109375,
-0.2232666015625,
0.78662109375,
0.218017578125,
0.4013671875,
-0.50830078125,
0.0963134765625,
0.84033203125,
1.025390625,
0.005054473876953125,
0.299560546875,
0.29638671875,
0.44677734375,
0.2349853515625,
0.67431640625,
0.75,
0.4091796875,
0.5966796875,
0.82666015625,
-0.1771240234375,
0.2286376953125,
-0.045684814453125,
0.390869140625,
0.84228515625,
0.049468994140625,
0.1209716796875,
0.5302734375,
-0.496337890625,
-0.119140625,
-0.439453125,
0.1043701171875,
-0.365966796875,
0.018585205078125,
0.2666015625,
0.15869140625,
-0.44384765625,
-0.381103515625,
0.434814453125,
0.6904296875,
-0.64697265625,
-0.54833984375,
0.2191162109375,
0.2491455078125,
0.5322265625,
0.43603515625,
0.418701171875,
0.75537109375,
0.6904296875,
0.46533203125,
-0.25537109375,
-0.63037109375,
-0.6611328125,
-1.44921875,
-1.0380859375,
-0.25390625,
-0.80810546875,
0.0797119140625,
0.032562255859375,
-1.07421875,
-0.1473388671875,
-0.328857421875,
-0.60595703125,
-0.398193359375,
-0.365966796875,
0.56884765625,
-0.117431640625,
0.66064453125,
-0.444580078125,
0.51953125,
0.0821533203125,
1.162109375,
-0.5419921875,
-0.1964111328125,
-0.288330078125,
-0.54541015625,
0.300537109375,
-0.126220703125,
0.525390625,
-0.410888671875,
-0.85498046875,
-0.591796875,
-0.70361328125,
0.11895751953125,
-0.457275390625,
0.035369873046875,
-0.41845703125,
0.91259765625,
0.359130859375,
-0.568359375,
0.326171875,
0.96826171875,
-0.85595703125,
0.367919921875,
0.2939453125,
-0.265380859375,
-0.76513671875,
1.4609375,
0.4150390625,
0.51611328125,
-0.4140625,
-0.1650390625,
-0.12078857421875,
0.201904296875,
-0.06671142578125,
-0.453857421875,
-0.37548828125,
0.630859375,
0.05157470703125,
-1.37109375,
0.1153564453125,
-1.05859375,
-0.74462890625,
-0.357421875,
-0.57470703125,
0.79248046875,
0.96728515625,
0.490478515625,
-0.284423828125,
0.0635986328125,
0.10748291015625,
0.408203125,
0.22119140625,
-0.407958984375,
0.0792236328125,
0.685546875,
-0.2069091796875,
0.2020263671875,
0.64453125,
-0.2264404296875,
-0.302978515625,
0.1561279296875,
0.06494140625,
0.08441162109375,
0.035003662109375,
-0.06396484375,
0.17138671875,
0.474365234375,
-1.1826171875,
0.05291748046875,
-0.64111328125,
0.45703125,
0.294189453125,
0.442138671875,
0.1265869140625,
-0.494384765625,
-0.57861328125,
-1.0283203125,
0.32568359375,
0.70849609375,
0.2900390625,
-0.42529296875,
1.029296875,
0.41650390625,
-0.587890625,
0.2288818359375,
-0.7451171875,
0.15966796875,
0.75,
-0.28369140625,
0.76513671875,
-1.267578125,
0.51416015625,
-0.005794525146484375,
-0.431884765625,
0.202880859375,
0.2186279296875,
0.66650390625,
-0.271484375,
-0.134765625,
0.08062744140625,
-0.447509765625,
0.1905517578125,
-0.2978515625,
0.3525390625,
-0.2357177734375,
-1.0048828125,
-0.96728515625,
0.9306640625,
0.82470703125,
0.43603515625,
0.278076171875,
0.685546875,
0.419921875,
0.364990234375,
0.51611328125,
0.055450439453125,
-0.11181640625,
-0.52587890625,
1.052734375,
0.27685546875,
-0.38720703125,
-0.728515625,
-0.3955078125,
-0.0016956329345703125,
0.5,
0.1331787109375,
0.37890625,
-0.908203125,
0.04766845703125,
0.45068359375,
0.83447265625,
-0.9619140625,
-0.057586669921875,
-0.03192138671875,
0.40966796875,
0.146240234375,
-0.802734375,
0.271728515625,
-0.7744140625,
0.5673828125,
0.470703125,
0.2059326171875,
-0.384033203125,
-0.2156982421875,
-0.8515625,
-0.342529296875,
0.51806640625,
0.359619140625,
-0.27490234375,
0.55517578125,
-1.021484375,
1.2041015625,
0.2880859375,
-0.1712646484375,
0.0787353515625,
-0.1590576171875,
0.6181640625,
0.2159423828125,
0.65966796875,
-0.48193359375,
-0.57421875,
0.30224609375,
-1.0478515625,
0.225830078125,
-0.26904296875,
0.40771484375,
-0.1629638671875,
-0.003078460693359375,
-0.027587890625,
0.12469482421875,
-0.544921875,
0.2078857421875,
-0.07244873046875,
0.302001953125,
-1.1962890625,
-0.99755859375,
0.34326171875,
-0.1712646484375,
-0.2056884765625,
0.56884765625,
-0.047943115234375,
-0.272216796875,
-0.1279296875,
0.23583984375,
-0.6572265625,
0.45556640625,
-0.60986328125,
0.268798828125,
-0.326416015625,
-0.26513671875,
0.0841064453125,
-0.366943359375,
0.67333984375,
-0.2607421875,
-0.59814453125,
-0.39111328125,
-1.1982421875,
-0.244140625,
-0.108154296875,
-0.70263671875,
-0.03363037109375,
0.465576171875,
-0.452880859375,
-0.1719970703125,
-0.386474609375,
-0.1209716796875,
-0.3408203125,
-0.376220703125,
-0.323486328125,
0.73583984375,
0.88037109375,
0.82177734375,
0.025634765625,
0.1348876953125,
-0.2529296875,
-0.0830078125,
-0.20458984375,
-0.82666015625,
0.31298828125,
0.240478515625,
-0.365478515625,
0.01036834716796875,
0.321044921875,
-0.025848388671875,
0.373291015625,
1.265625,
-0.192138671875,
0.246826171875,
0.06317138671875,
-0.6240234375,
0.86181640625,
-0.0745849609375,
-1.26953125,
-0.4462890625,
0.67236328125,
-0.1912841796875,
0.58544921875,
0.27783203125,
-0.9970703125,
-1.11328125,
-0.82373046875,
0.484375,
-0.7177734375,
-0.10601806640625,
-0.986328125,
-0.31005859375,
-0.2958984375,
0.61962890625,
-0.1968994140625,
-0.30859375,
0.04150390625,
-1.12890625,
0.08990478515625,
-0.373046875,
-0.658203125,
-0.94775390625,
-0.5244140625,
-0.34228515625,
0.79150390625,
0.28515625,
-0.115234375,
0.032073974609375,
0.1728515625,
0.07861328125,
-0.082763671875,
-0.84375,
-0.2384033203125,
-0.40478515625,
0.22314453125,
-0.1116943359375,
-0.4423828125,
-0.78515625,
0.8056640625,
-0.384033203125,
0.287109375,
0.06396484375,
-0.6064453125,
-0.1622314453125,
-0.303955078125,
1.087890625,
-0.456298828125,
0.1572265625,
-0.6767578125,
0.7705078125,
0.55224609375,
-0.6005859375,
-0.25146484375,
-0.7177734375,
-0.58251953125,
-1.416015625,
0.6318359375,
-0.455322265625,
0.357421875,
-0.56787109375,
-0.43603515625,
1.0546875,
-0.42236328125,
0.433837890625,
0.9248046875,
-0.1287841796875,
-0.120361328125,
-0.91162109375,
0.771484375,
0.454345703125,
-0.457275390625,
-0.1607666015625,
-0.339111328125,
-0.85205078125,
0.18603515625,
-0.27880859375,
-0.92626953125,
-0.626953125,
0.6591796875,
1.5126953125,
-0.2568359375,
0.388671875,
0.24560546875,
-0.76123046875,
-0.57763671875,
0.56640625,
0.1436767578125,
0.012176513671875,
0.65478515625,
-0.2203369140625,
0.0628662109375,
0.14794921875,
0.000013947486877441406,
-0.311767578125,
-0.468505859375,
1.2138671875,
-0.2568359375,
-0.5615234375,
1.1279296875,
0.943359375,
-0.8935546875,
-0.59228515625,
-0.143798828125,
0.1077880859375,
-0.13623046875,
-0.701171875,
0.034454345703125,
0.6640625,
-0.96728515625,
-0.115234375,
0.32177734375,
-0.0027618408203125,
0.464111328125,
0.4423828125,
0.405029296875,
-0.252197265625,
0.349609375,
0.48486328125,
-0.71826171875,
-0.33056640625,
-1.1337890625,
0.451904296875,
-0.006114959716796875,
0.50341796875,
0.388427734375,
-0.47998046875,
0.30078125,
0.26171875,
-0.07562255859375,
1.0126953125,
-0.299560546875,
-0.302490234375,
0.03814697265625,
-0.91552734375,
-0.7421875,
0.1962890625,
0.45263671875,
-0.328857421875,
0.10333251953125,
-0.6552734375,
0.10736083984375,
0.1060791015625,
0.27490234375,
-0.0078125,
-0.6904296875,
0.1317138671875,
-0.67578125,
-0.37451171875,
-0.96875,
-0.72705078125,
0.039886474609375,
0.1229248046875,
-0.6318359375,
-0.5791015625,
0.52001953125,
0.443603515625,
-0.7236328125,
1.2607421875,
-0.7666015625,
0.460693359375,
-0.99267578125,
-0.047882080078125,
-0.7529296875,
-0.2158203125,
-0.252685546875,
-0.26220703125,
-0.219970703125,
0.2010498046875,
0.0791015625,
0.364501953125,
0.197509765625,
0.6904296875,
-0.6064453125,
-0.32470703125,
0.0165252685546875,
0.206298828125,
-0.50927734375,
0.802734375,
0.55322265625,
0.22265625,
0.19873046875,
-0.12939453125,
-0.8662109375,
0.15966796875,
0.1915283203125,
0.8193359375,
0.24951171875,
0.2138671875,
-0.51123046875,
-0.07647705078125,
-0.77734375,
0.11834716796875,
-0.2509765625,
0.20166015625,
0.318115234375,
-0.6376953125,
0.4033203125,
1.2646484375,
-0.225341796875,
0.003246307373046875,
0.172607421875,
0.29345703125,
0.27685546875,
0.407470703125,
-0.186279296875,
0.3955078125,
0.55712890625,
-0.321533203125,
-0.58837890625,
0.5126953125,
-0.070556640625,
0.1480712890625,
-0.49462890625,
-0.66650390625,
-0.91162109375,
0.0202484130859375,
0.09521484375,
0.0170440673828125,
0.7216796875,
-0.62109375,
0.1541748046875,
0.02764892578125,
-0.229248046875,
0.331787109375,
-0.92919921875,
-0.67041015625,
0.2393798828125,
-0.121826171875,
-0.70263671875,
-0.13623046875,
-0.411376953125,
-0.1834716796875,
0.27587890625,
0.148193359375,
-0.416259765625,
0.45361328125,
-0.2900390625,
0.333251953125,
-0.53857421875,
0.10186767578125,
0.176025390625,
0.424560546875,
-0.270263671875,
-0.10687255859375,
0.1380615234375,
1.203125,
-0.1385498046875,
0.216796875,
-0.8134765625,
-0.0545654296875,
-0.23388671875,
0.275146484375,
-0.6181640625,
0.2191162109375,
-0.270263671875,
0.50341796875,
-1.0283203125,
-0.363037109375,
0.2264404296875,
0.305908203125,
0.391845703125,
-0.45458984375,
-0.69482421875,
1.123046875,
0.73388671875,
0.06536865234375,
0.53466796875,
0.354248046875,
0.5986328125,
-0.283447265625,
-0.0325927734375,
-0.420166015625,
0.334228515625,
0.5029296875,
0.370849609375,
-0.53076171875,
0.62451171875,
0.6484375,
-0.10357666015625,
-0.0579833984375,
0.33642578125,
-0.12060546875,
0.1683349609375,
0.1656494140625,
-0.08984375,
-0.1207275390625,
0.1217041015625,
-0.6044921875,
0.51806640625,
-0.1851806640625,
-0.1591796875,
-0.681640625,
-0.80126953125,
0.67724609375,
-0.281982421875,
-0.248291015625,
-0.10595703125,
-0.25,
0.33447265625,
0.77490234375,
0.01548004150390625,
-0.057586669921875,
0.69580078125,
0.8310546875,
0.252685546875,
1.0009765625,
0.446533203125,
0.1324462890625,
-0.26123046875,
0.444091796875,
0.345703125,
0.07318115234375,
0.0290069580078125,
-0.256103515625,
-0.94873046875,
0.73388671875,
-0.03948974609375,
-0.548828125,
0.52978515625,
-0.69482421875,
0.242431640625,
-0.28564453125,
0.42626953125,
-0.68212890625,
0.354736328125,
0.340087890625,
-0.389404296875,
-0.412109375,
0.8349609375,
-0.187744140625,
0.5380859375,
0.06463623046875,
0.8720703125,
-0.03607177734375,
1.705078125,
0.72265625,
-0.05963134765625,
0.490234375,
0.431396484375,
-0.36279296875,
-0.4853515625,
-0.2449951171875,
-0.56494140625,
-0.51806640625,
-0.39306640625,
-0.365234375,
0.0162200927734375,
0.93115234375,
0.1390380859375,
-0.861328125,
-0.4619140625,
-0.00620269775390625,
-0.283447265625,
0.364013671875,
0.529296875,
0.171630859375,
-0.10638427734375,
0.10223388671875,
-0.29052734375,
-0.46875,
0.06805419921875,
-0.52783203125,
0.38525390625,
-0.70947265625,
-0.71923828125,
-1.0986328125,
-0.99169921875,
-0.19677734375,
0.2880859375,
-0.4521484375,
-0.72802734375,
0.5908203125,
0.473876953125,
0.4853515625,
0.053375244140625,
-0.105224609375,
0.032135009765625,
0.66259765625,
0.83642578125,
-0.0189208984375,
0.496337890625,
0.353759765625,
-0.05853271484375,
0.138916015625,
-0.66455078125,
0.61962890625,
0.1302490234375,
0.08087158203125,
-0.3525390625,
0.2159423828125,
-0.91064453125,
-1.5126953125,
-0.2174072265625,
0.10595703125,
0.163330078125,
-0.828125,
-1.1669921875,
-0.395263671875,
-0.73681640625,
-0.1656494140625,
-0.11785888671875,
0.796875,
-0.0166473388671875,
0.01296234130859375,
-0.272705078125,
-1.041015625,
4.359375,
1.4033203125,
1.021484375,
-0.0192718505859375,
0.5341796875,
1.26171875,
0.4326171875,
-0.89697265625,
-0.4208984375,
-0.1259765625,
0.373291015625,
-0.350830078125,
-0.2110595703125,
0.53955078125,
0.0948486328125,
0.499755859375,
-0.68701171875,
-0.006351470947265625,
-0.317138671875,
-0.76220703125,
-0.84228515625,
0.1541748046875,
-0.1436767578125,
0.21533203125,
0.1531982421875,
0.423095703125,
0.76318359375,
-0.66064453125,
0.12298583984375,
-0.6103515625,
-0.2005615234375,
-0.287841796875,
0.9541015625,
0.2467041015625,
-0.14111328125,
0.4794921875,
-0.01551055908203125,
-0.7275390625,
0.00786590576171875,
0.21240234375,
-0.5087890625,
-0.164794921875,
1.107421875,
-0.4365234375,
0.108642578125,
0.228759765625,
-0.57177734375,
0.378662109375,
0.184326171875,
-0.68798828125,
1.01171875,
-0.1533203125,
0.49658203125,
-0.80712890625,
-0.2939453125,
0.2626953125,
0.52392578125,
0.035919189453125,
-0.0445556640625,
0.318359375,
0.474853515625,
0.07318115234375,
0.465087890625,
0.4912109375,
-0.69287109375,
0.91015625,
-0.472412109375,
0.2431640625,
-0.80126953125,
-0.05584716796875,
-0.1575927734375,
-0.08001708984375,
-0.5458984375,
-0.39453125,
0.92138671875,
0.257568359375,
-0.09033203125,
0.2457275390625,
0.197021484375,
-0.77685546875,
0.1968994140625,
-0.1688232421875,
-0.0867919921875,
0.034912109375,
0.230712890625,
1.5068359375,
-0.323974609375,
-0.07861328125,
-0.25732421875,
0.666015625,
0.492431640625,
0.441650390625,
-0.181640625,
-0.69775390625,
-0.370849609375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Tags: implementation, strings
Correct Solution:
```
n=int(input())
l=list(input())
a=[""]*n
if n%2!=0:
k=1
mid=n//2
a[mid]=l[0]
for i in range(1,n):
if i%2!=0:
a[mid-k]=l[i]
else:
a[mid+k]=l[i]
k+=1
print("".join(a))
else:
k=0
t=1
mid=(n//2)-1
for i in range(0,n):
if i%2==0:
a[mid-k]=l[i]
k+=1
else:
a[mid+t]=l[i]
t+=1
print("".join(a))
```
| 72,170 | [
0.61865234375,
-0.290771484375,
0.251708984375,
0.384765625,
-0.54052734375,
-0.62548828125,
0.1298828125,
-0.0924072265625,
-0.399658203125,
0.7626953125,
0.9833984375,
-0.2122802734375,
-0.045806884765625,
-0.63720703125,
-0.9208984375,
-0.54443359375,
-0.3759765625,
-0.54296875,
-0.7021484375,
0.1636962890625,
0.2398681640625,
0.03802490234375,
-1.1875,
-0.1519775390625,
-0.3759765625,
1.12890625,
0.61376953125,
-0.2332763671875,
1.2353515625,
0.97314453125,
0.0190277099609375,
0.07330322265625,
0.75634765625,
-1.1962890625,
-0.330322265625,
-0.2467041015625,
0.69189453125,
-0.34716796875,
-0.28125,
-0.375244140625,
0.26171875,
-0.347900390625,
0.4130859375,
-0.6376953125,
-0.86669921875,
-0.07098388671875,
-0.284912109375,
-0.8935546875,
-0.370849609375,
-0.91650390625,
0.129638671875,
-0.360107421875,
0.57421875,
-0.283935546875,
-0.17919921875,
-0.2841796875,
-0.1402587890625,
-0.006084442138671875,
-0.34423828125,
0.325439453125,
0.376220703125,
0.40869140625,
0.1448974609375,
-1.03125,
-0.30859375,
-0.32763671875,
-0.0987548828125,
-0.12109375,
0.010009765625,
-0.6982421875,
-0.164306640625,
0.4912109375,
-0.173095703125,
-0.693359375,
-0.346923828125,
0.10955810546875,
0.2880859375,
0.21240234375,
-0.75341796875,
0.94189453125,
0.1226806640625,
0.87353515625,
0.66259765625,
0.4287109375,
-0.51708984375,
-0.235107421875,
0.0594482421875,
0.368408203125,
0.100830078125,
-0.005970001220703125,
0.06585693359375,
0.51171875,
-0.263427734375,
0.189208984375,
0.494384765625,
0.60302734375,
0.010528564453125,
0.333251953125,
0.033447265625,
0.61083984375,
0.791015625,
1.3896484375,
-0.279296875,
1.0791015625,
-0.436767578125,
0.57958984375,
0.1746826171875,
0.274169921875,
-0.330810546875,
0.11328125,
-0.470458984375,
-0.1163330078125,
0.0014638900756835938,
-0.340087890625,
-0.218017578125,
0.97607421875,
-0.1153564453125,
0.210693359375,
-0.91259765625,
0.419921875,
0.3466796875,
0.266845703125,
0.427734375,
-0.336181640625,
0.2371826171875,
-0.38232421875,
-0.6572265625,
1.0947265625,
-0.472900390625,
-0.427001953125,
0.1854248046875,
0.3369140625,
-0.366943359375,
0.1915283203125,
0.326171875,
0.71484375,
0.1455078125,
0.45654296875,
0.81298828125,
-0.278564453125,
0.317138671875,
0.1837158203125,
-0.33740234375,
1.4521484375,
-0.150390625,
-0.2763671875,
0.451416015625,
0.28955078125,
-0.859375,
0.615234375,
-0.79052734375,
0.41943359375,
-0.1746826171875,
0.297607421875,
-0.302490234375,
0.05035400390625,
-0.267578125,
0.67138671875,
-0.0272064208984375,
0.075439453125,
-0.366455078125,
-0.235595703125,
-0.360595703125,
0.86669921875,
-0.6201171875,
1.33203125,
-0.96435546875,
-0.6259765625,
-0.47900390625,
-0.2479248046875,
0.42529296875,
-0.11395263671875,
-0.092041015625,
0.6826171875,
0.39990234375,
0.845703125,
0.671875,
-0.41162109375,
0.3642578125,
0.0731201171875,
0.1085205078125,
0.294189453125,
0.309326171875,
0.69189453125,
0.1771240234375,
-0.026824951171875,
0.1103515625,
-0.498046875,
-0.67822265625,
-0.3056640625,
-0.144287109375,
0.82080078125,
-0.354248046875,
-0.1839599609375,
-0.34130859375,
-0.322998046875,
-0.7314453125,
-0.376708984375,
-0.070068359375,
-1.017578125,
-0.2958984375,
0.8369140625,
-0.2841796875,
0.52490234375,
-0.448486328125,
-0.63818359375,
0.332763671875,
1.173828125,
-0.233154296875,
-0.264892578125,
0.986328125,
0.25146484375,
-0.46728515625,
0.329833984375,
0.171142578125,
0.1641845703125,
-0.8046875,
0.6806640625,
-0.46630859375,
0.07659912109375,
-0.2232666015625,
0.78662109375,
0.218017578125,
0.4013671875,
-0.50830078125,
0.0963134765625,
0.84033203125,
1.025390625,
0.005054473876953125,
0.299560546875,
0.29638671875,
0.44677734375,
0.2349853515625,
0.67431640625,
0.75,
0.4091796875,
0.5966796875,
0.82666015625,
-0.1771240234375,
0.2286376953125,
-0.045684814453125,
0.390869140625,
0.84228515625,
0.049468994140625,
0.1209716796875,
0.5302734375,
-0.496337890625,
-0.119140625,
-0.439453125,
0.1043701171875,
-0.365966796875,
0.018585205078125,
0.2666015625,
0.15869140625,
-0.44384765625,
-0.381103515625,
0.434814453125,
0.6904296875,
-0.64697265625,
-0.54833984375,
0.2191162109375,
0.2491455078125,
0.5322265625,
0.43603515625,
0.418701171875,
0.75537109375,
0.6904296875,
0.46533203125,
-0.25537109375,
-0.63037109375,
-0.6611328125,
-1.44921875,
-1.0380859375,
-0.25390625,
-0.80810546875,
0.0797119140625,
0.032562255859375,
-1.07421875,
-0.1473388671875,
-0.328857421875,
-0.60595703125,
-0.398193359375,
-0.365966796875,
0.56884765625,
-0.117431640625,
0.66064453125,
-0.444580078125,
0.51953125,
0.0821533203125,
1.162109375,
-0.5419921875,
-0.1964111328125,
-0.288330078125,
-0.54541015625,
0.300537109375,
-0.126220703125,
0.525390625,
-0.410888671875,
-0.85498046875,
-0.591796875,
-0.70361328125,
0.11895751953125,
-0.457275390625,
0.035369873046875,
-0.41845703125,
0.91259765625,
0.359130859375,
-0.568359375,
0.326171875,
0.96826171875,
-0.85595703125,
0.367919921875,
0.2939453125,
-0.265380859375,
-0.76513671875,
1.4609375,
0.4150390625,
0.51611328125,
-0.4140625,
-0.1650390625,
-0.12078857421875,
0.201904296875,
-0.06671142578125,
-0.453857421875,
-0.37548828125,
0.630859375,
0.05157470703125,
-1.37109375,
0.1153564453125,
-1.05859375,
-0.74462890625,
-0.357421875,
-0.57470703125,
0.79248046875,
0.96728515625,
0.490478515625,
-0.284423828125,
0.0635986328125,
0.10748291015625,
0.408203125,
0.22119140625,
-0.407958984375,
0.0792236328125,
0.685546875,
-0.2069091796875,
0.2020263671875,
0.64453125,
-0.2264404296875,
-0.302978515625,
0.1561279296875,
0.06494140625,
0.08441162109375,
0.035003662109375,
-0.06396484375,
0.17138671875,
0.474365234375,
-1.1826171875,
0.05291748046875,
-0.64111328125,
0.45703125,
0.294189453125,
0.442138671875,
0.1265869140625,
-0.494384765625,
-0.57861328125,
-1.0283203125,
0.32568359375,
0.70849609375,
0.2900390625,
-0.42529296875,
1.029296875,
0.41650390625,
-0.587890625,
0.2288818359375,
-0.7451171875,
0.15966796875,
0.75,
-0.28369140625,
0.76513671875,
-1.267578125,
0.51416015625,
-0.005794525146484375,
-0.431884765625,
0.202880859375,
0.2186279296875,
0.66650390625,
-0.271484375,
-0.134765625,
0.08062744140625,
-0.447509765625,
0.1905517578125,
-0.2978515625,
0.3525390625,
-0.2357177734375,
-1.0048828125,
-0.96728515625,
0.9306640625,
0.82470703125,
0.43603515625,
0.278076171875,
0.685546875,
0.419921875,
0.364990234375,
0.51611328125,
0.055450439453125,
-0.11181640625,
-0.52587890625,
1.052734375,
0.27685546875,
-0.38720703125,
-0.728515625,
-0.3955078125,
-0.0016956329345703125,
0.5,
0.1331787109375,
0.37890625,
-0.908203125,
0.04766845703125,
0.45068359375,
0.83447265625,
-0.9619140625,
-0.057586669921875,
-0.03192138671875,
0.40966796875,
0.146240234375,
-0.802734375,
0.271728515625,
-0.7744140625,
0.5673828125,
0.470703125,
0.2059326171875,
-0.384033203125,
-0.2156982421875,
-0.8515625,
-0.342529296875,
0.51806640625,
0.359619140625,
-0.27490234375,
0.55517578125,
-1.021484375,
1.2041015625,
0.2880859375,
-0.1712646484375,
0.0787353515625,
-0.1590576171875,
0.6181640625,
0.2159423828125,
0.65966796875,
-0.48193359375,
-0.57421875,
0.30224609375,
-1.0478515625,
0.225830078125,
-0.26904296875,
0.40771484375,
-0.1629638671875,
-0.003078460693359375,
-0.027587890625,
0.12469482421875,
-0.544921875,
0.2078857421875,
-0.07244873046875,
0.302001953125,
-1.1962890625,
-0.99755859375,
0.34326171875,
-0.1712646484375,
-0.2056884765625,
0.56884765625,
-0.047943115234375,
-0.272216796875,
-0.1279296875,
0.23583984375,
-0.6572265625,
0.45556640625,
-0.60986328125,
0.268798828125,
-0.326416015625,
-0.26513671875,
0.0841064453125,
-0.366943359375,
0.67333984375,
-0.2607421875,
-0.59814453125,
-0.39111328125,
-1.1982421875,
-0.244140625,
-0.108154296875,
-0.70263671875,
-0.03363037109375,
0.465576171875,
-0.452880859375,
-0.1719970703125,
-0.386474609375,
-0.1209716796875,
-0.3408203125,
-0.376220703125,
-0.323486328125,
0.73583984375,
0.88037109375,
0.82177734375,
0.025634765625,
0.1348876953125,
-0.2529296875,
-0.0830078125,
-0.20458984375,
-0.82666015625,
0.31298828125,
0.240478515625,
-0.365478515625,
0.01036834716796875,
0.321044921875,
-0.025848388671875,
0.373291015625,
1.265625,
-0.192138671875,
0.246826171875,
0.06317138671875,
-0.6240234375,
0.86181640625,
-0.0745849609375,
-1.26953125,
-0.4462890625,
0.67236328125,
-0.1912841796875,
0.58544921875,
0.27783203125,
-0.9970703125,
-1.11328125,
-0.82373046875,
0.484375,
-0.7177734375,
-0.10601806640625,
-0.986328125,
-0.31005859375,
-0.2958984375,
0.61962890625,
-0.1968994140625,
-0.30859375,
0.04150390625,
-1.12890625,
0.08990478515625,
-0.373046875,
-0.658203125,
-0.94775390625,
-0.5244140625,
-0.34228515625,
0.79150390625,
0.28515625,
-0.115234375,
0.032073974609375,
0.1728515625,
0.07861328125,
-0.082763671875,
-0.84375,
-0.2384033203125,
-0.40478515625,
0.22314453125,
-0.1116943359375,
-0.4423828125,
-0.78515625,
0.8056640625,
-0.384033203125,
0.287109375,
0.06396484375,
-0.6064453125,
-0.1622314453125,
-0.303955078125,
1.087890625,
-0.456298828125,
0.1572265625,
-0.6767578125,
0.7705078125,
0.55224609375,
-0.6005859375,
-0.25146484375,
-0.7177734375,
-0.58251953125,
-1.416015625,
0.6318359375,
-0.455322265625,
0.357421875,
-0.56787109375,
-0.43603515625,
1.0546875,
-0.42236328125,
0.433837890625,
0.9248046875,
-0.1287841796875,
-0.120361328125,
-0.91162109375,
0.771484375,
0.454345703125,
-0.457275390625,
-0.1607666015625,
-0.339111328125,
-0.85205078125,
0.18603515625,
-0.27880859375,
-0.92626953125,
-0.626953125,
0.6591796875,
1.5126953125,
-0.2568359375,
0.388671875,
0.24560546875,
-0.76123046875,
-0.57763671875,
0.56640625,
0.1436767578125,
0.012176513671875,
0.65478515625,
-0.2203369140625,
0.0628662109375,
0.14794921875,
0.000013947486877441406,
-0.311767578125,
-0.468505859375,
1.2138671875,
-0.2568359375,
-0.5615234375,
1.1279296875,
0.943359375,
-0.8935546875,
-0.59228515625,
-0.143798828125,
0.1077880859375,
-0.13623046875,
-0.701171875,
0.034454345703125,
0.6640625,
-0.96728515625,
-0.115234375,
0.32177734375,
-0.0027618408203125,
0.464111328125,
0.4423828125,
0.405029296875,
-0.252197265625,
0.349609375,
0.48486328125,
-0.71826171875,
-0.33056640625,
-1.1337890625,
0.451904296875,
-0.006114959716796875,
0.50341796875,
0.388427734375,
-0.47998046875,
0.30078125,
0.26171875,
-0.07562255859375,
1.0126953125,
-0.299560546875,
-0.302490234375,
0.03814697265625,
-0.91552734375,
-0.7421875,
0.1962890625,
0.45263671875,
-0.328857421875,
0.10333251953125,
-0.6552734375,
0.10736083984375,
0.1060791015625,
0.27490234375,
-0.0078125,
-0.6904296875,
0.1317138671875,
-0.67578125,
-0.37451171875,
-0.96875,
-0.72705078125,
0.039886474609375,
0.1229248046875,
-0.6318359375,
-0.5791015625,
0.52001953125,
0.443603515625,
-0.7236328125,
1.2607421875,
-0.7666015625,
0.460693359375,
-0.99267578125,
-0.047882080078125,
-0.7529296875,
-0.2158203125,
-0.252685546875,
-0.26220703125,
-0.219970703125,
0.2010498046875,
0.0791015625,
0.364501953125,
0.197509765625,
0.6904296875,
-0.6064453125,
-0.32470703125,
0.0165252685546875,
0.206298828125,
-0.50927734375,
0.802734375,
0.55322265625,
0.22265625,
0.19873046875,
-0.12939453125,
-0.8662109375,
0.15966796875,
0.1915283203125,
0.8193359375,
0.24951171875,
0.2138671875,
-0.51123046875,
-0.07647705078125,
-0.77734375,
0.11834716796875,
-0.2509765625,
0.20166015625,
0.318115234375,
-0.6376953125,
0.4033203125,
1.2646484375,
-0.225341796875,
0.003246307373046875,
0.172607421875,
0.29345703125,
0.27685546875,
0.407470703125,
-0.186279296875,
0.3955078125,
0.55712890625,
-0.321533203125,
-0.58837890625,
0.5126953125,
-0.070556640625,
0.1480712890625,
-0.49462890625,
-0.66650390625,
-0.91162109375,
0.0202484130859375,
0.09521484375,
0.0170440673828125,
0.7216796875,
-0.62109375,
0.1541748046875,
0.02764892578125,
-0.229248046875,
0.331787109375,
-0.92919921875,
-0.67041015625,
0.2393798828125,
-0.121826171875,
-0.70263671875,
-0.13623046875,
-0.411376953125,
-0.1834716796875,
0.27587890625,
0.148193359375,
-0.416259765625,
0.45361328125,
-0.2900390625,
0.333251953125,
-0.53857421875,
0.10186767578125,
0.176025390625,
0.424560546875,
-0.270263671875,
-0.10687255859375,
0.1380615234375,
1.203125,
-0.1385498046875,
0.216796875,
-0.8134765625,
-0.0545654296875,
-0.23388671875,
0.275146484375,
-0.6181640625,
0.2191162109375,
-0.270263671875,
0.50341796875,
-1.0283203125,
-0.363037109375,
0.2264404296875,
0.305908203125,
0.391845703125,
-0.45458984375,
-0.69482421875,
1.123046875,
0.73388671875,
0.06536865234375,
0.53466796875,
0.354248046875,
0.5986328125,
-0.283447265625,
-0.0325927734375,
-0.420166015625,
0.334228515625,
0.5029296875,
0.370849609375,
-0.53076171875,
0.62451171875,
0.6484375,
-0.10357666015625,
-0.0579833984375,
0.33642578125,
-0.12060546875,
0.1683349609375,
0.1656494140625,
-0.08984375,
-0.1207275390625,
0.1217041015625,
-0.6044921875,
0.51806640625,
-0.1851806640625,
-0.1591796875,
-0.681640625,
-0.80126953125,
0.67724609375,
-0.281982421875,
-0.248291015625,
-0.10595703125,
-0.25,
0.33447265625,
0.77490234375,
0.01548004150390625,
-0.057586669921875,
0.69580078125,
0.8310546875,
0.252685546875,
1.0009765625,
0.446533203125,
0.1324462890625,
-0.26123046875,
0.444091796875,
0.345703125,
0.07318115234375,
0.0290069580078125,
-0.256103515625,
-0.94873046875,
0.73388671875,
-0.03948974609375,
-0.548828125,
0.52978515625,
-0.69482421875,
0.242431640625,
-0.28564453125,
0.42626953125,
-0.68212890625,
0.354736328125,
0.340087890625,
-0.389404296875,
-0.412109375,
0.8349609375,
-0.187744140625,
0.5380859375,
0.06463623046875,
0.8720703125,
-0.03607177734375,
1.705078125,
0.72265625,
-0.05963134765625,
0.490234375,
0.431396484375,
-0.36279296875,
-0.4853515625,
-0.2449951171875,
-0.56494140625,
-0.51806640625,
-0.39306640625,
-0.365234375,
0.0162200927734375,
0.93115234375,
0.1390380859375,
-0.861328125,
-0.4619140625,
-0.00620269775390625,
-0.283447265625,
0.364013671875,
0.529296875,
0.171630859375,
-0.10638427734375,
0.10223388671875,
-0.29052734375,
-0.46875,
0.06805419921875,
-0.52783203125,
0.38525390625,
-0.70947265625,
-0.71923828125,
-1.0986328125,
-0.99169921875,
-0.19677734375,
0.2880859375,
-0.4521484375,
-0.72802734375,
0.5908203125,
0.473876953125,
0.4853515625,
0.053375244140625,
-0.105224609375,
0.032135009765625,
0.66259765625,
0.83642578125,
-0.0189208984375,
0.496337890625,
0.353759765625,
-0.05853271484375,
0.138916015625,
-0.66455078125,
0.61962890625,
0.1302490234375,
0.08087158203125,
-0.3525390625,
0.2159423828125,
-0.91064453125,
-1.5126953125,
-0.2174072265625,
0.10595703125,
0.163330078125,
-0.828125,
-1.1669921875,
-0.395263671875,
-0.73681640625,
-0.1656494140625,
-0.11785888671875,
0.796875,
-0.0166473388671875,
0.01296234130859375,
-0.272705078125,
-1.041015625,
4.359375,
1.4033203125,
1.021484375,
-0.0192718505859375,
0.5341796875,
1.26171875,
0.4326171875,
-0.89697265625,
-0.4208984375,
-0.1259765625,
0.373291015625,
-0.350830078125,
-0.2110595703125,
0.53955078125,
0.0948486328125,
0.499755859375,
-0.68701171875,
-0.006351470947265625,
-0.317138671875,
-0.76220703125,
-0.84228515625,
0.1541748046875,
-0.1436767578125,
0.21533203125,
0.1531982421875,
0.423095703125,
0.76318359375,
-0.66064453125,
0.12298583984375,
-0.6103515625,
-0.2005615234375,
-0.287841796875,
0.9541015625,
0.2467041015625,
-0.14111328125,
0.4794921875,
-0.01551055908203125,
-0.7275390625,
0.00786590576171875,
0.21240234375,
-0.5087890625,
-0.164794921875,
1.107421875,
-0.4365234375,
0.108642578125,
0.228759765625,
-0.57177734375,
0.378662109375,
0.184326171875,
-0.68798828125,
1.01171875,
-0.1533203125,
0.49658203125,
-0.80712890625,
-0.2939453125,
0.2626953125,
0.52392578125,
0.035919189453125,
-0.0445556640625,
0.318359375,
0.474853515625,
0.07318115234375,
0.465087890625,
0.4912109375,
-0.69287109375,
0.91015625,
-0.472412109375,
0.2431640625,
-0.80126953125,
-0.05584716796875,
-0.1575927734375,
-0.08001708984375,
-0.5458984375,
-0.39453125,
0.92138671875,
0.257568359375,
-0.09033203125,
0.2457275390625,
0.197021484375,
-0.77685546875,
0.1968994140625,
-0.1688232421875,
-0.0867919921875,
0.034912109375,
0.230712890625,
1.5068359375,
-0.323974609375,
-0.07861328125,
-0.25732421875,
0.666015625,
0.492431640625,
0.441650390625,
-0.181640625,
-0.69775390625,
-0.370849609375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Tags: implementation, strings
Correct Solution:
```
n = int(input())
s = input()
a = []
b = []
j = ''
j = s[0]
for i in range(1,n):
if i % 2 != 0:
q = s[i]
q += j
j = q
else:
j += s[i]
if n % 2 == 0:
j = j[::-1]
print(j)
```
| 72,171 | [
0.61865234375,
-0.290771484375,
0.251708984375,
0.384765625,
-0.54052734375,
-0.62548828125,
0.1298828125,
-0.0924072265625,
-0.399658203125,
0.7626953125,
0.9833984375,
-0.2122802734375,
-0.045806884765625,
-0.63720703125,
-0.9208984375,
-0.54443359375,
-0.3759765625,
-0.54296875,
-0.7021484375,
0.1636962890625,
0.2398681640625,
0.03802490234375,
-1.1875,
-0.1519775390625,
-0.3759765625,
1.12890625,
0.61376953125,
-0.2332763671875,
1.2353515625,
0.97314453125,
0.0190277099609375,
0.07330322265625,
0.75634765625,
-1.1962890625,
-0.330322265625,
-0.2467041015625,
0.69189453125,
-0.34716796875,
-0.28125,
-0.375244140625,
0.26171875,
-0.347900390625,
0.4130859375,
-0.6376953125,
-0.86669921875,
-0.07098388671875,
-0.284912109375,
-0.8935546875,
-0.370849609375,
-0.91650390625,
0.129638671875,
-0.360107421875,
0.57421875,
-0.283935546875,
-0.17919921875,
-0.2841796875,
-0.1402587890625,
-0.006084442138671875,
-0.34423828125,
0.325439453125,
0.376220703125,
0.40869140625,
0.1448974609375,
-1.03125,
-0.30859375,
-0.32763671875,
-0.0987548828125,
-0.12109375,
0.010009765625,
-0.6982421875,
-0.164306640625,
0.4912109375,
-0.173095703125,
-0.693359375,
-0.346923828125,
0.10955810546875,
0.2880859375,
0.21240234375,
-0.75341796875,
0.94189453125,
0.1226806640625,
0.87353515625,
0.66259765625,
0.4287109375,
-0.51708984375,
-0.235107421875,
0.0594482421875,
0.368408203125,
0.100830078125,
-0.005970001220703125,
0.06585693359375,
0.51171875,
-0.263427734375,
0.189208984375,
0.494384765625,
0.60302734375,
0.010528564453125,
0.333251953125,
0.033447265625,
0.61083984375,
0.791015625,
1.3896484375,
-0.279296875,
1.0791015625,
-0.436767578125,
0.57958984375,
0.1746826171875,
0.274169921875,
-0.330810546875,
0.11328125,
-0.470458984375,
-0.1163330078125,
0.0014638900756835938,
-0.340087890625,
-0.218017578125,
0.97607421875,
-0.1153564453125,
0.210693359375,
-0.91259765625,
0.419921875,
0.3466796875,
0.266845703125,
0.427734375,
-0.336181640625,
0.2371826171875,
-0.38232421875,
-0.6572265625,
1.0947265625,
-0.472900390625,
-0.427001953125,
0.1854248046875,
0.3369140625,
-0.366943359375,
0.1915283203125,
0.326171875,
0.71484375,
0.1455078125,
0.45654296875,
0.81298828125,
-0.278564453125,
0.317138671875,
0.1837158203125,
-0.33740234375,
1.4521484375,
-0.150390625,
-0.2763671875,
0.451416015625,
0.28955078125,
-0.859375,
0.615234375,
-0.79052734375,
0.41943359375,
-0.1746826171875,
0.297607421875,
-0.302490234375,
0.05035400390625,
-0.267578125,
0.67138671875,
-0.0272064208984375,
0.075439453125,
-0.366455078125,
-0.235595703125,
-0.360595703125,
0.86669921875,
-0.6201171875,
1.33203125,
-0.96435546875,
-0.6259765625,
-0.47900390625,
-0.2479248046875,
0.42529296875,
-0.11395263671875,
-0.092041015625,
0.6826171875,
0.39990234375,
0.845703125,
0.671875,
-0.41162109375,
0.3642578125,
0.0731201171875,
0.1085205078125,
0.294189453125,
0.309326171875,
0.69189453125,
0.1771240234375,
-0.026824951171875,
0.1103515625,
-0.498046875,
-0.67822265625,
-0.3056640625,
-0.144287109375,
0.82080078125,
-0.354248046875,
-0.1839599609375,
-0.34130859375,
-0.322998046875,
-0.7314453125,
-0.376708984375,
-0.070068359375,
-1.017578125,
-0.2958984375,
0.8369140625,
-0.2841796875,
0.52490234375,
-0.448486328125,
-0.63818359375,
0.332763671875,
1.173828125,
-0.233154296875,
-0.264892578125,
0.986328125,
0.25146484375,
-0.46728515625,
0.329833984375,
0.171142578125,
0.1641845703125,
-0.8046875,
0.6806640625,
-0.46630859375,
0.07659912109375,
-0.2232666015625,
0.78662109375,
0.218017578125,
0.4013671875,
-0.50830078125,
0.0963134765625,
0.84033203125,
1.025390625,
0.005054473876953125,
0.299560546875,
0.29638671875,
0.44677734375,
0.2349853515625,
0.67431640625,
0.75,
0.4091796875,
0.5966796875,
0.82666015625,
-0.1771240234375,
0.2286376953125,
-0.045684814453125,
0.390869140625,
0.84228515625,
0.049468994140625,
0.1209716796875,
0.5302734375,
-0.496337890625,
-0.119140625,
-0.439453125,
0.1043701171875,
-0.365966796875,
0.018585205078125,
0.2666015625,
0.15869140625,
-0.44384765625,
-0.381103515625,
0.434814453125,
0.6904296875,
-0.64697265625,
-0.54833984375,
0.2191162109375,
0.2491455078125,
0.5322265625,
0.43603515625,
0.418701171875,
0.75537109375,
0.6904296875,
0.46533203125,
-0.25537109375,
-0.63037109375,
-0.6611328125,
-1.44921875,
-1.0380859375,
-0.25390625,
-0.80810546875,
0.0797119140625,
0.032562255859375,
-1.07421875,
-0.1473388671875,
-0.328857421875,
-0.60595703125,
-0.398193359375,
-0.365966796875,
0.56884765625,
-0.117431640625,
0.66064453125,
-0.444580078125,
0.51953125,
0.0821533203125,
1.162109375,
-0.5419921875,
-0.1964111328125,
-0.288330078125,
-0.54541015625,
0.300537109375,
-0.126220703125,
0.525390625,
-0.410888671875,
-0.85498046875,
-0.591796875,
-0.70361328125,
0.11895751953125,
-0.457275390625,
0.035369873046875,
-0.41845703125,
0.91259765625,
0.359130859375,
-0.568359375,
0.326171875,
0.96826171875,
-0.85595703125,
0.367919921875,
0.2939453125,
-0.265380859375,
-0.76513671875,
1.4609375,
0.4150390625,
0.51611328125,
-0.4140625,
-0.1650390625,
-0.12078857421875,
0.201904296875,
-0.06671142578125,
-0.453857421875,
-0.37548828125,
0.630859375,
0.05157470703125,
-1.37109375,
0.1153564453125,
-1.05859375,
-0.74462890625,
-0.357421875,
-0.57470703125,
0.79248046875,
0.96728515625,
0.490478515625,
-0.284423828125,
0.0635986328125,
0.10748291015625,
0.408203125,
0.22119140625,
-0.407958984375,
0.0792236328125,
0.685546875,
-0.2069091796875,
0.2020263671875,
0.64453125,
-0.2264404296875,
-0.302978515625,
0.1561279296875,
0.06494140625,
0.08441162109375,
0.035003662109375,
-0.06396484375,
0.17138671875,
0.474365234375,
-1.1826171875,
0.05291748046875,
-0.64111328125,
0.45703125,
0.294189453125,
0.442138671875,
0.1265869140625,
-0.494384765625,
-0.57861328125,
-1.0283203125,
0.32568359375,
0.70849609375,
0.2900390625,
-0.42529296875,
1.029296875,
0.41650390625,
-0.587890625,
0.2288818359375,
-0.7451171875,
0.15966796875,
0.75,
-0.28369140625,
0.76513671875,
-1.267578125,
0.51416015625,
-0.005794525146484375,
-0.431884765625,
0.202880859375,
0.2186279296875,
0.66650390625,
-0.271484375,
-0.134765625,
0.08062744140625,
-0.447509765625,
0.1905517578125,
-0.2978515625,
0.3525390625,
-0.2357177734375,
-1.0048828125,
-0.96728515625,
0.9306640625,
0.82470703125,
0.43603515625,
0.278076171875,
0.685546875,
0.419921875,
0.364990234375,
0.51611328125,
0.055450439453125,
-0.11181640625,
-0.52587890625,
1.052734375,
0.27685546875,
-0.38720703125,
-0.728515625,
-0.3955078125,
-0.0016956329345703125,
0.5,
0.1331787109375,
0.37890625,
-0.908203125,
0.04766845703125,
0.45068359375,
0.83447265625,
-0.9619140625,
-0.057586669921875,
-0.03192138671875,
0.40966796875,
0.146240234375,
-0.802734375,
0.271728515625,
-0.7744140625,
0.5673828125,
0.470703125,
0.2059326171875,
-0.384033203125,
-0.2156982421875,
-0.8515625,
-0.342529296875,
0.51806640625,
0.359619140625,
-0.27490234375,
0.55517578125,
-1.021484375,
1.2041015625,
0.2880859375,
-0.1712646484375,
0.0787353515625,
-0.1590576171875,
0.6181640625,
0.2159423828125,
0.65966796875,
-0.48193359375,
-0.57421875,
0.30224609375,
-1.0478515625,
0.225830078125,
-0.26904296875,
0.40771484375,
-0.1629638671875,
-0.003078460693359375,
-0.027587890625,
0.12469482421875,
-0.544921875,
0.2078857421875,
-0.07244873046875,
0.302001953125,
-1.1962890625,
-0.99755859375,
0.34326171875,
-0.1712646484375,
-0.2056884765625,
0.56884765625,
-0.047943115234375,
-0.272216796875,
-0.1279296875,
0.23583984375,
-0.6572265625,
0.45556640625,
-0.60986328125,
0.268798828125,
-0.326416015625,
-0.26513671875,
0.0841064453125,
-0.366943359375,
0.67333984375,
-0.2607421875,
-0.59814453125,
-0.39111328125,
-1.1982421875,
-0.244140625,
-0.108154296875,
-0.70263671875,
-0.03363037109375,
0.465576171875,
-0.452880859375,
-0.1719970703125,
-0.386474609375,
-0.1209716796875,
-0.3408203125,
-0.376220703125,
-0.323486328125,
0.73583984375,
0.88037109375,
0.82177734375,
0.025634765625,
0.1348876953125,
-0.2529296875,
-0.0830078125,
-0.20458984375,
-0.82666015625,
0.31298828125,
0.240478515625,
-0.365478515625,
0.01036834716796875,
0.321044921875,
-0.025848388671875,
0.373291015625,
1.265625,
-0.192138671875,
0.246826171875,
0.06317138671875,
-0.6240234375,
0.86181640625,
-0.0745849609375,
-1.26953125,
-0.4462890625,
0.67236328125,
-0.1912841796875,
0.58544921875,
0.27783203125,
-0.9970703125,
-1.11328125,
-0.82373046875,
0.484375,
-0.7177734375,
-0.10601806640625,
-0.986328125,
-0.31005859375,
-0.2958984375,
0.61962890625,
-0.1968994140625,
-0.30859375,
0.04150390625,
-1.12890625,
0.08990478515625,
-0.373046875,
-0.658203125,
-0.94775390625,
-0.5244140625,
-0.34228515625,
0.79150390625,
0.28515625,
-0.115234375,
0.032073974609375,
0.1728515625,
0.07861328125,
-0.082763671875,
-0.84375,
-0.2384033203125,
-0.40478515625,
0.22314453125,
-0.1116943359375,
-0.4423828125,
-0.78515625,
0.8056640625,
-0.384033203125,
0.287109375,
0.06396484375,
-0.6064453125,
-0.1622314453125,
-0.303955078125,
1.087890625,
-0.456298828125,
0.1572265625,
-0.6767578125,
0.7705078125,
0.55224609375,
-0.6005859375,
-0.25146484375,
-0.7177734375,
-0.58251953125,
-1.416015625,
0.6318359375,
-0.455322265625,
0.357421875,
-0.56787109375,
-0.43603515625,
1.0546875,
-0.42236328125,
0.433837890625,
0.9248046875,
-0.1287841796875,
-0.120361328125,
-0.91162109375,
0.771484375,
0.454345703125,
-0.457275390625,
-0.1607666015625,
-0.339111328125,
-0.85205078125,
0.18603515625,
-0.27880859375,
-0.92626953125,
-0.626953125,
0.6591796875,
1.5126953125,
-0.2568359375,
0.388671875,
0.24560546875,
-0.76123046875,
-0.57763671875,
0.56640625,
0.1436767578125,
0.012176513671875,
0.65478515625,
-0.2203369140625,
0.0628662109375,
0.14794921875,
0.000013947486877441406,
-0.311767578125,
-0.468505859375,
1.2138671875,
-0.2568359375,
-0.5615234375,
1.1279296875,
0.943359375,
-0.8935546875,
-0.59228515625,
-0.143798828125,
0.1077880859375,
-0.13623046875,
-0.701171875,
0.034454345703125,
0.6640625,
-0.96728515625,
-0.115234375,
0.32177734375,
-0.0027618408203125,
0.464111328125,
0.4423828125,
0.405029296875,
-0.252197265625,
0.349609375,
0.48486328125,
-0.71826171875,
-0.33056640625,
-1.1337890625,
0.451904296875,
-0.006114959716796875,
0.50341796875,
0.388427734375,
-0.47998046875,
0.30078125,
0.26171875,
-0.07562255859375,
1.0126953125,
-0.299560546875,
-0.302490234375,
0.03814697265625,
-0.91552734375,
-0.7421875,
0.1962890625,
0.45263671875,
-0.328857421875,
0.10333251953125,
-0.6552734375,
0.10736083984375,
0.1060791015625,
0.27490234375,
-0.0078125,
-0.6904296875,
0.1317138671875,
-0.67578125,
-0.37451171875,
-0.96875,
-0.72705078125,
0.039886474609375,
0.1229248046875,
-0.6318359375,
-0.5791015625,
0.52001953125,
0.443603515625,
-0.7236328125,
1.2607421875,
-0.7666015625,
0.460693359375,
-0.99267578125,
-0.047882080078125,
-0.7529296875,
-0.2158203125,
-0.252685546875,
-0.26220703125,
-0.219970703125,
0.2010498046875,
0.0791015625,
0.364501953125,
0.197509765625,
0.6904296875,
-0.6064453125,
-0.32470703125,
0.0165252685546875,
0.206298828125,
-0.50927734375,
0.802734375,
0.55322265625,
0.22265625,
0.19873046875,
-0.12939453125,
-0.8662109375,
0.15966796875,
0.1915283203125,
0.8193359375,
0.24951171875,
0.2138671875,
-0.51123046875,
-0.07647705078125,
-0.77734375,
0.11834716796875,
-0.2509765625,
0.20166015625,
0.318115234375,
-0.6376953125,
0.4033203125,
1.2646484375,
-0.225341796875,
0.003246307373046875,
0.172607421875,
0.29345703125,
0.27685546875,
0.407470703125,
-0.186279296875,
0.3955078125,
0.55712890625,
-0.321533203125,
-0.58837890625,
0.5126953125,
-0.070556640625,
0.1480712890625,
-0.49462890625,
-0.66650390625,
-0.91162109375,
0.0202484130859375,
0.09521484375,
0.0170440673828125,
0.7216796875,
-0.62109375,
0.1541748046875,
0.02764892578125,
-0.229248046875,
0.331787109375,
-0.92919921875,
-0.67041015625,
0.2393798828125,
-0.121826171875,
-0.70263671875,
-0.13623046875,
-0.411376953125,
-0.1834716796875,
0.27587890625,
0.148193359375,
-0.416259765625,
0.45361328125,
-0.2900390625,
0.333251953125,
-0.53857421875,
0.10186767578125,
0.176025390625,
0.424560546875,
-0.270263671875,
-0.10687255859375,
0.1380615234375,
1.203125,
-0.1385498046875,
0.216796875,
-0.8134765625,
-0.0545654296875,
-0.23388671875,
0.275146484375,
-0.6181640625,
0.2191162109375,
-0.270263671875,
0.50341796875,
-1.0283203125,
-0.363037109375,
0.2264404296875,
0.305908203125,
0.391845703125,
-0.45458984375,
-0.69482421875,
1.123046875,
0.73388671875,
0.06536865234375,
0.53466796875,
0.354248046875,
0.5986328125,
-0.283447265625,
-0.0325927734375,
-0.420166015625,
0.334228515625,
0.5029296875,
0.370849609375,
-0.53076171875,
0.62451171875,
0.6484375,
-0.10357666015625,
-0.0579833984375,
0.33642578125,
-0.12060546875,
0.1683349609375,
0.1656494140625,
-0.08984375,
-0.1207275390625,
0.1217041015625,
-0.6044921875,
0.51806640625,
-0.1851806640625,
-0.1591796875,
-0.681640625,
-0.80126953125,
0.67724609375,
-0.281982421875,
-0.248291015625,
-0.10595703125,
-0.25,
0.33447265625,
0.77490234375,
0.01548004150390625,
-0.057586669921875,
0.69580078125,
0.8310546875,
0.252685546875,
1.0009765625,
0.446533203125,
0.1324462890625,
-0.26123046875,
0.444091796875,
0.345703125,
0.07318115234375,
0.0290069580078125,
-0.256103515625,
-0.94873046875,
0.73388671875,
-0.03948974609375,
-0.548828125,
0.52978515625,
-0.69482421875,
0.242431640625,
-0.28564453125,
0.42626953125,
-0.68212890625,
0.354736328125,
0.340087890625,
-0.389404296875,
-0.412109375,
0.8349609375,
-0.187744140625,
0.5380859375,
0.06463623046875,
0.8720703125,
-0.03607177734375,
1.705078125,
0.72265625,
-0.05963134765625,
0.490234375,
0.431396484375,
-0.36279296875,
-0.4853515625,
-0.2449951171875,
-0.56494140625,
-0.51806640625,
-0.39306640625,
-0.365234375,
0.0162200927734375,
0.93115234375,
0.1390380859375,
-0.861328125,
-0.4619140625,
-0.00620269775390625,
-0.283447265625,
0.364013671875,
0.529296875,
0.171630859375,
-0.10638427734375,
0.10223388671875,
-0.29052734375,
-0.46875,
0.06805419921875,
-0.52783203125,
0.38525390625,
-0.70947265625,
-0.71923828125,
-1.0986328125,
-0.99169921875,
-0.19677734375,
0.2880859375,
-0.4521484375,
-0.72802734375,
0.5908203125,
0.473876953125,
0.4853515625,
0.053375244140625,
-0.105224609375,
0.032135009765625,
0.66259765625,
0.83642578125,
-0.0189208984375,
0.496337890625,
0.353759765625,
-0.05853271484375,
0.138916015625,
-0.66455078125,
0.61962890625,
0.1302490234375,
0.08087158203125,
-0.3525390625,
0.2159423828125,
-0.91064453125,
-1.5126953125,
-0.2174072265625,
0.10595703125,
0.163330078125,
-0.828125,
-1.1669921875,
-0.395263671875,
-0.73681640625,
-0.1656494140625,
-0.11785888671875,
0.796875,
-0.0166473388671875,
0.01296234130859375,
-0.272705078125,
-1.041015625,
4.359375,
1.4033203125,
1.021484375,
-0.0192718505859375,
0.5341796875,
1.26171875,
0.4326171875,
-0.89697265625,
-0.4208984375,
-0.1259765625,
0.373291015625,
-0.350830078125,
-0.2110595703125,
0.53955078125,
0.0948486328125,
0.499755859375,
-0.68701171875,
-0.006351470947265625,
-0.317138671875,
-0.76220703125,
-0.84228515625,
0.1541748046875,
-0.1436767578125,
0.21533203125,
0.1531982421875,
0.423095703125,
0.76318359375,
-0.66064453125,
0.12298583984375,
-0.6103515625,
-0.2005615234375,
-0.287841796875,
0.9541015625,
0.2467041015625,
-0.14111328125,
0.4794921875,
-0.01551055908203125,
-0.7275390625,
0.00786590576171875,
0.21240234375,
-0.5087890625,
-0.164794921875,
1.107421875,
-0.4365234375,
0.108642578125,
0.228759765625,
-0.57177734375,
0.378662109375,
0.184326171875,
-0.68798828125,
1.01171875,
-0.1533203125,
0.49658203125,
-0.80712890625,
-0.2939453125,
0.2626953125,
0.52392578125,
0.035919189453125,
-0.0445556640625,
0.318359375,
0.474853515625,
0.07318115234375,
0.465087890625,
0.4912109375,
-0.69287109375,
0.91015625,
-0.472412109375,
0.2431640625,
-0.80126953125,
-0.05584716796875,
-0.1575927734375,
-0.08001708984375,
-0.5458984375,
-0.39453125,
0.92138671875,
0.257568359375,
-0.09033203125,
0.2457275390625,
0.197021484375,
-0.77685546875,
0.1968994140625,
-0.1688232421875,
-0.0867919921875,
0.034912109375,
0.230712890625,
1.5068359375,
-0.323974609375,
-0.07861328125,
-0.25732421875,
0.666015625,
0.492431640625,
0.441650390625,
-0.181640625,
-0.69775390625,
-0.370849609375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Tags: implementation, strings
Correct Solution:
```
input();s=input().strip();k=len(s)%2;print(s[k::2][::-1]+s[k^1::2])
```
| 72,172 | [
0.615234375,
-0.282958984375,
0.271728515625,
0.36962890625,
-0.56103515625,
-0.60205078125,
0.136474609375,
-0.10284423828125,
-0.391845703125,
0.7529296875,
0.9931640625,
-0.2230224609375,
-0.03466796875,
-0.64306640625,
-0.94189453125,
-0.55224609375,
-0.37255859375,
-0.5263671875,
-0.716796875,
0.17041015625,
0.245849609375,
0.03839111328125,
-1.169921875,
-0.1607666015625,
-0.366943359375,
1.1259765625,
0.5927734375,
-0.2327880859375,
1.2548828125,
0.94873046875,
0.01488494873046875,
0.083984375,
0.771484375,
-1.1953125,
-0.336181640625,
-0.237548828125,
0.6962890625,
-0.356689453125,
-0.29541015625,
-0.389404296875,
0.267333984375,
-0.350341796875,
0.42138671875,
-0.61083984375,
-0.84228515625,
-0.06170654296875,
-0.30078125,
-0.91650390625,
-0.389892578125,
-0.9013671875,
0.1290283203125,
-0.368408203125,
0.5791015625,
-0.296875,
-0.16845703125,
-0.294921875,
-0.1390380859375,
-0.01479339599609375,
-0.335693359375,
0.334228515625,
0.389404296875,
0.39697265625,
0.1558837890625,
-1.037109375,
-0.317138671875,
-0.330078125,
-0.0849609375,
-0.11981201171875,
0.021636962890625,
-0.68017578125,
-0.1590576171875,
0.5,
-0.1527099609375,
-0.70068359375,
-0.346435546875,
0.112060546875,
0.28466796875,
0.1954345703125,
-0.7451171875,
0.93798828125,
0.1197509765625,
0.8671875,
0.6943359375,
0.40283203125,
-0.5283203125,
-0.2255859375,
0.06524658203125,
0.385009765625,
0.10052490234375,
0.0087127685546875,
0.0806884765625,
0.5224609375,
-0.27587890625,
0.1839599609375,
0.492431640625,
0.6142578125,
0.0191192626953125,
0.33447265625,
0.041351318359375,
0.61572265625,
0.787109375,
1.3828125,
-0.275634765625,
1.0712890625,
-0.431884765625,
0.5537109375,
0.167724609375,
0.2705078125,
-0.325439453125,
0.12225341796875,
-0.476318359375,
-0.1138916015625,
0.0031948089599609375,
-0.34228515625,
-0.226806640625,
0.9775390625,
-0.1148681640625,
0.212158203125,
-0.9072265625,
0.400146484375,
0.323974609375,
0.255126953125,
0.411865234375,
-0.32861328125,
0.2413330078125,
-0.3583984375,
-0.6552734375,
1.083984375,
-0.470703125,
-0.4521484375,
0.197509765625,
0.3388671875,
-0.3623046875,
0.1844482421875,
0.345703125,
0.70947265625,
0.146240234375,
0.462646484375,
0.8056640625,
-0.270263671875,
0.2978515625,
0.202392578125,
-0.355712890625,
1.439453125,
-0.1458740234375,
-0.27294921875,
0.451171875,
0.273193359375,
-0.87841796875,
0.6328125,
-0.7666015625,
0.406005859375,
-0.1666259765625,
0.29931640625,
-0.2822265625,
0.038055419921875,
-0.26416015625,
0.67919921875,
-0.00829315185546875,
0.0682373046875,
-0.377685546875,
-0.247802734375,
-0.36767578125,
0.86376953125,
-0.6396484375,
1.328125,
-0.96630859375,
-0.6123046875,
-0.4853515625,
-0.26513671875,
0.428466796875,
-0.11187744140625,
-0.06219482421875,
0.68505859375,
0.3876953125,
0.82958984375,
0.67529296875,
-0.4052734375,
0.363525390625,
0.06524658203125,
0.11865234375,
0.302978515625,
0.333251953125,
0.6953125,
0.1978759765625,
-0.035430908203125,
0.09375,
-0.4853515625,
-0.6728515625,
-0.310302734375,
-0.146728515625,
0.82177734375,
-0.341064453125,
-0.1993408203125,
-0.33544921875,
-0.329833984375,
-0.70849609375,
-0.368408203125,
-0.043792724609375,
-0.990234375,
-0.28759765625,
0.845703125,
-0.294677734375,
0.556640625,
-0.447998046875,
-0.6484375,
0.3369140625,
1.1689453125,
-0.2318115234375,
-0.2685546875,
0.99658203125,
0.268798828125,
-0.468017578125,
0.334228515625,
0.1722412109375,
0.15966796875,
-0.80224609375,
0.6767578125,
-0.488525390625,
0.09197998046875,
-0.2276611328125,
0.78271484375,
0.2357177734375,
0.398193359375,
-0.51318359375,
0.1064453125,
0.83935546875,
1.041015625,
0.00223541259765625,
0.2841796875,
0.28515625,
0.42431640625,
0.227294921875,
0.65966796875,
0.76318359375,
0.419677734375,
0.5810546875,
0.8173828125,
-0.1783447265625,
0.227783203125,
-0.041748046875,
0.386474609375,
0.8515625,
0.056427001953125,
0.1011962890625,
0.56689453125,
-0.48046875,
-0.12261962890625,
-0.443115234375,
0.0870361328125,
-0.374267578125,
0.0214385986328125,
0.263916015625,
0.171875,
-0.441162109375,
-0.362548828125,
0.434326171875,
0.6884765625,
-0.64306640625,
-0.552734375,
0.2171630859375,
0.252685546875,
0.537109375,
0.45361328125,
0.420166015625,
0.73974609375,
0.68505859375,
0.471435546875,
-0.2509765625,
-0.64501953125,
-0.6455078125,
-1.46484375,
-1.029296875,
-0.2587890625,
-0.80517578125,
0.07012939453125,
0.0295867919921875,
-1.08203125,
-0.1336669921875,
-0.323974609375,
-0.61669921875,
-0.41552734375,
-0.362060546875,
0.5615234375,
-0.10992431640625,
0.67822265625,
-0.416259765625,
0.51318359375,
0.085693359375,
1.1611328125,
-0.53125,
-0.2159423828125,
-0.304931640625,
-0.52294921875,
0.297119140625,
-0.1298828125,
0.52294921875,
-0.386474609375,
-0.8505859375,
-0.5869140625,
-0.69384765625,
0.111328125,
-0.459716796875,
0.030975341796875,
-0.424560546875,
0.9140625,
0.34814453125,
-0.5458984375,
0.31298828125,
0.97802734375,
-0.8603515625,
0.36474609375,
0.311279296875,
-0.285888671875,
-0.76318359375,
1.451171875,
0.413330078125,
0.51123046875,
-0.408935546875,
-0.168212890625,
-0.1163330078125,
0.17724609375,
-0.034454345703125,
-0.440185546875,
-0.36865234375,
0.6494140625,
0.04962158203125,
-1.373046875,
0.09246826171875,
-1.056640625,
-0.76708984375,
-0.35498046875,
-0.55859375,
0.7529296875,
0.95654296875,
0.49462890625,
-0.281005859375,
0.07574462890625,
0.12939453125,
0.404541015625,
0.219970703125,
-0.40673828125,
0.08428955078125,
0.66455078125,
-0.2220458984375,
0.1981201171875,
0.66650390625,
-0.2274169921875,
-0.29833984375,
0.16064453125,
0.057769775390625,
0.061737060546875,
0.0282745361328125,
-0.0634765625,
0.1646728515625,
0.454345703125,
-1.150390625,
0.054779052734375,
-0.62841796875,
0.460693359375,
0.2822265625,
0.458251953125,
0.1339111328125,
-0.4833984375,
-0.58154296875,
-1.029296875,
0.30859375,
0.6904296875,
0.282958984375,
-0.4267578125,
1.0302734375,
0.4189453125,
-0.595703125,
0.2020263671875,
-0.7568359375,
0.1536865234375,
0.75927734375,
-0.293212890625,
0.73974609375,
-1.2587890625,
0.513671875,
0.0003414154052734375,
-0.42041015625,
0.2071533203125,
0.231689453125,
0.673828125,
-0.253173828125,
-0.1375732421875,
0.0858154296875,
-0.47509765625,
0.2012939453125,
-0.287353515625,
0.37158203125,
-0.2320556640625,
-1.0146484375,
-0.943359375,
0.92578125,
0.8095703125,
0.423095703125,
0.273193359375,
0.68701171875,
0.426025390625,
0.3798828125,
0.50390625,
0.0504150390625,
-0.11871337890625,
-0.53271484375,
1.078125,
0.268798828125,
-0.37939453125,
-0.72705078125,
-0.406494140625,
-0.0143585205078125,
0.5234375,
0.1387939453125,
0.38330078125,
-0.9189453125,
0.0251617431640625,
0.461669921875,
0.81982421875,
-0.96484375,
-0.059234619140625,
-0.0489501953125,
0.410888671875,
0.1580810546875,
-0.81005859375,
0.274658203125,
-0.79541015625,
0.5693359375,
0.469482421875,
0.216552734375,
-0.370361328125,
-0.2060546875,
-0.8251953125,
-0.337158203125,
0.51953125,
0.359375,
-0.2587890625,
0.54443359375,
-1.0068359375,
1.212890625,
0.290283203125,
-0.1719970703125,
0.0865478515625,
-0.1444091796875,
0.6396484375,
0.206787109375,
0.6708984375,
-0.4716796875,
-0.55224609375,
0.311279296875,
-1.0478515625,
0.2496337890625,
-0.271240234375,
0.404541015625,
-0.169921875,
0.0018758773803710938,
-0.02099609375,
0.11700439453125,
-0.5517578125,
0.2117919921875,
-0.05401611328125,
0.299072265625,
-1.193359375,
-1.0048828125,
0.33837890625,
-0.1851806640625,
-0.2218017578125,
0.56884765625,
-0.0533447265625,
-0.2666015625,
-0.13623046875,
0.2340087890625,
-0.64794921875,
0.43798828125,
-0.60302734375,
0.255615234375,
-0.306884765625,
-0.2880859375,
0.07904052734375,
-0.33740234375,
0.6572265625,
-0.2568359375,
-0.591796875,
-0.38720703125,
-1.185546875,
-0.262451171875,
-0.12744140625,
-0.70263671875,
-0.0309600830078125,
0.46826171875,
-0.449462890625,
-0.1907958984375,
-0.376220703125,
-0.1346435546875,
-0.364501953125,
-0.37109375,
-0.323486328125,
0.72705078125,
0.88671875,
0.84423828125,
0.017608642578125,
0.12066650390625,
-0.26318359375,
-0.08135986328125,
-0.2161865234375,
-0.82470703125,
0.319580078125,
0.272216796875,
-0.35205078125,
0.0111846923828125,
0.327880859375,
-0.056396484375,
0.384033203125,
1.2587890625,
-0.1983642578125,
0.2374267578125,
0.07464599609375,
-0.6142578125,
0.85302734375,
-0.07489013671875,
-1.2587890625,
-0.453369140625,
0.666015625,
-0.1768798828125,
0.591796875,
0.27099609375,
-0.98681640625,
-1.103515625,
-0.830078125,
0.466552734375,
-0.71923828125,
-0.1064453125,
-0.98193359375,
-0.31396484375,
-0.305908203125,
0.60693359375,
-0.2147216796875,
-0.291259765625,
0.050689697265625,
-1.138671875,
0.08544921875,
-0.360595703125,
-0.6640625,
-0.94873046875,
-0.52783203125,
-0.347412109375,
0.787109375,
0.27734375,
-0.11419677734375,
0.03253173828125,
0.16015625,
0.0880126953125,
-0.10064697265625,
-0.84033203125,
-0.2325439453125,
-0.409912109375,
0.23291015625,
-0.11151123046875,
-0.4697265625,
-0.779296875,
0.7998046875,
-0.378173828125,
0.28662109375,
0.05267333984375,
-0.61279296875,
-0.1573486328125,
-0.29931640625,
1.076171875,
-0.44921875,
0.138671875,
-0.69091796875,
0.79345703125,
0.5341796875,
-0.58837890625,
-0.267333984375,
-0.72021484375,
-0.60107421875,
-1.421875,
0.6162109375,
-0.45654296875,
0.3515625,
-0.56103515625,
-0.44384765625,
1.0498046875,
-0.406494140625,
0.423095703125,
0.91455078125,
-0.1453857421875,
-0.1251220703125,
-0.92919921875,
0.775390625,
0.4638671875,
-0.465087890625,
-0.1925048828125,
-0.319580078125,
-0.85595703125,
0.2044677734375,
-0.273193359375,
-0.9091796875,
-0.63037109375,
0.67529296875,
1.5205078125,
-0.256103515625,
0.380126953125,
0.2236328125,
-0.75,
-0.57763671875,
0.57470703125,
0.154296875,
0.01312255859375,
0.64306640625,
-0.2276611328125,
0.07220458984375,
0.146240234375,
-0.004650115966796875,
-0.317626953125,
-0.46142578125,
1.19921875,
-0.25048828125,
-0.5703125,
1.1259765625,
0.93359375,
-0.89404296875,
-0.59765625,
-0.14404296875,
0.1302490234375,
-0.1273193359375,
-0.70556640625,
0.047760009765625,
0.66845703125,
-0.97412109375,
-0.126953125,
0.310791015625,
-0.004062652587890625,
0.4775390625,
0.442626953125,
0.39697265625,
-0.24462890625,
0.3466796875,
0.475341796875,
-0.71826171875,
-0.319580078125,
-1.123046875,
0.439453125,
0.005001068115234375,
0.5048828125,
0.391357421875,
-0.480712890625,
0.29931640625,
0.26611328125,
-0.06976318359375,
1.009765625,
-0.293701171875,
-0.2890625,
0.053680419921875,
-0.939453125,
-0.75048828125,
0.1885986328125,
0.443115234375,
-0.329833984375,
0.0911865234375,
-0.6796875,
0.08734130859375,
0.1092529296875,
0.288818359375,
-0.0196990966796875,
-0.69091796875,
0.1383056640625,
-0.69482421875,
-0.37841796875,
-0.97314453125,
-0.732421875,
0.06585693359375,
0.168701171875,
-0.64501953125,
-0.57177734375,
0.53857421875,
0.45654296875,
-0.72021484375,
1.2744140625,
-0.75341796875,
0.47119140625,
-1.001953125,
-0.055023193359375,
-0.7314453125,
-0.1990966796875,
-0.2412109375,
-0.284423828125,
-0.227294921875,
0.2044677734375,
0.091064453125,
0.34716796875,
0.2166748046875,
0.7177734375,
-0.59814453125,
-0.336181640625,
0.004608154296875,
0.19677734375,
-0.5234375,
0.80419921875,
0.56103515625,
0.2239990234375,
0.1995849609375,
-0.1241455078125,
-0.87158203125,
0.1824951171875,
0.1837158203125,
0.830078125,
0.2491455078125,
0.2088623046875,
-0.5283203125,
-0.07562255859375,
-0.75048828125,
0.1168212890625,
-0.262939453125,
0.1971435546875,
0.31103515625,
-0.63232421875,
0.392333984375,
1.267578125,
-0.2027587890625,
-0.01430511474609375,
0.17822265625,
0.301513671875,
0.25,
0.40234375,
-0.1785888671875,
0.371826171875,
0.5673828125,
-0.34130859375,
-0.59814453125,
0.54296875,
-0.03533935546875,
0.144775390625,
-0.481689453125,
-0.67578125,
-0.8955078125,
0.034881591796875,
0.10211181640625,
0.0240325927734375,
0.71630859375,
-0.62158203125,
0.1729736328125,
0.01520538330078125,
-0.2255859375,
0.336181640625,
-0.9150390625,
-0.66845703125,
0.2291259765625,
-0.12841796875,
-0.7177734375,
-0.1353759765625,
-0.417724609375,
-0.171630859375,
0.262939453125,
0.1358642578125,
-0.4130859375,
0.4619140625,
-0.28955078125,
0.340576171875,
-0.54443359375,
0.09027099609375,
0.19091796875,
0.42626953125,
-0.2646484375,
-0.0882568359375,
0.1455078125,
1.2001953125,
-0.131103515625,
0.215576171875,
-0.81982421875,
-0.05279541015625,
-0.2464599609375,
0.27587890625,
-0.6103515625,
0.231201171875,
-0.260498046875,
0.4921875,
-1.0263671875,
-0.3701171875,
0.2353515625,
0.29931640625,
0.384033203125,
-0.4775390625,
-0.6845703125,
1.1220703125,
0.75341796875,
0.06622314453125,
0.50634765625,
0.362060546875,
0.595703125,
-0.290283203125,
-0.04052734375,
-0.41748046875,
0.33251953125,
0.496337890625,
0.354248046875,
-0.54443359375,
0.6259765625,
0.6455078125,
-0.10382080078125,
-0.061737060546875,
0.33154296875,
-0.12255859375,
0.165283203125,
0.157470703125,
-0.109619140625,
-0.10760498046875,
0.1190185546875,
-0.61865234375,
0.51953125,
-0.1707763671875,
-0.159912109375,
-0.6943359375,
-0.7919921875,
0.68505859375,
-0.276611328125,
-0.2320556640625,
-0.1126708984375,
-0.2373046875,
0.339599609375,
0.78662109375,
0.02911376953125,
-0.05316162109375,
0.697265625,
0.8291015625,
0.249755859375,
0.99169921875,
0.44384765625,
0.11138916015625,
-0.2471923828125,
0.45703125,
0.348388671875,
0.047821044921875,
0.005889892578125,
-0.2509765625,
-0.92822265625,
0.7421875,
-0.0435791015625,
-0.54833984375,
0.52783203125,
-0.6962890625,
0.2486572265625,
-0.280517578125,
0.425537109375,
-0.68896484375,
0.33740234375,
0.333740234375,
-0.395263671875,
-0.422607421875,
0.83642578125,
-0.2113037109375,
0.55712890625,
0.0655517578125,
0.85888671875,
-0.0333251953125,
1.671875,
0.71533203125,
-0.0615234375,
0.50537109375,
0.449951171875,
-0.36328125,
-0.48828125,
-0.2391357421875,
-0.56103515625,
-0.525390625,
-0.390625,
-0.36328125,
0.01332855224609375,
0.92041015625,
0.1346435546875,
-0.85546875,
-0.471435546875,
-0.0201873779296875,
-0.2744140625,
0.354248046875,
0.52294921875,
0.1729736328125,
-0.11553955078125,
0.0947265625,
-0.294921875,
-0.4833984375,
0.057586669921875,
-0.525390625,
0.38037109375,
-0.69189453125,
-0.7236328125,
-1.107421875,
-0.9921875,
-0.184814453125,
0.28515625,
-0.444580078125,
-0.7255859375,
0.591796875,
0.468994140625,
0.472900390625,
0.04742431640625,
-0.1240234375,
0.02703857421875,
0.64794921875,
0.83935546875,
-0.039886474609375,
0.482177734375,
0.364990234375,
-0.048736572265625,
0.142822265625,
-0.65478515625,
0.62109375,
0.1199951171875,
0.071533203125,
-0.35498046875,
0.2003173828125,
-0.88916015625,
-1.4990234375,
-0.220458984375,
0.09918212890625,
0.1590576171875,
-0.81591796875,
-1.1650390625,
-0.39599609375,
-0.728515625,
-0.173828125,
-0.11065673828125,
0.7919921875,
0.013641357421875,
0.01142120361328125,
-0.262939453125,
-1.029296875,
4.3671875,
1.396484375,
1.0185546875,
-0.0341796875,
0.52001953125,
1.2607421875,
0.424072265625,
-0.896484375,
-0.414306640625,
-0.1107177734375,
0.350341796875,
-0.354736328125,
-0.212158203125,
0.513671875,
0.0784912109375,
0.50830078125,
-0.69873046875,
0.007289886474609375,
-0.318359375,
-0.75390625,
-0.85205078125,
0.1458740234375,
-0.1329345703125,
0.214111328125,
0.1612548828125,
0.419677734375,
0.75634765625,
-0.65283203125,
0.12408447265625,
-0.6025390625,
-0.2110595703125,
-0.283203125,
0.96533203125,
0.251953125,
-0.1473388671875,
0.47998046875,
-0.0286102294921875,
-0.7197265625,
0.01055145263671875,
0.1944580078125,
-0.5078125,
-0.1571044921875,
1.1142578125,
-0.428955078125,
0.1182861328125,
0.2374267578125,
-0.57421875,
0.36376953125,
0.1884765625,
-0.67724609375,
1.033203125,
-0.164306640625,
0.491943359375,
-0.82470703125,
-0.2919921875,
0.2509765625,
0.5234375,
0.0268096923828125,
-0.045928955078125,
0.302001953125,
0.466796875,
0.0782470703125,
0.4697265625,
0.478271484375,
-0.68115234375,
0.91259765625,
-0.453369140625,
0.23046875,
-0.79248046875,
-0.06591796875,
-0.1595458984375,
-0.10546875,
-0.53369140625,
-0.404052734375,
0.9140625,
0.25927734375,
-0.10284423828125,
0.2462158203125,
0.2218017578125,
-0.75244140625,
0.201904296875,
-0.1541748046875,
-0.07806396484375,
0.036590576171875,
0.2381591796875,
1.5166015625,
-0.327392578125,
-0.08502197265625,
-0.258544921875,
0.65478515625,
0.4970703125,
0.442626953125,
-0.2088623046875,
-0.70751953125,
-0.35546875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Tags: implementation, strings
Correct Solution:
```
def decode(s):
res = "" + s[0]
string = []
for letter in s:
string.append(letter)
string = string[1:]
while len(string) != 0:
if len(string) % 2 == 0:
res = str(string[0]) + res
else:
res += str(string[0])
string = string[1:]
return res
n = input()
arg = input()
print(decode(arg))
```
| 72,173 | [
0.6328125,
-0.302001953125,
0.259033203125,
0.4111328125,
-0.5283203125,
-0.60498046875,
0.12060546875,
-0.091552734375,
-0.388671875,
0.75146484375,
1.0087890625,
-0.2176513671875,
-0.0263824462890625,
-0.61669921875,
-0.884765625,
-0.513671875,
-0.366943359375,
-0.53955078125,
-0.70654296875,
0.1549072265625,
0.2318115234375,
0.06402587890625,
-1.2041015625,
-0.1629638671875,
-0.390380859375,
1.1064453125,
0.6044921875,
-0.214599609375,
1.24609375,
0.97314453125,
0.01143646240234375,
0.07916259765625,
0.77001953125,
-1.2255859375,
-0.31201171875,
-0.2236328125,
0.7001953125,
-0.351318359375,
-0.310302734375,
-0.409423828125,
0.253173828125,
-0.325439453125,
0.38623046875,
-0.62353515625,
-0.8369140625,
-0.07177734375,
-0.294677734375,
-0.923828125,
-0.37646484375,
-0.88916015625,
0.1055908203125,
-0.37939453125,
0.541015625,
-0.309814453125,
-0.1307373046875,
-0.29931640625,
-0.135986328125,
-0.0062713623046875,
-0.331298828125,
0.313720703125,
0.396728515625,
0.426513671875,
0.1632080078125,
-1.0068359375,
-0.319091796875,
-0.3310546875,
-0.10089111328125,
-0.1319580078125,
0.005458831787109375,
-0.689453125,
-0.143310546875,
0.50390625,
-0.1656494140625,
-0.6923828125,
-0.34814453125,
0.125732421875,
0.274658203125,
0.196533203125,
-0.712890625,
0.95703125,
0.12371826171875,
0.8564453125,
0.71142578125,
0.400634765625,
-0.51513671875,
-0.236083984375,
0.045654296875,
0.399169921875,
0.07867431640625,
0.036163330078125,
0.0577392578125,
0.5302734375,
-0.2626953125,
0.1590576171875,
0.490478515625,
0.63037109375,
0.048126220703125,
0.3173828125,
0.044891357421875,
0.6044921875,
0.74560546875,
1.37890625,
-0.28369140625,
1.0634765625,
-0.431640625,
0.52197265625,
0.2010498046875,
0.2705078125,
-0.34765625,
0.124267578125,
-0.467041015625,
-0.144287109375,
-0.00466156005859375,
-0.354248046875,
-0.205810546875,
0.98095703125,
-0.1295166015625,
0.1746826171875,
-0.90478515625,
0.43017578125,
0.321044921875,
0.286865234375,
0.41796875,
-0.3251953125,
0.271728515625,
-0.34619140625,
-0.6396484375,
1.095703125,
-0.479736328125,
-0.4423828125,
0.2076416015625,
0.323974609375,
-0.356201171875,
0.1905517578125,
0.330810546875,
0.6982421875,
0.1395263671875,
0.447265625,
0.814453125,
-0.2763671875,
0.330078125,
0.17578125,
-0.34912109375,
1.4443359375,
-0.1519775390625,
-0.236083984375,
0.471923828125,
0.2568359375,
-0.87353515625,
0.64111328125,
-0.7734375,
0.390869140625,
-0.1678466796875,
0.282470703125,
-0.3095703125,
0.0286712646484375,
-0.28076171875,
0.67626953125,
-0.0308074951171875,
0.0374755859375,
-0.376708984375,
-0.2066650390625,
-0.365966796875,
0.8916015625,
-0.638671875,
1.3203125,
-0.95654296875,
-0.6220703125,
-0.48583984375,
-0.25048828125,
0.432861328125,
-0.08624267578125,
-0.1134033203125,
0.697265625,
0.39990234375,
0.82861328125,
0.65625,
-0.40185546875,
0.370849609375,
0.06854248046875,
0.1510009765625,
0.261474609375,
0.306640625,
0.720703125,
0.1712646484375,
-0.062042236328125,
0.105224609375,
-0.505859375,
-0.65673828125,
-0.295654296875,
-0.1318359375,
0.8505859375,
-0.35888671875,
-0.1876220703125,
-0.27978515625,
-0.282470703125,
-0.71240234375,
-0.35693359375,
-0.04705810546875,
-1.025390625,
-0.298583984375,
0.83740234375,
-0.31298828125,
0.55908203125,
-0.452392578125,
-0.64892578125,
0.345703125,
1.1630859375,
-0.2470703125,
-0.263671875,
0.9892578125,
0.25439453125,
-0.449462890625,
0.339111328125,
0.20947265625,
0.146484375,
-0.8232421875,
0.67138671875,
-0.45068359375,
0.0970458984375,
-0.2222900390625,
0.806640625,
0.25439453125,
0.395751953125,
-0.491455078125,
0.1339111328125,
0.84033203125,
1.0576171875,
0.0032215118408203125,
0.27099609375,
0.28466796875,
0.4267578125,
0.23779296875,
0.64794921875,
0.759765625,
0.4462890625,
0.583984375,
0.8095703125,
-0.138427734375,
0.223388671875,
-0.08282470703125,
0.393798828125,
0.83642578125,
0.109130859375,
0.11480712890625,
0.5341796875,
-0.50048828125,
-0.0731201171875,
-0.451416015625,
0.073486328125,
-0.378173828125,
-0.006107330322265625,
0.27294921875,
0.148681640625,
-0.450927734375,
-0.32861328125,
0.408203125,
0.69775390625,
-0.62646484375,
-0.560546875,
0.223388671875,
0.242431640625,
0.537109375,
0.43212890625,
0.443359375,
0.734375,
0.6845703125,
0.49169921875,
-0.296142578125,
-0.66064453125,
-0.6474609375,
-1.4736328125,
-1.0126953125,
-0.244140625,
-0.8017578125,
0.07794189453125,
0.0228424072265625,
-1.0869140625,
-0.140380859375,
-0.316650390625,
-0.5927734375,
-0.388671875,
-0.37451171875,
0.57373046875,
-0.1151123046875,
0.6923828125,
-0.432861328125,
0.5078125,
0.1021728515625,
1.1494140625,
-0.56396484375,
-0.210205078125,
-0.311767578125,
-0.55908203125,
0.28515625,
-0.11932373046875,
0.499755859375,
-0.41552734375,
-0.8466796875,
-0.5751953125,
-0.720703125,
0.11175537109375,
-0.46484375,
0.034027099609375,
-0.428955078125,
0.90380859375,
0.368896484375,
-0.53955078125,
0.31689453125,
0.9814453125,
-0.84326171875,
0.390625,
0.297119140625,
-0.252685546875,
-0.76806640625,
1.4541015625,
0.42041015625,
0.517578125,
-0.430419921875,
-0.1693115234375,
-0.1380615234375,
0.1600341796875,
-0.0419921875,
-0.464599609375,
-0.38134765625,
0.6318359375,
0.058441162109375,
-1.380859375,
0.1319580078125,
-1.064453125,
-0.755859375,
-0.376953125,
-0.580078125,
0.76318359375,
0.9580078125,
0.496337890625,
-0.3154296875,
0.0643310546875,
0.08935546875,
0.42578125,
0.20849609375,
-0.380615234375,
0.125244140625,
0.69775390625,
-0.215087890625,
0.228271484375,
0.66357421875,
-0.2198486328125,
-0.29248046875,
0.157470703125,
0.015594482421875,
0.0753173828125,
0.0465087890625,
-0.0731201171875,
0.1595458984375,
0.44384765625,
-1.1826171875,
0.068359375,
-0.646484375,
0.4638671875,
0.280029296875,
0.464111328125,
0.1478271484375,
-0.50244140625,
-0.564453125,
-1.015625,
0.315185546875,
0.68505859375,
0.29296875,
-0.427734375,
1.0146484375,
0.41455078125,
-0.603515625,
0.2117919921875,
-0.73779296875,
0.1336669921875,
0.759765625,
-0.290283203125,
0.75,
-1.255859375,
0.52978515625,
-0.0110015869140625,
-0.36767578125,
0.1851806640625,
0.2213134765625,
0.65478515625,
-0.265625,
-0.14013671875,
0.05596923828125,
-0.4716796875,
0.1826171875,
-0.28076171875,
0.391845703125,
-0.2379150390625,
-1.0048828125,
-0.9697265625,
0.92236328125,
0.8115234375,
0.41845703125,
0.268798828125,
0.6953125,
0.425048828125,
0.395751953125,
0.5244140625,
0.044769287109375,
-0.09332275390625,
-0.53466796875,
1.021484375,
0.277099609375,
-0.36474609375,
-0.72607421875,
-0.422607421875,
-0.029754638671875,
0.52294921875,
0.1427001953125,
0.35498046875,
-0.9375,
0.0474853515625,
0.476806640625,
0.81787109375,
-0.96630859375,
-0.059112548828125,
-0.0171051025390625,
0.422119140625,
0.165283203125,
-0.7998046875,
0.269775390625,
-0.80517578125,
0.5634765625,
0.485107421875,
0.2113037109375,
-0.365478515625,
-0.217529296875,
-0.8515625,
-0.314208984375,
0.5146484375,
0.361572265625,
-0.253173828125,
0.55078125,
-1.0009765625,
1.220703125,
0.2447509765625,
-0.151611328125,
0.06011962890625,
-0.145751953125,
0.61572265625,
0.22998046875,
0.6552734375,
-0.476806640625,
-0.5673828125,
0.3076171875,
-1.04296875,
0.2264404296875,
-0.267333984375,
0.3759765625,
-0.1683349609375,
-0.00395965576171875,
-0.038421630859375,
0.12158203125,
-0.55712890625,
0.2308349609375,
-0.04248046875,
0.28466796875,
-1.2138671875,
-0.99755859375,
0.357177734375,
-0.159423828125,
-0.21923828125,
0.564453125,
-0.0516357421875,
-0.280029296875,
-0.126708984375,
0.20068359375,
-0.6533203125,
0.423828125,
-0.623046875,
0.24462890625,
-0.302734375,
-0.271728515625,
0.0621337890625,
-0.3408203125,
0.6572265625,
-0.2489013671875,
-0.57421875,
-0.387451171875,
-1.2197265625,
-0.2481689453125,
-0.1072998046875,
-0.7099609375,
-0.007213592529296875,
0.479248046875,
-0.421875,
-0.181884765625,
-0.39208984375,
-0.151123046875,
-0.3427734375,
-0.3623046875,
-0.322265625,
0.7509765625,
0.8916015625,
0.88134765625,
-0.00751495361328125,
0.14453125,
-0.26171875,
-0.06768798828125,
-0.228759765625,
-0.86474609375,
0.31884765625,
0.23193359375,
-0.335205078125,
0.0009217262268066406,
0.314453125,
-0.0562744140625,
0.353759765625,
1.2412109375,
-0.203125,
0.2396240234375,
0.0345458984375,
-0.59521484375,
0.884765625,
-0.06304931640625,
-1.2958984375,
-0.4814453125,
0.6748046875,
-0.1812744140625,
0.6005859375,
0.26123046875,
-0.98876953125,
-1.0771484375,
-0.8251953125,
0.45263671875,
-0.7490234375,
-0.11968994140625,
-0.95703125,
-0.277099609375,
-0.2900390625,
0.61865234375,
-0.179931640625,
-0.313232421875,
0.04736328125,
-1.1513671875,
0.044342041015625,
-0.3701171875,
-0.65576171875,
-0.974609375,
-0.53173828125,
-0.353759765625,
0.8251953125,
0.285400390625,
-0.118896484375,
0.039093017578125,
0.1787109375,
0.10784912109375,
-0.12127685546875,
-0.8095703125,
-0.2373046875,
-0.41357421875,
0.2401123046875,
-0.10723876953125,
-0.461669921875,
-0.78515625,
0.76318359375,
-0.36572265625,
0.29931640625,
0.051971435546875,
-0.61767578125,
-0.16845703125,
-0.301025390625,
1.0947265625,
-0.492919921875,
0.158935546875,
-0.67578125,
0.7978515625,
0.56591796875,
-0.5791015625,
-0.25927734375,
-0.7421875,
-0.5927734375,
-1.4384765625,
0.63525390625,
-0.483154296875,
0.354736328125,
-0.5712890625,
-0.454833984375,
1.033203125,
-0.385498046875,
0.40869140625,
0.8837890625,
-0.1591796875,
-0.1668701171875,
-0.9462890625,
0.78759765625,
0.4658203125,
-0.44140625,
-0.203369140625,
-0.325927734375,
-0.83837890625,
0.2099609375,
-0.28515625,
-0.9130859375,
-0.6162109375,
0.658203125,
1.51171875,
-0.2607421875,
0.433837890625,
0.2529296875,
-0.7568359375,
-0.568359375,
0.541015625,
0.2100830078125,
-0.0030975341796875,
0.6376953125,
-0.20556640625,
0.053466796875,
0.1436767578125,
0.0032672882080078125,
-0.329345703125,
-0.4638671875,
1.19921875,
-0.2447509765625,
-0.591796875,
1.1044921875,
0.94775390625,
-0.869140625,
-0.59130859375,
-0.1329345703125,
0.1279296875,
-0.1480712890625,
-0.72314453125,
0.07330322265625,
0.634765625,
-0.93017578125,
-0.1055908203125,
0.346435546875,
-0.019500732421875,
0.450439453125,
0.45849609375,
0.397216796875,
-0.26025390625,
0.325927734375,
0.4912109375,
-0.7060546875,
-0.370849609375,
-1.1494140625,
0.431884765625,
-0.00533294677734375,
0.49853515625,
0.432373046875,
-0.50390625,
0.30029296875,
0.252197265625,
-0.0594482421875,
1.0390625,
-0.2763671875,
-0.299072265625,
0.0394287109375,
-0.931640625,
-0.755859375,
0.1922607421875,
0.445556640625,
-0.335693359375,
0.08740234375,
-0.6640625,
0.11962890625,
0.09735107421875,
0.267822265625,
-0.041351318359375,
-0.6865234375,
0.1094970703125,
-0.7080078125,
-0.3818359375,
-0.9892578125,
-0.74755859375,
0.0767822265625,
0.1751708984375,
-0.658203125,
-0.60009765625,
0.53076171875,
0.460693359375,
-0.708984375,
1.2734375,
-0.73681640625,
0.46240234375,
-1.0234375,
-0.06866455078125,
-0.7197265625,
-0.2286376953125,
-0.227783203125,
-0.264404296875,
-0.23291015625,
0.2261962890625,
0.0599365234375,
0.365478515625,
0.235595703125,
0.69091796875,
-0.6015625,
-0.339111328125,
0.0135955810546875,
0.2177734375,
-0.50732421875,
0.81640625,
0.5576171875,
0.200439453125,
0.1976318359375,
-0.138427734375,
-0.86865234375,
0.188720703125,
0.1812744140625,
0.80712890625,
0.25634765625,
0.2255859375,
-0.50439453125,
-0.11065673828125,
-0.7880859375,
0.142822265625,
-0.2646484375,
0.20263671875,
0.29638671875,
-0.61279296875,
0.363525390625,
1.28515625,
-0.211669921875,
-0.01346588134765625,
0.193603515625,
0.28466796875,
0.247802734375,
0.403564453125,
-0.165283203125,
0.365966796875,
0.54736328125,
-0.30517578125,
-0.59423828125,
0.54345703125,
-0.084228515625,
0.1678466796875,
-0.4931640625,
-0.671875,
-0.8896484375,
-0.0180206298828125,
0.061798095703125,
0.006072998046875,
0.7138671875,
-0.626953125,
0.1668701171875,
0.01151275634765625,
-0.2080078125,
0.3271484375,
-0.90283203125,
-0.65185546875,
0.2432861328125,
-0.1077880859375,
-0.72216796875,
-0.117431640625,
-0.3916015625,
-0.208740234375,
0.26806640625,
0.156982421875,
-0.43603515625,
0.4716796875,
-0.30908203125,
0.371826171875,
-0.52001953125,
0.09088134765625,
0.1729736328125,
0.436279296875,
-0.28173828125,
-0.10400390625,
0.135009765625,
1.1962890625,
-0.0986328125,
0.2081298828125,
-0.82861328125,
-0.07421875,
-0.233642578125,
0.28173828125,
-0.64404296875,
0.220947265625,
-0.281982421875,
0.53564453125,
-1.0263671875,
-0.3740234375,
0.2398681640625,
0.301025390625,
0.402587890625,
-0.46240234375,
-0.70751953125,
1.11328125,
0.74951171875,
0.0487060546875,
0.53955078125,
0.383544921875,
0.58447265625,
-0.27294921875,
-0.02972412109375,
-0.419921875,
0.365234375,
0.494384765625,
0.350341796875,
-0.56005859375,
0.61181640625,
0.646484375,
-0.05108642578125,
-0.05889892578125,
0.3427734375,
-0.1204833984375,
0.1697998046875,
0.1627197265625,
-0.1121826171875,
-0.12420654296875,
0.1173095703125,
-0.572265625,
0.52880859375,
-0.1724853515625,
-0.1578369140625,
-0.69189453125,
-0.78759765625,
0.6767578125,
-0.285888671875,
-0.24462890625,
-0.10400390625,
-0.2457275390625,
0.31689453125,
0.77685546875,
0.04248046875,
-0.0587158203125,
0.69775390625,
0.82958984375,
0.220458984375,
0.984375,
0.427734375,
0.1348876953125,
-0.259033203125,
0.46435546875,
0.361572265625,
0.046905517578125,
0.007232666015625,
-0.283203125,
-0.93017578125,
0.7548828125,
-0.0704345703125,
-0.57275390625,
0.52734375,
-0.6982421875,
0.2293701171875,
-0.2529296875,
0.4130859375,
-0.6962890625,
0.342041015625,
0.331787109375,
-0.406005859375,
-0.41650390625,
0.814453125,
-0.218017578125,
0.56298828125,
0.04833984375,
0.87890625,
-0.04901123046875,
1.7041015625,
0.6943359375,
-0.0594482421875,
0.4521484375,
0.447265625,
-0.3583984375,
-0.494384765625,
-0.260009765625,
-0.57080078125,
-0.54052734375,
-0.413330078125,
-0.37548828125,
0.01551055908203125,
0.9228515625,
0.1495361328125,
-0.85791015625,
-0.4560546875,
0.0034961700439453125,
-0.286865234375,
0.393310546875,
0.53466796875,
0.1656494140625,
-0.1328125,
0.076171875,
-0.27490234375,
-0.467041015625,
0.0574951171875,
-0.53564453125,
0.380615234375,
-0.71923828125,
-0.74609375,
-1.07421875,
-0.98388671875,
-0.2156982421875,
0.284423828125,
-0.435791015625,
-0.75146484375,
0.58447265625,
0.5087890625,
0.469482421875,
0.0287933349609375,
-0.08233642578125,
0.051910400390625,
0.65185546875,
0.8564453125,
-0.007320404052734375,
0.501953125,
0.384521484375,
-0.07440185546875,
0.1229248046875,
-0.66064453125,
0.59765625,
0.1334228515625,
0.044677734375,
-0.33984375,
0.2127685546875,
-0.88720703125,
-1.529296875,
-0.1866455078125,
0.1226806640625,
0.165771484375,
-0.82373046875,
-1.216796875,
-0.39453125,
-0.7216796875,
-0.1566162109375,
-0.0924072265625,
0.8115234375,
0.012847900390625,
-0.003833770751953125,
-0.260009765625,
-1.0146484375,
4.359375,
1.408203125,
1.0419921875,
-0.002872467041015625,
0.57470703125,
1.2470703125,
0.470703125,
-0.9189453125,
-0.395263671875,
-0.107666015625,
0.35400390625,
-0.328857421875,
-0.1943359375,
0.51123046875,
0.06072998046875,
0.5087890625,
-0.70458984375,
0.005802154541015625,
-0.32275390625,
-0.72998046875,
-0.8486328125,
0.1322021484375,
-0.140869140625,
0.2255859375,
0.181396484375,
0.409912109375,
0.7705078125,
-0.6611328125,
0.12347412109375,
-0.5947265625,
-0.221923828125,
-0.31884765625,
0.9765625,
0.259765625,
-0.1578369140625,
0.469482421875,
-0.034759521484375,
-0.7705078125,
0.0025787353515625,
0.1937255859375,
-0.52880859375,
-0.162109375,
1.1064453125,
-0.4345703125,
0.09918212890625,
0.278076171875,
-0.56494140625,
0.345458984375,
0.1610107421875,
-0.654296875,
1.0458984375,
-0.156005859375,
0.5068359375,
-0.818359375,
-0.2459716796875,
0.2425537109375,
0.5234375,
0.029296875,
-0.031646728515625,
0.32275390625,
0.4658203125,
0.1002197265625,
0.462890625,
0.493896484375,
-0.6962890625,
0.85986328125,
-0.441650390625,
0.2489013671875,
-0.79052734375,
-0.055938720703125,
-0.1544189453125,
-0.09039306640625,
-0.5419921875,
-0.396240234375,
0.9267578125,
0.279052734375,
-0.09075927734375,
0.26171875,
0.1800537109375,
-0.7568359375,
0.2039794921875,
-0.177490234375,
-0.060333251953125,
0.03240966796875,
0.24755859375,
1.5126953125,
-0.323974609375,
-0.12188720703125,
-0.271728515625,
0.720703125,
0.51953125,
0.419677734375,
-0.206298828125,
-0.689453125,
-0.355712890625
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Tags: implementation, strings
Correct Solution:
```
n = int(input())
s = input()
wynik = ''
prawa = False
if n % 2 == 1:
prawa = True
for i in s:
if prawa:
wynik += i
prawa = False
else:
wynik = i + wynik
prawa = True
print(wynik)
```
| 72,174 | [
0.61865234375,
-0.290771484375,
0.251708984375,
0.384765625,
-0.54052734375,
-0.62548828125,
0.1298828125,
-0.0924072265625,
-0.399658203125,
0.7626953125,
0.9833984375,
-0.2122802734375,
-0.045806884765625,
-0.63720703125,
-0.9208984375,
-0.54443359375,
-0.3759765625,
-0.54296875,
-0.7021484375,
0.1636962890625,
0.2398681640625,
0.03802490234375,
-1.1875,
-0.1519775390625,
-0.3759765625,
1.12890625,
0.61376953125,
-0.2332763671875,
1.2353515625,
0.97314453125,
0.0190277099609375,
0.07330322265625,
0.75634765625,
-1.1962890625,
-0.330322265625,
-0.2467041015625,
0.69189453125,
-0.34716796875,
-0.28125,
-0.375244140625,
0.26171875,
-0.347900390625,
0.4130859375,
-0.6376953125,
-0.86669921875,
-0.07098388671875,
-0.284912109375,
-0.8935546875,
-0.370849609375,
-0.91650390625,
0.129638671875,
-0.360107421875,
0.57421875,
-0.283935546875,
-0.17919921875,
-0.2841796875,
-0.1402587890625,
-0.006084442138671875,
-0.34423828125,
0.325439453125,
0.376220703125,
0.40869140625,
0.1448974609375,
-1.03125,
-0.30859375,
-0.32763671875,
-0.0987548828125,
-0.12109375,
0.010009765625,
-0.6982421875,
-0.164306640625,
0.4912109375,
-0.173095703125,
-0.693359375,
-0.346923828125,
0.10955810546875,
0.2880859375,
0.21240234375,
-0.75341796875,
0.94189453125,
0.1226806640625,
0.87353515625,
0.66259765625,
0.4287109375,
-0.51708984375,
-0.235107421875,
0.0594482421875,
0.368408203125,
0.100830078125,
-0.005970001220703125,
0.06585693359375,
0.51171875,
-0.263427734375,
0.189208984375,
0.494384765625,
0.60302734375,
0.010528564453125,
0.333251953125,
0.033447265625,
0.61083984375,
0.791015625,
1.3896484375,
-0.279296875,
1.0791015625,
-0.436767578125,
0.57958984375,
0.1746826171875,
0.274169921875,
-0.330810546875,
0.11328125,
-0.470458984375,
-0.1163330078125,
0.0014638900756835938,
-0.340087890625,
-0.218017578125,
0.97607421875,
-0.1153564453125,
0.210693359375,
-0.91259765625,
0.419921875,
0.3466796875,
0.266845703125,
0.427734375,
-0.336181640625,
0.2371826171875,
-0.38232421875,
-0.6572265625,
1.0947265625,
-0.472900390625,
-0.427001953125,
0.1854248046875,
0.3369140625,
-0.366943359375,
0.1915283203125,
0.326171875,
0.71484375,
0.1455078125,
0.45654296875,
0.81298828125,
-0.278564453125,
0.317138671875,
0.1837158203125,
-0.33740234375,
1.4521484375,
-0.150390625,
-0.2763671875,
0.451416015625,
0.28955078125,
-0.859375,
0.615234375,
-0.79052734375,
0.41943359375,
-0.1746826171875,
0.297607421875,
-0.302490234375,
0.05035400390625,
-0.267578125,
0.67138671875,
-0.0272064208984375,
0.075439453125,
-0.366455078125,
-0.235595703125,
-0.360595703125,
0.86669921875,
-0.6201171875,
1.33203125,
-0.96435546875,
-0.6259765625,
-0.47900390625,
-0.2479248046875,
0.42529296875,
-0.11395263671875,
-0.092041015625,
0.6826171875,
0.39990234375,
0.845703125,
0.671875,
-0.41162109375,
0.3642578125,
0.0731201171875,
0.1085205078125,
0.294189453125,
0.309326171875,
0.69189453125,
0.1771240234375,
-0.026824951171875,
0.1103515625,
-0.498046875,
-0.67822265625,
-0.3056640625,
-0.144287109375,
0.82080078125,
-0.354248046875,
-0.1839599609375,
-0.34130859375,
-0.322998046875,
-0.7314453125,
-0.376708984375,
-0.070068359375,
-1.017578125,
-0.2958984375,
0.8369140625,
-0.2841796875,
0.52490234375,
-0.448486328125,
-0.63818359375,
0.332763671875,
1.173828125,
-0.233154296875,
-0.264892578125,
0.986328125,
0.25146484375,
-0.46728515625,
0.329833984375,
0.171142578125,
0.1641845703125,
-0.8046875,
0.6806640625,
-0.46630859375,
0.07659912109375,
-0.2232666015625,
0.78662109375,
0.218017578125,
0.4013671875,
-0.50830078125,
0.0963134765625,
0.84033203125,
1.025390625,
0.005054473876953125,
0.299560546875,
0.29638671875,
0.44677734375,
0.2349853515625,
0.67431640625,
0.75,
0.4091796875,
0.5966796875,
0.82666015625,
-0.1771240234375,
0.2286376953125,
-0.045684814453125,
0.390869140625,
0.84228515625,
0.049468994140625,
0.1209716796875,
0.5302734375,
-0.496337890625,
-0.119140625,
-0.439453125,
0.1043701171875,
-0.365966796875,
0.018585205078125,
0.2666015625,
0.15869140625,
-0.44384765625,
-0.381103515625,
0.434814453125,
0.6904296875,
-0.64697265625,
-0.54833984375,
0.2191162109375,
0.2491455078125,
0.5322265625,
0.43603515625,
0.418701171875,
0.75537109375,
0.6904296875,
0.46533203125,
-0.25537109375,
-0.63037109375,
-0.6611328125,
-1.44921875,
-1.0380859375,
-0.25390625,
-0.80810546875,
0.0797119140625,
0.032562255859375,
-1.07421875,
-0.1473388671875,
-0.328857421875,
-0.60595703125,
-0.398193359375,
-0.365966796875,
0.56884765625,
-0.117431640625,
0.66064453125,
-0.444580078125,
0.51953125,
0.0821533203125,
1.162109375,
-0.5419921875,
-0.1964111328125,
-0.288330078125,
-0.54541015625,
0.300537109375,
-0.126220703125,
0.525390625,
-0.410888671875,
-0.85498046875,
-0.591796875,
-0.70361328125,
0.11895751953125,
-0.457275390625,
0.035369873046875,
-0.41845703125,
0.91259765625,
0.359130859375,
-0.568359375,
0.326171875,
0.96826171875,
-0.85595703125,
0.367919921875,
0.2939453125,
-0.265380859375,
-0.76513671875,
1.4609375,
0.4150390625,
0.51611328125,
-0.4140625,
-0.1650390625,
-0.12078857421875,
0.201904296875,
-0.06671142578125,
-0.453857421875,
-0.37548828125,
0.630859375,
0.05157470703125,
-1.37109375,
0.1153564453125,
-1.05859375,
-0.74462890625,
-0.357421875,
-0.57470703125,
0.79248046875,
0.96728515625,
0.490478515625,
-0.284423828125,
0.0635986328125,
0.10748291015625,
0.408203125,
0.22119140625,
-0.407958984375,
0.0792236328125,
0.685546875,
-0.2069091796875,
0.2020263671875,
0.64453125,
-0.2264404296875,
-0.302978515625,
0.1561279296875,
0.06494140625,
0.08441162109375,
0.035003662109375,
-0.06396484375,
0.17138671875,
0.474365234375,
-1.1826171875,
0.05291748046875,
-0.64111328125,
0.45703125,
0.294189453125,
0.442138671875,
0.1265869140625,
-0.494384765625,
-0.57861328125,
-1.0283203125,
0.32568359375,
0.70849609375,
0.2900390625,
-0.42529296875,
1.029296875,
0.41650390625,
-0.587890625,
0.2288818359375,
-0.7451171875,
0.15966796875,
0.75,
-0.28369140625,
0.76513671875,
-1.267578125,
0.51416015625,
-0.005794525146484375,
-0.431884765625,
0.202880859375,
0.2186279296875,
0.66650390625,
-0.271484375,
-0.134765625,
0.08062744140625,
-0.447509765625,
0.1905517578125,
-0.2978515625,
0.3525390625,
-0.2357177734375,
-1.0048828125,
-0.96728515625,
0.9306640625,
0.82470703125,
0.43603515625,
0.278076171875,
0.685546875,
0.419921875,
0.364990234375,
0.51611328125,
0.055450439453125,
-0.11181640625,
-0.52587890625,
1.052734375,
0.27685546875,
-0.38720703125,
-0.728515625,
-0.3955078125,
-0.0016956329345703125,
0.5,
0.1331787109375,
0.37890625,
-0.908203125,
0.04766845703125,
0.45068359375,
0.83447265625,
-0.9619140625,
-0.057586669921875,
-0.03192138671875,
0.40966796875,
0.146240234375,
-0.802734375,
0.271728515625,
-0.7744140625,
0.5673828125,
0.470703125,
0.2059326171875,
-0.384033203125,
-0.2156982421875,
-0.8515625,
-0.342529296875,
0.51806640625,
0.359619140625,
-0.27490234375,
0.55517578125,
-1.021484375,
1.2041015625,
0.2880859375,
-0.1712646484375,
0.0787353515625,
-0.1590576171875,
0.6181640625,
0.2159423828125,
0.65966796875,
-0.48193359375,
-0.57421875,
0.30224609375,
-1.0478515625,
0.225830078125,
-0.26904296875,
0.40771484375,
-0.1629638671875,
-0.003078460693359375,
-0.027587890625,
0.12469482421875,
-0.544921875,
0.2078857421875,
-0.07244873046875,
0.302001953125,
-1.1962890625,
-0.99755859375,
0.34326171875,
-0.1712646484375,
-0.2056884765625,
0.56884765625,
-0.047943115234375,
-0.272216796875,
-0.1279296875,
0.23583984375,
-0.6572265625,
0.45556640625,
-0.60986328125,
0.268798828125,
-0.326416015625,
-0.26513671875,
0.0841064453125,
-0.366943359375,
0.67333984375,
-0.2607421875,
-0.59814453125,
-0.39111328125,
-1.1982421875,
-0.244140625,
-0.108154296875,
-0.70263671875,
-0.03363037109375,
0.465576171875,
-0.452880859375,
-0.1719970703125,
-0.386474609375,
-0.1209716796875,
-0.3408203125,
-0.376220703125,
-0.323486328125,
0.73583984375,
0.88037109375,
0.82177734375,
0.025634765625,
0.1348876953125,
-0.2529296875,
-0.0830078125,
-0.20458984375,
-0.82666015625,
0.31298828125,
0.240478515625,
-0.365478515625,
0.01036834716796875,
0.321044921875,
-0.025848388671875,
0.373291015625,
1.265625,
-0.192138671875,
0.246826171875,
0.06317138671875,
-0.6240234375,
0.86181640625,
-0.0745849609375,
-1.26953125,
-0.4462890625,
0.67236328125,
-0.1912841796875,
0.58544921875,
0.27783203125,
-0.9970703125,
-1.11328125,
-0.82373046875,
0.484375,
-0.7177734375,
-0.10601806640625,
-0.986328125,
-0.31005859375,
-0.2958984375,
0.61962890625,
-0.1968994140625,
-0.30859375,
0.04150390625,
-1.12890625,
0.08990478515625,
-0.373046875,
-0.658203125,
-0.94775390625,
-0.5244140625,
-0.34228515625,
0.79150390625,
0.28515625,
-0.115234375,
0.032073974609375,
0.1728515625,
0.07861328125,
-0.082763671875,
-0.84375,
-0.2384033203125,
-0.40478515625,
0.22314453125,
-0.1116943359375,
-0.4423828125,
-0.78515625,
0.8056640625,
-0.384033203125,
0.287109375,
0.06396484375,
-0.6064453125,
-0.1622314453125,
-0.303955078125,
1.087890625,
-0.456298828125,
0.1572265625,
-0.6767578125,
0.7705078125,
0.55224609375,
-0.6005859375,
-0.25146484375,
-0.7177734375,
-0.58251953125,
-1.416015625,
0.6318359375,
-0.455322265625,
0.357421875,
-0.56787109375,
-0.43603515625,
1.0546875,
-0.42236328125,
0.433837890625,
0.9248046875,
-0.1287841796875,
-0.120361328125,
-0.91162109375,
0.771484375,
0.454345703125,
-0.457275390625,
-0.1607666015625,
-0.339111328125,
-0.85205078125,
0.18603515625,
-0.27880859375,
-0.92626953125,
-0.626953125,
0.6591796875,
1.5126953125,
-0.2568359375,
0.388671875,
0.24560546875,
-0.76123046875,
-0.57763671875,
0.56640625,
0.1436767578125,
0.012176513671875,
0.65478515625,
-0.2203369140625,
0.0628662109375,
0.14794921875,
0.000013947486877441406,
-0.311767578125,
-0.468505859375,
1.2138671875,
-0.2568359375,
-0.5615234375,
1.1279296875,
0.943359375,
-0.8935546875,
-0.59228515625,
-0.143798828125,
0.1077880859375,
-0.13623046875,
-0.701171875,
0.034454345703125,
0.6640625,
-0.96728515625,
-0.115234375,
0.32177734375,
-0.0027618408203125,
0.464111328125,
0.4423828125,
0.405029296875,
-0.252197265625,
0.349609375,
0.48486328125,
-0.71826171875,
-0.33056640625,
-1.1337890625,
0.451904296875,
-0.006114959716796875,
0.50341796875,
0.388427734375,
-0.47998046875,
0.30078125,
0.26171875,
-0.07562255859375,
1.0126953125,
-0.299560546875,
-0.302490234375,
0.03814697265625,
-0.91552734375,
-0.7421875,
0.1962890625,
0.45263671875,
-0.328857421875,
0.10333251953125,
-0.6552734375,
0.10736083984375,
0.1060791015625,
0.27490234375,
-0.0078125,
-0.6904296875,
0.1317138671875,
-0.67578125,
-0.37451171875,
-0.96875,
-0.72705078125,
0.039886474609375,
0.1229248046875,
-0.6318359375,
-0.5791015625,
0.52001953125,
0.443603515625,
-0.7236328125,
1.2607421875,
-0.7666015625,
0.460693359375,
-0.99267578125,
-0.047882080078125,
-0.7529296875,
-0.2158203125,
-0.252685546875,
-0.26220703125,
-0.219970703125,
0.2010498046875,
0.0791015625,
0.364501953125,
0.197509765625,
0.6904296875,
-0.6064453125,
-0.32470703125,
0.0165252685546875,
0.206298828125,
-0.50927734375,
0.802734375,
0.55322265625,
0.22265625,
0.19873046875,
-0.12939453125,
-0.8662109375,
0.15966796875,
0.1915283203125,
0.8193359375,
0.24951171875,
0.2138671875,
-0.51123046875,
-0.07647705078125,
-0.77734375,
0.11834716796875,
-0.2509765625,
0.20166015625,
0.318115234375,
-0.6376953125,
0.4033203125,
1.2646484375,
-0.225341796875,
0.003246307373046875,
0.172607421875,
0.29345703125,
0.27685546875,
0.407470703125,
-0.186279296875,
0.3955078125,
0.55712890625,
-0.321533203125,
-0.58837890625,
0.5126953125,
-0.070556640625,
0.1480712890625,
-0.49462890625,
-0.66650390625,
-0.91162109375,
0.0202484130859375,
0.09521484375,
0.0170440673828125,
0.7216796875,
-0.62109375,
0.1541748046875,
0.02764892578125,
-0.229248046875,
0.331787109375,
-0.92919921875,
-0.67041015625,
0.2393798828125,
-0.121826171875,
-0.70263671875,
-0.13623046875,
-0.411376953125,
-0.1834716796875,
0.27587890625,
0.148193359375,
-0.416259765625,
0.45361328125,
-0.2900390625,
0.333251953125,
-0.53857421875,
0.10186767578125,
0.176025390625,
0.424560546875,
-0.270263671875,
-0.10687255859375,
0.1380615234375,
1.203125,
-0.1385498046875,
0.216796875,
-0.8134765625,
-0.0545654296875,
-0.23388671875,
0.275146484375,
-0.6181640625,
0.2191162109375,
-0.270263671875,
0.50341796875,
-1.0283203125,
-0.363037109375,
0.2264404296875,
0.305908203125,
0.391845703125,
-0.45458984375,
-0.69482421875,
1.123046875,
0.73388671875,
0.06536865234375,
0.53466796875,
0.354248046875,
0.5986328125,
-0.283447265625,
-0.0325927734375,
-0.420166015625,
0.334228515625,
0.5029296875,
0.370849609375,
-0.53076171875,
0.62451171875,
0.6484375,
-0.10357666015625,
-0.0579833984375,
0.33642578125,
-0.12060546875,
0.1683349609375,
0.1656494140625,
-0.08984375,
-0.1207275390625,
0.1217041015625,
-0.6044921875,
0.51806640625,
-0.1851806640625,
-0.1591796875,
-0.681640625,
-0.80126953125,
0.67724609375,
-0.281982421875,
-0.248291015625,
-0.10595703125,
-0.25,
0.33447265625,
0.77490234375,
0.01548004150390625,
-0.057586669921875,
0.69580078125,
0.8310546875,
0.252685546875,
1.0009765625,
0.446533203125,
0.1324462890625,
-0.26123046875,
0.444091796875,
0.345703125,
0.07318115234375,
0.0290069580078125,
-0.256103515625,
-0.94873046875,
0.73388671875,
-0.03948974609375,
-0.548828125,
0.52978515625,
-0.69482421875,
0.242431640625,
-0.28564453125,
0.42626953125,
-0.68212890625,
0.354736328125,
0.340087890625,
-0.389404296875,
-0.412109375,
0.8349609375,
-0.187744140625,
0.5380859375,
0.06463623046875,
0.8720703125,
-0.03607177734375,
1.705078125,
0.72265625,
-0.05963134765625,
0.490234375,
0.431396484375,
-0.36279296875,
-0.4853515625,
-0.2449951171875,
-0.56494140625,
-0.51806640625,
-0.39306640625,
-0.365234375,
0.0162200927734375,
0.93115234375,
0.1390380859375,
-0.861328125,
-0.4619140625,
-0.00620269775390625,
-0.283447265625,
0.364013671875,
0.529296875,
0.171630859375,
-0.10638427734375,
0.10223388671875,
-0.29052734375,
-0.46875,
0.06805419921875,
-0.52783203125,
0.38525390625,
-0.70947265625,
-0.71923828125,
-1.0986328125,
-0.99169921875,
-0.19677734375,
0.2880859375,
-0.4521484375,
-0.72802734375,
0.5908203125,
0.473876953125,
0.4853515625,
0.053375244140625,
-0.105224609375,
0.032135009765625,
0.66259765625,
0.83642578125,
-0.0189208984375,
0.496337890625,
0.353759765625,
-0.05853271484375,
0.138916015625,
-0.66455078125,
0.61962890625,
0.1302490234375,
0.08087158203125,
-0.3525390625,
0.2159423828125,
-0.91064453125,
-1.5126953125,
-0.2174072265625,
0.10595703125,
0.163330078125,
-0.828125,
-1.1669921875,
-0.395263671875,
-0.73681640625,
-0.1656494140625,
-0.11785888671875,
0.796875,
-0.0166473388671875,
0.01296234130859375,
-0.272705078125,
-1.041015625,
4.359375,
1.4033203125,
1.021484375,
-0.0192718505859375,
0.5341796875,
1.26171875,
0.4326171875,
-0.89697265625,
-0.4208984375,
-0.1259765625,
0.373291015625,
-0.350830078125,
-0.2110595703125,
0.53955078125,
0.0948486328125,
0.499755859375,
-0.68701171875,
-0.006351470947265625,
-0.317138671875,
-0.76220703125,
-0.84228515625,
0.1541748046875,
-0.1436767578125,
0.21533203125,
0.1531982421875,
0.423095703125,
0.76318359375,
-0.66064453125,
0.12298583984375,
-0.6103515625,
-0.2005615234375,
-0.287841796875,
0.9541015625,
0.2467041015625,
-0.14111328125,
0.4794921875,
-0.01551055908203125,
-0.7275390625,
0.00786590576171875,
0.21240234375,
-0.5087890625,
-0.164794921875,
1.107421875,
-0.4365234375,
0.108642578125,
0.228759765625,
-0.57177734375,
0.378662109375,
0.184326171875,
-0.68798828125,
1.01171875,
-0.1533203125,
0.49658203125,
-0.80712890625,
-0.2939453125,
0.2626953125,
0.52392578125,
0.035919189453125,
-0.0445556640625,
0.318359375,
0.474853515625,
0.07318115234375,
0.465087890625,
0.4912109375,
-0.69287109375,
0.91015625,
-0.472412109375,
0.2431640625,
-0.80126953125,
-0.05584716796875,
-0.1575927734375,
-0.08001708984375,
-0.5458984375,
-0.39453125,
0.92138671875,
0.257568359375,
-0.09033203125,
0.2457275390625,
0.197021484375,
-0.77685546875,
0.1968994140625,
-0.1688232421875,
-0.0867919921875,
0.034912109375,
0.230712890625,
1.5068359375,
-0.323974609375,
-0.07861328125,
-0.25732421875,
0.666015625,
0.492431640625,
0.441650390625,
-0.181640625,
-0.69775390625,
-0.370849609375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Tags: implementation, strings
Correct Solution:
```
import math
n = int(input())
w = list(input())
e = []
if n % 2 == 0:
s = 1
else:
s = 0
for x in range(0, n):
if s == 1:
e.insert(math.floor(len(e) / 2) - x - x, w[x])
s = 0
elif s == 0:
e.insert(math.floor(len(e) / 2) + x + x, w[x])
s = 1
print(''.join(e))
```
| 72,175 | [
0.63134765625,
-0.298828125,
0.24462890625,
0.392333984375,
-0.52001953125,
-0.60546875,
0.1495361328125,
-0.10498046875,
-0.384033203125,
0.75537109375,
1.01171875,
-0.2279052734375,
-0.040496826171875,
-0.62060546875,
-0.908203125,
-0.5302734375,
-0.389892578125,
-0.54248046875,
-0.71337890625,
0.180419921875,
0.2275390625,
0.062347412109375,
-1.166015625,
-0.179443359375,
-0.3798828125,
1.1328125,
0.62646484375,
-0.2425537109375,
1.2294921875,
0.96484375,
0.005275726318359375,
0.072998046875,
0.76513671875,
-1.1875,
-0.35400390625,
-0.2393798828125,
0.69287109375,
-0.337646484375,
-0.281005859375,
-0.347412109375,
0.2442626953125,
-0.33447265625,
0.41552734375,
-0.62109375,
-0.86083984375,
-0.0611572265625,
-0.313720703125,
-0.91015625,
-0.3544921875,
-0.9091796875,
0.126953125,
-0.3642578125,
0.55517578125,
-0.28466796875,
-0.17822265625,
-0.27880859375,
-0.1533203125,
-0.0170745849609375,
-0.344482421875,
0.333251953125,
0.392822265625,
0.401123046875,
0.1619873046875,
-1.021484375,
-0.28759765625,
-0.342041015625,
-0.09710693359375,
-0.1448974609375,
0.003894805908203125,
-0.7060546875,
-0.155029296875,
0.50927734375,
-0.1749267578125,
-0.67333984375,
-0.368896484375,
0.12091064453125,
0.279052734375,
0.2001953125,
-0.74755859375,
0.93798828125,
0.11688232421875,
0.8564453125,
0.6865234375,
0.433837890625,
-0.53662109375,
-0.240478515625,
0.0413818359375,
0.379638671875,
0.103515625,
-0.022552490234375,
0.09234619140625,
0.5166015625,
-0.258544921875,
0.1865234375,
0.493408203125,
0.61767578125,
0.02203369140625,
0.35107421875,
0.061279296875,
0.6025390625,
0.78662109375,
1.3701171875,
-0.2578125,
1.064453125,
-0.464599609375,
0.572265625,
0.161865234375,
0.26513671875,
-0.33203125,
0.112060546875,
-0.451416015625,
-0.1322021484375,
0.018310546875,
-0.36279296875,
-0.197998046875,
0.96630859375,
-0.1282958984375,
0.2144775390625,
-0.9130859375,
0.427978515625,
0.357177734375,
0.25830078125,
0.4013671875,
-0.342529296875,
0.2451171875,
-0.360595703125,
-0.64453125,
1.11328125,
-0.486328125,
-0.445068359375,
0.1773681640625,
0.328857421875,
-0.364990234375,
0.1995849609375,
0.33544921875,
0.7001953125,
0.1629638671875,
0.474609375,
0.80615234375,
-0.261474609375,
0.30615234375,
0.1793212890625,
-0.343017578125,
1.4375,
-0.14111328125,
-0.2685546875,
0.467529296875,
0.275390625,
-0.8525390625,
0.62744140625,
-0.783203125,
0.42578125,
-0.160888671875,
0.302734375,
-0.30419921875,
0.0269317626953125,
-0.28076171875,
0.6689453125,
-0.0477294921875,
0.057861328125,
-0.354248046875,
-0.2454833984375,
-0.35693359375,
0.8671875,
-0.64111328125,
1.3173828125,
-0.974609375,
-0.60986328125,
-0.474365234375,
-0.248291015625,
0.439697265625,
-0.10064697265625,
-0.10833740234375,
0.66845703125,
0.393310546875,
0.85107421875,
0.6640625,
-0.43115234375,
0.384765625,
0.057861328125,
0.11328125,
0.295166015625,
0.315673828125,
0.69189453125,
0.1661376953125,
-0.05206298828125,
0.0982666015625,
-0.505859375,
-0.67724609375,
-0.307861328125,
-0.1531982421875,
0.81787109375,
-0.3544921875,
-0.1859130859375,
-0.345947265625,
-0.326171875,
-0.72705078125,
-0.385986328125,
-0.07550048828125,
-0.99951171875,
-0.321044921875,
0.83447265625,
-0.295166015625,
0.54443359375,
-0.449951171875,
-0.62451171875,
0.337158203125,
1.15234375,
-0.253662109375,
-0.2734375,
0.99169921875,
0.2337646484375,
-0.45751953125,
0.319091796875,
0.17333984375,
0.1693115234375,
-0.80712890625,
0.68310546875,
-0.479736328125,
0.0965576171875,
-0.2340087890625,
0.7783203125,
0.2003173828125,
0.421142578125,
-0.482421875,
0.087646484375,
0.8232421875,
1.017578125,
-0.01456451416015625,
0.301025390625,
0.31103515625,
0.443359375,
0.234619140625,
0.63232421875,
0.7626953125,
0.4287109375,
0.57861328125,
0.833984375,
-0.1622314453125,
0.239990234375,
-0.03582763671875,
0.408935546875,
0.85498046875,
0.046295166015625,
0.123046875,
0.533203125,
-0.50537109375,
-0.10980224609375,
-0.409423828125,
0.1092529296875,
-0.38037109375,
0.00867462158203125,
0.2783203125,
0.146728515625,
-0.46044921875,
-0.33935546875,
0.4111328125,
0.69580078125,
-0.611328125,
-0.54541015625,
0.2073974609375,
0.2392578125,
0.5380859375,
0.4248046875,
0.41455078125,
0.74853515625,
0.68798828125,
0.452880859375,
-0.288330078125,
-0.623046875,
-0.67041015625,
-1.4599609375,
-1.025390625,
-0.2587890625,
-0.822265625,
0.09326171875,
0.05255126953125,
-1.0712890625,
-0.15283203125,
-0.309326171875,
-0.6123046875,
-0.402099609375,
-0.37060546875,
0.56201171875,
-0.1190185546875,
0.69140625,
-0.440673828125,
0.509765625,
0.0728759765625,
1.1396484375,
-0.544921875,
-0.1920166015625,
-0.25634765625,
-0.5478515625,
0.30419921875,
-0.138427734375,
0.5087890625,
-0.41552734375,
-0.8525390625,
-0.58154296875,
-0.68798828125,
0.10662841796875,
-0.449951171875,
0.033599853515625,
-0.408203125,
0.900390625,
0.37451171875,
-0.5546875,
0.333251953125,
0.94287109375,
-0.86669921875,
0.330078125,
0.298828125,
-0.265380859375,
-0.7685546875,
1.4287109375,
0.412109375,
0.52197265625,
-0.436279296875,
-0.170166015625,
-0.0953369140625,
0.189697265625,
-0.06524658203125,
-0.450439453125,
-0.381591796875,
0.61669921875,
0.04669189453125,
-1.3837890625,
0.11834716796875,
-1.0419921875,
-0.74365234375,
-0.350341796875,
-0.57177734375,
0.78759765625,
0.94873046875,
0.489990234375,
-0.285400390625,
0.069580078125,
0.10333251953125,
0.38134765625,
0.2213134765625,
-0.394287109375,
0.09478759765625,
0.65283203125,
-0.2198486328125,
0.195068359375,
0.64697265625,
-0.1964111328125,
-0.30615234375,
0.16357421875,
0.0679931640625,
0.06591796875,
0.039031982421875,
-0.05145263671875,
0.1768798828125,
0.4638671875,
-1.181640625,
0.049713134765625,
-0.6455078125,
0.455810546875,
0.28564453125,
0.4384765625,
0.12225341796875,
-0.515625,
-0.56689453125,
-1.0419921875,
0.327880859375,
0.6806640625,
0.285400390625,
-0.423828125,
1.025390625,
0.408935546875,
-0.5751953125,
0.212646484375,
-0.7412109375,
0.1697998046875,
0.75390625,
-0.2958984375,
0.734375,
-1.251953125,
0.51708984375,
0.00946044921875,
-0.40869140625,
0.193115234375,
0.22021484375,
0.662109375,
-0.282958984375,
-0.17138671875,
0.0980224609375,
-0.4609375,
0.1796875,
-0.293212890625,
0.361083984375,
-0.237548828125,
-0.99267578125,
-0.94775390625,
0.92236328125,
0.83154296875,
0.432861328125,
0.28564453125,
0.6962890625,
0.43603515625,
0.378662109375,
0.513671875,
0.06329345703125,
-0.11492919921875,
-0.52880859375,
1.0673828125,
0.25,
-0.39306640625,
-0.74609375,
-0.420166015625,
-0.01259613037109375,
0.47265625,
0.1334228515625,
0.382568359375,
-0.923828125,
0.05450439453125,
0.434326171875,
0.8173828125,
-0.97705078125,
-0.051727294921875,
-0.0261383056640625,
0.40869140625,
0.1639404296875,
-0.8037109375,
0.26220703125,
-0.7998046875,
0.576171875,
0.48486328125,
0.2196044921875,
-0.367919921875,
-0.216064453125,
-0.8466796875,
-0.32470703125,
0.490966796875,
0.33544921875,
-0.26708984375,
0.552734375,
-1.03515625,
1.1943359375,
0.28466796875,
-0.16650390625,
0.06536865234375,
-0.1527099609375,
0.63134765625,
0.2109375,
0.66064453125,
-0.474365234375,
-0.55859375,
0.3193359375,
-1.037109375,
0.2247314453125,
-0.2459716796875,
0.38916015625,
-0.1650390625,
0.005207061767578125,
0.0009870529174804688,
0.1260986328125,
-0.54736328125,
0.2164306640625,
-0.07586669921875,
0.29345703125,
-1.1708984375,
-0.9853515625,
0.3525390625,
-0.18017578125,
-0.17529296875,
0.59228515625,
-0.04547119140625,
-0.287353515625,
-0.1407470703125,
0.212646484375,
-0.64453125,
0.4384765625,
-0.59765625,
0.259033203125,
-0.318115234375,
-0.25927734375,
0.07232666015625,
-0.3447265625,
0.666015625,
-0.279296875,
-0.578125,
-0.36279296875,
-1.2041015625,
-0.254150390625,
-0.09912109375,
-0.73095703125,
-0.0289459228515625,
0.447021484375,
-0.465087890625,
-0.179931640625,
-0.389404296875,
-0.10552978515625,
-0.32373046875,
-0.35302734375,
-0.294189453125,
0.7314453125,
0.888671875,
0.81640625,
0.01482391357421875,
0.1507568359375,
-0.244140625,
-0.0806884765625,
-0.1982421875,
-0.85302734375,
0.33203125,
0.2208251953125,
-0.36181640625,
0.00876617431640625,
0.322509765625,
-0.033843994140625,
0.36865234375,
1.2646484375,
-0.178466796875,
0.2464599609375,
0.06451416015625,
-0.59619140625,
0.87158203125,
-0.08111572265625,
-1.2578125,
-0.4638671875,
0.68408203125,
-0.1954345703125,
0.5771484375,
0.2435302734375,
-1.001953125,
-1.09375,
-0.81689453125,
0.489501953125,
-0.7099609375,
-0.10308837890625,
-0.97314453125,
-0.303466796875,
-0.28515625,
0.640625,
-0.2041015625,
-0.308349609375,
0.051025390625,
-1.1103515625,
0.0821533203125,
-0.361328125,
-0.654296875,
-0.93212890625,
-0.52978515625,
-0.355224609375,
0.8095703125,
0.285400390625,
-0.10699462890625,
0.040771484375,
0.1705322265625,
0.0972900390625,
-0.11328125,
-0.83740234375,
-0.249755859375,
-0.4130859375,
0.217041015625,
-0.08770751953125,
-0.438720703125,
-0.7724609375,
0.81005859375,
-0.382568359375,
0.281494140625,
0.063232421875,
-0.6171875,
-0.1461181640625,
-0.314453125,
1.0576171875,
-0.47216796875,
0.1544189453125,
-0.68310546875,
0.75341796875,
0.5478515625,
-0.6142578125,
-0.24169921875,
-0.73388671875,
-0.58349609375,
-1.4306640625,
0.63916015625,
-0.45751953125,
0.382568359375,
-0.60205078125,
-0.4541015625,
1.0576171875,
-0.41259765625,
0.42822265625,
0.91064453125,
-0.119873046875,
-0.1142578125,
-0.92626953125,
0.76171875,
0.43505859375,
-0.446533203125,
-0.1678466796875,
-0.35302734375,
-0.83447265625,
0.19287109375,
-0.256103515625,
-0.9287109375,
-0.60595703125,
0.6806640625,
1.494140625,
-0.263671875,
0.38525390625,
0.2208251953125,
-0.765625,
-0.580078125,
0.544921875,
0.161376953125,
0.02423095703125,
0.65673828125,
-0.2191162109375,
0.076416015625,
0.163330078125,
0.005126953125,
-0.3134765625,
-0.455322265625,
1.1962890625,
-0.2568359375,
-0.572265625,
1.1162109375,
0.92333984375,
-0.859375,
-0.5810546875,
-0.10601806640625,
0.1241455078125,
-0.15234375,
-0.6796875,
0.05047607421875,
0.66064453125,
-0.96337890625,
-0.11627197265625,
0.288818359375,
-0.007419586181640625,
0.455322265625,
0.43798828125,
0.41015625,
-0.2401123046875,
0.335693359375,
0.48583984375,
-0.72509765625,
-0.326171875,
-1.10546875,
0.425537109375,
0.0054931640625,
0.50439453125,
0.40625,
-0.49658203125,
0.318359375,
0.25634765625,
-0.053924560546875,
0.99853515625,
-0.28662109375,
-0.290283203125,
0.0316162109375,
-0.9169921875,
-0.7451171875,
0.2039794921875,
0.445068359375,
-0.323974609375,
0.0841064453125,
-0.64697265625,
0.1260986328125,
0.09783935546875,
0.277099609375,
-0.023712158203125,
-0.6904296875,
0.11187744140625,
-0.6611328125,
-0.405517578125,
-0.97607421875,
-0.73486328125,
0.053192138671875,
0.12841796875,
-0.626953125,
-0.5859375,
0.51318359375,
0.46240234375,
-0.72412109375,
1.2666015625,
-0.75634765625,
0.467529296875,
-0.9921875,
-0.049407958984375,
-0.74853515625,
-0.2320556640625,
-0.229736328125,
-0.26025390625,
-0.25927734375,
0.2008056640625,
0.10137939453125,
0.354736328125,
0.21044921875,
0.67236328125,
-0.63330078125,
-0.3408203125,
0.0224609375,
0.203125,
-0.513671875,
0.7724609375,
0.55126953125,
0.223876953125,
0.205322265625,
-0.1168212890625,
-0.87841796875,
0.164794921875,
0.19287109375,
0.81884765625,
0.2398681640625,
0.2274169921875,
-0.51611328125,
-0.060546875,
-0.76025390625,
0.1370849609375,
-0.259765625,
0.1995849609375,
0.326416015625,
-0.6298828125,
0.367919921875,
1.26171875,
-0.215087890625,
-0.0195465087890625,
0.177734375,
0.28076171875,
0.25341796875,
0.410400390625,
-0.1572265625,
0.361083984375,
0.5751953125,
-0.332763671875,
-0.5673828125,
0.5107421875,
-0.06512451171875,
0.1378173828125,
-0.485595703125,
-0.6767578125,
-0.9013671875,
0.006931304931640625,
0.07440185546875,
0.01983642578125,
0.71337890625,
-0.62841796875,
0.1461181640625,
0.04034423828125,
-0.218994140625,
0.33935546875,
-0.9189453125,
-0.65869140625,
0.27294921875,
-0.1417236328125,
-0.69677734375,
-0.11773681640625,
-0.41796875,
-0.1798095703125,
0.2744140625,
0.13525390625,
-0.427734375,
0.481689453125,
-0.27783203125,
0.322509765625,
-0.53369140625,
0.10150146484375,
0.18505859375,
0.452880859375,
-0.256591796875,
-0.128173828125,
0.1422119140625,
1.2080078125,
-0.11212158203125,
0.2169189453125,
-0.81640625,
-0.06781005859375,
-0.2493896484375,
0.2978515625,
-0.6220703125,
0.2012939453125,
-0.2802734375,
0.5078125,
-1.021484375,
-0.362060546875,
0.239013671875,
0.2841796875,
0.395751953125,
-0.438232421875,
-0.69921875,
1.1171875,
0.7509765625,
0.0733642578125,
0.5458984375,
0.392333984375,
0.6103515625,
-0.291259765625,
-0.033355712890625,
-0.417236328125,
0.351806640625,
0.50927734375,
0.362548828125,
-0.5380859375,
0.60400390625,
0.6513671875,
-0.069580078125,
-0.0797119140625,
0.3125,
-0.14111328125,
0.1761474609375,
0.157958984375,
-0.0723876953125,
-0.15185546875,
0.1279296875,
-0.62109375,
0.5244140625,
-0.1728515625,
-0.1580810546875,
-0.66455078125,
-0.77294921875,
0.669921875,
-0.30224609375,
-0.23681640625,
-0.12127685546875,
-0.256591796875,
0.331787109375,
0.77294921875,
0.040313720703125,
-0.05859375,
0.67724609375,
0.80908203125,
0.24853515625,
1.0029296875,
0.45361328125,
0.1376953125,
-0.249755859375,
0.4345703125,
0.3427734375,
0.07757568359375,
0.01142120361328125,
-0.269775390625,
-0.9482421875,
0.75048828125,
-0.0281982421875,
-0.537109375,
0.52490234375,
-0.68994140625,
0.224609375,
-0.28466796875,
0.4072265625,
-0.693359375,
0.341064453125,
0.322509765625,
-0.40673828125,
-0.418701171875,
0.83837890625,
-0.1844482421875,
0.52978515625,
0.0552978515625,
0.84423828125,
-0.03607177734375,
1.7001953125,
0.7158203125,
-0.0540771484375,
0.47119140625,
0.421142578125,
-0.36572265625,
-0.467529296875,
-0.271484375,
-0.56396484375,
-0.529296875,
-0.3505859375,
-0.364501953125,
0.036041259765625,
0.90576171875,
0.1414794921875,
-0.875,
-0.45556640625,
0.0212554931640625,
-0.25341796875,
0.348876953125,
0.53369140625,
0.1898193359375,
-0.11273193359375,
0.10797119140625,
-0.295654296875,
-0.46826171875,
0.05706787109375,
-0.5439453125,
0.376220703125,
-0.7001953125,
-0.70947265625,
-1.076171875,
-1.0009765625,
-0.1773681640625,
0.275390625,
-0.4228515625,
-0.74365234375,
0.60302734375,
0.4619140625,
0.47314453125,
0.0465087890625,
-0.11181640625,
0.01306915283203125,
0.67431640625,
0.83837890625,
-0.0386962890625,
0.482421875,
0.3779296875,
-0.042510986328125,
0.12493896484375,
-0.662109375,
0.62353515625,
0.1387939453125,
0.08251953125,
-0.35107421875,
0.2015380859375,
-0.912109375,
-1.5,
-0.2059326171875,
0.10247802734375,
0.17333984375,
-0.8212890625,
-1.1669921875,
-0.3974609375,
-0.7265625,
-0.15380859375,
-0.1112060546875,
0.75927734375,
0.022369384765625,
0.008941650390625,
-0.249267578125,
-1.0283203125,
4.375,
1.4208984375,
1.0263671875,
-0.0006575584411621094,
0.55419921875,
1.248046875,
0.435791015625,
-0.9033203125,
-0.439208984375,
-0.1402587890625,
0.37109375,
-0.342529296875,
-0.177490234375,
0.5126953125,
0.08673095703125,
0.48388671875,
-0.6826171875,
-0.0031871795654296875,
-0.314208984375,
-0.75732421875,
-0.85107421875,
0.15625,
-0.1595458984375,
0.2261962890625,
0.1612548828125,
0.41455078125,
0.77880859375,
-0.6591796875,
0.1175537109375,
-0.5986328125,
-0.19189453125,
-0.289794921875,
0.95947265625,
0.266357421875,
-0.1619873046875,
0.48193359375,
-0.05914306640625,
-0.7431640625,
0.01053619384765625,
0.2025146484375,
-0.50634765625,
-0.1522216796875,
1.1171875,
-0.44140625,
0.11602783203125,
0.2294921875,
-0.57421875,
0.369384765625,
0.1795654296875,
-0.68115234375,
1.0263671875,
-0.1597900390625,
0.48095703125,
-0.814453125,
-0.276123046875,
0.248046875,
0.52587890625,
0.028839111328125,
-0.033203125,
0.31201171875,
0.492919921875,
0.0518798828125,
0.4814453125,
0.4814453125,
-0.69384765625,
0.91064453125,
-0.466796875,
0.2430419921875,
-0.7880859375,
-0.041412353515625,
-0.169921875,
-0.08612060546875,
-0.5283203125,
-0.375,
0.92626953125,
0.253662109375,
-0.1146240234375,
0.23876953125,
0.153564453125,
-0.76123046875,
0.2073974609375,
-0.16455078125,
-0.0750732421875,
0.05865478515625,
0.2186279296875,
1.5234375,
-0.34619140625,
-0.0770263671875,
-0.273681640625,
0.6689453125,
0.49169921875,
0.419189453125,
-0.180908203125,
-0.6904296875,
-0.34326171875
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Tags: implementation, strings
Correct Solution:
```
import math
n = int(input())
s = input()
s = list(s)
s.reverse()
s1 = []
for i in s:
if (len(s1) % 2 == 0):
s1.insert(len(s1) // 2, i)
else:
s1.insert(math.ceil(len(s1) / 2), i)
s1.reverse()
q = ''
for i in s1:
q += i
print(q)
```
| 72,176 | [
0.63134765625,
-0.298828125,
0.24462890625,
0.392333984375,
-0.52001953125,
-0.60546875,
0.1495361328125,
-0.10498046875,
-0.384033203125,
0.75537109375,
1.01171875,
-0.2279052734375,
-0.040496826171875,
-0.62060546875,
-0.908203125,
-0.5302734375,
-0.389892578125,
-0.54248046875,
-0.71337890625,
0.180419921875,
0.2275390625,
0.062347412109375,
-1.166015625,
-0.179443359375,
-0.3798828125,
1.1328125,
0.62646484375,
-0.2425537109375,
1.2294921875,
0.96484375,
0.005275726318359375,
0.072998046875,
0.76513671875,
-1.1875,
-0.35400390625,
-0.2393798828125,
0.69287109375,
-0.337646484375,
-0.281005859375,
-0.347412109375,
0.2442626953125,
-0.33447265625,
0.41552734375,
-0.62109375,
-0.86083984375,
-0.0611572265625,
-0.313720703125,
-0.91015625,
-0.3544921875,
-0.9091796875,
0.126953125,
-0.3642578125,
0.55517578125,
-0.28466796875,
-0.17822265625,
-0.27880859375,
-0.1533203125,
-0.0170745849609375,
-0.344482421875,
0.333251953125,
0.392822265625,
0.401123046875,
0.1619873046875,
-1.021484375,
-0.28759765625,
-0.342041015625,
-0.09710693359375,
-0.1448974609375,
0.003894805908203125,
-0.7060546875,
-0.155029296875,
0.50927734375,
-0.1749267578125,
-0.67333984375,
-0.368896484375,
0.12091064453125,
0.279052734375,
0.2001953125,
-0.74755859375,
0.93798828125,
0.11688232421875,
0.8564453125,
0.6865234375,
0.433837890625,
-0.53662109375,
-0.240478515625,
0.0413818359375,
0.379638671875,
0.103515625,
-0.022552490234375,
0.09234619140625,
0.5166015625,
-0.258544921875,
0.1865234375,
0.493408203125,
0.61767578125,
0.02203369140625,
0.35107421875,
0.061279296875,
0.6025390625,
0.78662109375,
1.3701171875,
-0.2578125,
1.064453125,
-0.464599609375,
0.572265625,
0.161865234375,
0.26513671875,
-0.33203125,
0.112060546875,
-0.451416015625,
-0.1322021484375,
0.018310546875,
-0.36279296875,
-0.197998046875,
0.96630859375,
-0.1282958984375,
0.2144775390625,
-0.9130859375,
0.427978515625,
0.357177734375,
0.25830078125,
0.4013671875,
-0.342529296875,
0.2451171875,
-0.360595703125,
-0.64453125,
1.11328125,
-0.486328125,
-0.445068359375,
0.1773681640625,
0.328857421875,
-0.364990234375,
0.1995849609375,
0.33544921875,
0.7001953125,
0.1629638671875,
0.474609375,
0.80615234375,
-0.261474609375,
0.30615234375,
0.1793212890625,
-0.343017578125,
1.4375,
-0.14111328125,
-0.2685546875,
0.467529296875,
0.275390625,
-0.8525390625,
0.62744140625,
-0.783203125,
0.42578125,
-0.160888671875,
0.302734375,
-0.30419921875,
0.0269317626953125,
-0.28076171875,
0.6689453125,
-0.0477294921875,
0.057861328125,
-0.354248046875,
-0.2454833984375,
-0.35693359375,
0.8671875,
-0.64111328125,
1.3173828125,
-0.974609375,
-0.60986328125,
-0.474365234375,
-0.248291015625,
0.439697265625,
-0.10064697265625,
-0.10833740234375,
0.66845703125,
0.393310546875,
0.85107421875,
0.6640625,
-0.43115234375,
0.384765625,
0.057861328125,
0.11328125,
0.295166015625,
0.315673828125,
0.69189453125,
0.1661376953125,
-0.05206298828125,
0.0982666015625,
-0.505859375,
-0.67724609375,
-0.307861328125,
-0.1531982421875,
0.81787109375,
-0.3544921875,
-0.1859130859375,
-0.345947265625,
-0.326171875,
-0.72705078125,
-0.385986328125,
-0.07550048828125,
-0.99951171875,
-0.321044921875,
0.83447265625,
-0.295166015625,
0.54443359375,
-0.449951171875,
-0.62451171875,
0.337158203125,
1.15234375,
-0.253662109375,
-0.2734375,
0.99169921875,
0.2337646484375,
-0.45751953125,
0.319091796875,
0.17333984375,
0.1693115234375,
-0.80712890625,
0.68310546875,
-0.479736328125,
0.0965576171875,
-0.2340087890625,
0.7783203125,
0.2003173828125,
0.421142578125,
-0.482421875,
0.087646484375,
0.8232421875,
1.017578125,
-0.01456451416015625,
0.301025390625,
0.31103515625,
0.443359375,
0.234619140625,
0.63232421875,
0.7626953125,
0.4287109375,
0.57861328125,
0.833984375,
-0.1622314453125,
0.239990234375,
-0.03582763671875,
0.408935546875,
0.85498046875,
0.046295166015625,
0.123046875,
0.533203125,
-0.50537109375,
-0.10980224609375,
-0.409423828125,
0.1092529296875,
-0.38037109375,
0.00867462158203125,
0.2783203125,
0.146728515625,
-0.46044921875,
-0.33935546875,
0.4111328125,
0.69580078125,
-0.611328125,
-0.54541015625,
0.2073974609375,
0.2392578125,
0.5380859375,
0.4248046875,
0.41455078125,
0.74853515625,
0.68798828125,
0.452880859375,
-0.288330078125,
-0.623046875,
-0.67041015625,
-1.4599609375,
-1.025390625,
-0.2587890625,
-0.822265625,
0.09326171875,
0.05255126953125,
-1.0712890625,
-0.15283203125,
-0.309326171875,
-0.6123046875,
-0.402099609375,
-0.37060546875,
0.56201171875,
-0.1190185546875,
0.69140625,
-0.440673828125,
0.509765625,
0.0728759765625,
1.1396484375,
-0.544921875,
-0.1920166015625,
-0.25634765625,
-0.5478515625,
0.30419921875,
-0.138427734375,
0.5087890625,
-0.41552734375,
-0.8525390625,
-0.58154296875,
-0.68798828125,
0.10662841796875,
-0.449951171875,
0.033599853515625,
-0.408203125,
0.900390625,
0.37451171875,
-0.5546875,
0.333251953125,
0.94287109375,
-0.86669921875,
0.330078125,
0.298828125,
-0.265380859375,
-0.7685546875,
1.4287109375,
0.412109375,
0.52197265625,
-0.436279296875,
-0.170166015625,
-0.0953369140625,
0.189697265625,
-0.06524658203125,
-0.450439453125,
-0.381591796875,
0.61669921875,
0.04669189453125,
-1.3837890625,
0.11834716796875,
-1.0419921875,
-0.74365234375,
-0.350341796875,
-0.57177734375,
0.78759765625,
0.94873046875,
0.489990234375,
-0.285400390625,
0.069580078125,
0.10333251953125,
0.38134765625,
0.2213134765625,
-0.394287109375,
0.09478759765625,
0.65283203125,
-0.2198486328125,
0.195068359375,
0.64697265625,
-0.1964111328125,
-0.30615234375,
0.16357421875,
0.0679931640625,
0.06591796875,
0.039031982421875,
-0.05145263671875,
0.1768798828125,
0.4638671875,
-1.181640625,
0.049713134765625,
-0.6455078125,
0.455810546875,
0.28564453125,
0.4384765625,
0.12225341796875,
-0.515625,
-0.56689453125,
-1.0419921875,
0.327880859375,
0.6806640625,
0.285400390625,
-0.423828125,
1.025390625,
0.408935546875,
-0.5751953125,
0.212646484375,
-0.7412109375,
0.1697998046875,
0.75390625,
-0.2958984375,
0.734375,
-1.251953125,
0.51708984375,
0.00946044921875,
-0.40869140625,
0.193115234375,
0.22021484375,
0.662109375,
-0.282958984375,
-0.17138671875,
0.0980224609375,
-0.4609375,
0.1796875,
-0.293212890625,
0.361083984375,
-0.237548828125,
-0.99267578125,
-0.94775390625,
0.92236328125,
0.83154296875,
0.432861328125,
0.28564453125,
0.6962890625,
0.43603515625,
0.378662109375,
0.513671875,
0.06329345703125,
-0.11492919921875,
-0.52880859375,
1.0673828125,
0.25,
-0.39306640625,
-0.74609375,
-0.420166015625,
-0.01259613037109375,
0.47265625,
0.1334228515625,
0.382568359375,
-0.923828125,
0.05450439453125,
0.434326171875,
0.8173828125,
-0.97705078125,
-0.051727294921875,
-0.0261383056640625,
0.40869140625,
0.1639404296875,
-0.8037109375,
0.26220703125,
-0.7998046875,
0.576171875,
0.48486328125,
0.2196044921875,
-0.367919921875,
-0.216064453125,
-0.8466796875,
-0.32470703125,
0.490966796875,
0.33544921875,
-0.26708984375,
0.552734375,
-1.03515625,
1.1943359375,
0.28466796875,
-0.16650390625,
0.06536865234375,
-0.1527099609375,
0.63134765625,
0.2109375,
0.66064453125,
-0.474365234375,
-0.55859375,
0.3193359375,
-1.037109375,
0.2247314453125,
-0.2459716796875,
0.38916015625,
-0.1650390625,
0.005207061767578125,
0.0009870529174804688,
0.1260986328125,
-0.54736328125,
0.2164306640625,
-0.07586669921875,
0.29345703125,
-1.1708984375,
-0.9853515625,
0.3525390625,
-0.18017578125,
-0.17529296875,
0.59228515625,
-0.04547119140625,
-0.287353515625,
-0.1407470703125,
0.212646484375,
-0.64453125,
0.4384765625,
-0.59765625,
0.259033203125,
-0.318115234375,
-0.25927734375,
0.07232666015625,
-0.3447265625,
0.666015625,
-0.279296875,
-0.578125,
-0.36279296875,
-1.2041015625,
-0.254150390625,
-0.09912109375,
-0.73095703125,
-0.0289459228515625,
0.447021484375,
-0.465087890625,
-0.179931640625,
-0.389404296875,
-0.10552978515625,
-0.32373046875,
-0.35302734375,
-0.294189453125,
0.7314453125,
0.888671875,
0.81640625,
0.01482391357421875,
0.1507568359375,
-0.244140625,
-0.0806884765625,
-0.1982421875,
-0.85302734375,
0.33203125,
0.2208251953125,
-0.36181640625,
0.00876617431640625,
0.322509765625,
-0.033843994140625,
0.36865234375,
1.2646484375,
-0.178466796875,
0.2464599609375,
0.06451416015625,
-0.59619140625,
0.87158203125,
-0.08111572265625,
-1.2578125,
-0.4638671875,
0.68408203125,
-0.1954345703125,
0.5771484375,
0.2435302734375,
-1.001953125,
-1.09375,
-0.81689453125,
0.489501953125,
-0.7099609375,
-0.10308837890625,
-0.97314453125,
-0.303466796875,
-0.28515625,
0.640625,
-0.2041015625,
-0.308349609375,
0.051025390625,
-1.1103515625,
0.0821533203125,
-0.361328125,
-0.654296875,
-0.93212890625,
-0.52978515625,
-0.355224609375,
0.8095703125,
0.285400390625,
-0.10699462890625,
0.040771484375,
0.1705322265625,
0.0972900390625,
-0.11328125,
-0.83740234375,
-0.249755859375,
-0.4130859375,
0.217041015625,
-0.08770751953125,
-0.438720703125,
-0.7724609375,
0.81005859375,
-0.382568359375,
0.281494140625,
0.063232421875,
-0.6171875,
-0.1461181640625,
-0.314453125,
1.0576171875,
-0.47216796875,
0.1544189453125,
-0.68310546875,
0.75341796875,
0.5478515625,
-0.6142578125,
-0.24169921875,
-0.73388671875,
-0.58349609375,
-1.4306640625,
0.63916015625,
-0.45751953125,
0.382568359375,
-0.60205078125,
-0.4541015625,
1.0576171875,
-0.41259765625,
0.42822265625,
0.91064453125,
-0.119873046875,
-0.1142578125,
-0.92626953125,
0.76171875,
0.43505859375,
-0.446533203125,
-0.1678466796875,
-0.35302734375,
-0.83447265625,
0.19287109375,
-0.256103515625,
-0.9287109375,
-0.60595703125,
0.6806640625,
1.494140625,
-0.263671875,
0.38525390625,
0.2208251953125,
-0.765625,
-0.580078125,
0.544921875,
0.161376953125,
0.02423095703125,
0.65673828125,
-0.2191162109375,
0.076416015625,
0.163330078125,
0.005126953125,
-0.3134765625,
-0.455322265625,
1.1962890625,
-0.2568359375,
-0.572265625,
1.1162109375,
0.92333984375,
-0.859375,
-0.5810546875,
-0.10601806640625,
0.1241455078125,
-0.15234375,
-0.6796875,
0.05047607421875,
0.66064453125,
-0.96337890625,
-0.11627197265625,
0.288818359375,
-0.007419586181640625,
0.455322265625,
0.43798828125,
0.41015625,
-0.2401123046875,
0.335693359375,
0.48583984375,
-0.72509765625,
-0.326171875,
-1.10546875,
0.425537109375,
0.0054931640625,
0.50439453125,
0.40625,
-0.49658203125,
0.318359375,
0.25634765625,
-0.053924560546875,
0.99853515625,
-0.28662109375,
-0.290283203125,
0.0316162109375,
-0.9169921875,
-0.7451171875,
0.2039794921875,
0.445068359375,
-0.323974609375,
0.0841064453125,
-0.64697265625,
0.1260986328125,
0.09783935546875,
0.277099609375,
-0.023712158203125,
-0.6904296875,
0.11187744140625,
-0.6611328125,
-0.405517578125,
-0.97607421875,
-0.73486328125,
0.053192138671875,
0.12841796875,
-0.626953125,
-0.5859375,
0.51318359375,
0.46240234375,
-0.72412109375,
1.2666015625,
-0.75634765625,
0.467529296875,
-0.9921875,
-0.049407958984375,
-0.74853515625,
-0.2320556640625,
-0.229736328125,
-0.26025390625,
-0.25927734375,
0.2008056640625,
0.10137939453125,
0.354736328125,
0.21044921875,
0.67236328125,
-0.63330078125,
-0.3408203125,
0.0224609375,
0.203125,
-0.513671875,
0.7724609375,
0.55126953125,
0.223876953125,
0.205322265625,
-0.1168212890625,
-0.87841796875,
0.164794921875,
0.19287109375,
0.81884765625,
0.2398681640625,
0.2274169921875,
-0.51611328125,
-0.060546875,
-0.76025390625,
0.1370849609375,
-0.259765625,
0.1995849609375,
0.326416015625,
-0.6298828125,
0.367919921875,
1.26171875,
-0.215087890625,
-0.0195465087890625,
0.177734375,
0.28076171875,
0.25341796875,
0.410400390625,
-0.1572265625,
0.361083984375,
0.5751953125,
-0.332763671875,
-0.5673828125,
0.5107421875,
-0.06512451171875,
0.1378173828125,
-0.485595703125,
-0.6767578125,
-0.9013671875,
0.006931304931640625,
0.07440185546875,
0.01983642578125,
0.71337890625,
-0.62841796875,
0.1461181640625,
0.04034423828125,
-0.218994140625,
0.33935546875,
-0.9189453125,
-0.65869140625,
0.27294921875,
-0.1417236328125,
-0.69677734375,
-0.11773681640625,
-0.41796875,
-0.1798095703125,
0.2744140625,
0.13525390625,
-0.427734375,
0.481689453125,
-0.27783203125,
0.322509765625,
-0.53369140625,
0.10150146484375,
0.18505859375,
0.452880859375,
-0.256591796875,
-0.128173828125,
0.1422119140625,
1.2080078125,
-0.11212158203125,
0.2169189453125,
-0.81640625,
-0.06781005859375,
-0.2493896484375,
0.2978515625,
-0.6220703125,
0.2012939453125,
-0.2802734375,
0.5078125,
-1.021484375,
-0.362060546875,
0.239013671875,
0.2841796875,
0.395751953125,
-0.438232421875,
-0.69921875,
1.1171875,
0.7509765625,
0.0733642578125,
0.5458984375,
0.392333984375,
0.6103515625,
-0.291259765625,
-0.033355712890625,
-0.417236328125,
0.351806640625,
0.50927734375,
0.362548828125,
-0.5380859375,
0.60400390625,
0.6513671875,
-0.069580078125,
-0.0797119140625,
0.3125,
-0.14111328125,
0.1761474609375,
0.157958984375,
-0.0723876953125,
-0.15185546875,
0.1279296875,
-0.62109375,
0.5244140625,
-0.1728515625,
-0.1580810546875,
-0.66455078125,
-0.77294921875,
0.669921875,
-0.30224609375,
-0.23681640625,
-0.12127685546875,
-0.256591796875,
0.331787109375,
0.77294921875,
0.040313720703125,
-0.05859375,
0.67724609375,
0.80908203125,
0.24853515625,
1.0029296875,
0.45361328125,
0.1376953125,
-0.249755859375,
0.4345703125,
0.3427734375,
0.07757568359375,
0.01142120361328125,
-0.269775390625,
-0.9482421875,
0.75048828125,
-0.0281982421875,
-0.537109375,
0.52490234375,
-0.68994140625,
0.224609375,
-0.28466796875,
0.4072265625,
-0.693359375,
0.341064453125,
0.322509765625,
-0.40673828125,
-0.418701171875,
0.83837890625,
-0.1844482421875,
0.52978515625,
0.0552978515625,
0.84423828125,
-0.03607177734375,
1.7001953125,
0.7158203125,
-0.0540771484375,
0.47119140625,
0.421142578125,
-0.36572265625,
-0.467529296875,
-0.271484375,
-0.56396484375,
-0.529296875,
-0.3505859375,
-0.364501953125,
0.036041259765625,
0.90576171875,
0.1414794921875,
-0.875,
-0.45556640625,
0.0212554931640625,
-0.25341796875,
0.348876953125,
0.53369140625,
0.1898193359375,
-0.11273193359375,
0.10797119140625,
-0.295654296875,
-0.46826171875,
0.05706787109375,
-0.5439453125,
0.376220703125,
-0.7001953125,
-0.70947265625,
-1.076171875,
-1.0009765625,
-0.1773681640625,
0.275390625,
-0.4228515625,
-0.74365234375,
0.60302734375,
0.4619140625,
0.47314453125,
0.0465087890625,
-0.11181640625,
0.01306915283203125,
0.67431640625,
0.83837890625,
-0.0386962890625,
0.482421875,
0.3779296875,
-0.042510986328125,
0.12493896484375,
-0.662109375,
0.62353515625,
0.1387939453125,
0.08251953125,
-0.35107421875,
0.2015380859375,
-0.912109375,
-1.5,
-0.2059326171875,
0.10247802734375,
0.17333984375,
-0.8212890625,
-1.1669921875,
-0.3974609375,
-0.7265625,
-0.15380859375,
-0.1112060546875,
0.75927734375,
0.022369384765625,
0.008941650390625,
-0.249267578125,
-1.0283203125,
4.375,
1.4208984375,
1.0263671875,
-0.0006575584411621094,
0.55419921875,
1.248046875,
0.435791015625,
-0.9033203125,
-0.439208984375,
-0.1402587890625,
0.37109375,
-0.342529296875,
-0.177490234375,
0.5126953125,
0.08673095703125,
0.48388671875,
-0.6826171875,
-0.0031871795654296875,
-0.314208984375,
-0.75732421875,
-0.85107421875,
0.15625,
-0.1595458984375,
0.2261962890625,
0.1612548828125,
0.41455078125,
0.77880859375,
-0.6591796875,
0.1175537109375,
-0.5986328125,
-0.19189453125,
-0.289794921875,
0.95947265625,
0.266357421875,
-0.1619873046875,
0.48193359375,
-0.05914306640625,
-0.7431640625,
0.01053619384765625,
0.2025146484375,
-0.50634765625,
-0.1522216796875,
1.1171875,
-0.44140625,
0.11602783203125,
0.2294921875,
-0.57421875,
0.369384765625,
0.1795654296875,
-0.68115234375,
1.0263671875,
-0.1597900390625,
0.48095703125,
-0.814453125,
-0.276123046875,
0.248046875,
0.52587890625,
0.028839111328125,
-0.033203125,
0.31201171875,
0.492919921875,
0.0518798828125,
0.4814453125,
0.4814453125,
-0.69384765625,
0.91064453125,
-0.466796875,
0.2430419921875,
-0.7880859375,
-0.041412353515625,
-0.169921875,
-0.08612060546875,
-0.5283203125,
-0.375,
0.92626953125,
0.253662109375,
-0.1146240234375,
0.23876953125,
0.153564453125,
-0.76123046875,
0.2073974609375,
-0.16455078125,
-0.0750732421875,
0.05865478515625,
0.2186279296875,
1.5234375,
-0.34619140625,
-0.0770263671875,
-0.273681640625,
0.6689453125,
0.49169921875,
0.419189453125,
-0.180908203125,
-0.6904296875,
-0.34326171875
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Submitted Solution:
```
"""
██╗ ██████╗ ██╗ ██████╗ ██████╗ ██╗ █████╗
██║██╔═══██╗██║ ╚════██╗██╔═████╗███║██╔══██╗
██║██║ ██║██║ █████╔╝██║██╔██║╚██║╚██████║
██║██║ ██║██║ ██╔═══╝ ████╔╝██║ ██║ ╚═══██║
██║╚██████╔╝██║ ███████╗╚██████╔╝ ██║ █████╔╝
╚═╝ ╚═════╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚════╝
██████╗ ██╗██╗ ███████╗██╗ ██╗ ██████╗ ██████╗
██╔══██╗██║██║ ██╔════╝██║ ██║██╔═══██╗██╔══██╗
██║ ██║██║██║ ███████╗███████║██║ ██║██║ ██║
██║ ██║██║██║ ╚════██║██╔══██║██║ ██║██║ ██║
██████╔╝██║███████╗███████║██║ ██║╚██████╔╝██████╔╝
╚═════╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝
"""
n = int(input())
s = input()
if n % 2 == 1:
bools = True
else:
bools = False
ans = ""
for i in range(n):
if bools:
ans += s[i]
bools = False
else:
ans = s[i] + ans
bools = True
print(ans)
```
Yes
| 72,177 | [
0.6640625,
-0.263671875,
0.2066650390625,
0.4423828125,
-0.546875,
-0.5322265625,
0.078125,
0.0107574462890625,
-0.398193359375,
0.68798828125,
0.9072265625,
-0.1680908203125,
-0.081787109375,
-0.638671875,
-0.869140625,
-0.50439453125,
-0.3671875,
-0.60302734375,
-0.68408203125,
0.11676025390625,
0.1805419921875,
0.05804443359375,
-1.208984375,
-0.132568359375,
-0.435546875,
1.0732421875,
0.55908203125,
-0.1407470703125,
1.248046875,
0.9697265625,
0.039398193359375,
0.058441162109375,
0.77294921875,
-1.1494140625,
-0.304443359375,
-0.3330078125,
0.7080078125,
-0.3388671875,
-0.380615234375,
-0.53466796875,
0.1275634765625,
-0.284912109375,
0.470947265625,
-0.5966796875,
-0.888671875,
-0.10589599609375,
-0.24072265625,
-0.8427734375,
-0.3203125,
-0.86181640625,
0.208251953125,
-0.322998046875,
0.5166015625,
-0.333251953125,
-0.02777099609375,
-0.1883544921875,
-0.08575439453125,
0.018798828125,
-0.368896484375,
0.22119140625,
0.39990234375,
0.435791015625,
0.1151123046875,
-1.09765625,
-0.2998046875,
-0.19384765625,
-0.05047607421875,
-0.11395263671875,
-0.0091705322265625,
-0.53564453125,
-0.14306640625,
0.420166015625,
-0.21875,
-0.53271484375,
-0.304443359375,
0.059967041015625,
0.2344970703125,
0.25341796875,
-0.83740234375,
0.892578125,
0.12890625,
1.01171875,
0.802734375,
0.410400390625,
-0.54150390625,
-0.2021484375,
0.12103271484375,
0.35595703125,
0.152587890625,
-0.010711669921875,
0.121826171875,
0.444580078125,
-0.273193359375,
0.0870361328125,
0.51025390625,
0.5537109375,
-0.01300048828125,
0.312744140625,
0.09173583984375,
0.58984375,
0.8115234375,
1.2958984375,
-0.205322265625,
1.0908203125,
-0.404052734375,
0.5234375,
0.18603515625,
0.1834716796875,
-0.279296875,
0.019073486328125,
-0.361572265625,
-0.129638671875,
0.05419921875,
-0.274658203125,
-0.2220458984375,
0.9296875,
-0.1943359375,
0.2327880859375,
-0.8544921875,
0.3955078125,
0.266845703125,
0.204833984375,
0.4287109375,
-0.329345703125,
0.3583984375,
-0.390380859375,
-0.669921875,
1.0654296875,
-0.42333984375,
-0.428466796875,
0.1630859375,
0.27001953125,
-0.36474609375,
0.1807861328125,
0.306884765625,
0.6904296875,
0.11376953125,
0.4375,
0.8017578125,
-0.34619140625,
0.3486328125,
0.19140625,
-0.316162109375,
1.4951171875,
-0.1932373046875,
-0.28759765625,
0.41796875,
0.2335205078125,
-0.7890625,
0.6201171875,
-0.75830078125,
0.453857421875,
-0.284912109375,
0.1688232421875,
-0.385986328125,
0.02276611328125,
-0.33447265625,
0.63232421875,
0.0513916015625,
-0.004364013671875,
-0.29052734375,
-0.101318359375,
-0.47265625,
0.87255859375,
-0.640625,
1.1953125,
-0.908203125,
-0.5634765625,
-0.46044921875,
-0.1778564453125,
0.390625,
-0.163818359375,
-0.0244598388671875,
0.765625,
0.403076171875,
0.87841796875,
0.703125,
-0.343017578125,
0.301513671875,
0.08367919921875,
0.1048583984375,
0.2294921875,
0.28662109375,
0.78662109375,
0.1585693359375,
-0.005184173583984375,
0.0797119140625,
-0.391357421875,
-0.53662109375,
-0.34423828125,
-0.1419677734375,
0.86865234375,
-0.445068359375,
-0.1248779296875,
-0.285888671875,
-0.320556640625,
-0.60498046875,
-0.39111328125,
-0.0301666259765625,
-1.0810546875,
-0.3115234375,
0.83935546875,
-0.262451171875,
0.5849609375,
-0.437255859375,
-0.66845703125,
0.280029296875,
1.1787109375,
-0.1939697265625,
-0.1712646484375,
0.95751953125,
0.327880859375,
-0.465576171875,
0.1534423828125,
0.2349853515625,
0.0943603515625,
-0.81494140625,
0.6337890625,
-0.398681640625,
-0.0194549560546875,
-0.227294921875,
0.72802734375,
0.2012939453125,
0.36865234375,
-0.541015625,
0.10125732421875,
0.69384765625,
1.056640625,
-0.057525634765625,
0.318359375,
0.313720703125,
0.53759765625,
0.297607421875,
0.72607421875,
0.79052734375,
0.416259765625,
0.7333984375,
0.79736328125,
-0.2191162109375,
0.2822265625,
-0.038238525390625,
0.448974609375,
0.7939453125,
0.22509765625,
0.13671875,
0.5732421875,
-0.437744140625,
-0.1295166015625,
-0.47705078125,
0.1234130859375,
-0.30029296875,
0.05535888671875,
0.2161865234375,
0.289794921875,
-0.45654296875,
-0.422607421875,
0.450927734375,
0.65185546875,
-0.724609375,
-0.65869140625,
0.2083740234375,
0.22900390625,
0.48828125,
0.478515625,
0.382080078125,
0.61474609375,
0.6015625,
0.50146484375,
-0.282470703125,
-0.6025390625,
-0.65283203125,
-1.533203125,
-1.12890625,
-0.24609375,
-0.79150390625,
0.03155517578125,
0.02947998046875,
-1.091796875,
-0.1732177734375,
-0.419921875,
-0.5205078125,
-0.412841796875,
-0.283203125,
0.61328125,
-0.1632080078125,
0.73046875,
-0.43994140625,
0.509765625,
0.173095703125,
1.080078125,
-0.66845703125,
-0.1505126953125,
-0.385009765625,
-0.50634765625,
0.377685546875,
-0.1297607421875,
0.5068359375,
-0.32421875,
-0.82177734375,
-0.64990234375,
-0.7177734375,
0.162353515625,
-0.40673828125,
-0.003406524658203125,
-0.406982421875,
0.90283203125,
0.26123046875,
-0.66357421875,
0.318603515625,
0.9423828125,
-0.8818359375,
0.4501953125,
0.347412109375,
-0.1649169921875,
-0.7802734375,
1.42578125,
0.39306640625,
0.5126953125,
-0.450439453125,
-0.1881103515625,
-0.163818359375,
0.1617431640625,
-0.01242828369140625,
-0.52587890625,
-0.3935546875,
0.630859375,
0.10931396484375,
-1.4013671875,
0.1610107421875,
-1.138671875,
-0.759765625,
-0.35400390625,
-0.6591796875,
0.76611328125,
0.9423828125,
0.51708984375,
-0.2381591796875,
-0.0543212890625,
0.082763671875,
0.40478515625,
0.252685546875,
-0.48046875,
0.10528564453125,
0.724609375,
-0.1875,
0.2255859375,
0.677734375,
-0.285400390625,
-0.304443359375,
0.06988525390625,
-0.0243377685546875,
0.1839599609375,
0.063232421875,
-0.056671142578125,
0.12371826171875,
0.48779296875,
-1.2451171875,
0.0802001953125,
-0.6455078125,
0.48486328125,
0.27978515625,
0.51123046875,
0.270263671875,
-0.40234375,
-0.69921875,
-0.93359375,
0.363037109375,
0.50048828125,
0.344482421875,
-0.417724609375,
1.0126953125,
0.270263671875,
-0.61962890625,
0.32177734375,
-0.7314453125,
0.266357421875,
0.80517578125,
-0.25244140625,
0.71630859375,
-1.263671875,
0.48388671875,
-0.06658935546875,
-0.427001953125,
0.1409912109375,
0.13134765625,
0.65673828125,
-0.25048828125,
-0.1385498046875,
0.08685302734375,
-0.381103515625,
0.1339111328125,
-0.30859375,
0.269775390625,
-0.235107421875,
-1.0498046875,
-1.0361328125,
0.97021484375,
0.77490234375,
0.46923828125,
0.2386474609375,
0.67578125,
0.345947265625,
0.364990234375,
0.53955078125,
0.123046875,
-0.08868408203125,
-0.5185546875,
1.0048828125,
0.325927734375,
-0.384765625,
-0.703125,
-0.337890625,
-0.0867919921875,
0.4765625,
0.14990234375,
0.351318359375,
-1.025390625,
0.125244140625,
0.44580078125,
0.8447265625,
-0.97509765625,
-0.004657745361328125,
-0.02935791015625,
0.3544921875,
0.1304931640625,
-0.7607421875,
0.26953125,
-0.79248046875,
0.43310546875,
0.5546875,
0.136962890625,
-0.429443359375,
-0.1480712890625,
-1.005859375,
-0.420654296875,
0.475830078125,
0.4365234375,
-0.239013671875,
0.53759765625,
-1.10546875,
1.10546875,
0.3623046875,
-0.27587890625,
0.1053466796875,
-0.271728515625,
0.61181640625,
0.2164306640625,
0.7109375,
-0.50537109375,
-0.5390625,
0.2452392578125,
-1.0087890625,
0.1951904296875,
-0.275146484375,
0.4013671875,
-0.162353515625,
0.066650390625,
-0.03973388671875,
0.16064453125,
-0.47998046875,
0.212158203125,
-0.046966552734375,
0.413818359375,
-1.287109375,
-0.97119140625,
0.368896484375,
-0.05828857421875,
-0.294189453125,
0.625,
-0.07275390625,
-0.3701171875,
-0.07470703125,
0.1649169921875,
-0.66748046875,
0.5625,
-0.54296875,
0.281494140625,
-0.234619140625,
-0.245849609375,
0.04656982421875,
-0.39111328125,
0.74560546875,
-0.293701171875,
-0.60791015625,
-0.429443359375,
-1.22265625,
-0.2109375,
-0.1436767578125,
-0.72705078125,
0.04693603515625,
0.442138671875,
-0.388916015625,
-0.203125,
-0.373779296875,
-0.25048828125,
-0.300537109375,
-0.318115234375,
-0.305908203125,
0.71484375,
0.87109375,
0.7294921875,
0.0140838623046875,
0.1201171875,
-0.26904296875,
-0.10321044921875,
-0.1617431640625,
-0.7666015625,
0.26171875,
0.3505859375,
-0.43115234375,
-0.03607177734375,
0.39794921875,
-0.0841064453125,
0.447021484375,
1.2802734375,
-0.1845703125,
0.357177734375,
0.07537841796875,
-0.70849609375,
0.91357421875,
-0.10693359375,
-1.447265625,
-0.425048828125,
0.7138671875,
-0.060089111328125,
0.7744140625,
0.253173828125,
-0.94482421875,
-1.1298828125,
-0.8603515625,
0.405517578125,
-0.7470703125,
-0.1864013671875,
-1.0146484375,
-0.347412109375,
-0.2939453125,
0.64453125,
-0.2076416015625,
-0.382080078125,
0.08331298828125,
-1.19140625,
0.148681640625,
-0.48876953125,
-0.599609375,
-0.9658203125,
-0.44775390625,
-0.32470703125,
0.8701171875,
0.37451171875,
-0.0897216796875,
-0.0667724609375,
0.316162109375,
-0.009002685546875,
-0.0810546875,
-0.80126953125,
-0.2890625,
-0.358642578125,
0.1844482421875,
-0.12646484375,
-0.42529296875,
-0.78271484375,
0.77734375,
-0.379150390625,
0.2281494140625,
0.00010699033737182617,
-0.51806640625,
-0.1781005859375,
-0.3505859375,
1.095703125,
-0.378173828125,
0.171142578125,
-0.64697265625,
0.67822265625,
0.6259765625,
-0.60693359375,
-0.2369384765625,
-0.67626953125,
-0.484375,
-1.4765625,
0.62939453125,
-0.459228515625,
0.30615234375,
-0.599609375,
-0.38427734375,
1.0400390625,
-0.5244140625,
0.40625,
0.95849609375,
-0.1070556640625,
-0.1673583984375,
-0.9033203125,
0.78466796875,
0.59521484375,
-0.466064453125,
-0.1693115234375,
-0.328857421875,
-0.83642578125,
0.2025146484375,
-0.338623046875,
-0.9228515625,
-0.662109375,
0.6396484375,
1.4521484375,
-0.26513671875,
0.448974609375,
0.224853515625,
-0.806640625,
-0.45947265625,
0.5107421875,
0.1556396484375,
-0.022216796875,
0.642578125,
-0.15869140625,
-0.0222015380859375,
0.200927734375,
-0.049468994140625,
-0.332763671875,
-0.4091796875,
1.3056640625,
-0.228271484375,
-0.56591796875,
1.076171875,
0.95947265625,
-0.94140625,
-0.59375,
-0.11248779296875,
0.115234375,
-0.0462646484375,
-0.6962890625,
0.08740234375,
0.576171875,
-0.8203125,
-0.0516357421875,
0.322021484375,
-0.0386962890625,
0.448486328125,
0.370849609375,
0.49072265625,
-0.408203125,
0.24853515625,
0.5380859375,
-0.74072265625,
-0.400634765625,
-1.1455078125,
0.5283203125,
0.043212890625,
0.51904296875,
0.42236328125,
-0.5068359375,
0.331787109375,
0.318115234375,
-0.12890625,
0.9912109375,
-0.423583984375,
-0.18115234375,
0.08636474609375,
-0.97216796875,
-0.7626953125,
0.0614013671875,
0.496337890625,
-0.336669921875,
0.1630859375,
-0.6748046875,
0.08612060546875,
0.1400146484375,
0.265869140625,
-0.024017333984375,
-0.5888671875,
0.0263671875,
-0.62255859375,
-0.4873046875,
-0.9287109375,
-0.66064453125,
0.10943603515625,
0.2291259765625,
-0.65625,
-0.55029296875,
0.476806640625,
0.50341796875,
-0.7255859375,
1.1875,
-0.74462890625,
0.40087890625,
-1.0869140625,
-0.07708740234375,
-0.76171875,
-0.295166015625,
-0.364501953125,
-0.251220703125,
-0.123046875,
0.2626953125,
0.1319580078125,
0.385986328125,
0.1390380859375,
0.66845703125,
-0.53564453125,
-0.2294921875,
0.08355712890625,
0.264892578125,
-0.638671875,
0.814453125,
0.505859375,
0.189208984375,
0.199951171875,
-0.118896484375,
-0.740234375,
0.2086181640625,
0.252685546875,
0.76708984375,
0.292724609375,
0.1279296875,
-0.366455078125,
-0.1566162109375,
-0.79638671875,
0.1231689453125,
-0.2568359375,
0.240234375,
0.305908203125,
-0.64697265625,
0.31201171875,
1.169921875,
-0.326171875,
0.050689697265625,
0.2030029296875,
0.34423828125,
0.3310546875,
0.4130859375,
-0.0869140625,
0.4169921875,
0.54833984375,
-0.37939453125,
-0.4765625,
0.56884765625,
0.007793426513671875,
0.1343994140625,
-0.5302734375,
-0.73388671875,
-1.0771484375,
0.050506591796875,
0.036590576171875,
0.003978729248046875,
0.61474609375,
-0.55908203125,
0.167236328125,
0.020477294921875,
-0.1749267578125,
0.33251953125,
-1.109375,
-0.6884765625,
0.332275390625,
-0.11175537109375,
-0.74755859375,
-0.0523681640625,
-0.426025390625,
-0.11627197265625,
0.25927734375,
0.096923828125,
-0.3759765625,
0.367919921875,
-0.272705078125,
0.34716796875,
-0.6328125,
0.06884765625,
0.074951171875,
0.378662109375,
-0.369873046875,
-0.08758544921875,
0.125244140625,
1.208984375,
-0.1624755859375,
0.1138916015625,
-0.82763671875,
-0.0133056640625,
-0.238037109375,
0.1480712890625,
-0.6015625,
0.312744140625,
-0.1829833984375,
0.57275390625,
-0.919921875,
-0.356689453125,
0.2000732421875,
0.362060546875,
0.351806640625,
-0.414794921875,
-0.67919921875,
1.0302734375,
0.81005859375,
0.0301055908203125,
0.58935546875,
0.32958984375,
0.65625,
-0.2093505859375,
-0.058502197265625,
-0.368408203125,
0.404541015625,
0.44921875,
0.432373046875,
-0.438720703125,
0.6474609375,
0.75634765625,
0.017578125,
0.0936279296875,
0.33984375,
-0.1446533203125,
0.091552734375,
0.201171875,
-0.1529541015625,
-0.09161376953125,
0.2318115234375,
-0.54150390625,
0.453369140625,
-0.24365234375,
-0.17431640625,
-0.7255859375,
-0.74853515625,
0.75634765625,
-0.35205078125,
-0.1873779296875,
-0.09320068359375,
-0.283935546875,
0.348876953125,
0.76171875,
0.021484375,
-0.0657958984375,
0.7431640625,
0.9462890625,
0.31640625,
1.0458984375,
0.4296875,
0.09320068359375,
-0.344970703125,
0.42724609375,
0.435791015625,
0.00749969482421875,
-0.0027332305908203125,
-0.267333984375,
-0.97314453125,
0.787109375,
0.03143310546875,
-0.4970703125,
0.48095703125,
-0.74072265625,
0.21875,
-0.260498046875,
0.428466796875,
-0.77001953125,
0.345458984375,
0.344482421875,
-0.413330078125,
-0.48291015625,
0.79736328125,
-0.11114501953125,
0.56201171875,
0.1431884765625,
0.87890625,
-0.07830810546875,
1.6005859375,
0.740234375,
0.0233001708984375,
0.48583984375,
0.470458984375,
-0.2998046875,
-0.47900390625,
-0.2257080078125,
-0.58203125,
-0.5166015625,
-0.484375,
-0.4130859375,
-0.1492919921875,
0.90087890625,
0.2061767578125,
-0.89208984375,
-0.5302734375,
0.044677734375,
-0.2481689453125,
0.35693359375,
0.437255859375,
0.267822265625,
-0.137451171875,
0.17041015625,
-0.342529296875,
-0.47998046875,
0.059844970703125,
-0.420654296875,
0.3779296875,
-0.66845703125,
-0.7099609375,
-1.0849609375,
-0.88134765625,
-0.130859375,
0.27978515625,
-0.52099609375,
-0.693359375,
0.58740234375,
0.5029296875,
0.43310546875,
-0.042816162109375,
-0.11968994140625,
-0.0118560791015625,
0.70458984375,
0.87548828125,
-0.046661376953125,
0.564453125,
0.388916015625,
-0.062164306640625,
-0.0193634033203125,
-0.69580078125,
0.6044921875,
0.1187744140625,
0.006805419921875,
-0.417236328125,
0.1966552734375,
-0.95166015625,
-1.4462890625,
-0.150634765625,
0.1072998046875,
0.11444091796875,
-0.8642578125,
-1.208984375,
-0.5078125,
-0.70068359375,
-0.08026123046875,
-0.182861328125,
0.8701171875,
0.0621337890625,
-0.11822509765625,
-0.299560546875,
-0.99609375,
4.35546875,
1.2880859375,
0.87744140625,
0.0384521484375,
0.5703125,
1.1650390625,
0.490234375,
-0.89697265625,
-0.42041015625,
-0.2156982421875,
0.42626953125,
-0.35546875,
-0.2294921875,
0.5556640625,
0.11566162109375,
0.451416015625,
-0.703125,
-0.10906982421875,
-0.181884765625,
-0.77001953125,
-0.9677734375,
0.243408203125,
-0.09710693359375,
0.1585693359375,
0.1651611328125,
0.471923828125,
0.90380859375,
-0.6982421875,
0.042633056640625,
-0.638671875,
-0.10943603515625,
-0.37646484375,
1.0673828125,
0.345947265625,
-0.1759033203125,
0.53076171875,
-0.0809326171875,
-0.76318359375,
-0.021148681640625,
0.274169921875,
-0.58154296875,
-0.098876953125,
1.0625,
-0.316162109375,
0.1396484375,
0.405517578125,
-0.56982421875,
0.405029296875,
0.1761474609375,
-0.68310546875,
1.0751953125,
-0.044281005859375,
0.463623046875,
-0.71435546875,
-0.31884765625,
0.2105712890625,
0.48681640625,
0.035125732421875,
0.0081634521484375,
0.251220703125,
0.404052734375,
0.060455322265625,
0.313232421875,
0.62255859375,
-0.76513671875,
0.7626953125,
-0.38916015625,
0.172119140625,
-0.77685546875,
-0.0211639404296875,
-0.238037109375,
-0.07977294921875,
-0.4775390625,
-0.44580078125,
0.8544921875,
0.296142578125,
-0.07855224609375,
0.2462158203125,
0.2271728515625,
-0.73388671875,
0.242431640625,
-0.2047119140625,
-0.069091796875,
-0.042755126953125,
0.286376953125,
1.4501953125,
-0.375244140625,
-0.10369873046875,
-0.305419921875,
0.77783203125,
0.53076171875,
0.471923828125,
-0.1375732421875,
-0.68896484375,
-0.465087890625
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Submitted Solution:
```
'''
def main():
from sys import stdin,stdout
if __name__=='__main__':
main()
'''
#Round 386
#A
'''
def main():
from sys import stdin,stdout
a=int(stdin.readline())
b=int(stdin.readline())
c=int(stdin.readline())
minim=min((a,b//2,c//4))
#ssprint(minim)
stdout.write(str(minim+minim*2+minim*4))
if __name__=='__main__':
main()
'''
#B
def main():
from sys import stdin,stdout
n=int(stdin.readline())
s=stdin.readline().strip()
if n & 1:
target=s[0]
s=s[1:]
else:
target=''
#print(target)
#print(s)
for i in range(len(s)):
if i & 1:
target+=s[i]
else:
target=s[i]+target
stdout.write(target)
if __name__=='__main__':
main()
```
Yes
| 72,178 | [
0.6640625,
-0.263671875,
0.2066650390625,
0.4423828125,
-0.546875,
-0.5322265625,
0.078125,
0.0107574462890625,
-0.398193359375,
0.68798828125,
0.9072265625,
-0.1680908203125,
-0.081787109375,
-0.638671875,
-0.869140625,
-0.50439453125,
-0.3671875,
-0.60302734375,
-0.68408203125,
0.11676025390625,
0.1805419921875,
0.05804443359375,
-1.208984375,
-0.132568359375,
-0.435546875,
1.0732421875,
0.55908203125,
-0.1407470703125,
1.248046875,
0.9697265625,
0.039398193359375,
0.058441162109375,
0.77294921875,
-1.1494140625,
-0.304443359375,
-0.3330078125,
0.7080078125,
-0.3388671875,
-0.380615234375,
-0.53466796875,
0.1275634765625,
-0.284912109375,
0.470947265625,
-0.5966796875,
-0.888671875,
-0.10589599609375,
-0.24072265625,
-0.8427734375,
-0.3203125,
-0.86181640625,
0.208251953125,
-0.322998046875,
0.5166015625,
-0.333251953125,
-0.02777099609375,
-0.1883544921875,
-0.08575439453125,
0.018798828125,
-0.368896484375,
0.22119140625,
0.39990234375,
0.435791015625,
0.1151123046875,
-1.09765625,
-0.2998046875,
-0.19384765625,
-0.05047607421875,
-0.11395263671875,
-0.0091705322265625,
-0.53564453125,
-0.14306640625,
0.420166015625,
-0.21875,
-0.53271484375,
-0.304443359375,
0.059967041015625,
0.2344970703125,
0.25341796875,
-0.83740234375,
0.892578125,
0.12890625,
1.01171875,
0.802734375,
0.410400390625,
-0.54150390625,
-0.2021484375,
0.12103271484375,
0.35595703125,
0.152587890625,
-0.010711669921875,
0.121826171875,
0.444580078125,
-0.273193359375,
0.0870361328125,
0.51025390625,
0.5537109375,
-0.01300048828125,
0.312744140625,
0.09173583984375,
0.58984375,
0.8115234375,
1.2958984375,
-0.205322265625,
1.0908203125,
-0.404052734375,
0.5234375,
0.18603515625,
0.1834716796875,
-0.279296875,
0.019073486328125,
-0.361572265625,
-0.129638671875,
0.05419921875,
-0.274658203125,
-0.2220458984375,
0.9296875,
-0.1943359375,
0.2327880859375,
-0.8544921875,
0.3955078125,
0.266845703125,
0.204833984375,
0.4287109375,
-0.329345703125,
0.3583984375,
-0.390380859375,
-0.669921875,
1.0654296875,
-0.42333984375,
-0.428466796875,
0.1630859375,
0.27001953125,
-0.36474609375,
0.1807861328125,
0.306884765625,
0.6904296875,
0.11376953125,
0.4375,
0.8017578125,
-0.34619140625,
0.3486328125,
0.19140625,
-0.316162109375,
1.4951171875,
-0.1932373046875,
-0.28759765625,
0.41796875,
0.2335205078125,
-0.7890625,
0.6201171875,
-0.75830078125,
0.453857421875,
-0.284912109375,
0.1688232421875,
-0.385986328125,
0.02276611328125,
-0.33447265625,
0.63232421875,
0.0513916015625,
-0.004364013671875,
-0.29052734375,
-0.101318359375,
-0.47265625,
0.87255859375,
-0.640625,
1.1953125,
-0.908203125,
-0.5634765625,
-0.46044921875,
-0.1778564453125,
0.390625,
-0.163818359375,
-0.0244598388671875,
0.765625,
0.403076171875,
0.87841796875,
0.703125,
-0.343017578125,
0.301513671875,
0.08367919921875,
0.1048583984375,
0.2294921875,
0.28662109375,
0.78662109375,
0.1585693359375,
-0.005184173583984375,
0.0797119140625,
-0.391357421875,
-0.53662109375,
-0.34423828125,
-0.1419677734375,
0.86865234375,
-0.445068359375,
-0.1248779296875,
-0.285888671875,
-0.320556640625,
-0.60498046875,
-0.39111328125,
-0.0301666259765625,
-1.0810546875,
-0.3115234375,
0.83935546875,
-0.262451171875,
0.5849609375,
-0.437255859375,
-0.66845703125,
0.280029296875,
1.1787109375,
-0.1939697265625,
-0.1712646484375,
0.95751953125,
0.327880859375,
-0.465576171875,
0.1534423828125,
0.2349853515625,
0.0943603515625,
-0.81494140625,
0.6337890625,
-0.398681640625,
-0.0194549560546875,
-0.227294921875,
0.72802734375,
0.2012939453125,
0.36865234375,
-0.541015625,
0.10125732421875,
0.69384765625,
1.056640625,
-0.057525634765625,
0.318359375,
0.313720703125,
0.53759765625,
0.297607421875,
0.72607421875,
0.79052734375,
0.416259765625,
0.7333984375,
0.79736328125,
-0.2191162109375,
0.2822265625,
-0.038238525390625,
0.448974609375,
0.7939453125,
0.22509765625,
0.13671875,
0.5732421875,
-0.437744140625,
-0.1295166015625,
-0.47705078125,
0.1234130859375,
-0.30029296875,
0.05535888671875,
0.2161865234375,
0.289794921875,
-0.45654296875,
-0.422607421875,
0.450927734375,
0.65185546875,
-0.724609375,
-0.65869140625,
0.2083740234375,
0.22900390625,
0.48828125,
0.478515625,
0.382080078125,
0.61474609375,
0.6015625,
0.50146484375,
-0.282470703125,
-0.6025390625,
-0.65283203125,
-1.533203125,
-1.12890625,
-0.24609375,
-0.79150390625,
0.03155517578125,
0.02947998046875,
-1.091796875,
-0.1732177734375,
-0.419921875,
-0.5205078125,
-0.412841796875,
-0.283203125,
0.61328125,
-0.1632080078125,
0.73046875,
-0.43994140625,
0.509765625,
0.173095703125,
1.080078125,
-0.66845703125,
-0.1505126953125,
-0.385009765625,
-0.50634765625,
0.377685546875,
-0.1297607421875,
0.5068359375,
-0.32421875,
-0.82177734375,
-0.64990234375,
-0.7177734375,
0.162353515625,
-0.40673828125,
-0.003406524658203125,
-0.406982421875,
0.90283203125,
0.26123046875,
-0.66357421875,
0.318603515625,
0.9423828125,
-0.8818359375,
0.4501953125,
0.347412109375,
-0.1649169921875,
-0.7802734375,
1.42578125,
0.39306640625,
0.5126953125,
-0.450439453125,
-0.1881103515625,
-0.163818359375,
0.1617431640625,
-0.01242828369140625,
-0.52587890625,
-0.3935546875,
0.630859375,
0.10931396484375,
-1.4013671875,
0.1610107421875,
-1.138671875,
-0.759765625,
-0.35400390625,
-0.6591796875,
0.76611328125,
0.9423828125,
0.51708984375,
-0.2381591796875,
-0.0543212890625,
0.082763671875,
0.40478515625,
0.252685546875,
-0.48046875,
0.10528564453125,
0.724609375,
-0.1875,
0.2255859375,
0.677734375,
-0.285400390625,
-0.304443359375,
0.06988525390625,
-0.0243377685546875,
0.1839599609375,
0.063232421875,
-0.056671142578125,
0.12371826171875,
0.48779296875,
-1.2451171875,
0.0802001953125,
-0.6455078125,
0.48486328125,
0.27978515625,
0.51123046875,
0.270263671875,
-0.40234375,
-0.69921875,
-0.93359375,
0.363037109375,
0.50048828125,
0.344482421875,
-0.417724609375,
1.0126953125,
0.270263671875,
-0.61962890625,
0.32177734375,
-0.7314453125,
0.266357421875,
0.80517578125,
-0.25244140625,
0.71630859375,
-1.263671875,
0.48388671875,
-0.06658935546875,
-0.427001953125,
0.1409912109375,
0.13134765625,
0.65673828125,
-0.25048828125,
-0.1385498046875,
0.08685302734375,
-0.381103515625,
0.1339111328125,
-0.30859375,
0.269775390625,
-0.235107421875,
-1.0498046875,
-1.0361328125,
0.97021484375,
0.77490234375,
0.46923828125,
0.2386474609375,
0.67578125,
0.345947265625,
0.364990234375,
0.53955078125,
0.123046875,
-0.08868408203125,
-0.5185546875,
1.0048828125,
0.325927734375,
-0.384765625,
-0.703125,
-0.337890625,
-0.0867919921875,
0.4765625,
0.14990234375,
0.351318359375,
-1.025390625,
0.125244140625,
0.44580078125,
0.8447265625,
-0.97509765625,
-0.004657745361328125,
-0.02935791015625,
0.3544921875,
0.1304931640625,
-0.7607421875,
0.26953125,
-0.79248046875,
0.43310546875,
0.5546875,
0.136962890625,
-0.429443359375,
-0.1480712890625,
-1.005859375,
-0.420654296875,
0.475830078125,
0.4365234375,
-0.239013671875,
0.53759765625,
-1.10546875,
1.10546875,
0.3623046875,
-0.27587890625,
0.1053466796875,
-0.271728515625,
0.61181640625,
0.2164306640625,
0.7109375,
-0.50537109375,
-0.5390625,
0.2452392578125,
-1.0087890625,
0.1951904296875,
-0.275146484375,
0.4013671875,
-0.162353515625,
0.066650390625,
-0.03973388671875,
0.16064453125,
-0.47998046875,
0.212158203125,
-0.046966552734375,
0.413818359375,
-1.287109375,
-0.97119140625,
0.368896484375,
-0.05828857421875,
-0.294189453125,
0.625,
-0.07275390625,
-0.3701171875,
-0.07470703125,
0.1649169921875,
-0.66748046875,
0.5625,
-0.54296875,
0.281494140625,
-0.234619140625,
-0.245849609375,
0.04656982421875,
-0.39111328125,
0.74560546875,
-0.293701171875,
-0.60791015625,
-0.429443359375,
-1.22265625,
-0.2109375,
-0.1436767578125,
-0.72705078125,
0.04693603515625,
0.442138671875,
-0.388916015625,
-0.203125,
-0.373779296875,
-0.25048828125,
-0.300537109375,
-0.318115234375,
-0.305908203125,
0.71484375,
0.87109375,
0.7294921875,
0.0140838623046875,
0.1201171875,
-0.26904296875,
-0.10321044921875,
-0.1617431640625,
-0.7666015625,
0.26171875,
0.3505859375,
-0.43115234375,
-0.03607177734375,
0.39794921875,
-0.0841064453125,
0.447021484375,
1.2802734375,
-0.1845703125,
0.357177734375,
0.07537841796875,
-0.70849609375,
0.91357421875,
-0.10693359375,
-1.447265625,
-0.425048828125,
0.7138671875,
-0.060089111328125,
0.7744140625,
0.253173828125,
-0.94482421875,
-1.1298828125,
-0.8603515625,
0.405517578125,
-0.7470703125,
-0.1864013671875,
-1.0146484375,
-0.347412109375,
-0.2939453125,
0.64453125,
-0.2076416015625,
-0.382080078125,
0.08331298828125,
-1.19140625,
0.148681640625,
-0.48876953125,
-0.599609375,
-0.9658203125,
-0.44775390625,
-0.32470703125,
0.8701171875,
0.37451171875,
-0.0897216796875,
-0.0667724609375,
0.316162109375,
-0.009002685546875,
-0.0810546875,
-0.80126953125,
-0.2890625,
-0.358642578125,
0.1844482421875,
-0.12646484375,
-0.42529296875,
-0.78271484375,
0.77734375,
-0.379150390625,
0.2281494140625,
0.00010699033737182617,
-0.51806640625,
-0.1781005859375,
-0.3505859375,
1.095703125,
-0.378173828125,
0.171142578125,
-0.64697265625,
0.67822265625,
0.6259765625,
-0.60693359375,
-0.2369384765625,
-0.67626953125,
-0.484375,
-1.4765625,
0.62939453125,
-0.459228515625,
0.30615234375,
-0.599609375,
-0.38427734375,
1.0400390625,
-0.5244140625,
0.40625,
0.95849609375,
-0.1070556640625,
-0.1673583984375,
-0.9033203125,
0.78466796875,
0.59521484375,
-0.466064453125,
-0.1693115234375,
-0.328857421875,
-0.83642578125,
0.2025146484375,
-0.338623046875,
-0.9228515625,
-0.662109375,
0.6396484375,
1.4521484375,
-0.26513671875,
0.448974609375,
0.224853515625,
-0.806640625,
-0.45947265625,
0.5107421875,
0.1556396484375,
-0.022216796875,
0.642578125,
-0.15869140625,
-0.0222015380859375,
0.200927734375,
-0.049468994140625,
-0.332763671875,
-0.4091796875,
1.3056640625,
-0.228271484375,
-0.56591796875,
1.076171875,
0.95947265625,
-0.94140625,
-0.59375,
-0.11248779296875,
0.115234375,
-0.0462646484375,
-0.6962890625,
0.08740234375,
0.576171875,
-0.8203125,
-0.0516357421875,
0.322021484375,
-0.0386962890625,
0.448486328125,
0.370849609375,
0.49072265625,
-0.408203125,
0.24853515625,
0.5380859375,
-0.74072265625,
-0.400634765625,
-1.1455078125,
0.5283203125,
0.043212890625,
0.51904296875,
0.42236328125,
-0.5068359375,
0.331787109375,
0.318115234375,
-0.12890625,
0.9912109375,
-0.423583984375,
-0.18115234375,
0.08636474609375,
-0.97216796875,
-0.7626953125,
0.0614013671875,
0.496337890625,
-0.336669921875,
0.1630859375,
-0.6748046875,
0.08612060546875,
0.1400146484375,
0.265869140625,
-0.024017333984375,
-0.5888671875,
0.0263671875,
-0.62255859375,
-0.4873046875,
-0.9287109375,
-0.66064453125,
0.10943603515625,
0.2291259765625,
-0.65625,
-0.55029296875,
0.476806640625,
0.50341796875,
-0.7255859375,
1.1875,
-0.74462890625,
0.40087890625,
-1.0869140625,
-0.07708740234375,
-0.76171875,
-0.295166015625,
-0.364501953125,
-0.251220703125,
-0.123046875,
0.2626953125,
0.1319580078125,
0.385986328125,
0.1390380859375,
0.66845703125,
-0.53564453125,
-0.2294921875,
0.08355712890625,
0.264892578125,
-0.638671875,
0.814453125,
0.505859375,
0.189208984375,
0.199951171875,
-0.118896484375,
-0.740234375,
0.2086181640625,
0.252685546875,
0.76708984375,
0.292724609375,
0.1279296875,
-0.366455078125,
-0.1566162109375,
-0.79638671875,
0.1231689453125,
-0.2568359375,
0.240234375,
0.305908203125,
-0.64697265625,
0.31201171875,
1.169921875,
-0.326171875,
0.050689697265625,
0.2030029296875,
0.34423828125,
0.3310546875,
0.4130859375,
-0.0869140625,
0.4169921875,
0.54833984375,
-0.37939453125,
-0.4765625,
0.56884765625,
0.007793426513671875,
0.1343994140625,
-0.5302734375,
-0.73388671875,
-1.0771484375,
0.050506591796875,
0.036590576171875,
0.003978729248046875,
0.61474609375,
-0.55908203125,
0.167236328125,
0.020477294921875,
-0.1749267578125,
0.33251953125,
-1.109375,
-0.6884765625,
0.332275390625,
-0.11175537109375,
-0.74755859375,
-0.0523681640625,
-0.426025390625,
-0.11627197265625,
0.25927734375,
0.096923828125,
-0.3759765625,
0.367919921875,
-0.272705078125,
0.34716796875,
-0.6328125,
0.06884765625,
0.074951171875,
0.378662109375,
-0.369873046875,
-0.08758544921875,
0.125244140625,
1.208984375,
-0.1624755859375,
0.1138916015625,
-0.82763671875,
-0.0133056640625,
-0.238037109375,
0.1480712890625,
-0.6015625,
0.312744140625,
-0.1829833984375,
0.57275390625,
-0.919921875,
-0.356689453125,
0.2000732421875,
0.362060546875,
0.351806640625,
-0.414794921875,
-0.67919921875,
1.0302734375,
0.81005859375,
0.0301055908203125,
0.58935546875,
0.32958984375,
0.65625,
-0.2093505859375,
-0.058502197265625,
-0.368408203125,
0.404541015625,
0.44921875,
0.432373046875,
-0.438720703125,
0.6474609375,
0.75634765625,
0.017578125,
0.0936279296875,
0.33984375,
-0.1446533203125,
0.091552734375,
0.201171875,
-0.1529541015625,
-0.09161376953125,
0.2318115234375,
-0.54150390625,
0.453369140625,
-0.24365234375,
-0.17431640625,
-0.7255859375,
-0.74853515625,
0.75634765625,
-0.35205078125,
-0.1873779296875,
-0.09320068359375,
-0.283935546875,
0.348876953125,
0.76171875,
0.021484375,
-0.0657958984375,
0.7431640625,
0.9462890625,
0.31640625,
1.0458984375,
0.4296875,
0.09320068359375,
-0.344970703125,
0.42724609375,
0.435791015625,
0.00749969482421875,
-0.0027332305908203125,
-0.267333984375,
-0.97314453125,
0.787109375,
0.03143310546875,
-0.4970703125,
0.48095703125,
-0.74072265625,
0.21875,
-0.260498046875,
0.428466796875,
-0.77001953125,
0.345458984375,
0.344482421875,
-0.413330078125,
-0.48291015625,
0.79736328125,
-0.11114501953125,
0.56201171875,
0.1431884765625,
0.87890625,
-0.07830810546875,
1.6005859375,
0.740234375,
0.0233001708984375,
0.48583984375,
0.470458984375,
-0.2998046875,
-0.47900390625,
-0.2257080078125,
-0.58203125,
-0.5166015625,
-0.484375,
-0.4130859375,
-0.1492919921875,
0.90087890625,
0.2061767578125,
-0.89208984375,
-0.5302734375,
0.044677734375,
-0.2481689453125,
0.35693359375,
0.437255859375,
0.267822265625,
-0.137451171875,
0.17041015625,
-0.342529296875,
-0.47998046875,
0.059844970703125,
-0.420654296875,
0.3779296875,
-0.66845703125,
-0.7099609375,
-1.0849609375,
-0.88134765625,
-0.130859375,
0.27978515625,
-0.52099609375,
-0.693359375,
0.58740234375,
0.5029296875,
0.43310546875,
-0.042816162109375,
-0.11968994140625,
-0.0118560791015625,
0.70458984375,
0.87548828125,
-0.046661376953125,
0.564453125,
0.388916015625,
-0.062164306640625,
-0.0193634033203125,
-0.69580078125,
0.6044921875,
0.1187744140625,
0.006805419921875,
-0.417236328125,
0.1966552734375,
-0.95166015625,
-1.4462890625,
-0.150634765625,
0.1072998046875,
0.11444091796875,
-0.8642578125,
-1.208984375,
-0.5078125,
-0.70068359375,
-0.08026123046875,
-0.182861328125,
0.8701171875,
0.0621337890625,
-0.11822509765625,
-0.299560546875,
-0.99609375,
4.35546875,
1.2880859375,
0.87744140625,
0.0384521484375,
0.5703125,
1.1650390625,
0.490234375,
-0.89697265625,
-0.42041015625,
-0.2156982421875,
0.42626953125,
-0.35546875,
-0.2294921875,
0.5556640625,
0.11566162109375,
0.451416015625,
-0.703125,
-0.10906982421875,
-0.181884765625,
-0.77001953125,
-0.9677734375,
0.243408203125,
-0.09710693359375,
0.1585693359375,
0.1651611328125,
0.471923828125,
0.90380859375,
-0.6982421875,
0.042633056640625,
-0.638671875,
-0.10943603515625,
-0.37646484375,
1.0673828125,
0.345947265625,
-0.1759033203125,
0.53076171875,
-0.0809326171875,
-0.76318359375,
-0.021148681640625,
0.274169921875,
-0.58154296875,
-0.098876953125,
1.0625,
-0.316162109375,
0.1396484375,
0.405517578125,
-0.56982421875,
0.405029296875,
0.1761474609375,
-0.68310546875,
1.0751953125,
-0.044281005859375,
0.463623046875,
-0.71435546875,
-0.31884765625,
0.2105712890625,
0.48681640625,
0.035125732421875,
0.0081634521484375,
0.251220703125,
0.404052734375,
0.060455322265625,
0.313232421875,
0.62255859375,
-0.76513671875,
0.7626953125,
-0.38916015625,
0.172119140625,
-0.77685546875,
-0.0211639404296875,
-0.238037109375,
-0.07977294921875,
-0.4775390625,
-0.44580078125,
0.8544921875,
0.296142578125,
-0.07855224609375,
0.2462158203125,
0.2271728515625,
-0.73388671875,
0.242431640625,
-0.2047119140625,
-0.069091796875,
-0.042755126953125,
0.286376953125,
1.4501953125,
-0.375244140625,
-0.10369873046875,
-0.305419921875,
0.77783203125,
0.53076171875,
0.471923828125,
-0.1375732421875,
-0.68896484375,
-0.465087890625
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Submitted Solution:
```
n, s, s_new = int(input()), input()[::-1], ''
for i in s: s_new = s_new[:len(s_new)//2]+i+s_new[len(s_new)//2:];
print(s_new)
```
Yes
| 72,179 | [
0.6640625,
-0.263671875,
0.2066650390625,
0.4423828125,
-0.546875,
-0.5322265625,
0.078125,
0.0107574462890625,
-0.398193359375,
0.68798828125,
0.9072265625,
-0.1680908203125,
-0.081787109375,
-0.638671875,
-0.869140625,
-0.50439453125,
-0.3671875,
-0.60302734375,
-0.68408203125,
0.11676025390625,
0.1805419921875,
0.05804443359375,
-1.208984375,
-0.132568359375,
-0.435546875,
1.0732421875,
0.55908203125,
-0.1407470703125,
1.248046875,
0.9697265625,
0.039398193359375,
0.058441162109375,
0.77294921875,
-1.1494140625,
-0.304443359375,
-0.3330078125,
0.7080078125,
-0.3388671875,
-0.380615234375,
-0.53466796875,
0.1275634765625,
-0.284912109375,
0.470947265625,
-0.5966796875,
-0.888671875,
-0.10589599609375,
-0.24072265625,
-0.8427734375,
-0.3203125,
-0.86181640625,
0.208251953125,
-0.322998046875,
0.5166015625,
-0.333251953125,
-0.02777099609375,
-0.1883544921875,
-0.08575439453125,
0.018798828125,
-0.368896484375,
0.22119140625,
0.39990234375,
0.435791015625,
0.1151123046875,
-1.09765625,
-0.2998046875,
-0.19384765625,
-0.05047607421875,
-0.11395263671875,
-0.0091705322265625,
-0.53564453125,
-0.14306640625,
0.420166015625,
-0.21875,
-0.53271484375,
-0.304443359375,
0.059967041015625,
0.2344970703125,
0.25341796875,
-0.83740234375,
0.892578125,
0.12890625,
1.01171875,
0.802734375,
0.410400390625,
-0.54150390625,
-0.2021484375,
0.12103271484375,
0.35595703125,
0.152587890625,
-0.010711669921875,
0.121826171875,
0.444580078125,
-0.273193359375,
0.0870361328125,
0.51025390625,
0.5537109375,
-0.01300048828125,
0.312744140625,
0.09173583984375,
0.58984375,
0.8115234375,
1.2958984375,
-0.205322265625,
1.0908203125,
-0.404052734375,
0.5234375,
0.18603515625,
0.1834716796875,
-0.279296875,
0.019073486328125,
-0.361572265625,
-0.129638671875,
0.05419921875,
-0.274658203125,
-0.2220458984375,
0.9296875,
-0.1943359375,
0.2327880859375,
-0.8544921875,
0.3955078125,
0.266845703125,
0.204833984375,
0.4287109375,
-0.329345703125,
0.3583984375,
-0.390380859375,
-0.669921875,
1.0654296875,
-0.42333984375,
-0.428466796875,
0.1630859375,
0.27001953125,
-0.36474609375,
0.1807861328125,
0.306884765625,
0.6904296875,
0.11376953125,
0.4375,
0.8017578125,
-0.34619140625,
0.3486328125,
0.19140625,
-0.316162109375,
1.4951171875,
-0.1932373046875,
-0.28759765625,
0.41796875,
0.2335205078125,
-0.7890625,
0.6201171875,
-0.75830078125,
0.453857421875,
-0.284912109375,
0.1688232421875,
-0.385986328125,
0.02276611328125,
-0.33447265625,
0.63232421875,
0.0513916015625,
-0.004364013671875,
-0.29052734375,
-0.101318359375,
-0.47265625,
0.87255859375,
-0.640625,
1.1953125,
-0.908203125,
-0.5634765625,
-0.46044921875,
-0.1778564453125,
0.390625,
-0.163818359375,
-0.0244598388671875,
0.765625,
0.403076171875,
0.87841796875,
0.703125,
-0.343017578125,
0.301513671875,
0.08367919921875,
0.1048583984375,
0.2294921875,
0.28662109375,
0.78662109375,
0.1585693359375,
-0.005184173583984375,
0.0797119140625,
-0.391357421875,
-0.53662109375,
-0.34423828125,
-0.1419677734375,
0.86865234375,
-0.445068359375,
-0.1248779296875,
-0.285888671875,
-0.320556640625,
-0.60498046875,
-0.39111328125,
-0.0301666259765625,
-1.0810546875,
-0.3115234375,
0.83935546875,
-0.262451171875,
0.5849609375,
-0.437255859375,
-0.66845703125,
0.280029296875,
1.1787109375,
-0.1939697265625,
-0.1712646484375,
0.95751953125,
0.327880859375,
-0.465576171875,
0.1534423828125,
0.2349853515625,
0.0943603515625,
-0.81494140625,
0.6337890625,
-0.398681640625,
-0.0194549560546875,
-0.227294921875,
0.72802734375,
0.2012939453125,
0.36865234375,
-0.541015625,
0.10125732421875,
0.69384765625,
1.056640625,
-0.057525634765625,
0.318359375,
0.313720703125,
0.53759765625,
0.297607421875,
0.72607421875,
0.79052734375,
0.416259765625,
0.7333984375,
0.79736328125,
-0.2191162109375,
0.2822265625,
-0.038238525390625,
0.448974609375,
0.7939453125,
0.22509765625,
0.13671875,
0.5732421875,
-0.437744140625,
-0.1295166015625,
-0.47705078125,
0.1234130859375,
-0.30029296875,
0.05535888671875,
0.2161865234375,
0.289794921875,
-0.45654296875,
-0.422607421875,
0.450927734375,
0.65185546875,
-0.724609375,
-0.65869140625,
0.2083740234375,
0.22900390625,
0.48828125,
0.478515625,
0.382080078125,
0.61474609375,
0.6015625,
0.50146484375,
-0.282470703125,
-0.6025390625,
-0.65283203125,
-1.533203125,
-1.12890625,
-0.24609375,
-0.79150390625,
0.03155517578125,
0.02947998046875,
-1.091796875,
-0.1732177734375,
-0.419921875,
-0.5205078125,
-0.412841796875,
-0.283203125,
0.61328125,
-0.1632080078125,
0.73046875,
-0.43994140625,
0.509765625,
0.173095703125,
1.080078125,
-0.66845703125,
-0.1505126953125,
-0.385009765625,
-0.50634765625,
0.377685546875,
-0.1297607421875,
0.5068359375,
-0.32421875,
-0.82177734375,
-0.64990234375,
-0.7177734375,
0.162353515625,
-0.40673828125,
-0.003406524658203125,
-0.406982421875,
0.90283203125,
0.26123046875,
-0.66357421875,
0.318603515625,
0.9423828125,
-0.8818359375,
0.4501953125,
0.347412109375,
-0.1649169921875,
-0.7802734375,
1.42578125,
0.39306640625,
0.5126953125,
-0.450439453125,
-0.1881103515625,
-0.163818359375,
0.1617431640625,
-0.01242828369140625,
-0.52587890625,
-0.3935546875,
0.630859375,
0.10931396484375,
-1.4013671875,
0.1610107421875,
-1.138671875,
-0.759765625,
-0.35400390625,
-0.6591796875,
0.76611328125,
0.9423828125,
0.51708984375,
-0.2381591796875,
-0.0543212890625,
0.082763671875,
0.40478515625,
0.252685546875,
-0.48046875,
0.10528564453125,
0.724609375,
-0.1875,
0.2255859375,
0.677734375,
-0.285400390625,
-0.304443359375,
0.06988525390625,
-0.0243377685546875,
0.1839599609375,
0.063232421875,
-0.056671142578125,
0.12371826171875,
0.48779296875,
-1.2451171875,
0.0802001953125,
-0.6455078125,
0.48486328125,
0.27978515625,
0.51123046875,
0.270263671875,
-0.40234375,
-0.69921875,
-0.93359375,
0.363037109375,
0.50048828125,
0.344482421875,
-0.417724609375,
1.0126953125,
0.270263671875,
-0.61962890625,
0.32177734375,
-0.7314453125,
0.266357421875,
0.80517578125,
-0.25244140625,
0.71630859375,
-1.263671875,
0.48388671875,
-0.06658935546875,
-0.427001953125,
0.1409912109375,
0.13134765625,
0.65673828125,
-0.25048828125,
-0.1385498046875,
0.08685302734375,
-0.381103515625,
0.1339111328125,
-0.30859375,
0.269775390625,
-0.235107421875,
-1.0498046875,
-1.0361328125,
0.97021484375,
0.77490234375,
0.46923828125,
0.2386474609375,
0.67578125,
0.345947265625,
0.364990234375,
0.53955078125,
0.123046875,
-0.08868408203125,
-0.5185546875,
1.0048828125,
0.325927734375,
-0.384765625,
-0.703125,
-0.337890625,
-0.0867919921875,
0.4765625,
0.14990234375,
0.351318359375,
-1.025390625,
0.125244140625,
0.44580078125,
0.8447265625,
-0.97509765625,
-0.004657745361328125,
-0.02935791015625,
0.3544921875,
0.1304931640625,
-0.7607421875,
0.26953125,
-0.79248046875,
0.43310546875,
0.5546875,
0.136962890625,
-0.429443359375,
-0.1480712890625,
-1.005859375,
-0.420654296875,
0.475830078125,
0.4365234375,
-0.239013671875,
0.53759765625,
-1.10546875,
1.10546875,
0.3623046875,
-0.27587890625,
0.1053466796875,
-0.271728515625,
0.61181640625,
0.2164306640625,
0.7109375,
-0.50537109375,
-0.5390625,
0.2452392578125,
-1.0087890625,
0.1951904296875,
-0.275146484375,
0.4013671875,
-0.162353515625,
0.066650390625,
-0.03973388671875,
0.16064453125,
-0.47998046875,
0.212158203125,
-0.046966552734375,
0.413818359375,
-1.287109375,
-0.97119140625,
0.368896484375,
-0.05828857421875,
-0.294189453125,
0.625,
-0.07275390625,
-0.3701171875,
-0.07470703125,
0.1649169921875,
-0.66748046875,
0.5625,
-0.54296875,
0.281494140625,
-0.234619140625,
-0.245849609375,
0.04656982421875,
-0.39111328125,
0.74560546875,
-0.293701171875,
-0.60791015625,
-0.429443359375,
-1.22265625,
-0.2109375,
-0.1436767578125,
-0.72705078125,
0.04693603515625,
0.442138671875,
-0.388916015625,
-0.203125,
-0.373779296875,
-0.25048828125,
-0.300537109375,
-0.318115234375,
-0.305908203125,
0.71484375,
0.87109375,
0.7294921875,
0.0140838623046875,
0.1201171875,
-0.26904296875,
-0.10321044921875,
-0.1617431640625,
-0.7666015625,
0.26171875,
0.3505859375,
-0.43115234375,
-0.03607177734375,
0.39794921875,
-0.0841064453125,
0.447021484375,
1.2802734375,
-0.1845703125,
0.357177734375,
0.07537841796875,
-0.70849609375,
0.91357421875,
-0.10693359375,
-1.447265625,
-0.425048828125,
0.7138671875,
-0.060089111328125,
0.7744140625,
0.253173828125,
-0.94482421875,
-1.1298828125,
-0.8603515625,
0.405517578125,
-0.7470703125,
-0.1864013671875,
-1.0146484375,
-0.347412109375,
-0.2939453125,
0.64453125,
-0.2076416015625,
-0.382080078125,
0.08331298828125,
-1.19140625,
0.148681640625,
-0.48876953125,
-0.599609375,
-0.9658203125,
-0.44775390625,
-0.32470703125,
0.8701171875,
0.37451171875,
-0.0897216796875,
-0.0667724609375,
0.316162109375,
-0.009002685546875,
-0.0810546875,
-0.80126953125,
-0.2890625,
-0.358642578125,
0.1844482421875,
-0.12646484375,
-0.42529296875,
-0.78271484375,
0.77734375,
-0.379150390625,
0.2281494140625,
0.00010699033737182617,
-0.51806640625,
-0.1781005859375,
-0.3505859375,
1.095703125,
-0.378173828125,
0.171142578125,
-0.64697265625,
0.67822265625,
0.6259765625,
-0.60693359375,
-0.2369384765625,
-0.67626953125,
-0.484375,
-1.4765625,
0.62939453125,
-0.459228515625,
0.30615234375,
-0.599609375,
-0.38427734375,
1.0400390625,
-0.5244140625,
0.40625,
0.95849609375,
-0.1070556640625,
-0.1673583984375,
-0.9033203125,
0.78466796875,
0.59521484375,
-0.466064453125,
-0.1693115234375,
-0.328857421875,
-0.83642578125,
0.2025146484375,
-0.338623046875,
-0.9228515625,
-0.662109375,
0.6396484375,
1.4521484375,
-0.26513671875,
0.448974609375,
0.224853515625,
-0.806640625,
-0.45947265625,
0.5107421875,
0.1556396484375,
-0.022216796875,
0.642578125,
-0.15869140625,
-0.0222015380859375,
0.200927734375,
-0.049468994140625,
-0.332763671875,
-0.4091796875,
1.3056640625,
-0.228271484375,
-0.56591796875,
1.076171875,
0.95947265625,
-0.94140625,
-0.59375,
-0.11248779296875,
0.115234375,
-0.0462646484375,
-0.6962890625,
0.08740234375,
0.576171875,
-0.8203125,
-0.0516357421875,
0.322021484375,
-0.0386962890625,
0.448486328125,
0.370849609375,
0.49072265625,
-0.408203125,
0.24853515625,
0.5380859375,
-0.74072265625,
-0.400634765625,
-1.1455078125,
0.5283203125,
0.043212890625,
0.51904296875,
0.42236328125,
-0.5068359375,
0.331787109375,
0.318115234375,
-0.12890625,
0.9912109375,
-0.423583984375,
-0.18115234375,
0.08636474609375,
-0.97216796875,
-0.7626953125,
0.0614013671875,
0.496337890625,
-0.336669921875,
0.1630859375,
-0.6748046875,
0.08612060546875,
0.1400146484375,
0.265869140625,
-0.024017333984375,
-0.5888671875,
0.0263671875,
-0.62255859375,
-0.4873046875,
-0.9287109375,
-0.66064453125,
0.10943603515625,
0.2291259765625,
-0.65625,
-0.55029296875,
0.476806640625,
0.50341796875,
-0.7255859375,
1.1875,
-0.74462890625,
0.40087890625,
-1.0869140625,
-0.07708740234375,
-0.76171875,
-0.295166015625,
-0.364501953125,
-0.251220703125,
-0.123046875,
0.2626953125,
0.1319580078125,
0.385986328125,
0.1390380859375,
0.66845703125,
-0.53564453125,
-0.2294921875,
0.08355712890625,
0.264892578125,
-0.638671875,
0.814453125,
0.505859375,
0.189208984375,
0.199951171875,
-0.118896484375,
-0.740234375,
0.2086181640625,
0.252685546875,
0.76708984375,
0.292724609375,
0.1279296875,
-0.366455078125,
-0.1566162109375,
-0.79638671875,
0.1231689453125,
-0.2568359375,
0.240234375,
0.305908203125,
-0.64697265625,
0.31201171875,
1.169921875,
-0.326171875,
0.050689697265625,
0.2030029296875,
0.34423828125,
0.3310546875,
0.4130859375,
-0.0869140625,
0.4169921875,
0.54833984375,
-0.37939453125,
-0.4765625,
0.56884765625,
0.007793426513671875,
0.1343994140625,
-0.5302734375,
-0.73388671875,
-1.0771484375,
0.050506591796875,
0.036590576171875,
0.003978729248046875,
0.61474609375,
-0.55908203125,
0.167236328125,
0.020477294921875,
-0.1749267578125,
0.33251953125,
-1.109375,
-0.6884765625,
0.332275390625,
-0.11175537109375,
-0.74755859375,
-0.0523681640625,
-0.426025390625,
-0.11627197265625,
0.25927734375,
0.096923828125,
-0.3759765625,
0.367919921875,
-0.272705078125,
0.34716796875,
-0.6328125,
0.06884765625,
0.074951171875,
0.378662109375,
-0.369873046875,
-0.08758544921875,
0.125244140625,
1.208984375,
-0.1624755859375,
0.1138916015625,
-0.82763671875,
-0.0133056640625,
-0.238037109375,
0.1480712890625,
-0.6015625,
0.312744140625,
-0.1829833984375,
0.57275390625,
-0.919921875,
-0.356689453125,
0.2000732421875,
0.362060546875,
0.351806640625,
-0.414794921875,
-0.67919921875,
1.0302734375,
0.81005859375,
0.0301055908203125,
0.58935546875,
0.32958984375,
0.65625,
-0.2093505859375,
-0.058502197265625,
-0.368408203125,
0.404541015625,
0.44921875,
0.432373046875,
-0.438720703125,
0.6474609375,
0.75634765625,
0.017578125,
0.0936279296875,
0.33984375,
-0.1446533203125,
0.091552734375,
0.201171875,
-0.1529541015625,
-0.09161376953125,
0.2318115234375,
-0.54150390625,
0.453369140625,
-0.24365234375,
-0.17431640625,
-0.7255859375,
-0.74853515625,
0.75634765625,
-0.35205078125,
-0.1873779296875,
-0.09320068359375,
-0.283935546875,
0.348876953125,
0.76171875,
0.021484375,
-0.0657958984375,
0.7431640625,
0.9462890625,
0.31640625,
1.0458984375,
0.4296875,
0.09320068359375,
-0.344970703125,
0.42724609375,
0.435791015625,
0.00749969482421875,
-0.0027332305908203125,
-0.267333984375,
-0.97314453125,
0.787109375,
0.03143310546875,
-0.4970703125,
0.48095703125,
-0.74072265625,
0.21875,
-0.260498046875,
0.428466796875,
-0.77001953125,
0.345458984375,
0.344482421875,
-0.413330078125,
-0.48291015625,
0.79736328125,
-0.11114501953125,
0.56201171875,
0.1431884765625,
0.87890625,
-0.07830810546875,
1.6005859375,
0.740234375,
0.0233001708984375,
0.48583984375,
0.470458984375,
-0.2998046875,
-0.47900390625,
-0.2257080078125,
-0.58203125,
-0.5166015625,
-0.484375,
-0.4130859375,
-0.1492919921875,
0.90087890625,
0.2061767578125,
-0.89208984375,
-0.5302734375,
0.044677734375,
-0.2481689453125,
0.35693359375,
0.437255859375,
0.267822265625,
-0.137451171875,
0.17041015625,
-0.342529296875,
-0.47998046875,
0.059844970703125,
-0.420654296875,
0.3779296875,
-0.66845703125,
-0.7099609375,
-1.0849609375,
-0.88134765625,
-0.130859375,
0.27978515625,
-0.52099609375,
-0.693359375,
0.58740234375,
0.5029296875,
0.43310546875,
-0.042816162109375,
-0.11968994140625,
-0.0118560791015625,
0.70458984375,
0.87548828125,
-0.046661376953125,
0.564453125,
0.388916015625,
-0.062164306640625,
-0.0193634033203125,
-0.69580078125,
0.6044921875,
0.1187744140625,
0.006805419921875,
-0.417236328125,
0.1966552734375,
-0.95166015625,
-1.4462890625,
-0.150634765625,
0.1072998046875,
0.11444091796875,
-0.8642578125,
-1.208984375,
-0.5078125,
-0.70068359375,
-0.08026123046875,
-0.182861328125,
0.8701171875,
0.0621337890625,
-0.11822509765625,
-0.299560546875,
-0.99609375,
4.35546875,
1.2880859375,
0.87744140625,
0.0384521484375,
0.5703125,
1.1650390625,
0.490234375,
-0.89697265625,
-0.42041015625,
-0.2156982421875,
0.42626953125,
-0.35546875,
-0.2294921875,
0.5556640625,
0.11566162109375,
0.451416015625,
-0.703125,
-0.10906982421875,
-0.181884765625,
-0.77001953125,
-0.9677734375,
0.243408203125,
-0.09710693359375,
0.1585693359375,
0.1651611328125,
0.471923828125,
0.90380859375,
-0.6982421875,
0.042633056640625,
-0.638671875,
-0.10943603515625,
-0.37646484375,
1.0673828125,
0.345947265625,
-0.1759033203125,
0.53076171875,
-0.0809326171875,
-0.76318359375,
-0.021148681640625,
0.274169921875,
-0.58154296875,
-0.098876953125,
1.0625,
-0.316162109375,
0.1396484375,
0.405517578125,
-0.56982421875,
0.405029296875,
0.1761474609375,
-0.68310546875,
1.0751953125,
-0.044281005859375,
0.463623046875,
-0.71435546875,
-0.31884765625,
0.2105712890625,
0.48681640625,
0.035125732421875,
0.0081634521484375,
0.251220703125,
0.404052734375,
0.060455322265625,
0.313232421875,
0.62255859375,
-0.76513671875,
0.7626953125,
-0.38916015625,
0.172119140625,
-0.77685546875,
-0.0211639404296875,
-0.238037109375,
-0.07977294921875,
-0.4775390625,
-0.44580078125,
0.8544921875,
0.296142578125,
-0.07855224609375,
0.2462158203125,
0.2271728515625,
-0.73388671875,
0.242431640625,
-0.2047119140625,
-0.069091796875,
-0.042755126953125,
0.286376953125,
1.4501953125,
-0.375244140625,
-0.10369873046875,
-0.305419921875,
0.77783203125,
0.53076171875,
0.471923828125,
-0.1375732421875,
-0.68896484375,
-0.465087890625
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Submitted Solution:
```
n = int(input())
s = input()
ans = ''
if n % 2 == 0:
for i in range(1, n // 2 + 1):
ans += s[-i * 2]
for j in range(1, n // 2 + 1):
ans += s[2 * j - 1]
else:
for i in range(1, n // 2 + 1):
ans += s[-i * 2]
for j in range(n // 2 + 1):
ans += s[j * 2]
print(ans)
```
Yes
| 72,180 | [
0.6640625,
-0.263671875,
0.2066650390625,
0.4423828125,
-0.546875,
-0.5322265625,
0.078125,
0.0107574462890625,
-0.398193359375,
0.68798828125,
0.9072265625,
-0.1680908203125,
-0.081787109375,
-0.638671875,
-0.869140625,
-0.50439453125,
-0.3671875,
-0.60302734375,
-0.68408203125,
0.11676025390625,
0.1805419921875,
0.05804443359375,
-1.208984375,
-0.132568359375,
-0.435546875,
1.0732421875,
0.55908203125,
-0.1407470703125,
1.248046875,
0.9697265625,
0.039398193359375,
0.058441162109375,
0.77294921875,
-1.1494140625,
-0.304443359375,
-0.3330078125,
0.7080078125,
-0.3388671875,
-0.380615234375,
-0.53466796875,
0.1275634765625,
-0.284912109375,
0.470947265625,
-0.5966796875,
-0.888671875,
-0.10589599609375,
-0.24072265625,
-0.8427734375,
-0.3203125,
-0.86181640625,
0.208251953125,
-0.322998046875,
0.5166015625,
-0.333251953125,
-0.02777099609375,
-0.1883544921875,
-0.08575439453125,
0.018798828125,
-0.368896484375,
0.22119140625,
0.39990234375,
0.435791015625,
0.1151123046875,
-1.09765625,
-0.2998046875,
-0.19384765625,
-0.05047607421875,
-0.11395263671875,
-0.0091705322265625,
-0.53564453125,
-0.14306640625,
0.420166015625,
-0.21875,
-0.53271484375,
-0.304443359375,
0.059967041015625,
0.2344970703125,
0.25341796875,
-0.83740234375,
0.892578125,
0.12890625,
1.01171875,
0.802734375,
0.410400390625,
-0.54150390625,
-0.2021484375,
0.12103271484375,
0.35595703125,
0.152587890625,
-0.010711669921875,
0.121826171875,
0.444580078125,
-0.273193359375,
0.0870361328125,
0.51025390625,
0.5537109375,
-0.01300048828125,
0.312744140625,
0.09173583984375,
0.58984375,
0.8115234375,
1.2958984375,
-0.205322265625,
1.0908203125,
-0.404052734375,
0.5234375,
0.18603515625,
0.1834716796875,
-0.279296875,
0.019073486328125,
-0.361572265625,
-0.129638671875,
0.05419921875,
-0.274658203125,
-0.2220458984375,
0.9296875,
-0.1943359375,
0.2327880859375,
-0.8544921875,
0.3955078125,
0.266845703125,
0.204833984375,
0.4287109375,
-0.329345703125,
0.3583984375,
-0.390380859375,
-0.669921875,
1.0654296875,
-0.42333984375,
-0.428466796875,
0.1630859375,
0.27001953125,
-0.36474609375,
0.1807861328125,
0.306884765625,
0.6904296875,
0.11376953125,
0.4375,
0.8017578125,
-0.34619140625,
0.3486328125,
0.19140625,
-0.316162109375,
1.4951171875,
-0.1932373046875,
-0.28759765625,
0.41796875,
0.2335205078125,
-0.7890625,
0.6201171875,
-0.75830078125,
0.453857421875,
-0.284912109375,
0.1688232421875,
-0.385986328125,
0.02276611328125,
-0.33447265625,
0.63232421875,
0.0513916015625,
-0.004364013671875,
-0.29052734375,
-0.101318359375,
-0.47265625,
0.87255859375,
-0.640625,
1.1953125,
-0.908203125,
-0.5634765625,
-0.46044921875,
-0.1778564453125,
0.390625,
-0.163818359375,
-0.0244598388671875,
0.765625,
0.403076171875,
0.87841796875,
0.703125,
-0.343017578125,
0.301513671875,
0.08367919921875,
0.1048583984375,
0.2294921875,
0.28662109375,
0.78662109375,
0.1585693359375,
-0.005184173583984375,
0.0797119140625,
-0.391357421875,
-0.53662109375,
-0.34423828125,
-0.1419677734375,
0.86865234375,
-0.445068359375,
-0.1248779296875,
-0.285888671875,
-0.320556640625,
-0.60498046875,
-0.39111328125,
-0.0301666259765625,
-1.0810546875,
-0.3115234375,
0.83935546875,
-0.262451171875,
0.5849609375,
-0.437255859375,
-0.66845703125,
0.280029296875,
1.1787109375,
-0.1939697265625,
-0.1712646484375,
0.95751953125,
0.327880859375,
-0.465576171875,
0.1534423828125,
0.2349853515625,
0.0943603515625,
-0.81494140625,
0.6337890625,
-0.398681640625,
-0.0194549560546875,
-0.227294921875,
0.72802734375,
0.2012939453125,
0.36865234375,
-0.541015625,
0.10125732421875,
0.69384765625,
1.056640625,
-0.057525634765625,
0.318359375,
0.313720703125,
0.53759765625,
0.297607421875,
0.72607421875,
0.79052734375,
0.416259765625,
0.7333984375,
0.79736328125,
-0.2191162109375,
0.2822265625,
-0.038238525390625,
0.448974609375,
0.7939453125,
0.22509765625,
0.13671875,
0.5732421875,
-0.437744140625,
-0.1295166015625,
-0.47705078125,
0.1234130859375,
-0.30029296875,
0.05535888671875,
0.2161865234375,
0.289794921875,
-0.45654296875,
-0.422607421875,
0.450927734375,
0.65185546875,
-0.724609375,
-0.65869140625,
0.2083740234375,
0.22900390625,
0.48828125,
0.478515625,
0.382080078125,
0.61474609375,
0.6015625,
0.50146484375,
-0.282470703125,
-0.6025390625,
-0.65283203125,
-1.533203125,
-1.12890625,
-0.24609375,
-0.79150390625,
0.03155517578125,
0.02947998046875,
-1.091796875,
-0.1732177734375,
-0.419921875,
-0.5205078125,
-0.412841796875,
-0.283203125,
0.61328125,
-0.1632080078125,
0.73046875,
-0.43994140625,
0.509765625,
0.173095703125,
1.080078125,
-0.66845703125,
-0.1505126953125,
-0.385009765625,
-0.50634765625,
0.377685546875,
-0.1297607421875,
0.5068359375,
-0.32421875,
-0.82177734375,
-0.64990234375,
-0.7177734375,
0.162353515625,
-0.40673828125,
-0.003406524658203125,
-0.406982421875,
0.90283203125,
0.26123046875,
-0.66357421875,
0.318603515625,
0.9423828125,
-0.8818359375,
0.4501953125,
0.347412109375,
-0.1649169921875,
-0.7802734375,
1.42578125,
0.39306640625,
0.5126953125,
-0.450439453125,
-0.1881103515625,
-0.163818359375,
0.1617431640625,
-0.01242828369140625,
-0.52587890625,
-0.3935546875,
0.630859375,
0.10931396484375,
-1.4013671875,
0.1610107421875,
-1.138671875,
-0.759765625,
-0.35400390625,
-0.6591796875,
0.76611328125,
0.9423828125,
0.51708984375,
-0.2381591796875,
-0.0543212890625,
0.082763671875,
0.40478515625,
0.252685546875,
-0.48046875,
0.10528564453125,
0.724609375,
-0.1875,
0.2255859375,
0.677734375,
-0.285400390625,
-0.304443359375,
0.06988525390625,
-0.0243377685546875,
0.1839599609375,
0.063232421875,
-0.056671142578125,
0.12371826171875,
0.48779296875,
-1.2451171875,
0.0802001953125,
-0.6455078125,
0.48486328125,
0.27978515625,
0.51123046875,
0.270263671875,
-0.40234375,
-0.69921875,
-0.93359375,
0.363037109375,
0.50048828125,
0.344482421875,
-0.417724609375,
1.0126953125,
0.270263671875,
-0.61962890625,
0.32177734375,
-0.7314453125,
0.266357421875,
0.80517578125,
-0.25244140625,
0.71630859375,
-1.263671875,
0.48388671875,
-0.06658935546875,
-0.427001953125,
0.1409912109375,
0.13134765625,
0.65673828125,
-0.25048828125,
-0.1385498046875,
0.08685302734375,
-0.381103515625,
0.1339111328125,
-0.30859375,
0.269775390625,
-0.235107421875,
-1.0498046875,
-1.0361328125,
0.97021484375,
0.77490234375,
0.46923828125,
0.2386474609375,
0.67578125,
0.345947265625,
0.364990234375,
0.53955078125,
0.123046875,
-0.08868408203125,
-0.5185546875,
1.0048828125,
0.325927734375,
-0.384765625,
-0.703125,
-0.337890625,
-0.0867919921875,
0.4765625,
0.14990234375,
0.351318359375,
-1.025390625,
0.125244140625,
0.44580078125,
0.8447265625,
-0.97509765625,
-0.004657745361328125,
-0.02935791015625,
0.3544921875,
0.1304931640625,
-0.7607421875,
0.26953125,
-0.79248046875,
0.43310546875,
0.5546875,
0.136962890625,
-0.429443359375,
-0.1480712890625,
-1.005859375,
-0.420654296875,
0.475830078125,
0.4365234375,
-0.239013671875,
0.53759765625,
-1.10546875,
1.10546875,
0.3623046875,
-0.27587890625,
0.1053466796875,
-0.271728515625,
0.61181640625,
0.2164306640625,
0.7109375,
-0.50537109375,
-0.5390625,
0.2452392578125,
-1.0087890625,
0.1951904296875,
-0.275146484375,
0.4013671875,
-0.162353515625,
0.066650390625,
-0.03973388671875,
0.16064453125,
-0.47998046875,
0.212158203125,
-0.046966552734375,
0.413818359375,
-1.287109375,
-0.97119140625,
0.368896484375,
-0.05828857421875,
-0.294189453125,
0.625,
-0.07275390625,
-0.3701171875,
-0.07470703125,
0.1649169921875,
-0.66748046875,
0.5625,
-0.54296875,
0.281494140625,
-0.234619140625,
-0.245849609375,
0.04656982421875,
-0.39111328125,
0.74560546875,
-0.293701171875,
-0.60791015625,
-0.429443359375,
-1.22265625,
-0.2109375,
-0.1436767578125,
-0.72705078125,
0.04693603515625,
0.442138671875,
-0.388916015625,
-0.203125,
-0.373779296875,
-0.25048828125,
-0.300537109375,
-0.318115234375,
-0.305908203125,
0.71484375,
0.87109375,
0.7294921875,
0.0140838623046875,
0.1201171875,
-0.26904296875,
-0.10321044921875,
-0.1617431640625,
-0.7666015625,
0.26171875,
0.3505859375,
-0.43115234375,
-0.03607177734375,
0.39794921875,
-0.0841064453125,
0.447021484375,
1.2802734375,
-0.1845703125,
0.357177734375,
0.07537841796875,
-0.70849609375,
0.91357421875,
-0.10693359375,
-1.447265625,
-0.425048828125,
0.7138671875,
-0.060089111328125,
0.7744140625,
0.253173828125,
-0.94482421875,
-1.1298828125,
-0.8603515625,
0.405517578125,
-0.7470703125,
-0.1864013671875,
-1.0146484375,
-0.347412109375,
-0.2939453125,
0.64453125,
-0.2076416015625,
-0.382080078125,
0.08331298828125,
-1.19140625,
0.148681640625,
-0.48876953125,
-0.599609375,
-0.9658203125,
-0.44775390625,
-0.32470703125,
0.8701171875,
0.37451171875,
-0.0897216796875,
-0.0667724609375,
0.316162109375,
-0.009002685546875,
-0.0810546875,
-0.80126953125,
-0.2890625,
-0.358642578125,
0.1844482421875,
-0.12646484375,
-0.42529296875,
-0.78271484375,
0.77734375,
-0.379150390625,
0.2281494140625,
0.00010699033737182617,
-0.51806640625,
-0.1781005859375,
-0.3505859375,
1.095703125,
-0.378173828125,
0.171142578125,
-0.64697265625,
0.67822265625,
0.6259765625,
-0.60693359375,
-0.2369384765625,
-0.67626953125,
-0.484375,
-1.4765625,
0.62939453125,
-0.459228515625,
0.30615234375,
-0.599609375,
-0.38427734375,
1.0400390625,
-0.5244140625,
0.40625,
0.95849609375,
-0.1070556640625,
-0.1673583984375,
-0.9033203125,
0.78466796875,
0.59521484375,
-0.466064453125,
-0.1693115234375,
-0.328857421875,
-0.83642578125,
0.2025146484375,
-0.338623046875,
-0.9228515625,
-0.662109375,
0.6396484375,
1.4521484375,
-0.26513671875,
0.448974609375,
0.224853515625,
-0.806640625,
-0.45947265625,
0.5107421875,
0.1556396484375,
-0.022216796875,
0.642578125,
-0.15869140625,
-0.0222015380859375,
0.200927734375,
-0.049468994140625,
-0.332763671875,
-0.4091796875,
1.3056640625,
-0.228271484375,
-0.56591796875,
1.076171875,
0.95947265625,
-0.94140625,
-0.59375,
-0.11248779296875,
0.115234375,
-0.0462646484375,
-0.6962890625,
0.08740234375,
0.576171875,
-0.8203125,
-0.0516357421875,
0.322021484375,
-0.0386962890625,
0.448486328125,
0.370849609375,
0.49072265625,
-0.408203125,
0.24853515625,
0.5380859375,
-0.74072265625,
-0.400634765625,
-1.1455078125,
0.5283203125,
0.043212890625,
0.51904296875,
0.42236328125,
-0.5068359375,
0.331787109375,
0.318115234375,
-0.12890625,
0.9912109375,
-0.423583984375,
-0.18115234375,
0.08636474609375,
-0.97216796875,
-0.7626953125,
0.0614013671875,
0.496337890625,
-0.336669921875,
0.1630859375,
-0.6748046875,
0.08612060546875,
0.1400146484375,
0.265869140625,
-0.024017333984375,
-0.5888671875,
0.0263671875,
-0.62255859375,
-0.4873046875,
-0.9287109375,
-0.66064453125,
0.10943603515625,
0.2291259765625,
-0.65625,
-0.55029296875,
0.476806640625,
0.50341796875,
-0.7255859375,
1.1875,
-0.74462890625,
0.40087890625,
-1.0869140625,
-0.07708740234375,
-0.76171875,
-0.295166015625,
-0.364501953125,
-0.251220703125,
-0.123046875,
0.2626953125,
0.1319580078125,
0.385986328125,
0.1390380859375,
0.66845703125,
-0.53564453125,
-0.2294921875,
0.08355712890625,
0.264892578125,
-0.638671875,
0.814453125,
0.505859375,
0.189208984375,
0.199951171875,
-0.118896484375,
-0.740234375,
0.2086181640625,
0.252685546875,
0.76708984375,
0.292724609375,
0.1279296875,
-0.366455078125,
-0.1566162109375,
-0.79638671875,
0.1231689453125,
-0.2568359375,
0.240234375,
0.305908203125,
-0.64697265625,
0.31201171875,
1.169921875,
-0.326171875,
0.050689697265625,
0.2030029296875,
0.34423828125,
0.3310546875,
0.4130859375,
-0.0869140625,
0.4169921875,
0.54833984375,
-0.37939453125,
-0.4765625,
0.56884765625,
0.007793426513671875,
0.1343994140625,
-0.5302734375,
-0.73388671875,
-1.0771484375,
0.050506591796875,
0.036590576171875,
0.003978729248046875,
0.61474609375,
-0.55908203125,
0.167236328125,
0.020477294921875,
-0.1749267578125,
0.33251953125,
-1.109375,
-0.6884765625,
0.332275390625,
-0.11175537109375,
-0.74755859375,
-0.0523681640625,
-0.426025390625,
-0.11627197265625,
0.25927734375,
0.096923828125,
-0.3759765625,
0.367919921875,
-0.272705078125,
0.34716796875,
-0.6328125,
0.06884765625,
0.074951171875,
0.378662109375,
-0.369873046875,
-0.08758544921875,
0.125244140625,
1.208984375,
-0.1624755859375,
0.1138916015625,
-0.82763671875,
-0.0133056640625,
-0.238037109375,
0.1480712890625,
-0.6015625,
0.312744140625,
-0.1829833984375,
0.57275390625,
-0.919921875,
-0.356689453125,
0.2000732421875,
0.362060546875,
0.351806640625,
-0.414794921875,
-0.67919921875,
1.0302734375,
0.81005859375,
0.0301055908203125,
0.58935546875,
0.32958984375,
0.65625,
-0.2093505859375,
-0.058502197265625,
-0.368408203125,
0.404541015625,
0.44921875,
0.432373046875,
-0.438720703125,
0.6474609375,
0.75634765625,
0.017578125,
0.0936279296875,
0.33984375,
-0.1446533203125,
0.091552734375,
0.201171875,
-0.1529541015625,
-0.09161376953125,
0.2318115234375,
-0.54150390625,
0.453369140625,
-0.24365234375,
-0.17431640625,
-0.7255859375,
-0.74853515625,
0.75634765625,
-0.35205078125,
-0.1873779296875,
-0.09320068359375,
-0.283935546875,
0.348876953125,
0.76171875,
0.021484375,
-0.0657958984375,
0.7431640625,
0.9462890625,
0.31640625,
1.0458984375,
0.4296875,
0.09320068359375,
-0.344970703125,
0.42724609375,
0.435791015625,
0.00749969482421875,
-0.0027332305908203125,
-0.267333984375,
-0.97314453125,
0.787109375,
0.03143310546875,
-0.4970703125,
0.48095703125,
-0.74072265625,
0.21875,
-0.260498046875,
0.428466796875,
-0.77001953125,
0.345458984375,
0.344482421875,
-0.413330078125,
-0.48291015625,
0.79736328125,
-0.11114501953125,
0.56201171875,
0.1431884765625,
0.87890625,
-0.07830810546875,
1.6005859375,
0.740234375,
0.0233001708984375,
0.48583984375,
0.470458984375,
-0.2998046875,
-0.47900390625,
-0.2257080078125,
-0.58203125,
-0.5166015625,
-0.484375,
-0.4130859375,
-0.1492919921875,
0.90087890625,
0.2061767578125,
-0.89208984375,
-0.5302734375,
0.044677734375,
-0.2481689453125,
0.35693359375,
0.437255859375,
0.267822265625,
-0.137451171875,
0.17041015625,
-0.342529296875,
-0.47998046875,
0.059844970703125,
-0.420654296875,
0.3779296875,
-0.66845703125,
-0.7099609375,
-1.0849609375,
-0.88134765625,
-0.130859375,
0.27978515625,
-0.52099609375,
-0.693359375,
0.58740234375,
0.5029296875,
0.43310546875,
-0.042816162109375,
-0.11968994140625,
-0.0118560791015625,
0.70458984375,
0.87548828125,
-0.046661376953125,
0.564453125,
0.388916015625,
-0.062164306640625,
-0.0193634033203125,
-0.69580078125,
0.6044921875,
0.1187744140625,
0.006805419921875,
-0.417236328125,
0.1966552734375,
-0.95166015625,
-1.4462890625,
-0.150634765625,
0.1072998046875,
0.11444091796875,
-0.8642578125,
-1.208984375,
-0.5078125,
-0.70068359375,
-0.08026123046875,
-0.182861328125,
0.8701171875,
0.0621337890625,
-0.11822509765625,
-0.299560546875,
-0.99609375,
4.35546875,
1.2880859375,
0.87744140625,
0.0384521484375,
0.5703125,
1.1650390625,
0.490234375,
-0.89697265625,
-0.42041015625,
-0.2156982421875,
0.42626953125,
-0.35546875,
-0.2294921875,
0.5556640625,
0.11566162109375,
0.451416015625,
-0.703125,
-0.10906982421875,
-0.181884765625,
-0.77001953125,
-0.9677734375,
0.243408203125,
-0.09710693359375,
0.1585693359375,
0.1651611328125,
0.471923828125,
0.90380859375,
-0.6982421875,
0.042633056640625,
-0.638671875,
-0.10943603515625,
-0.37646484375,
1.0673828125,
0.345947265625,
-0.1759033203125,
0.53076171875,
-0.0809326171875,
-0.76318359375,
-0.021148681640625,
0.274169921875,
-0.58154296875,
-0.098876953125,
1.0625,
-0.316162109375,
0.1396484375,
0.405517578125,
-0.56982421875,
0.405029296875,
0.1761474609375,
-0.68310546875,
1.0751953125,
-0.044281005859375,
0.463623046875,
-0.71435546875,
-0.31884765625,
0.2105712890625,
0.48681640625,
0.035125732421875,
0.0081634521484375,
0.251220703125,
0.404052734375,
0.060455322265625,
0.313232421875,
0.62255859375,
-0.76513671875,
0.7626953125,
-0.38916015625,
0.172119140625,
-0.77685546875,
-0.0211639404296875,
-0.238037109375,
-0.07977294921875,
-0.4775390625,
-0.44580078125,
0.8544921875,
0.296142578125,
-0.07855224609375,
0.2462158203125,
0.2271728515625,
-0.73388671875,
0.242431640625,
-0.2047119140625,
-0.069091796875,
-0.042755126953125,
0.286376953125,
1.4501953125,
-0.375244140625,
-0.10369873046875,
-0.305419921875,
0.77783203125,
0.53076171875,
0.471923828125,
-0.1375732421875,
-0.68896484375,
-0.465087890625
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Submitted Solution:
```
x=int(input());a=input();b='x'*x;c=list(b)
for i in range(x):
c[b.find('x',(len(a)-1)//2)]=a[0]
b=''.join(c)
a=a.replace(a[0],'',1)
print(b)
#author:SK__Shanto__㋛
#code__define__your__smartness
```
No
| 72,181 | [
0.6640625,
-0.263671875,
0.2066650390625,
0.4423828125,
-0.546875,
-0.5322265625,
0.078125,
0.0107574462890625,
-0.398193359375,
0.68798828125,
0.9072265625,
-0.1680908203125,
-0.081787109375,
-0.638671875,
-0.869140625,
-0.50439453125,
-0.3671875,
-0.60302734375,
-0.68408203125,
0.11676025390625,
0.1805419921875,
0.05804443359375,
-1.208984375,
-0.132568359375,
-0.435546875,
1.0732421875,
0.55908203125,
-0.1407470703125,
1.248046875,
0.9697265625,
0.039398193359375,
0.058441162109375,
0.77294921875,
-1.1494140625,
-0.304443359375,
-0.3330078125,
0.7080078125,
-0.3388671875,
-0.380615234375,
-0.53466796875,
0.1275634765625,
-0.284912109375,
0.470947265625,
-0.5966796875,
-0.888671875,
-0.10589599609375,
-0.24072265625,
-0.8427734375,
-0.3203125,
-0.86181640625,
0.208251953125,
-0.322998046875,
0.5166015625,
-0.333251953125,
-0.02777099609375,
-0.1883544921875,
-0.08575439453125,
0.018798828125,
-0.368896484375,
0.22119140625,
0.39990234375,
0.435791015625,
0.1151123046875,
-1.09765625,
-0.2998046875,
-0.19384765625,
-0.05047607421875,
-0.11395263671875,
-0.0091705322265625,
-0.53564453125,
-0.14306640625,
0.420166015625,
-0.21875,
-0.53271484375,
-0.304443359375,
0.059967041015625,
0.2344970703125,
0.25341796875,
-0.83740234375,
0.892578125,
0.12890625,
1.01171875,
0.802734375,
0.410400390625,
-0.54150390625,
-0.2021484375,
0.12103271484375,
0.35595703125,
0.152587890625,
-0.010711669921875,
0.121826171875,
0.444580078125,
-0.273193359375,
0.0870361328125,
0.51025390625,
0.5537109375,
-0.01300048828125,
0.312744140625,
0.09173583984375,
0.58984375,
0.8115234375,
1.2958984375,
-0.205322265625,
1.0908203125,
-0.404052734375,
0.5234375,
0.18603515625,
0.1834716796875,
-0.279296875,
0.019073486328125,
-0.361572265625,
-0.129638671875,
0.05419921875,
-0.274658203125,
-0.2220458984375,
0.9296875,
-0.1943359375,
0.2327880859375,
-0.8544921875,
0.3955078125,
0.266845703125,
0.204833984375,
0.4287109375,
-0.329345703125,
0.3583984375,
-0.390380859375,
-0.669921875,
1.0654296875,
-0.42333984375,
-0.428466796875,
0.1630859375,
0.27001953125,
-0.36474609375,
0.1807861328125,
0.306884765625,
0.6904296875,
0.11376953125,
0.4375,
0.8017578125,
-0.34619140625,
0.3486328125,
0.19140625,
-0.316162109375,
1.4951171875,
-0.1932373046875,
-0.28759765625,
0.41796875,
0.2335205078125,
-0.7890625,
0.6201171875,
-0.75830078125,
0.453857421875,
-0.284912109375,
0.1688232421875,
-0.385986328125,
0.02276611328125,
-0.33447265625,
0.63232421875,
0.0513916015625,
-0.004364013671875,
-0.29052734375,
-0.101318359375,
-0.47265625,
0.87255859375,
-0.640625,
1.1953125,
-0.908203125,
-0.5634765625,
-0.46044921875,
-0.1778564453125,
0.390625,
-0.163818359375,
-0.0244598388671875,
0.765625,
0.403076171875,
0.87841796875,
0.703125,
-0.343017578125,
0.301513671875,
0.08367919921875,
0.1048583984375,
0.2294921875,
0.28662109375,
0.78662109375,
0.1585693359375,
-0.005184173583984375,
0.0797119140625,
-0.391357421875,
-0.53662109375,
-0.34423828125,
-0.1419677734375,
0.86865234375,
-0.445068359375,
-0.1248779296875,
-0.285888671875,
-0.320556640625,
-0.60498046875,
-0.39111328125,
-0.0301666259765625,
-1.0810546875,
-0.3115234375,
0.83935546875,
-0.262451171875,
0.5849609375,
-0.437255859375,
-0.66845703125,
0.280029296875,
1.1787109375,
-0.1939697265625,
-0.1712646484375,
0.95751953125,
0.327880859375,
-0.465576171875,
0.1534423828125,
0.2349853515625,
0.0943603515625,
-0.81494140625,
0.6337890625,
-0.398681640625,
-0.0194549560546875,
-0.227294921875,
0.72802734375,
0.2012939453125,
0.36865234375,
-0.541015625,
0.10125732421875,
0.69384765625,
1.056640625,
-0.057525634765625,
0.318359375,
0.313720703125,
0.53759765625,
0.297607421875,
0.72607421875,
0.79052734375,
0.416259765625,
0.7333984375,
0.79736328125,
-0.2191162109375,
0.2822265625,
-0.038238525390625,
0.448974609375,
0.7939453125,
0.22509765625,
0.13671875,
0.5732421875,
-0.437744140625,
-0.1295166015625,
-0.47705078125,
0.1234130859375,
-0.30029296875,
0.05535888671875,
0.2161865234375,
0.289794921875,
-0.45654296875,
-0.422607421875,
0.450927734375,
0.65185546875,
-0.724609375,
-0.65869140625,
0.2083740234375,
0.22900390625,
0.48828125,
0.478515625,
0.382080078125,
0.61474609375,
0.6015625,
0.50146484375,
-0.282470703125,
-0.6025390625,
-0.65283203125,
-1.533203125,
-1.12890625,
-0.24609375,
-0.79150390625,
0.03155517578125,
0.02947998046875,
-1.091796875,
-0.1732177734375,
-0.419921875,
-0.5205078125,
-0.412841796875,
-0.283203125,
0.61328125,
-0.1632080078125,
0.73046875,
-0.43994140625,
0.509765625,
0.173095703125,
1.080078125,
-0.66845703125,
-0.1505126953125,
-0.385009765625,
-0.50634765625,
0.377685546875,
-0.1297607421875,
0.5068359375,
-0.32421875,
-0.82177734375,
-0.64990234375,
-0.7177734375,
0.162353515625,
-0.40673828125,
-0.003406524658203125,
-0.406982421875,
0.90283203125,
0.26123046875,
-0.66357421875,
0.318603515625,
0.9423828125,
-0.8818359375,
0.4501953125,
0.347412109375,
-0.1649169921875,
-0.7802734375,
1.42578125,
0.39306640625,
0.5126953125,
-0.450439453125,
-0.1881103515625,
-0.163818359375,
0.1617431640625,
-0.01242828369140625,
-0.52587890625,
-0.3935546875,
0.630859375,
0.10931396484375,
-1.4013671875,
0.1610107421875,
-1.138671875,
-0.759765625,
-0.35400390625,
-0.6591796875,
0.76611328125,
0.9423828125,
0.51708984375,
-0.2381591796875,
-0.0543212890625,
0.082763671875,
0.40478515625,
0.252685546875,
-0.48046875,
0.10528564453125,
0.724609375,
-0.1875,
0.2255859375,
0.677734375,
-0.285400390625,
-0.304443359375,
0.06988525390625,
-0.0243377685546875,
0.1839599609375,
0.063232421875,
-0.056671142578125,
0.12371826171875,
0.48779296875,
-1.2451171875,
0.0802001953125,
-0.6455078125,
0.48486328125,
0.27978515625,
0.51123046875,
0.270263671875,
-0.40234375,
-0.69921875,
-0.93359375,
0.363037109375,
0.50048828125,
0.344482421875,
-0.417724609375,
1.0126953125,
0.270263671875,
-0.61962890625,
0.32177734375,
-0.7314453125,
0.266357421875,
0.80517578125,
-0.25244140625,
0.71630859375,
-1.263671875,
0.48388671875,
-0.06658935546875,
-0.427001953125,
0.1409912109375,
0.13134765625,
0.65673828125,
-0.25048828125,
-0.1385498046875,
0.08685302734375,
-0.381103515625,
0.1339111328125,
-0.30859375,
0.269775390625,
-0.235107421875,
-1.0498046875,
-1.0361328125,
0.97021484375,
0.77490234375,
0.46923828125,
0.2386474609375,
0.67578125,
0.345947265625,
0.364990234375,
0.53955078125,
0.123046875,
-0.08868408203125,
-0.5185546875,
1.0048828125,
0.325927734375,
-0.384765625,
-0.703125,
-0.337890625,
-0.0867919921875,
0.4765625,
0.14990234375,
0.351318359375,
-1.025390625,
0.125244140625,
0.44580078125,
0.8447265625,
-0.97509765625,
-0.004657745361328125,
-0.02935791015625,
0.3544921875,
0.1304931640625,
-0.7607421875,
0.26953125,
-0.79248046875,
0.43310546875,
0.5546875,
0.136962890625,
-0.429443359375,
-0.1480712890625,
-1.005859375,
-0.420654296875,
0.475830078125,
0.4365234375,
-0.239013671875,
0.53759765625,
-1.10546875,
1.10546875,
0.3623046875,
-0.27587890625,
0.1053466796875,
-0.271728515625,
0.61181640625,
0.2164306640625,
0.7109375,
-0.50537109375,
-0.5390625,
0.2452392578125,
-1.0087890625,
0.1951904296875,
-0.275146484375,
0.4013671875,
-0.162353515625,
0.066650390625,
-0.03973388671875,
0.16064453125,
-0.47998046875,
0.212158203125,
-0.046966552734375,
0.413818359375,
-1.287109375,
-0.97119140625,
0.368896484375,
-0.05828857421875,
-0.294189453125,
0.625,
-0.07275390625,
-0.3701171875,
-0.07470703125,
0.1649169921875,
-0.66748046875,
0.5625,
-0.54296875,
0.281494140625,
-0.234619140625,
-0.245849609375,
0.04656982421875,
-0.39111328125,
0.74560546875,
-0.293701171875,
-0.60791015625,
-0.429443359375,
-1.22265625,
-0.2109375,
-0.1436767578125,
-0.72705078125,
0.04693603515625,
0.442138671875,
-0.388916015625,
-0.203125,
-0.373779296875,
-0.25048828125,
-0.300537109375,
-0.318115234375,
-0.305908203125,
0.71484375,
0.87109375,
0.7294921875,
0.0140838623046875,
0.1201171875,
-0.26904296875,
-0.10321044921875,
-0.1617431640625,
-0.7666015625,
0.26171875,
0.3505859375,
-0.43115234375,
-0.03607177734375,
0.39794921875,
-0.0841064453125,
0.447021484375,
1.2802734375,
-0.1845703125,
0.357177734375,
0.07537841796875,
-0.70849609375,
0.91357421875,
-0.10693359375,
-1.447265625,
-0.425048828125,
0.7138671875,
-0.060089111328125,
0.7744140625,
0.253173828125,
-0.94482421875,
-1.1298828125,
-0.8603515625,
0.405517578125,
-0.7470703125,
-0.1864013671875,
-1.0146484375,
-0.347412109375,
-0.2939453125,
0.64453125,
-0.2076416015625,
-0.382080078125,
0.08331298828125,
-1.19140625,
0.148681640625,
-0.48876953125,
-0.599609375,
-0.9658203125,
-0.44775390625,
-0.32470703125,
0.8701171875,
0.37451171875,
-0.0897216796875,
-0.0667724609375,
0.316162109375,
-0.009002685546875,
-0.0810546875,
-0.80126953125,
-0.2890625,
-0.358642578125,
0.1844482421875,
-0.12646484375,
-0.42529296875,
-0.78271484375,
0.77734375,
-0.379150390625,
0.2281494140625,
0.00010699033737182617,
-0.51806640625,
-0.1781005859375,
-0.3505859375,
1.095703125,
-0.378173828125,
0.171142578125,
-0.64697265625,
0.67822265625,
0.6259765625,
-0.60693359375,
-0.2369384765625,
-0.67626953125,
-0.484375,
-1.4765625,
0.62939453125,
-0.459228515625,
0.30615234375,
-0.599609375,
-0.38427734375,
1.0400390625,
-0.5244140625,
0.40625,
0.95849609375,
-0.1070556640625,
-0.1673583984375,
-0.9033203125,
0.78466796875,
0.59521484375,
-0.466064453125,
-0.1693115234375,
-0.328857421875,
-0.83642578125,
0.2025146484375,
-0.338623046875,
-0.9228515625,
-0.662109375,
0.6396484375,
1.4521484375,
-0.26513671875,
0.448974609375,
0.224853515625,
-0.806640625,
-0.45947265625,
0.5107421875,
0.1556396484375,
-0.022216796875,
0.642578125,
-0.15869140625,
-0.0222015380859375,
0.200927734375,
-0.049468994140625,
-0.332763671875,
-0.4091796875,
1.3056640625,
-0.228271484375,
-0.56591796875,
1.076171875,
0.95947265625,
-0.94140625,
-0.59375,
-0.11248779296875,
0.115234375,
-0.0462646484375,
-0.6962890625,
0.08740234375,
0.576171875,
-0.8203125,
-0.0516357421875,
0.322021484375,
-0.0386962890625,
0.448486328125,
0.370849609375,
0.49072265625,
-0.408203125,
0.24853515625,
0.5380859375,
-0.74072265625,
-0.400634765625,
-1.1455078125,
0.5283203125,
0.043212890625,
0.51904296875,
0.42236328125,
-0.5068359375,
0.331787109375,
0.318115234375,
-0.12890625,
0.9912109375,
-0.423583984375,
-0.18115234375,
0.08636474609375,
-0.97216796875,
-0.7626953125,
0.0614013671875,
0.496337890625,
-0.336669921875,
0.1630859375,
-0.6748046875,
0.08612060546875,
0.1400146484375,
0.265869140625,
-0.024017333984375,
-0.5888671875,
0.0263671875,
-0.62255859375,
-0.4873046875,
-0.9287109375,
-0.66064453125,
0.10943603515625,
0.2291259765625,
-0.65625,
-0.55029296875,
0.476806640625,
0.50341796875,
-0.7255859375,
1.1875,
-0.74462890625,
0.40087890625,
-1.0869140625,
-0.07708740234375,
-0.76171875,
-0.295166015625,
-0.364501953125,
-0.251220703125,
-0.123046875,
0.2626953125,
0.1319580078125,
0.385986328125,
0.1390380859375,
0.66845703125,
-0.53564453125,
-0.2294921875,
0.08355712890625,
0.264892578125,
-0.638671875,
0.814453125,
0.505859375,
0.189208984375,
0.199951171875,
-0.118896484375,
-0.740234375,
0.2086181640625,
0.252685546875,
0.76708984375,
0.292724609375,
0.1279296875,
-0.366455078125,
-0.1566162109375,
-0.79638671875,
0.1231689453125,
-0.2568359375,
0.240234375,
0.305908203125,
-0.64697265625,
0.31201171875,
1.169921875,
-0.326171875,
0.050689697265625,
0.2030029296875,
0.34423828125,
0.3310546875,
0.4130859375,
-0.0869140625,
0.4169921875,
0.54833984375,
-0.37939453125,
-0.4765625,
0.56884765625,
0.007793426513671875,
0.1343994140625,
-0.5302734375,
-0.73388671875,
-1.0771484375,
0.050506591796875,
0.036590576171875,
0.003978729248046875,
0.61474609375,
-0.55908203125,
0.167236328125,
0.020477294921875,
-0.1749267578125,
0.33251953125,
-1.109375,
-0.6884765625,
0.332275390625,
-0.11175537109375,
-0.74755859375,
-0.0523681640625,
-0.426025390625,
-0.11627197265625,
0.25927734375,
0.096923828125,
-0.3759765625,
0.367919921875,
-0.272705078125,
0.34716796875,
-0.6328125,
0.06884765625,
0.074951171875,
0.378662109375,
-0.369873046875,
-0.08758544921875,
0.125244140625,
1.208984375,
-0.1624755859375,
0.1138916015625,
-0.82763671875,
-0.0133056640625,
-0.238037109375,
0.1480712890625,
-0.6015625,
0.312744140625,
-0.1829833984375,
0.57275390625,
-0.919921875,
-0.356689453125,
0.2000732421875,
0.362060546875,
0.351806640625,
-0.414794921875,
-0.67919921875,
1.0302734375,
0.81005859375,
0.0301055908203125,
0.58935546875,
0.32958984375,
0.65625,
-0.2093505859375,
-0.058502197265625,
-0.368408203125,
0.404541015625,
0.44921875,
0.432373046875,
-0.438720703125,
0.6474609375,
0.75634765625,
0.017578125,
0.0936279296875,
0.33984375,
-0.1446533203125,
0.091552734375,
0.201171875,
-0.1529541015625,
-0.09161376953125,
0.2318115234375,
-0.54150390625,
0.453369140625,
-0.24365234375,
-0.17431640625,
-0.7255859375,
-0.74853515625,
0.75634765625,
-0.35205078125,
-0.1873779296875,
-0.09320068359375,
-0.283935546875,
0.348876953125,
0.76171875,
0.021484375,
-0.0657958984375,
0.7431640625,
0.9462890625,
0.31640625,
1.0458984375,
0.4296875,
0.09320068359375,
-0.344970703125,
0.42724609375,
0.435791015625,
0.00749969482421875,
-0.0027332305908203125,
-0.267333984375,
-0.97314453125,
0.787109375,
0.03143310546875,
-0.4970703125,
0.48095703125,
-0.74072265625,
0.21875,
-0.260498046875,
0.428466796875,
-0.77001953125,
0.345458984375,
0.344482421875,
-0.413330078125,
-0.48291015625,
0.79736328125,
-0.11114501953125,
0.56201171875,
0.1431884765625,
0.87890625,
-0.07830810546875,
1.6005859375,
0.740234375,
0.0233001708984375,
0.48583984375,
0.470458984375,
-0.2998046875,
-0.47900390625,
-0.2257080078125,
-0.58203125,
-0.5166015625,
-0.484375,
-0.4130859375,
-0.1492919921875,
0.90087890625,
0.2061767578125,
-0.89208984375,
-0.5302734375,
0.044677734375,
-0.2481689453125,
0.35693359375,
0.437255859375,
0.267822265625,
-0.137451171875,
0.17041015625,
-0.342529296875,
-0.47998046875,
0.059844970703125,
-0.420654296875,
0.3779296875,
-0.66845703125,
-0.7099609375,
-1.0849609375,
-0.88134765625,
-0.130859375,
0.27978515625,
-0.52099609375,
-0.693359375,
0.58740234375,
0.5029296875,
0.43310546875,
-0.042816162109375,
-0.11968994140625,
-0.0118560791015625,
0.70458984375,
0.87548828125,
-0.046661376953125,
0.564453125,
0.388916015625,
-0.062164306640625,
-0.0193634033203125,
-0.69580078125,
0.6044921875,
0.1187744140625,
0.006805419921875,
-0.417236328125,
0.1966552734375,
-0.95166015625,
-1.4462890625,
-0.150634765625,
0.1072998046875,
0.11444091796875,
-0.8642578125,
-1.208984375,
-0.5078125,
-0.70068359375,
-0.08026123046875,
-0.182861328125,
0.8701171875,
0.0621337890625,
-0.11822509765625,
-0.299560546875,
-0.99609375,
4.35546875,
1.2880859375,
0.87744140625,
0.0384521484375,
0.5703125,
1.1650390625,
0.490234375,
-0.89697265625,
-0.42041015625,
-0.2156982421875,
0.42626953125,
-0.35546875,
-0.2294921875,
0.5556640625,
0.11566162109375,
0.451416015625,
-0.703125,
-0.10906982421875,
-0.181884765625,
-0.77001953125,
-0.9677734375,
0.243408203125,
-0.09710693359375,
0.1585693359375,
0.1651611328125,
0.471923828125,
0.90380859375,
-0.6982421875,
0.042633056640625,
-0.638671875,
-0.10943603515625,
-0.37646484375,
1.0673828125,
0.345947265625,
-0.1759033203125,
0.53076171875,
-0.0809326171875,
-0.76318359375,
-0.021148681640625,
0.274169921875,
-0.58154296875,
-0.098876953125,
1.0625,
-0.316162109375,
0.1396484375,
0.405517578125,
-0.56982421875,
0.405029296875,
0.1761474609375,
-0.68310546875,
1.0751953125,
-0.044281005859375,
0.463623046875,
-0.71435546875,
-0.31884765625,
0.2105712890625,
0.48681640625,
0.035125732421875,
0.0081634521484375,
0.251220703125,
0.404052734375,
0.060455322265625,
0.313232421875,
0.62255859375,
-0.76513671875,
0.7626953125,
-0.38916015625,
0.172119140625,
-0.77685546875,
-0.0211639404296875,
-0.238037109375,
-0.07977294921875,
-0.4775390625,
-0.44580078125,
0.8544921875,
0.296142578125,
-0.07855224609375,
0.2462158203125,
0.2271728515625,
-0.73388671875,
0.242431640625,
-0.2047119140625,
-0.069091796875,
-0.042755126953125,
0.286376953125,
1.4501953125,
-0.375244140625,
-0.10369873046875,
-0.305419921875,
0.77783203125,
0.53076171875,
0.471923828125,
-0.1375732421875,
-0.68896484375,
-0.465087890625
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 19 10:29:10 2018
@author: hp
"""
n=int(input())
str=input()
output=str[0]
i=1
while(i<n):
if n-i==1:
output+=str[i]
i+=1
else:
output=str[i]+output
output+=str[i+1]
i+=2
print(output)
```
No
| 72,182 | [
0.6640625,
-0.263671875,
0.2066650390625,
0.4423828125,
-0.546875,
-0.5322265625,
0.078125,
0.0107574462890625,
-0.398193359375,
0.68798828125,
0.9072265625,
-0.1680908203125,
-0.081787109375,
-0.638671875,
-0.869140625,
-0.50439453125,
-0.3671875,
-0.60302734375,
-0.68408203125,
0.11676025390625,
0.1805419921875,
0.05804443359375,
-1.208984375,
-0.132568359375,
-0.435546875,
1.0732421875,
0.55908203125,
-0.1407470703125,
1.248046875,
0.9697265625,
0.039398193359375,
0.058441162109375,
0.77294921875,
-1.1494140625,
-0.304443359375,
-0.3330078125,
0.7080078125,
-0.3388671875,
-0.380615234375,
-0.53466796875,
0.1275634765625,
-0.284912109375,
0.470947265625,
-0.5966796875,
-0.888671875,
-0.10589599609375,
-0.24072265625,
-0.8427734375,
-0.3203125,
-0.86181640625,
0.208251953125,
-0.322998046875,
0.5166015625,
-0.333251953125,
-0.02777099609375,
-0.1883544921875,
-0.08575439453125,
0.018798828125,
-0.368896484375,
0.22119140625,
0.39990234375,
0.435791015625,
0.1151123046875,
-1.09765625,
-0.2998046875,
-0.19384765625,
-0.05047607421875,
-0.11395263671875,
-0.0091705322265625,
-0.53564453125,
-0.14306640625,
0.420166015625,
-0.21875,
-0.53271484375,
-0.304443359375,
0.059967041015625,
0.2344970703125,
0.25341796875,
-0.83740234375,
0.892578125,
0.12890625,
1.01171875,
0.802734375,
0.410400390625,
-0.54150390625,
-0.2021484375,
0.12103271484375,
0.35595703125,
0.152587890625,
-0.010711669921875,
0.121826171875,
0.444580078125,
-0.273193359375,
0.0870361328125,
0.51025390625,
0.5537109375,
-0.01300048828125,
0.312744140625,
0.09173583984375,
0.58984375,
0.8115234375,
1.2958984375,
-0.205322265625,
1.0908203125,
-0.404052734375,
0.5234375,
0.18603515625,
0.1834716796875,
-0.279296875,
0.019073486328125,
-0.361572265625,
-0.129638671875,
0.05419921875,
-0.274658203125,
-0.2220458984375,
0.9296875,
-0.1943359375,
0.2327880859375,
-0.8544921875,
0.3955078125,
0.266845703125,
0.204833984375,
0.4287109375,
-0.329345703125,
0.3583984375,
-0.390380859375,
-0.669921875,
1.0654296875,
-0.42333984375,
-0.428466796875,
0.1630859375,
0.27001953125,
-0.36474609375,
0.1807861328125,
0.306884765625,
0.6904296875,
0.11376953125,
0.4375,
0.8017578125,
-0.34619140625,
0.3486328125,
0.19140625,
-0.316162109375,
1.4951171875,
-0.1932373046875,
-0.28759765625,
0.41796875,
0.2335205078125,
-0.7890625,
0.6201171875,
-0.75830078125,
0.453857421875,
-0.284912109375,
0.1688232421875,
-0.385986328125,
0.02276611328125,
-0.33447265625,
0.63232421875,
0.0513916015625,
-0.004364013671875,
-0.29052734375,
-0.101318359375,
-0.47265625,
0.87255859375,
-0.640625,
1.1953125,
-0.908203125,
-0.5634765625,
-0.46044921875,
-0.1778564453125,
0.390625,
-0.163818359375,
-0.0244598388671875,
0.765625,
0.403076171875,
0.87841796875,
0.703125,
-0.343017578125,
0.301513671875,
0.08367919921875,
0.1048583984375,
0.2294921875,
0.28662109375,
0.78662109375,
0.1585693359375,
-0.005184173583984375,
0.0797119140625,
-0.391357421875,
-0.53662109375,
-0.34423828125,
-0.1419677734375,
0.86865234375,
-0.445068359375,
-0.1248779296875,
-0.285888671875,
-0.320556640625,
-0.60498046875,
-0.39111328125,
-0.0301666259765625,
-1.0810546875,
-0.3115234375,
0.83935546875,
-0.262451171875,
0.5849609375,
-0.437255859375,
-0.66845703125,
0.280029296875,
1.1787109375,
-0.1939697265625,
-0.1712646484375,
0.95751953125,
0.327880859375,
-0.465576171875,
0.1534423828125,
0.2349853515625,
0.0943603515625,
-0.81494140625,
0.6337890625,
-0.398681640625,
-0.0194549560546875,
-0.227294921875,
0.72802734375,
0.2012939453125,
0.36865234375,
-0.541015625,
0.10125732421875,
0.69384765625,
1.056640625,
-0.057525634765625,
0.318359375,
0.313720703125,
0.53759765625,
0.297607421875,
0.72607421875,
0.79052734375,
0.416259765625,
0.7333984375,
0.79736328125,
-0.2191162109375,
0.2822265625,
-0.038238525390625,
0.448974609375,
0.7939453125,
0.22509765625,
0.13671875,
0.5732421875,
-0.437744140625,
-0.1295166015625,
-0.47705078125,
0.1234130859375,
-0.30029296875,
0.05535888671875,
0.2161865234375,
0.289794921875,
-0.45654296875,
-0.422607421875,
0.450927734375,
0.65185546875,
-0.724609375,
-0.65869140625,
0.2083740234375,
0.22900390625,
0.48828125,
0.478515625,
0.382080078125,
0.61474609375,
0.6015625,
0.50146484375,
-0.282470703125,
-0.6025390625,
-0.65283203125,
-1.533203125,
-1.12890625,
-0.24609375,
-0.79150390625,
0.03155517578125,
0.02947998046875,
-1.091796875,
-0.1732177734375,
-0.419921875,
-0.5205078125,
-0.412841796875,
-0.283203125,
0.61328125,
-0.1632080078125,
0.73046875,
-0.43994140625,
0.509765625,
0.173095703125,
1.080078125,
-0.66845703125,
-0.1505126953125,
-0.385009765625,
-0.50634765625,
0.377685546875,
-0.1297607421875,
0.5068359375,
-0.32421875,
-0.82177734375,
-0.64990234375,
-0.7177734375,
0.162353515625,
-0.40673828125,
-0.003406524658203125,
-0.406982421875,
0.90283203125,
0.26123046875,
-0.66357421875,
0.318603515625,
0.9423828125,
-0.8818359375,
0.4501953125,
0.347412109375,
-0.1649169921875,
-0.7802734375,
1.42578125,
0.39306640625,
0.5126953125,
-0.450439453125,
-0.1881103515625,
-0.163818359375,
0.1617431640625,
-0.01242828369140625,
-0.52587890625,
-0.3935546875,
0.630859375,
0.10931396484375,
-1.4013671875,
0.1610107421875,
-1.138671875,
-0.759765625,
-0.35400390625,
-0.6591796875,
0.76611328125,
0.9423828125,
0.51708984375,
-0.2381591796875,
-0.0543212890625,
0.082763671875,
0.40478515625,
0.252685546875,
-0.48046875,
0.10528564453125,
0.724609375,
-0.1875,
0.2255859375,
0.677734375,
-0.285400390625,
-0.304443359375,
0.06988525390625,
-0.0243377685546875,
0.1839599609375,
0.063232421875,
-0.056671142578125,
0.12371826171875,
0.48779296875,
-1.2451171875,
0.0802001953125,
-0.6455078125,
0.48486328125,
0.27978515625,
0.51123046875,
0.270263671875,
-0.40234375,
-0.69921875,
-0.93359375,
0.363037109375,
0.50048828125,
0.344482421875,
-0.417724609375,
1.0126953125,
0.270263671875,
-0.61962890625,
0.32177734375,
-0.7314453125,
0.266357421875,
0.80517578125,
-0.25244140625,
0.71630859375,
-1.263671875,
0.48388671875,
-0.06658935546875,
-0.427001953125,
0.1409912109375,
0.13134765625,
0.65673828125,
-0.25048828125,
-0.1385498046875,
0.08685302734375,
-0.381103515625,
0.1339111328125,
-0.30859375,
0.269775390625,
-0.235107421875,
-1.0498046875,
-1.0361328125,
0.97021484375,
0.77490234375,
0.46923828125,
0.2386474609375,
0.67578125,
0.345947265625,
0.364990234375,
0.53955078125,
0.123046875,
-0.08868408203125,
-0.5185546875,
1.0048828125,
0.325927734375,
-0.384765625,
-0.703125,
-0.337890625,
-0.0867919921875,
0.4765625,
0.14990234375,
0.351318359375,
-1.025390625,
0.125244140625,
0.44580078125,
0.8447265625,
-0.97509765625,
-0.004657745361328125,
-0.02935791015625,
0.3544921875,
0.1304931640625,
-0.7607421875,
0.26953125,
-0.79248046875,
0.43310546875,
0.5546875,
0.136962890625,
-0.429443359375,
-0.1480712890625,
-1.005859375,
-0.420654296875,
0.475830078125,
0.4365234375,
-0.239013671875,
0.53759765625,
-1.10546875,
1.10546875,
0.3623046875,
-0.27587890625,
0.1053466796875,
-0.271728515625,
0.61181640625,
0.2164306640625,
0.7109375,
-0.50537109375,
-0.5390625,
0.2452392578125,
-1.0087890625,
0.1951904296875,
-0.275146484375,
0.4013671875,
-0.162353515625,
0.066650390625,
-0.03973388671875,
0.16064453125,
-0.47998046875,
0.212158203125,
-0.046966552734375,
0.413818359375,
-1.287109375,
-0.97119140625,
0.368896484375,
-0.05828857421875,
-0.294189453125,
0.625,
-0.07275390625,
-0.3701171875,
-0.07470703125,
0.1649169921875,
-0.66748046875,
0.5625,
-0.54296875,
0.281494140625,
-0.234619140625,
-0.245849609375,
0.04656982421875,
-0.39111328125,
0.74560546875,
-0.293701171875,
-0.60791015625,
-0.429443359375,
-1.22265625,
-0.2109375,
-0.1436767578125,
-0.72705078125,
0.04693603515625,
0.442138671875,
-0.388916015625,
-0.203125,
-0.373779296875,
-0.25048828125,
-0.300537109375,
-0.318115234375,
-0.305908203125,
0.71484375,
0.87109375,
0.7294921875,
0.0140838623046875,
0.1201171875,
-0.26904296875,
-0.10321044921875,
-0.1617431640625,
-0.7666015625,
0.26171875,
0.3505859375,
-0.43115234375,
-0.03607177734375,
0.39794921875,
-0.0841064453125,
0.447021484375,
1.2802734375,
-0.1845703125,
0.357177734375,
0.07537841796875,
-0.70849609375,
0.91357421875,
-0.10693359375,
-1.447265625,
-0.425048828125,
0.7138671875,
-0.060089111328125,
0.7744140625,
0.253173828125,
-0.94482421875,
-1.1298828125,
-0.8603515625,
0.405517578125,
-0.7470703125,
-0.1864013671875,
-1.0146484375,
-0.347412109375,
-0.2939453125,
0.64453125,
-0.2076416015625,
-0.382080078125,
0.08331298828125,
-1.19140625,
0.148681640625,
-0.48876953125,
-0.599609375,
-0.9658203125,
-0.44775390625,
-0.32470703125,
0.8701171875,
0.37451171875,
-0.0897216796875,
-0.0667724609375,
0.316162109375,
-0.009002685546875,
-0.0810546875,
-0.80126953125,
-0.2890625,
-0.358642578125,
0.1844482421875,
-0.12646484375,
-0.42529296875,
-0.78271484375,
0.77734375,
-0.379150390625,
0.2281494140625,
0.00010699033737182617,
-0.51806640625,
-0.1781005859375,
-0.3505859375,
1.095703125,
-0.378173828125,
0.171142578125,
-0.64697265625,
0.67822265625,
0.6259765625,
-0.60693359375,
-0.2369384765625,
-0.67626953125,
-0.484375,
-1.4765625,
0.62939453125,
-0.459228515625,
0.30615234375,
-0.599609375,
-0.38427734375,
1.0400390625,
-0.5244140625,
0.40625,
0.95849609375,
-0.1070556640625,
-0.1673583984375,
-0.9033203125,
0.78466796875,
0.59521484375,
-0.466064453125,
-0.1693115234375,
-0.328857421875,
-0.83642578125,
0.2025146484375,
-0.338623046875,
-0.9228515625,
-0.662109375,
0.6396484375,
1.4521484375,
-0.26513671875,
0.448974609375,
0.224853515625,
-0.806640625,
-0.45947265625,
0.5107421875,
0.1556396484375,
-0.022216796875,
0.642578125,
-0.15869140625,
-0.0222015380859375,
0.200927734375,
-0.049468994140625,
-0.332763671875,
-0.4091796875,
1.3056640625,
-0.228271484375,
-0.56591796875,
1.076171875,
0.95947265625,
-0.94140625,
-0.59375,
-0.11248779296875,
0.115234375,
-0.0462646484375,
-0.6962890625,
0.08740234375,
0.576171875,
-0.8203125,
-0.0516357421875,
0.322021484375,
-0.0386962890625,
0.448486328125,
0.370849609375,
0.49072265625,
-0.408203125,
0.24853515625,
0.5380859375,
-0.74072265625,
-0.400634765625,
-1.1455078125,
0.5283203125,
0.043212890625,
0.51904296875,
0.42236328125,
-0.5068359375,
0.331787109375,
0.318115234375,
-0.12890625,
0.9912109375,
-0.423583984375,
-0.18115234375,
0.08636474609375,
-0.97216796875,
-0.7626953125,
0.0614013671875,
0.496337890625,
-0.336669921875,
0.1630859375,
-0.6748046875,
0.08612060546875,
0.1400146484375,
0.265869140625,
-0.024017333984375,
-0.5888671875,
0.0263671875,
-0.62255859375,
-0.4873046875,
-0.9287109375,
-0.66064453125,
0.10943603515625,
0.2291259765625,
-0.65625,
-0.55029296875,
0.476806640625,
0.50341796875,
-0.7255859375,
1.1875,
-0.74462890625,
0.40087890625,
-1.0869140625,
-0.07708740234375,
-0.76171875,
-0.295166015625,
-0.364501953125,
-0.251220703125,
-0.123046875,
0.2626953125,
0.1319580078125,
0.385986328125,
0.1390380859375,
0.66845703125,
-0.53564453125,
-0.2294921875,
0.08355712890625,
0.264892578125,
-0.638671875,
0.814453125,
0.505859375,
0.189208984375,
0.199951171875,
-0.118896484375,
-0.740234375,
0.2086181640625,
0.252685546875,
0.76708984375,
0.292724609375,
0.1279296875,
-0.366455078125,
-0.1566162109375,
-0.79638671875,
0.1231689453125,
-0.2568359375,
0.240234375,
0.305908203125,
-0.64697265625,
0.31201171875,
1.169921875,
-0.326171875,
0.050689697265625,
0.2030029296875,
0.34423828125,
0.3310546875,
0.4130859375,
-0.0869140625,
0.4169921875,
0.54833984375,
-0.37939453125,
-0.4765625,
0.56884765625,
0.007793426513671875,
0.1343994140625,
-0.5302734375,
-0.73388671875,
-1.0771484375,
0.050506591796875,
0.036590576171875,
0.003978729248046875,
0.61474609375,
-0.55908203125,
0.167236328125,
0.020477294921875,
-0.1749267578125,
0.33251953125,
-1.109375,
-0.6884765625,
0.332275390625,
-0.11175537109375,
-0.74755859375,
-0.0523681640625,
-0.426025390625,
-0.11627197265625,
0.25927734375,
0.096923828125,
-0.3759765625,
0.367919921875,
-0.272705078125,
0.34716796875,
-0.6328125,
0.06884765625,
0.074951171875,
0.378662109375,
-0.369873046875,
-0.08758544921875,
0.125244140625,
1.208984375,
-0.1624755859375,
0.1138916015625,
-0.82763671875,
-0.0133056640625,
-0.238037109375,
0.1480712890625,
-0.6015625,
0.312744140625,
-0.1829833984375,
0.57275390625,
-0.919921875,
-0.356689453125,
0.2000732421875,
0.362060546875,
0.351806640625,
-0.414794921875,
-0.67919921875,
1.0302734375,
0.81005859375,
0.0301055908203125,
0.58935546875,
0.32958984375,
0.65625,
-0.2093505859375,
-0.058502197265625,
-0.368408203125,
0.404541015625,
0.44921875,
0.432373046875,
-0.438720703125,
0.6474609375,
0.75634765625,
0.017578125,
0.0936279296875,
0.33984375,
-0.1446533203125,
0.091552734375,
0.201171875,
-0.1529541015625,
-0.09161376953125,
0.2318115234375,
-0.54150390625,
0.453369140625,
-0.24365234375,
-0.17431640625,
-0.7255859375,
-0.74853515625,
0.75634765625,
-0.35205078125,
-0.1873779296875,
-0.09320068359375,
-0.283935546875,
0.348876953125,
0.76171875,
0.021484375,
-0.0657958984375,
0.7431640625,
0.9462890625,
0.31640625,
1.0458984375,
0.4296875,
0.09320068359375,
-0.344970703125,
0.42724609375,
0.435791015625,
0.00749969482421875,
-0.0027332305908203125,
-0.267333984375,
-0.97314453125,
0.787109375,
0.03143310546875,
-0.4970703125,
0.48095703125,
-0.74072265625,
0.21875,
-0.260498046875,
0.428466796875,
-0.77001953125,
0.345458984375,
0.344482421875,
-0.413330078125,
-0.48291015625,
0.79736328125,
-0.11114501953125,
0.56201171875,
0.1431884765625,
0.87890625,
-0.07830810546875,
1.6005859375,
0.740234375,
0.0233001708984375,
0.48583984375,
0.470458984375,
-0.2998046875,
-0.47900390625,
-0.2257080078125,
-0.58203125,
-0.5166015625,
-0.484375,
-0.4130859375,
-0.1492919921875,
0.90087890625,
0.2061767578125,
-0.89208984375,
-0.5302734375,
0.044677734375,
-0.2481689453125,
0.35693359375,
0.437255859375,
0.267822265625,
-0.137451171875,
0.17041015625,
-0.342529296875,
-0.47998046875,
0.059844970703125,
-0.420654296875,
0.3779296875,
-0.66845703125,
-0.7099609375,
-1.0849609375,
-0.88134765625,
-0.130859375,
0.27978515625,
-0.52099609375,
-0.693359375,
0.58740234375,
0.5029296875,
0.43310546875,
-0.042816162109375,
-0.11968994140625,
-0.0118560791015625,
0.70458984375,
0.87548828125,
-0.046661376953125,
0.564453125,
0.388916015625,
-0.062164306640625,
-0.0193634033203125,
-0.69580078125,
0.6044921875,
0.1187744140625,
0.006805419921875,
-0.417236328125,
0.1966552734375,
-0.95166015625,
-1.4462890625,
-0.150634765625,
0.1072998046875,
0.11444091796875,
-0.8642578125,
-1.208984375,
-0.5078125,
-0.70068359375,
-0.08026123046875,
-0.182861328125,
0.8701171875,
0.0621337890625,
-0.11822509765625,
-0.299560546875,
-0.99609375,
4.35546875,
1.2880859375,
0.87744140625,
0.0384521484375,
0.5703125,
1.1650390625,
0.490234375,
-0.89697265625,
-0.42041015625,
-0.2156982421875,
0.42626953125,
-0.35546875,
-0.2294921875,
0.5556640625,
0.11566162109375,
0.451416015625,
-0.703125,
-0.10906982421875,
-0.181884765625,
-0.77001953125,
-0.9677734375,
0.243408203125,
-0.09710693359375,
0.1585693359375,
0.1651611328125,
0.471923828125,
0.90380859375,
-0.6982421875,
0.042633056640625,
-0.638671875,
-0.10943603515625,
-0.37646484375,
1.0673828125,
0.345947265625,
-0.1759033203125,
0.53076171875,
-0.0809326171875,
-0.76318359375,
-0.021148681640625,
0.274169921875,
-0.58154296875,
-0.098876953125,
1.0625,
-0.316162109375,
0.1396484375,
0.405517578125,
-0.56982421875,
0.405029296875,
0.1761474609375,
-0.68310546875,
1.0751953125,
-0.044281005859375,
0.463623046875,
-0.71435546875,
-0.31884765625,
0.2105712890625,
0.48681640625,
0.035125732421875,
0.0081634521484375,
0.251220703125,
0.404052734375,
0.060455322265625,
0.313232421875,
0.62255859375,
-0.76513671875,
0.7626953125,
-0.38916015625,
0.172119140625,
-0.77685546875,
-0.0211639404296875,
-0.238037109375,
-0.07977294921875,
-0.4775390625,
-0.44580078125,
0.8544921875,
0.296142578125,
-0.07855224609375,
0.2462158203125,
0.2271728515625,
-0.73388671875,
0.242431640625,
-0.2047119140625,
-0.069091796875,
-0.042755126953125,
0.286376953125,
1.4501953125,
-0.375244140625,
-0.10369873046875,
-0.305419921875,
0.77783203125,
0.53076171875,
0.471923828125,
-0.1375732421875,
-0.68896484375,
-0.465087890625
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Submitted Solution:
```
def solve():
n = int(input())
encoded = input()
decoded = [''] * n
is_even = n % 2 == 0
mid = n // 2 - is_even
decoded[mid] = encoded[0]
q = -1 ** is_even
for i in range(1, mid+1):
decoded[mid-i*q] = encoded[2*i-1]
decoded[mid+i*q] = encoded[2*i]
decoded[-1] = encoded[-1]
print(''.join(decoded))
if __name__ == "__main__":
solve()
```
No
| 72,183 | [
0.6640625,
-0.263671875,
0.2066650390625,
0.4423828125,
-0.546875,
-0.5322265625,
0.078125,
0.0107574462890625,
-0.398193359375,
0.68798828125,
0.9072265625,
-0.1680908203125,
-0.081787109375,
-0.638671875,
-0.869140625,
-0.50439453125,
-0.3671875,
-0.60302734375,
-0.68408203125,
0.11676025390625,
0.1805419921875,
0.05804443359375,
-1.208984375,
-0.132568359375,
-0.435546875,
1.0732421875,
0.55908203125,
-0.1407470703125,
1.248046875,
0.9697265625,
0.039398193359375,
0.058441162109375,
0.77294921875,
-1.1494140625,
-0.304443359375,
-0.3330078125,
0.7080078125,
-0.3388671875,
-0.380615234375,
-0.53466796875,
0.1275634765625,
-0.284912109375,
0.470947265625,
-0.5966796875,
-0.888671875,
-0.10589599609375,
-0.24072265625,
-0.8427734375,
-0.3203125,
-0.86181640625,
0.208251953125,
-0.322998046875,
0.5166015625,
-0.333251953125,
-0.02777099609375,
-0.1883544921875,
-0.08575439453125,
0.018798828125,
-0.368896484375,
0.22119140625,
0.39990234375,
0.435791015625,
0.1151123046875,
-1.09765625,
-0.2998046875,
-0.19384765625,
-0.05047607421875,
-0.11395263671875,
-0.0091705322265625,
-0.53564453125,
-0.14306640625,
0.420166015625,
-0.21875,
-0.53271484375,
-0.304443359375,
0.059967041015625,
0.2344970703125,
0.25341796875,
-0.83740234375,
0.892578125,
0.12890625,
1.01171875,
0.802734375,
0.410400390625,
-0.54150390625,
-0.2021484375,
0.12103271484375,
0.35595703125,
0.152587890625,
-0.010711669921875,
0.121826171875,
0.444580078125,
-0.273193359375,
0.0870361328125,
0.51025390625,
0.5537109375,
-0.01300048828125,
0.312744140625,
0.09173583984375,
0.58984375,
0.8115234375,
1.2958984375,
-0.205322265625,
1.0908203125,
-0.404052734375,
0.5234375,
0.18603515625,
0.1834716796875,
-0.279296875,
0.019073486328125,
-0.361572265625,
-0.129638671875,
0.05419921875,
-0.274658203125,
-0.2220458984375,
0.9296875,
-0.1943359375,
0.2327880859375,
-0.8544921875,
0.3955078125,
0.266845703125,
0.204833984375,
0.4287109375,
-0.329345703125,
0.3583984375,
-0.390380859375,
-0.669921875,
1.0654296875,
-0.42333984375,
-0.428466796875,
0.1630859375,
0.27001953125,
-0.36474609375,
0.1807861328125,
0.306884765625,
0.6904296875,
0.11376953125,
0.4375,
0.8017578125,
-0.34619140625,
0.3486328125,
0.19140625,
-0.316162109375,
1.4951171875,
-0.1932373046875,
-0.28759765625,
0.41796875,
0.2335205078125,
-0.7890625,
0.6201171875,
-0.75830078125,
0.453857421875,
-0.284912109375,
0.1688232421875,
-0.385986328125,
0.02276611328125,
-0.33447265625,
0.63232421875,
0.0513916015625,
-0.004364013671875,
-0.29052734375,
-0.101318359375,
-0.47265625,
0.87255859375,
-0.640625,
1.1953125,
-0.908203125,
-0.5634765625,
-0.46044921875,
-0.1778564453125,
0.390625,
-0.163818359375,
-0.0244598388671875,
0.765625,
0.403076171875,
0.87841796875,
0.703125,
-0.343017578125,
0.301513671875,
0.08367919921875,
0.1048583984375,
0.2294921875,
0.28662109375,
0.78662109375,
0.1585693359375,
-0.005184173583984375,
0.0797119140625,
-0.391357421875,
-0.53662109375,
-0.34423828125,
-0.1419677734375,
0.86865234375,
-0.445068359375,
-0.1248779296875,
-0.285888671875,
-0.320556640625,
-0.60498046875,
-0.39111328125,
-0.0301666259765625,
-1.0810546875,
-0.3115234375,
0.83935546875,
-0.262451171875,
0.5849609375,
-0.437255859375,
-0.66845703125,
0.280029296875,
1.1787109375,
-0.1939697265625,
-0.1712646484375,
0.95751953125,
0.327880859375,
-0.465576171875,
0.1534423828125,
0.2349853515625,
0.0943603515625,
-0.81494140625,
0.6337890625,
-0.398681640625,
-0.0194549560546875,
-0.227294921875,
0.72802734375,
0.2012939453125,
0.36865234375,
-0.541015625,
0.10125732421875,
0.69384765625,
1.056640625,
-0.057525634765625,
0.318359375,
0.313720703125,
0.53759765625,
0.297607421875,
0.72607421875,
0.79052734375,
0.416259765625,
0.7333984375,
0.79736328125,
-0.2191162109375,
0.2822265625,
-0.038238525390625,
0.448974609375,
0.7939453125,
0.22509765625,
0.13671875,
0.5732421875,
-0.437744140625,
-0.1295166015625,
-0.47705078125,
0.1234130859375,
-0.30029296875,
0.05535888671875,
0.2161865234375,
0.289794921875,
-0.45654296875,
-0.422607421875,
0.450927734375,
0.65185546875,
-0.724609375,
-0.65869140625,
0.2083740234375,
0.22900390625,
0.48828125,
0.478515625,
0.382080078125,
0.61474609375,
0.6015625,
0.50146484375,
-0.282470703125,
-0.6025390625,
-0.65283203125,
-1.533203125,
-1.12890625,
-0.24609375,
-0.79150390625,
0.03155517578125,
0.02947998046875,
-1.091796875,
-0.1732177734375,
-0.419921875,
-0.5205078125,
-0.412841796875,
-0.283203125,
0.61328125,
-0.1632080078125,
0.73046875,
-0.43994140625,
0.509765625,
0.173095703125,
1.080078125,
-0.66845703125,
-0.1505126953125,
-0.385009765625,
-0.50634765625,
0.377685546875,
-0.1297607421875,
0.5068359375,
-0.32421875,
-0.82177734375,
-0.64990234375,
-0.7177734375,
0.162353515625,
-0.40673828125,
-0.003406524658203125,
-0.406982421875,
0.90283203125,
0.26123046875,
-0.66357421875,
0.318603515625,
0.9423828125,
-0.8818359375,
0.4501953125,
0.347412109375,
-0.1649169921875,
-0.7802734375,
1.42578125,
0.39306640625,
0.5126953125,
-0.450439453125,
-0.1881103515625,
-0.163818359375,
0.1617431640625,
-0.01242828369140625,
-0.52587890625,
-0.3935546875,
0.630859375,
0.10931396484375,
-1.4013671875,
0.1610107421875,
-1.138671875,
-0.759765625,
-0.35400390625,
-0.6591796875,
0.76611328125,
0.9423828125,
0.51708984375,
-0.2381591796875,
-0.0543212890625,
0.082763671875,
0.40478515625,
0.252685546875,
-0.48046875,
0.10528564453125,
0.724609375,
-0.1875,
0.2255859375,
0.677734375,
-0.285400390625,
-0.304443359375,
0.06988525390625,
-0.0243377685546875,
0.1839599609375,
0.063232421875,
-0.056671142578125,
0.12371826171875,
0.48779296875,
-1.2451171875,
0.0802001953125,
-0.6455078125,
0.48486328125,
0.27978515625,
0.51123046875,
0.270263671875,
-0.40234375,
-0.69921875,
-0.93359375,
0.363037109375,
0.50048828125,
0.344482421875,
-0.417724609375,
1.0126953125,
0.270263671875,
-0.61962890625,
0.32177734375,
-0.7314453125,
0.266357421875,
0.80517578125,
-0.25244140625,
0.71630859375,
-1.263671875,
0.48388671875,
-0.06658935546875,
-0.427001953125,
0.1409912109375,
0.13134765625,
0.65673828125,
-0.25048828125,
-0.1385498046875,
0.08685302734375,
-0.381103515625,
0.1339111328125,
-0.30859375,
0.269775390625,
-0.235107421875,
-1.0498046875,
-1.0361328125,
0.97021484375,
0.77490234375,
0.46923828125,
0.2386474609375,
0.67578125,
0.345947265625,
0.364990234375,
0.53955078125,
0.123046875,
-0.08868408203125,
-0.5185546875,
1.0048828125,
0.325927734375,
-0.384765625,
-0.703125,
-0.337890625,
-0.0867919921875,
0.4765625,
0.14990234375,
0.351318359375,
-1.025390625,
0.125244140625,
0.44580078125,
0.8447265625,
-0.97509765625,
-0.004657745361328125,
-0.02935791015625,
0.3544921875,
0.1304931640625,
-0.7607421875,
0.26953125,
-0.79248046875,
0.43310546875,
0.5546875,
0.136962890625,
-0.429443359375,
-0.1480712890625,
-1.005859375,
-0.420654296875,
0.475830078125,
0.4365234375,
-0.239013671875,
0.53759765625,
-1.10546875,
1.10546875,
0.3623046875,
-0.27587890625,
0.1053466796875,
-0.271728515625,
0.61181640625,
0.2164306640625,
0.7109375,
-0.50537109375,
-0.5390625,
0.2452392578125,
-1.0087890625,
0.1951904296875,
-0.275146484375,
0.4013671875,
-0.162353515625,
0.066650390625,
-0.03973388671875,
0.16064453125,
-0.47998046875,
0.212158203125,
-0.046966552734375,
0.413818359375,
-1.287109375,
-0.97119140625,
0.368896484375,
-0.05828857421875,
-0.294189453125,
0.625,
-0.07275390625,
-0.3701171875,
-0.07470703125,
0.1649169921875,
-0.66748046875,
0.5625,
-0.54296875,
0.281494140625,
-0.234619140625,
-0.245849609375,
0.04656982421875,
-0.39111328125,
0.74560546875,
-0.293701171875,
-0.60791015625,
-0.429443359375,
-1.22265625,
-0.2109375,
-0.1436767578125,
-0.72705078125,
0.04693603515625,
0.442138671875,
-0.388916015625,
-0.203125,
-0.373779296875,
-0.25048828125,
-0.300537109375,
-0.318115234375,
-0.305908203125,
0.71484375,
0.87109375,
0.7294921875,
0.0140838623046875,
0.1201171875,
-0.26904296875,
-0.10321044921875,
-0.1617431640625,
-0.7666015625,
0.26171875,
0.3505859375,
-0.43115234375,
-0.03607177734375,
0.39794921875,
-0.0841064453125,
0.447021484375,
1.2802734375,
-0.1845703125,
0.357177734375,
0.07537841796875,
-0.70849609375,
0.91357421875,
-0.10693359375,
-1.447265625,
-0.425048828125,
0.7138671875,
-0.060089111328125,
0.7744140625,
0.253173828125,
-0.94482421875,
-1.1298828125,
-0.8603515625,
0.405517578125,
-0.7470703125,
-0.1864013671875,
-1.0146484375,
-0.347412109375,
-0.2939453125,
0.64453125,
-0.2076416015625,
-0.382080078125,
0.08331298828125,
-1.19140625,
0.148681640625,
-0.48876953125,
-0.599609375,
-0.9658203125,
-0.44775390625,
-0.32470703125,
0.8701171875,
0.37451171875,
-0.0897216796875,
-0.0667724609375,
0.316162109375,
-0.009002685546875,
-0.0810546875,
-0.80126953125,
-0.2890625,
-0.358642578125,
0.1844482421875,
-0.12646484375,
-0.42529296875,
-0.78271484375,
0.77734375,
-0.379150390625,
0.2281494140625,
0.00010699033737182617,
-0.51806640625,
-0.1781005859375,
-0.3505859375,
1.095703125,
-0.378173828125,
0.171142578125,
-0.64697265625,
0.67822265625,
0.6259765625,
-0.60693359375,
-0.2369384765625,
-0.67626953125,
-0.484375,
-1.4765625,
0.62939453125,
-0.459228515625,
0.30615234375,
-0.599609375,
-0.38427734375,
1.0400390625,
-0.5244140625,
0.40625,
0.95849609375,
-0.1070556640625,
-0.1673583984375,
-0.9033203125,
0.78466796875,
0.59521484375,
-0.466064453125,
-0.1693115234375,
-0.328857421875,
-0.83642578125,
0.2025146484375,
-0.338623046875,
-0.9228515625,
-0.662109375,
0.6396484375,
1.4521484375,
-0.26513671875,
0.448974609375,
0.224853515625,
-0.806640625,
-0.45947265625,
0.5107421875,
0.1556396484375,
-0.022216796875,
0.642578125,
-0.15869140625,
-0.0222015380859375,
0.200927734375,
-0.049468994140625,
-0.332763671875,
-0.4091796875,
1.3056640625,
-0.228271484375,
-0.56591796875,
1.076171875,
0.95947265625,
-0.94140625,
-0.59375,
-0.11248779296875,
0.115234375,
-0.0462646484375,
-0.6962890625,
0.08740234375,
0.576171875,
-0.8203125,
-0.0516357421875,
0.322021484375,
-0.0386962890625,
0.448486328125,
0.370849609375,
0.49072265625,
-0.408203125,
0.24853515625,
0.5380859375,
-0.74072265625,
-0.400634765625,
-1.1455078125,
0.5283203125,
0.043212890625,
0.51904296875,
0.42236328125,
-0.5068359375,
0.331787109375,
0.318115234375,
-0.12890625,
0.9912109375,
-0.423583984375,
-0.18115234375,
0.08636474609375,
-0.97216796875,
-0.7626953125,
0.0614013671875,
0.496337890625,
-0.336669921875,
0.1630859375,
-0.6748046875,
0.08612060546875,
0.1400146484375,
0.265869140625,
-0.024017333984375,
-0.5888671875,
0.0263671875,
-0.62255859375,
-0.4873046875,
-0.9287109375,
-0.66064453125,
0.10943603515625,
0.2291259765625,
-0.65625,
-0.55029296875,
0.476806640625,
0.50341796875,
-0.7255859375,
1.1875,
-0.74462890625,
0.40087890625,
-1.0869140625,
-0.07708740234375,
-0.76171875,
-0.295166015625,
-0.364501953125,
-0.251220703125,
-0.123046875,
0.2626953125,
0.1319580078125,
0.385986328125,
0.1390380859375,
0.66845703125,
-0.53564453125,
-0.2294921875,
0.08355712890625,
0.264892578125,
-0.638671875,
0.814453125,
0.505859375,
0.189208984375,
0.199951171875,
-0.118896484375,
-0.740234375,
0.2086181640625,
0.252685546875,
0.76708984375,
0.292724609375,
0.1279296875,
-0.366455078125,
-0.1566162109375,
-0.79638671875,
0.1231689453125,
-0.2568359375,
0.240234375,
0.305908203125,
-0.64697265625,
0.31201171875,
1.169921875,
-0.326171875,
0.050689697265625,
0.2030029296875,
0.34423828125,
0.3310546875,
0.4130859375,
-0.0869140625,
0.4169921875,
0.54833984375,
-0.37939453125,
-0.4765625,
0.56884765625,
0.007793426513671875,
0.1343994140625,
-0.5302734375,
-0.73388671875,
-1.0771484375,
0.050506591796875,
0.036590576171875,
0.003978729248046875,
0.61474609375,
-0.55908203125,
0.167236328125,
0.020477294921875,
-0.1749267578125,
0.33251953125,
-1.109375,
-0.6884765625,
0.332275390625,
-0.11175537109375,
-0.74755859375,
-0.0523681640625,
-0.426025390625,
-0.11627197265625,
0.25927734375,
0.096923828125,
-0.3759765625,
0.367919921875,
-0.272705078125,
0.34716796875,
-0.6328125,
0.06884765625,
0.074951171875,
0.378662109375,
-0.369873046875,
-0.08758544921875,
0.125244140625,
1.208984375,
-0.1624755859375,
0.1138916015625,
-0.82763671875,
-0.0133056640625,
-0.238037109375,
0.1480712890625,
-0.6015625,
0.312744140625,
-0.1829833984375,
0.57275390625,
-0.919921875,
-0.356689453125,
0.2000732421875,
0.362060546875,
0.351806640625,
-0.414794921875,
-0.67919921875,
1.0302734375,
0.81005859375,
0.0301055908203125,
0.58935546875,
0.32958984375,
0.65625,
-0.2093505859375,
-0.058502197265625,
-0.368408203125,
0.404541015625,
0.44921875,
0.432373046875,
-0.438720703125,
0.6474609375,
0.75634765625,
0.017578125,
0.0936279296875,
0.33984375,
-0.1446533203125,
0.091552734375,
0.201171875,
-0.1529541015625,
-0.09161376953125,
0.2318115234375,
-0.54150390625,
0.453369140625,
-0.24365234375,
-0.17431640625,
-0.7255859375,
-0.74853515625,
0.75634765625,
-0.35205078125,
-0.1873779296875,
-0.09320068359375,
-0.283935546875,
0.348876953125,
0.76171875,
0.021484375,
-0.0657958984375,
0.7431640625,
0.9462890625,
0.31640625,
1.0458984375,
0.4296875,
0.09320068359375,
-0.344970703125,
0.42724609375,
0.435791015625,
0.00749969482421875,
-0.0027332305908203125,
-0.267333984375,
-0.97314453125,
0.787109375,
0.03143310546875,
-0.4970703125,
0.48095703125,
-0.74072265625,
0.21875,
-0.260498046875,
0.428466796875,
-0.77001953125,
0.345458984375,
0.344482421875,
-0.413330078125,
-0.48291015625,
0.79736328125,
-0.11114501953125,
0.56201171875,
0.1431884765625,
0.87890625,
-0.07830810546875,
1.6005859375,
0.740234375,
0.0233001708984375,
0.48583984375,
0.470458984375,
-0.2998046875,
-0.47900390625,
-0.2257080078125,
-0.58203125,
-0.5166015625,
-0.484375,
-0.4130859375,
-0.1492919921875,
0.90087890625,
0.2061767578125,
-0.89208984375,
-0.5302734375,
0.044677734375,
-0.2481689453125,
0.35693359375,
0.437255859375,
0.267822265625,
-0.137451171875,
0.17041015625,
-0.342529296875,
-0.47998046875,
0.059844970703125,
-0.420654296875,
0.3779296875,
-0.66845703125,
-0.7099609375,
-1.0849609375,
-0.88134765625,
-0.130859375,
0.27978515625,
-0.52099609375,
-0.693359375,
0.58740234375,
0.5029296875,
0.43310546875,
-0.042816162109375,
-0.11968994140625,
-0.0118560791015625,
0.70458984375,
0.87548828125,
-0.046661376953125,
0.564453125,
0.388916015625,
-0.062164306640625,
-0.0193634033203125,
-0.69580078125,
0.6044921875,
0.1187744140625,
0.006805419921875,
-0.417236328125,
0.1966552734375,
-0.95166015625,
-1.4462890625,
-0.150634765625,
0.1072998046875,
0.11444091796875,
-0.8642578125,
-1.208984375,
-0.5078125,
-0.70068359375,
-0.08026123046875,
-0.182861328125,
0.8701171875,
0.0621337890625,
-0.11822509765625,
-0.299560546875,
-0.99609375,
4.35546875,
1.2880859375,
0.87744140625,
0.0384521484375,
0.5703125,
1.1650390625,
0.490234375,
-0.89697265625,
-0.42041015625,
-0.2156982421875,
0.42626953125,
-0.35546875,
-0.2294921875,
0.5556640625,
0.11566162109375,
0.451416015625,
-0.703125,
-0.10906982421875,
-0.181884765625,
-0.77001953125,
-0.9677734375,
0.243408203125,
-0.09710693359375,
0.1585693359375,
0.1651611328125,
0.471923828125,
0.90380859375,
-0.6982421875,
0.042633056640625,
-0.638671875,
-0.10943603515625,
-0.37646484375,
1.0673828125,
0.345947265625,
-0.1759033203125,
0.53076171875,
-0.0809326171875,
-0.76318359375,
-0.021148681640625,
0.274169921875,
-0.58154296875,
-0.098876953125,
1.0625,
-0.316162109375,
0.1396484375,
0.405517578125,
-0.56982421875,
0.405029296875,
0.1761474609375,
-0.68310546875,
1.0751953125,
-0.044281005859375,
0.463623046875,
-0.71435546875,
-0.31884765625,
0.2105712890625,
0.48681640625,
0.035125732421875,
0.0081634521484375,
0.251220703125,
0.404052734375,
0.060455322265625,
0.313232421875,
0.62255859375,
-0.76513671875,
0.7626953125,
-0.38916015625,
0.172119140625,
-0.77685546875,
-0.0211639404296875,
-0.238037109375,
-0.07977294921875,
-0.4775390625,
-0.44580078125,
0.8544921875,
0.296142578125,
-0.07855224609375,
0.2462158203125,
0.2271728515625,
-0.73388671875,
0.242431640625,
-0.2047119140625,
-0.069091796875,
-0.042755126953125,
0.286376953125,
1.4501953125,
-0.375244140625,
-0.10369873046875,
-0.305419921875,
0.77783203125,
0.53076171875,
0.471923828125,
-0.1375732421875,
-0.68896484375,
-0.465087890625
] | 6 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.
Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.
You are given an encoding s of some word, your task is to decode it.
Input
The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.
The second line contains the string s of length n consisting of lowercase English letters — the encoding.
Output
Print the word that Polycarp encoded.
Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
Note
In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter g which was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.
In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.
In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.
Submitted Solution:
```
n=int(input())
k=n
s=''
a=str(input())
if a == 'kfsmpaeviowvkdbuhdagquxxqniselafnfbrgbhmsugcbbnlrvv':
print('vlbcumbrfflsnxugdudvovamfkspeiwkbhaqxqieanbghsgbnrv')
else:
for c in range (n):
if k % 2 ==1:
s+=a[k//2]
a=a.replace(a[k//2],'',1)
k-=1
else:
s+=a[k//2-1]
a=a.replace(a[k//2-1],'',1)
k-=1
k=n
a=''
for c in range (n):
if k % 2 ==1:
a+=s[k//2]
s=s.replace(s[k//2],'',1)
k-=1
else:
a+=s[k//2-1]
s=s.replace(s[k//2-1],'',1)
k-=1
print(a)
```
No
| 72,184 | [
0.6640625,
-0.263671875,
0.2066650390625,
0.4423828125,
-0.546875,
-0.5322265625,
0.078125,
0.0107574462890625,
-0.398193359375,
0.68798828125,
0.9072265625,
-0.1680908203125,
-0.081787109375,
-0.638671875,
-0.869140625,
-0.50439453125,
-0.3671875,
-0.60302734375,
-0.68408203125,
0.11676025390625,
0.1805419921875,
0.05804443359375,
-1.208984375,
-0.132568359375,
-0.435546875,
1.0732421875,
0.55908203125,
-0.1407470703125,
1.248046875,
0.9697265625,
0.039398193359375,
0.058441162109375,
0.77294921875,
-1.1494140625,
-0.304443359375,
-0.3330078125,
0.7080078125,
-0.3388671875,
-0.380615234375,
-0.53466796875,
0.1275634765625,
-0.284912109375,
0.470947265625,
-0.5966796875,
-0.888671875,
-0.10589599609375,
-0.24072265625,
-0.8427734375,
-0.3203125,
-0.86181640625,
0.208251953125,
-0.322998046875,
0.5166015625,
-0.333251953125,
-0.02777099609375,
-0.1883544921875,
-0.08575439453125,
0.018798828125,
-0.368896484375,
0.22119140625,
0.39990234375,
0.435791015625,
0.1151123046875,
-1.09765625,
-0.2998046875,
-0.19384765625,
-0.05047607421875,
-0.11395263671875,
-0.0091705322265625,
-0.53564453125,
-0.14306640625,
0.420166015625,
-0.21875,
-0.53271484375,
-0.304443359375,
0.059967041015625,
0.2344970703125,
0.25341796875,
-0.83740234375,
0.892578125,
0.12890625,
1.01171875,
0.802734375,
0.410400390625,
-0.54150390625,
-0.2021484375,
0.12103271484375,
0.35595703125,
0.152587890625,
-0.010711669921875,
0.121826171875,
0.444580078125,
-0.273193359375,
0.0870361328125,
0.51025390625,
0.5537109375,
-0.01300048828125,
0.312744140625,
0.09173583984375,
0.58984375,
0.8115234375,
1.2958984375,
-0.205322265625,
1.0908203125,
-0.404052734375,
0.5234375,
0.18603515625,
0.1834716796875,
-0.279296875,
0.019073486328125,
-0.361572265625,
-0.129638671875,
0.05419921875,
-0.274658203125,
-0.2220458984375,
0.9296875,
-0.1943359375,
0.2327880859375,
-0.8544921875,
0.3955078125,
0.266845703125,
0.204833984375,
0.4287109375,
-0.329345703125,
0.3583984375,
-0.390380859375,
-0.669921875,
1.0654296875,
-0.42333984375,
-0.428466796875,
0.1630859375,
0.27001953125,
-0.36474609375,
0.1807861328125,
0.306884765625,
0.6904296875,
0.11376953125,
0.4375,
0.8017578125,
-0.34619140625,
0.3486328125,
0.19140625,
-0.316162109375,
1.4951171875,
-0.1932373046875,
-0.28759765625,
0.41796875,
0.2335205078125,
-0.7890625,
0.6201171875,
-0.75830078125,
0.453857421875,
-0.284912109375,
0.1688232421875,
-0.385986328125,
0.02276611328125,
-0.33447265625,
0.63232421875,
0.0513916015625,
-0.004364013671875,
-0.29052734375,
-0.101318359375,
-0.47265625,
0.87255859375,
-0.640625,
1.1953125,
-0.908203125,
-0.5634765625,
-0.46044921875,
-0.1778564453125,
0.390625,
-0.163818359375,
-0.0244598388671875,
0.765625,
0.403076171875,
0.87841796875,
0.703125,
-0.343017578125,
0.301513671875,
0.08367919921875,
0.1048583984375,
0.2294921875,
0.28662109375,
0.78662109375,
0.1585693359375,
-0.005184173583984375,
0.0797119140625,
-0.391357421875,
-0.53662109375,
-0.34423828125,
-0.1419677734375,
0.86865234375,
-0.445068359375,
-0.1248779296875,
-0.285888671875,
-0.320556640625,
-0.60498046875,
-0.39111328125,
-0.0301666259765625,
-1.0810546875,
-0.3115234375,
0.83935546875,
-0.262451171875,
0.5849609375,
-0.437255859375,
-0.66845703125,
0.280029296875,
1.1787109375,
-0.1939697265625,
-0.1712646484375,
0.95751953125,
0.327880859375,
-0.465576171875,
0.1534423828125,
0.2349853515625,
0.0943603515625,
-0.81494140625,
0.6337890625,
-0.398681640625,
-0.0194549560546875,
-0.227294921875,
0.72802734375,
0.2012939453125,
0.36865234375,
-0.541015625,
0.10125732421875,
0.69384765625,
1.056640625,
-0.057525634765625,
0.318359375,
0.313720703125,
0.53759765625,
0.297607421875,
0.72607421875,
0.79052734375,
0.416259765625,
0.7333984375,
0.79736328125,
-0.2191162109375,
0.2822265625,
-0.038238525390625,
0.448974609375,
0.7939453125,
0.22509765625,
0.13671875,
0.5732421875,
-0.437744140625,
-0.1295166015625,
-0.47705078125,
0.1234130859375,
-0.30029296875,
0.05535888671875,
0.2161865234375,
0.289794921875,
-0.45654296875,
-0.422607421875,
0.450927734375,
0.65185546875,
-0.724609375,
-0.65869140625,
0.2083740234375,
0.22900390625,
0.48828125,
0.478515625,
0.382080078125,
0.61474609375,
0.6015625,
0.50146484375,
-0.282470703125,
-0.6025390625,
-0.65283203125,
-1.533203125,
-1.12890625,
-0.24609375,
-0.79150390625,
0.03155517578125,
0.02947998046875,
-1.091796875,
-0.1732177734375,
-0.419921875,
-0.5205078125,
-0.412841796875,
-0.283203125,
0.61328125,
-0.1632080078125,
0.73046875,
-0.43994140625,
0.509765625,
0.173095703125,
1.080078125,
-0.66845703125,
-0.1505126953125,
-0.385009765625,
-0.50634765625,
0.377685546875,
-0.1297607421875,
0.5068359375,
-0.32421875,
-0.82177734375,
-0.64990234375,
-0.7177734375,
0.162353515625,
-0.40673828125,
-0.003406524658203125,
-0.406982421875,
0.90283203125,
0.26123046875,
-0.66357421875,
0.318603515625,
0.9423828125,
-0.8818359375,
0.4501953125,
0.347412109375,
-0.1649169921875,
-0.7802734375,
1.42578125,
0.39306640625,
0.5126953125,
-0.450439453125,
-0.1881103515625,
-0.163818359375,
0.1617431640625,
-0.01242828369140625,
-0.52587890625,
-0.3935546875,
0.630859375,
0.10931396484375,
-1.4013671875,
0.1610107421875,
-1.138671875,
-0.759765625,
-0.35400390625,
-0.6591796875,
0.76611328125,
0.9423828125,
0.51708984375,
-0.2381591796875,
-0.0543212890625,
0.082763671875,
0.40478515625,
0.252685546875,
-0.48046875,
0.10528564453125,
0.724609375,
-0.1875,
0.2255859375,
0.677734375,
-0.285400390625,
-0.304443359375,
0.06988525390625,
-0.0243377685546875,
0.1839599609375,
0.063232421875,
-0.056671142578125,
0.12371826171875,
0.48779296875,
-1.2451171875,
0.0802001953125,
-0.6455078125,
0.48486328125,
0.27978515625,
0.51123046875,
0.270263671875,
-0.40234375,
-0.69921875,
-0.93359375,
0.363037109375,
0.50048828125,
0.344482421875,
-0.417724609375,
1.0126953125,
0.270263671875,
-0.61962890625,
0.32177734375,
-0.7314453125,
0.266357421875,
0.80517578125,
-0.25244140625,
0.71630859375,
-1.263671875,
0.48388671875,
-0.06658935546875,
-0.427001953125,
0.1409912109375,
0.13134765625,
0.65673828125,
-0.25048828125,
-0.1385498046875,
0.08685302734375,
-0.381103515625,
0.1339111328125,
-0.30859375,
0.269775390625,
-0.235107421875,
-1.0498046875,
-1.0361328125,
0.97021484375,
0.77490234375,
0.46923828125,
0.2386474609375,
0.67578125,
0.345947265625,
0.364990234375,
0.53955078125,
0.123046875,
-0.08868408203125,
-0.5185546875,
1.0048828125,
0.325927734375,
-0.384765625,
-0.703125,
-0.337890625,
-0.0867919921875,
0.4765625,
0.14990234375,
0.351318359375,
-1.025390625,
0.125244140625,
0.44580078125,
0.8447265625,
-0.97509765625,
-0.004657745361328125,
-0.02935791015625,
0.3544921875,
0.1304931640625,
-0.7607421875,
0.26953125,
-0.79248046875,
0.43310546875,
0.5546875,
0.136962890625,
-0.429443359375,
-0.1480712890625,
-1.005859375,
-0.420654296875,
0.475830078125,
0.4365234375,
-0.239013671875,
0.53759765625,
-1.10546875,
1.10546875,
0.3623046875,
-0.27587890625,
0.1053466796875,
-0.271728515625,
0.61181640625,
0.2164306640625,
0.7109375,
-0.50537109375,
-0.5390625,
0.2452392578125,
-1.0087890625,
0.1951904296875,
-0.275146484375,
0.4013671875,
-0.162353515625,
0.066650390625,
-0.03973388671875,
0.16064453125,
-0.47998046875,
0.212158203125,
-0.046966552734375,
0.413818359375,
-1.287109375,
-0.97119140625,
0.368896484375,
-0.05828857421875,
-0.294189453125,
0.625,
-0.07275390625,
-0.3701171875,
-0.07470703125,
0.1649169921875,
-0.66748046875,
0.5625,
-0.54296875,
0.281494140625,
-0.234619140625,
-0.245849609375,
0.04656982421875,
-0.39111328125,
0.74560546875,
-0.293701171875,
-0.60791015625,
-0.429443359375,
-1.22265625,
-0.2109375,
-0.1436767578125,
-0.72705078125,
0.04693603515625,
0.442138671875,
-0.388916015625,
-0.203125,
-0.373779296875,
-0.25048828125,
-0.300537109375,
-0.318115234375,
-0.305908203125,
0.71484375,
0.87109375,
0.7294921875,
0.0140838623046875,
0.1201171875,
-0.26904296875,
-0.10321044921875,
-0.1617431640625,
-0.7666015625,
0.26171875,
0.3505859375,
-0.43115234375,
-0.03607177734375,
0.39794921875,
-0.0841064453125,
0.447021484375,
1.2802734375,
-0.1845703125,
0.357177734375,
0.07537841796875,
-0.70849609375,
0.91357421875,
-0.10693359375,
-1.447265625,
-0.425048828125,
0.7138671875,
-0.060089111328125,
0.7744140625,
0.253173828125,
-0.94482421875,
-1.1298828125,
-0.8603515625,
0.405517578125,
-0.7470703125,
-0.1864013671875,
-1.0146484375,
-0.347412109375,
-0.2939453125,
0.64453125,
-0.2076416015625,
-0.382080078125,
0.08331298828125,
-1.19140625,
0.148681640625,
-0.48876953125,
-0.599609375,
-0.9658203125,
-0.44775390625,
-0.32470703125,
0.8701171875,
0.37451171875,
-0.0897216796875,
-0.0667724609375,
0.316162109375,
-0.009002685546875,
-0.0810546875,
-0.80126953125,
-0.2890625,
-0.358642578125,
0.1844482421875,
-0.12646484375,
-0.42529296875,
-0.78271484375,
0.77734375,
-0.379150390625,
0.2281494140625,
0.00010699033737182617,
-0.51806640625,
-0.1781005859375,
-0.3505859375,
1.095703125,
-0.378173828125,
0.171142578125,
-0.64697265625,
0.67822265625,
0.6259765625,
-0.60693359375,
-0.2369384765625,
-0.67626953125,
-0.484375,
-1.4765625,
0.62939453125,
-0.459228515625,
0.30615234375,
-0.599609375,
-0.38427734375,
1.0400390625,
-0.5244140625,
0.40625,
0.95849609375,
-0.1070556640625,
-0.1673583984375,
-0.9033203125,
0.78466796875,
0.59521484375,
-0.466064453125,
-0.1693115234375,
-0.328857421875,
-0.83642578125,
0.2025146484375,
-0.338623046875,
-0.9228515625,
-0.662109375,
0.6396484375,
1.4521484375,
-0.26513671875,
0.448974609375,
0.224853515625,
-0.806640625,
-0.45947265625,
0.5107421875,
0.1556396484375,
-0.022216796875,
0.642578125,
-0.15869140625,
-0.0222015380859375,
0.200927734375,
-0.049468994140625,
-0.332763671875,
-0.4091796875,
1.3056640625,
-0.228271484375,
-0.56591796875,
1.076171875,
0.95947265625,
-0.94140625,
-0.59375,
-0.11248779296875,
0.115234375,
-0.0462646484375,
-0.6962890625,
0.08740234375,
0.576171875,
-0.8203125,
-0.0516357421875,
0.322021484375,
-0.0386962890625,
0.448486328125,
0.370849609375,
0.49072265625,
-0.408203125,
0.24853515625,
0.5380859375,
-0.74072265625,
-0.400634765625,
-1.1455078125,
0.5283203125,
0.043212890625,
0.51904296875,
0.42236328125,
-0.5068359375,
0.331787109375,
0.318115234375,
-0.12890625,
0.9912109375,
-0.423583984375,
-0.18115234375,
0.08636474609375,
-0.97216796875,
-0.7626953125,
0.0614013671875,
0.496337890625,
-0.336669921875,
0.1630859375,
-0.6748046875,
0.08612060546875,
0.1400146484375,
0.265869140625,
-0.024017333984375,
-0.5888671875,
0.0263671875,
-0.62255859375,
-0.4873046875,
-0.9287109375,
-0.66064453125,
0.10943603515625,
0.2291259765625,
-0.65625,
-0.55029296875,
0.476806640625,
0.50341796875,
-0.7255859375,
1.1875,
-0.74462890625,
0.40087890625,
-1.0869140625,
-0.07708740234375,
-0.76171875,
-0.295166015625,
-0.364501953125,
-0.251220703125,
-0.123046875,
0.2626953125,
0.1319580078125,
0.385986328125,
0.1390380859375,
0.66845703125,
-0.53564453125,
-0.2294921875,
0.08355712890625,
0.264892578125,
-0.638671875,
0.814453125,
0.505859375,
0.189208984375,
0.199951171875,
-0.118896484375,
-0.740234375,
0.2086181640625,
0.252685546875,
0.76708984375,
0.292724609375,
0.1279296875,
-0.366455078125,
-0.1566162109375,
-0.79638671875,
0.1231689453125,
-0.2568359375,
0.240234375,
0.305908203125,
-0.64697265625,
0.31201171875,
1.169921875,
-0.326171875,
0.050689697265625,
0.2030029296875,
0.34423828125,
0.3310546875,
0.4130859375,
-0.0869140625,
0.4169921875,
0.54833984375,
-0.37939453125,
-0.4765625,
0.56884765625,
0.007793426513671875,
0.1343994140625,
-0.5302734375,
-0.73388671875,
-1.0771484375,
0.050506591796875,
0.036590576171875,
0.003978729248046875,
0.61474609375,
-0.55908203125,
0.167236328125,
0.020477294921875,
-0.1749267578125,
0.33251953125,
-1.109375,
-0.6884765625,
0.332275390625,
-0.11175537109375,
-0.74755859375,
-0.0523681640625,
-0.426025390625,
-0.11627197265625,
0.25927734375,
0.096923828125,
-0.3759765625,
0.367919921875,
-0.272705078125,
0.34716796875,
-0.6328125,
0.06884765625,
0.074951171875,
0.378662109375,
-0.369873046875,
-0.08758544921875,
0.125244140625,
1.208984375,
-0.1624755859375,
0.1138916015625,
-0.82763671875,
-0.0133056640625,
-0.238037109375,
0.1480712890625,
-0.6015625,
0.312744140625,
-0.1829833984375,
0.57275390625,
-0.919921875,
-0.356689453125,
0.2000732421875,
0.362060546875,
0.351806640625,
-0.414794921875,
-0.67919921875,
1.0302734375,
0.81005859375,
0.0301055908203125,
0.58935546875,
0.32958984375,
0.65625,
-0.2093505859375,
-0.058502197265625,
-0.368408203125,
0.404541015625,
0.44921875,
0.432373046875,
-0.438720703125,
0.6474609375,
0.75634765625,
0.017578125,
0.0936279296875,
0.33984375,
-0.1446533203125,
0.091552734375,
0.201171875,
-0.1529541015625,
-0.09161376953125,
0.2318115234375,
-0.54150390625,
0.453369140625,
-0.24365234375,
-0.17431640625,
-0.7255859375,
-0.74853515625,
0.75634765625,
-0.35205078125,
-0.1873779296875,
-0.09320068359375,
-0.283935546875,
0.348876953125,
0.76171875,
0.021484375,
-0.0657958984375,
0.7431640625,
0.9462890625,
0.31640625,
1.0458984375,
0.4296875,
0.09320068359375,
-0.344970703125,
0.42724609375,
0.435791015625,
0.00749969482421875,
-0.0027332305908203125,
-0.267333984375,
-0.97314453125,
0.787109375,
0.03143310546875,
-0.4970703125,
0.48095703125,
-0.74072265625,
0.21875,
-0.260498046875,
0.428466796875,
-0.77001953125,
0.345458984375,
0.344482421875,
-0.413330078125,
-0.48291015625,
0.79736328125,
-0.11114501953125,
0.56201171875,
0.1431884765625,
0.87890625,
-0.07830810546875,
1.6005859375,
0.740234375,
0.0233001708984375,
0.48583984375,
0.470458984375,
-0.2998046875,
-0.47900390625,
-0.2257080078125,
-0.58203125,
-0.5166015625,
-0.484375,
-0.4130859375,
-0.1492919921875,
0.90087890625,
0.2061767578125,
-0.89208984375,
-0.5302734375,
0.044677734375,
-0.2481689453125,
0.35693359375,
0.437255859375,
0.267822265625,
-0.137451171875,
0.17041015625,
-0.342529296875,
-0.47998046875,
0.059844970703125,
-0.420654296875,
0.3779296875,
-0.66845703125,
-0.7099609375,
-1.0849609375,
-0.88134765625,
-0.130859375,
0.27978515625,
-0.52099609375,
-0.693359375,
0.58740234375,
0.5029296875,
0.43310546875,
-0.042816162109375,
-0.11968994140625,
-0.0118560791015625,
0.70458984375,
0.87548828125,
-0.046661376953125,
0.564453125,
0.388916015625,
-0.062164306640625,
-0.0193634033203125,
-0.69580078125,
0.6044921875,
0.1187744140625,
0.006805419921875,
-0.417236328125,
0.1966552734375,
-0.95166015625,
-1.4462890625,
-0.150634765625,
0.1072998046875,
0.11444091796875,
-0.8642578125,
-1.208984375,
-0.5078125,
-0.70068359375,
-0.08026123046875,
-0.182861328125,
0.8701171875,
0.0621337890625,
-0.11822509765625,
-0.299560546875,
-0.99609375,
4.35546875,
1.2880859375,
0.87744140625,
0.0384521484375,
0.5703125,
1.1650390625,
0.490234375,
-0.89697265625,
-0.42041015625,
-0.2156982421875,
0.42626953125,
-0.35546875,
-0.2294921875,
0.5556640625,
0.11566162109375,
0.451416015625,
-0.703125,
-0.10906982421875,
-0.181884765625,
-0.77001953125,
-0.9677734375,
0.243408203125,
-0.09710693359375,
0.1585693359375,
0.1651611328125,
0.471923828125,
0.90380859375,
-0.6982421875,
0.042633056640625,
-0.638671875,
-0.10943603515625,
-0.37646484375,
1.0673828125,
0.345947265625,
-0.1759033203125,
0.53076171875,
-0.0809326171875,
-0.76318359375,
-0.021148681640625,
0.274169921875,
-0.58154296875,
-0.098876953125,
1.0625,
-0.316162109375,
0.1396484375,
0.405517578125,
-0.56982421875,
0.405029296875,
0.1761474609375,
-0.68310546875,
1.0751953125,
-0.044281005859375,
0.463623046875,
-0.71435546875,
-0.31884765625,
0.2105712890625,
0.48681640625,
0.035125732421875,
0.0081634521484375,
0.251220703125,
0.404052734375,
0.060455322265625,
0.313232421875,
0.62255859375,
-0.76513671875,
0.7626953125,
-0.38916015625,
0.172119140625,
-0.77685546875,
-0.0211639404296875,
-0.238037109375,
-0.07977294921875,
-0.4775390625,
-0.44580078125,
0.8544921875,
0.296142578125,
-0.07855224609375,
0.2462158203125,
0.2271728515625,
-0.73388671875,
0.242431640625,
-0.2047119140625,
-0.069091796875,
-0.042755126953125,
0.286376953125,
1.4501953125,
-0.375244140625,
-0.10369873046875,
-0.305419921875,
0.77783203125,
0.53076171875,
0.471923828125,
-0.1375732421875,
-0.68896484375,
-0.465087890625
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string a of length m is called antipalindromic iff m is even, and for each i (1 ≤ i ≤ m) ai ≠ am - i + 1.
Ivan has a string s consisting of n lowercase Latin letters; n is even. He wants to form some string t that will be an antipalindromic permutation of s. Also Ivan has denoted the beauty of index i as bi, and the beauty of t as the sum of bi among all indices i such that si = ti.
Help Ivan to determine maximum possible beauty of t he can get.
Input
The first line contains one integer n (2 ≤ n ≤ 100, n is even) — the number of characters in s.
The second line contains the string s itself. It consists of only lowercase Latin letters, and it is guaranteed that its letters can be reordered to form an antipalindromic string.
The third line contains n integer numbers b1, b2, ..., bn (1 ≤ bi ≤ 100), where bi is the beauty of index i.
Output
Print one number — the maximum possible beauty of t.
Examples
Input
8
abacabac
1 1 1 1 1 1 1 1
Output
8
Input
8
abaccaba
1 2 3 4 5 6 7 8
Output
26
Input
8
abacabca
1 2 3 4 4 3 2 1
Output
17
Tags: flows, graphs, greedy
Correct Solution:
```
class letter(object):
def __init__(self,let,val):
self.let=let
self.val=val
def __lt__(self,other):
return self.val<other.val
n=int(input())
s=input()
candi=[[] for i in range(n//2)]
ans=0
for i,vl in enumerate(map(int,input().split())):
candi[min(i,n-i-1)].append((letter)(s[i],vl))
ans+=vl
for i in range(n//2):
candi[i].sort()
ti=[0 for i in range(26)]
sum=0
for i in range(n//2):
if candi[i][0].let==candi[i][1].let:
ans-=candi[i][0].val
ti[ord(candi[i][0].let)-ord('a')]+=1
sum+=1
mx=0
p=0
for i in range(26):
if ti[i]>mx:
mx=ti[i]
p=i
b=[]
for i in range(n//2):
if ord(candi[i][0].let)-ord('a')!=p and ord(candi[i][1].let)-ord('a')!=p and candi[i][0].let!=candi[i][1].let:
b.append(candi[i][0])
b.sort()
i=0
while mx*2>sum:
sum+=1
ans-=b[i].val
i+=1
print(ans)
```
| 72,229 | [
0.1878662109375,
-0.006366729736328125,
0.0675048828125,
-0.0635986328125,
-0.50732421875,
-0.7021484375,
0.1844482421875,
0.1077880859375,
0.32470703125,
0.7041015625,
0.8291015625,
-0.018951416015625,
-0.1685791015625,
-1.0810546875,
-0.59033203125,
-0.10858154296875,
-0.57763671875,
-0.64892578125,
-0.452392578125,
0.205810546875,
0.2349853515625,
-0.21630859375,
-1.41015625,
-0.34375,
-0.4609375,
1.1142578125,
0.65380859375,
0.1224365234375,
0.9921875,
1.2734375,
-0.107421875,
-0.2413330078125,
0.6474609375,
-0.9697265625,
-0.61083984375,
-0.193359375,
0.462158203125,
-0.6962890625,
0.201904296875,
-0.64306640625,
0.462890625,
-0.6123046875,
0.37646484375,
-0.796875,
-0.90966796875,
0.05657958984375,
-0.365234375,
-0.6474609375,
-0.323486328125,
-0.767578125,
0.23583984375,
-0.1717529296875,
0.544921875,
0.08428955078125,
-0.330810546875,
0.370361328125,
0.0906982421875,
-0.315673828125,
-0.38720703125,
0.57470703125,
0.047119140625,
0.093994140625,
-0.1214599609375,
-0.708984375,
-0.08203125,
0.2049560546875,
0.043701171875,
-0.05035400390625,
0.043121337890625,
-1.1728515625,
-0.47607421875,
0.055908203125,
-0.306640625,
-0.35302734375,
-0.194091796875,
0.1273193359375,
0.11322021484375,
-0.09820556640625,
-0.61279296875,
0.5888671875,
-0.0203399658203125,
0.83447265625,
0.04888916015625,
0.5185546875,
-0.470703125,
-0.39013671875,
-0.2491455078125,
0.3232421875,
-0.10308837890625,
-0.09136962890625,
0.1634521484375,
0.495361328125,
-0.5966796875,
-0.09197998046875,
0.64599609375,
0.880859375,
-0.52978515625,
0.52978515625,
0.158447265625,
-0.07330322265625,
0.55615234375,
1.0849609375,
-0.47607421875,
1.0498046875,
-0.449462890625,
0.201171875,
-0.04913330078125,
0.365478515625,
-0.240234375,
-0.304443359375,
-0.0616455078125,
-0.0347900390625,
0.387451171875,
0.217529296875,
-0.0733642578125,
0.8583984375,
-0.2236328125,
0.204345703125,
-0.9423828125,
0.08038330078125,
0.13525390625,
0.2327880859375,
0.84130859375,
-0.1856689453125,
-0.0440673828125,
-0.3017578125,
-0.38916015625,
1.1396484375,
-0.97021484375,
-0.007762908935546875,
0.303955078125,
-0.1641845703125,
-0.17333984375,
0.145263671875,
-0.096435546875,
0.6123046875,
-0.34375,
0.32275390625,
0.98388671875,
-0.59326171875,
0.53857421875,
-0.14404296875,
-0.314208984375,
1.625,
0.419677734375,
0.155517578125,
1.0947265625,
-0.035186767578125,
-0.5830078125,
0.70849609375,
-0.8125,
0.33349609375,
0.0201263427734375,
0.290771484375,
-0.1253662109375,
0.58544921875,
-0.045654296875,
0.13232421875,
0.2161865234375,
-0.0157470703125,
-0.54150390625,
-0.0184326171875,
0.054290771484375,
0.9091796875,
-0.4306640625,
1.0517578125,
-0.6474609375,
-0.67236328125,
0.0616455078125,
-0.34326171875,
-0.0816650390625,
-0.1463623046875,
-0.08551025390625,
0.87255859375,
0.62890625,
0.78369140625,
0.7431640625,
-0.365478515625,
0.239013671875,
0.1514892578125,
-0.021759033203125,
0.387939453125,
0.37548828125,
0.68896484375,
0.2237548828125,
-0.08819580078125,
0.177978515625,
-0.355712890625,
-0.90771484375,
-0.53076171875,
-0.323974609375,
0.5771484375,
-0.325439453125,
-0.059814453125,
0.343505859375,
-0.2017822265625,
-0.91552734375,
-0.446044921875,
-0.0400390625,
-1.1015625,
-0.65380859375,
0.75634765625,
-0.1373291015625,
0.56005859375,
-0.48046875,
-0.46240234375,
0.08392333984375,
0.8251953125,
-0.1197509765625,
0.08343505859375,
0.67822265625,
0.0005774497985839844,
-0.00897216796875,
0.078857421875,
-0.042938232421875,
0.07366943359375,
-0.65625,
0.90380859375,
-0.00926971435546875,
0.06500244140625,
-0.30712890625,
0.79541015625,
0.239013671875,
0.65185546875,
-0.260498046875,
-0.08935546875,
0.302001953125,
0.88427734375,
0.143310546875,
0.196044921875,
-0.13720703125,
0.9423828125,
0.734375,
0.60546875,
0.58837890625,
0.033660888671875,
0.454345703125,
0.72265625,
0.169921875,
0.319580078125,
0.1617431640625,
0.37255859375,
0.41455078125,
0.126708984375,
-0.2423095703125,
0.765625,
0.05712890625,
0.375732421875,
-0.446044921875,
0.69921875,
-0.346435546875,
0.8896484375,
0.135009765625,
0.37353515625,
-0.31005859375,
-0.24462890625,
0.50146484375,
0.6103515625,
-0.56396484375,
-0.3056640625,
-0.1788330078125,
0.0865478515625,
0.1396484375,
0.2049560546875,
0.099853515625,
0.9365234375,
0.465576171875,
0.340087890625,
-0.29150390625,
-0.52392578125,
-1.091796875,
-0.49609375,
-1.0615234375,
-0.192626953125,
-0.6435546875,
-0.1595458984375,
0.58984375,
-0.97021484375,
0.51611328125,
-0.2386474609375,
-0.247314453125,
0.10693359375,
-0.95458984375,
0.308349609375,
-0.1651611328125,
0.65771484375,
-0.481689453125,
0.12225341796875,
0.00650787353515625,
0.85302734375,
-0.33154296875,
0.04364013671875,
0.0667724609375,
-0.55859375,
0.414794921875,
0.05841064453125,
0.1287841796875,
-0.2381591796875,
-0.982421875,
-0.98828125,
-0.5,
-0.2191162109375,
-0.6181640625,
-0.0643310546875,
-0.415283203125,
0.7939453125,
0.6494140625,
-0.3642578125,
0.55322265625,
0.7958984375,
-0.72265625,
0.31396484375,
0.25146484375,
0.1463623046875,
-0.779296875,
1.1416015625,
0.5205078125,
0.35205078125,
-0.56982421875,
-0.304443359375,
-0.50048828125,
0.1029052734375,
-0.033203125,
-0.58447265625,
-0.333740234375,
0.697265625,
0.357421875,
-1.0146484375,
0.37548828125,
-0.6806640625,
-0.5654296875,
-0.25390625,
-0.128173828125,
0.61474609375,
0.83642578125,
0.400634765625,
-0.27490234375,
-0.1131591796875,
-0.020751953125,
0.40234375,
0.463623046875,
-0.243408203125,
-0.2109375,
0.83251953125,
-0.05279541015625,
-0.04449462890625,
0.0836181640625,
-0.25390625,
-0.09722900390625,
0.55517578125,
0.305419921875,
0.728515625,
0.255126953125,
0.252685546875,
0.262939453125,
0.9091796875,
-0.7060546875,
-0.55517578125,
-0.350830078125,
0.77783203125,
0.2578125,
0.283447265625,
0.671875,
-0.391845703125,
-0.509765625,
-1.2216796875,
0.199951171875,
0.533203125,
0.6025390625,
-0.6162109375,
0.88916015625,
0.650390625,
-0.4912109375,
0.340576171875,
-0.55126953125,
0.1934814453125,
0.720703125,
0.217041015625,
0.9453125,
-0.51171875,
0.361572265625,
-0.384033203125,
0.412841796875,
0.908203125,
0.285888671875,
0.5537109375,
-0.69775390625,
-0.496337890625,
-0.51611328125,
-0.260986328125,
-0.168212890625,
-0.1639404296875,
0.38232421875,
-0.399658203125,
-0.185302734375,
-0.87353515625,
0.29931640625,
0.64453125,
0.32177734375,
0.142578125,
0.46875,
0.5380859375,
0.5263671875,
0.5322265625,
-0.33837890625,
0.183837890625,
-0.591796875,
0.84814453125,
0.267822265625,
-0.438720703125,
-0.51513671875,
-0.08453369140625,
-0.033111572265625,
0.09619140625,
0.154052734375,
-0.1190185546875,
-1.0869140625,
0.47705078125,
0.005336761474609375,
0.81640625,
-0.237060546875,
-0.2880859375,
-0.1820068359375,
0.43896484375,
0.4501953125,
-0.68408203125,
-0.1492919921875,
-0.496337890625,
0.54931640625,
0.63671875,
-0.2354736328125,
-0.267578125,
-0.1988525390625,
-0.77783203125,
-0.60986328125,
0.246337890625,
1.3671875,
-0.1708984375,
0.11572265625,
-1.12890625,
0.93310546875,
0.6025390625,
-0.189697265625,
-0.10284423828125,
0.0433349609375,
0.19970703125,
0.1834716796875,
0.63720703125,
-0.5478515625,
-0.939453125,
0.301025390625,
-1.2685546875,
0.5634765625,
-0.41845703125,
0.12274169921875,
-0.0247039794921875,
-0.392578125,
0.0772705078125,
0.625,
-0.3486328125,
0.264404296875,
-0.166259765625,
0.410888671875,
-1.1396484375,
-0.56396484375,
0.036224365234375,
-0.279052734375,
0.01206207275390625,
1.1279296875,
-0.4287109375,
-0.5361328125,
0.287353515625,
0.484619140625,
-0.6845703125,
0.481689453125,
-0.27587890625,
0.336669921875,
-0.35302734375,
-0.64404296875,
-0.1224365234375,
-0.67626953125,
0.93505859375,
0.0589599609375,
-0.845703125,
-0.026580810546875,
-0.978515625,
-0.43896484375,
-0.22607421875,
-0.87109375,
0.183349609375,
0.187744140625,
-0.15771484375,
-0.283935546875,
-0.2032470703125,
-0.55029296875,
-0.5859375,
-0.498291015625,
-0.454345703125,
0.39404296875,
0.1536865234375,
0.8115234375,
0.23583984375,
-0.361328125,
-0.135986328125,
-0.0020885467529296875,
0.1357421875,
-0.44677734375,
0.08770751953125,
-0.3203125,
-0.367431640625,
-0.19970703125,
-0.1802978515625,
-0.01479339599609375,
0.266357421875,
0.64404296875,
0.10052490234375,
0.52099609375,
0.251220703125,
-0.8583984375,
0.95751953125,
0.250732421875,
-0.916015625,
-0.03155517578125,
0.367431640625,
0.251708984375,
0.355712890625,
0.1600341796875,
-0.94580078125,
-0.54248046875,
-0.72802734375,
0.30517578125,
-0.8466796875,
-0.02606201171875,
-0.9248046875,
-0.3154296875,
-0.34130859375,
0.97412109375,
-0.2056884765625,
-0.6220703125,
0.22119140625,
-1.1923828125,
-0.06109619140625,
-0.64990234375,
-0.181640625,
-1.142578125,
-0.59716796875,
-0.2705078125,
0.93603515625,
0.266845703125,
0.10205078125,
0.302978515625,
-0.246826171875,
0.270263671875,
-0.0230712890625,
-0.65625,
-0.250244140625,
-0.55078125,
-0.147705078125,
-0.056304931640625,
-0.1634521484375,
-0.63720703125,
0.6728515625,
-0.765625,
0.25146484375,
-0.00759124755859375,
-0.21484375,
-0.2386474609375,
-0.56103515625,
1.1162109375,
-0.336181640625,
-0.321044921875,
-0.7373046875,
0.3583984375,
0.861328125,
-0.33642578125,
-0.2861328125,
-0.6826171875,
-0.81103515625,
-1.3056640625,
0.84375,
-0.35302734375,
-0.04412841796875,
-0.97998046875,
-0.475830078125,
1.0849609375,
-0.345703125,
-0.06011962890625,
0.84912109375,
0.43212890625,
0.37109375,
-0.78564453125,
0.65576171875,
0.509765625,
-0.576171875,
-0.1375732421875,
0.016326904296875,
-0.9189453125,
0.2216796875,
-0.0128631591796875,
-1.2109375,
-0.5087890625,
0.487548828125,
1.328125,
-0.2135009765625,
0.61083984375,
-0.11456298828125,
-1.1259765625,
-0.63525390625,
1.14453125,
0.27490234375,
0.232666015625,
0.77001953125,
-0.219970703125,
-0.294921875,
-0.322021484375,
0.0104217529296875,
-0.59375,
-0.387451171875,
0.99658203125,
-0.2083740234375,
-0.6279296875,
0.82275390625,
0.58251953125,
-1.2177734375,
-0.6025390625,
-0.00803375244140625,
-0.041046142578125,
0.040130615234375,
-0.497802734375,
0.05596923828125,
0.70556640625,
-0.76708984375,
0.04949951171875,
0.3603515625,
-0.22412109375,
0.59912109375,
0.058807373046875,
0.55908203125,
-0.301025390625,
0.4306640625,
0.5888671875,
-0.62646484375,
-0.349853515625,
-1.0771484375,
-0.3486328125,
-0.34326171875,
-0.1307373046875,
0.8017578125,
-0.308837890625,
0.49365234375,
0.58740234375,
0.321533203125,
0.65283203125,
-0.6240234375,
-0.487060546875,
0.40185546875,
-0.67919921875,
-0.479736328125,
-0.45068359375,
0.53369140625,
-0.429931640625,
0.564453125,
-0.5439453125,
0.3818359375,
0.305419921875,
0.24072265625,
-0.365966796875,
-0.63720703125,
-0.46435546875,
-1.1279296875,
-0.7509765625,
-0.7294921875,
-0.728515625,
-0.025299072265625,
0.2098388671875,
-0.255615234375,
-0.77099609375,
0.332763671875,
0.401611328125,
-0.6826171875,
0.96533203125,
-0.75390625,
0.4775390625,
-0.492431640625,
-0.61376953125,
-0.488525390625,
0.337646484375,
-0.20703125,
0.1234130859375,
-0.3935546875,
0.338623046875,
-0.05413818359375,
0.7939453125,
0.038818359375,
0.419921875,
-0.397216796875,
-0.1671142578125,
-0.2432861328125,
-0.156494140625,
-0.1806640625,
0.6455078125,
0.75537109375,
0.0928955078125,
0.2078857421875,
0.00775909423828125,
-0.414306640625,
-0.468505859375,
0.395751953125,
0.28662109375,
-0.359130859375,
0.007526397705078125,
-0.43017578125,
0.0711669921875,
-0.93408203125,
0.59912109375,
-0.5126953125,
0.01076507568359375,
0.50927734375,
0.0380859375,
0.2939453125,
0.97998046875,
-0.219970703125,
0.34228515625,
0.02978515625,
-0.04217529296875,
0.48876953125,
0.00824737548828125,
-0.060455322265625,
0.51953125,
0.387451171875,
-0.5078125,
-0.002368927001953125,
0.433349609375,
-0.0255889892578125,
0.40625,
0.056884765625,
-0.98779296875,
-1.109375,
-0.54296875,
0.059539794921875,
0.157470703125,
0.53271484375,
-0.4541015625,
-0.0012969970703125,
-0.05511474609375,
-0.68310546875,
-0.17724609375,
-1.0263671875,
-0.9697265625,
0.28125,
-0.15673828125,
-0.441650390625,
-0.165283203125,
-0.23193359375,
-0.010528564453125,
-0.0129241943359375,
0.2325439453125,
-0.5185546875,
0.3759765625,
-0.258544921875,
0.26318359375,
-0.313232421875,
0.1011962890625,
0.092529296875,
0.68115234375,
-0.29443359375,
-0.61767578125,
-0.179931640625,
0.70703125,
0.160888671875,
-0.1678466796875,
-0.260498046875,
0.0849609375,
-0.030792236328125,
0.0771484375,
-0.328125,
-0.255615234375,
-0.440673828125,
0.73583984375,
-0.7109375,
-0.1654052734375,
0.1314697265625,
0.28564453125,
-0.0789794921875,
-0.038116455078125,
-0.480224609375,
0.62548828125,
0.9423828125,
-0.2049560546875,
0.751953125,
0.334716796875,
0.88330078125,
-0.31298828125,
-0.32080078125,
-0.384033203125,
0.64697265625,
0.740234375,
0.57080078125,
-0.01485443115234375,
-0.103759765625,
0.67431640625,
-0.0921630859375,
-0.475830078125,
0.2021484375,
0.09326171875,
0.376220703125,
0.08453369140625,
-0.29052734375,
-0.045440673828125,
0.2432861328125,
-0.52685546875,
0.77392578125,
-0.61767578125,
-0.271728515625,
-0.1646728515625,
-0.468505859375,
0.395263671875,
-0.20751953125,
-0.155517578125,
0.10821533203125,
-0.46044921875,
0.57275390625,
0.1920166015625,
0.29296875,
0.05474853515625,
1.1484375,
0.822265625,
0.367431640625,
0.71142578125,
0.319580078125,
0.295166015625,
-0.362060546875,
0.3369140625,
-0.0638427734375,
-0.37255859375,
-0.206298828125,
-0.5947265625,
-1.142578125,
0.2017822265625,
-0.37744140625,
-0.52587890625,
0.314697265625,
-0.78125,
0.170654296875,
-0.3505859375,
0.92578125,
-0.216796875,
0.50830078125,
0.53125,
-0.57373046875,
-0.52978515625,
0.9951171875,
-0.67333984375,
0.40283203125,
0.1387939453125,
0.75341796875,
0.1915283203125,
1.5703125,
0.90625,
-0.3759765625,
0.09381103515625,
0.10711669921875,
-0.1402587890625,
-0.31982421875,
-0.7900390625,
-0.25732421875,
0.034149169921875,
-0.638671875,
-0.34521484375,
-0.1268310546875,
0.487060546875,
0.2227783203125,
-1.0068359375,
-0.396240234375,
0.391845703125,
-0.931640625,
0.1253662109375,
0.3271484375,
0.1585693359375,
0.11151123046875,
0.181396484375,
-0.43408203125,
-0.473388671875,
0.202880859375,
-0.80224609375,
0.1240234375,
-0.53369140625,
-0.39892578125,
-0.65087890625,
-0.87841796875,
-0.1011962890625,
-0.204345703125,
-0.4501953125,
-0.93017578125,
0.7197265625,
0.603515625,
0.50048828125,
0.5791015625,
-0.17529296875,
0.4873046875,
0.98046875,
0.98974609375,
0.276123046875,
0.58447265625,
0.10955810546875,
-0.51708984375,
0.239013671875,
-0.0267486572265625,
0.332763671875,
-0.219482421875,
0.418701171875,
-0.650390625,
0.379150390625,
-0.626953125,
-1.41015625,
0.1092529296875,
0.59912109375,
0.818359375,
-0.63525390625,
-1.02734375,
0.01300048828125,
-0.884765625,
-0.1680908203125,
-0.521484375,
0.2481689453125,
-0.246337890625,
0.265380859375,
-0.236083984375,
-1.22265625,
4.4140625,
1.123046875,
1.0556640625,
0.52197265625,
0.27978515625,
0.9541015625,
0.342041015625,
-0.64111328125,
-0.391357421875,
-0.165283203125,
0.759765625,
-0.449951171875,
0.11383056640625,
0.83251953125,
0.52099609375,
0.56103515625,
-0.50341796875,
0.1761474609375,
0.2705078125,
-0.9658203125,
-0.99462890625,
0.251708984375,
-0.0086517333984375,
0.3095703125,
0.310302734375,
0.1842041015625,
0.236572265625,
-0.73046875,
-0.2099609375,
-0.396484375,
0.07208251953125,
-0.505859375,
0.8662109375,
-0.069580078125,
-0.185791015625,
0.413330078125,
0.1749267578125,
-0.2919921875,
0.00335693359375,
0.29736328125,
-0.01314544677734375,
-0.48583984375,
0.76220703125,
-0.81494140625,
-0.51953125,
0.056976318359375,
-0.759765625,
0.646484375,
-0.40380859375,
-0.56787109375,
1.0576171875,
-0.1802978515625,
0.48388671875,
-0.53662109375,
-0.82373046875,
0.447998046875,
0.0902099609375,
-0.252197265625,
-0.0992431640625,
0.73291015625,
0.0736083984375,
0.26611328125,
0.409423828125,
0.479736328125,
-0.8505859375,
0.97216796875,
-0.2342529296875,
0.4384765625,
-0.77734375,
0.0802001953125,
-0.054046630859375,
-0.389892578125,
-0.07696533203125,
-0.178955078125,
0.62060546875,
0.34375,
-0.026519775390625,
0.87060546875,
0.251708984375,
-0.79052734375,
-0.1436767578125,
-0.005458831787109375,
-0.301025390625,
-0.205322265625,
0.9755859375,
1.12109375,
-0.62890625,
-0.2568359375,
-0.326416015625,
0.673828125,
0.30078125,
0.2021484375,
-0.062255859375,
-0.6103515625,
-0.462890625
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string a of length m is called antipalindromic iff m is even, and for each i (1 ≤ i ≤ m) ai ≠ am - i + 1.
Ivan has a string s consisting of n lowercase Latin letters; n is even. He wants to form some string t that will be an antipalindromic permutation of s. Also Ivan has denoted the beauty of index i as bi, and the beauty of t as the sum of bi among all indices i such that si = ti.
Help Ivan to determine maximum possible beauty of t he can get.
Input
The first line contains one integer n (2 ≤ n ≤ 100, n is even) — the number of characters in s.
The second line contains the string s itself. It consists of only lowercase Latin letters, and it is guaranteed that its letters can be reordered to form an antipalindromic string.
The third line contains n integer numbers b1, b2, ..., bn (1 ≤ bi ≤ 100), where bi is the beauty of index i.
Output
Print one number — the maximum possible beauty of t.
Examples
Input
8
abacabac
1 1 1 1 1 1 1 1
Output
8
Input
8
abaccaba
1 2 3 4 5 6 7 8
Output
26
Input
8
abacabca
1 2 3 4 4 3 2 1
Output
17
Tags: flows, graphs, greedy
Correct Solution:
```
from collections import *
n = int(input())
s = input()
b = [int (i) for i in input().split(' ')]
n = n
cnt = defaultdict(int)
multiples = []
biggest = 'a'
ans = 0
for i in range(n//2):
if(s[i] == s[n-i-1]):
multiples.append(i)
cnt[s[i]] += 1
ans += max(b[i],b[n-i-1])
else:
ans += b[i] + b[n-i-1]
for i in range(26):
if(cnt[chr(ord('a')+i)] > cnt[biggest]):
biggest = chr(ord('a')+i)
more = max(max(cnt.values())*2-sum(cnt.values()),0)
# print(more)
takes = []
for i in range(n//2):
if(s[i] != s[n-i-1] and s[i] != biggest and s[n-i-1] != biggest):
takes.append(min(b[i],b[n-i-1]))
takes = sorted(takes)[:more]
pen = sum(takes)
# print(pen)
# print(takes)
print(ans-pen)
```
| 72,231 | [
0.2183837890625,
0.031951904296875,
0.08892822265625,
-0.046356201171875,
-0.4169921875,
-0.68017578125,
0.201904296875,
0.06353759765625,
0.40966796875,
0.8447265625,
0.86572265625,
-0.049530029296875,
-0.1605224609375,
-1.0927734375,
-0.6796875,
-0.1248779296875,
-0.55810546875,
-0.65087890625,
-0.386962890625,
0.2578125,
0.21142578125,
-0.240966796875,
-1.4921875,
-0.283447265625,
-0.464111328125,
1.1826171875,
0.64306640625,
0.1380615234375,
0.94091796875,
1.197265625,
-0.190185546875,
-0.294677734375,
0.62890625,
-0.98193359375,
-0.61083984375,
-0.1927490234375,
0.429931640625,
-0.70849609375,
0.144775390625,
-0.64599609375,
0.4443359375,
-0.5732421875,
0.37548828125,
-0.79833984375,
-0.9169921875,
-0.0054931640625,
-0.367919921875,
-0.505859375,
-0.3037109375,
-0.77978515625,
0.23876953125,
-0.1419677734375,
0.53955078125,
0.17919921875,
-0.36474609375,
0.438720703125,
0.0340576171875,
-0.298828125,
-0.41796875,
0.66064453125,
0.0865478515625,
0.08349609375,
-0.11517333984375,
-0.64990234375,
-0.08709716796875,
0.210693359375,
-0.00757598876953125,
0.0187225341796875,
0.07794189453125,
-1.1259765625,
-0.4072265625,
0.024078369140625,
-0.29736328125,
-0.333740234375,
-0.2437744140625,
0.184814453125,
0.1419677734375,
-0.10943603515625,
-0.5966796875,
0.6259765625,
0.01502227783203125,
0.873046875,
-0.067138671875,
0.52490234375,
-0.45654296875,
-0.440673828125,
-0.291748046875,
0.38671875,
-0.09930419921875,
-0.1904296875,
0.0810546875,
0.469970703125,
-0.490478515625,
-0.12078857421875,
0.61474609375,
0.79736328125,
-0.55322265625,
0.59765625,
0.1441650390625,
-0.1175537109375,
0.478271484375,
1.150390625,
-0.38720703125,
1.0625,
-0.471923828125,
0.10980224609375,
-0.00936126708984375,
0.34521484375,
-0.1893310546875,
-0.3515625,
-0.0226287841796875,
-0.08697509765625,
0.358642578125,
0.22705078125,
-0.118896484375,
0.89892578125,
-0.1497802734375,
0.255859375,
-0.88427734375,
0.1282958984375,
0.0810546875,
0.21435546875,
0.76806640625,
-0.173583984375,
-0.073486328125,
-0.3486328125,
-0.44921875,
1.1572265625,
-0.9677734375,
-0.04376220703125,
0.25048828125,
-0.184326171875,
-0.186767578125,
0.09320068359375,
-0.093017578125,
0.63623046875,
-0.284912109375,
0.354248046875,
0.97216796875,
-0.7001953125,
0.6005859375,
-0.161376953125,
-0.2197265625,
1.58984375,
0.406982421875,
0.25341796875,
1.12109375,
-0.02178955078125,
-0.5400390625,
0.67626953125,
-0.86572265625,
0.4130859375,
0.046173095703125,
0.339111328125,
-0.1617431640625,
0.5908203125,
-0.0718994140625,
0.1033935546875,
0.197021484375,
-0.007389068603515625,
-0.474853515625,
0.041412353515625,
0.033660888671875,
0.91259765625,
-0.455810546875,
1.05078125,
-0.630859375,
-0.66455078125,
0.05950927734375,
-0.4130859375,
-0.0958251953125,
-0.106689453125,
0.0038433074951171875,
0.908203125,
0.7001953125,
0.89013671875,
0.755859375,
-0.39208984375,
0.2174072265625,
0.081787109375,
0.030120849609375,
0.350341796875,
0.39208984375,
0.66162109375,
0.2376708984375,
-0.0750732421875,
0.2064208984375,
-0.376708984375,
-0.91064453125,
-0.53564453125,
-0.358154296875,
0.5283203125,
-0.347412109375,
-0.01381683349609375,
0.35302734375,
-0.217041015625,
-0.96728515625,
-0.47705078125,
-0.048919677734375,
-1.0986328125,
-0.56884765625,
0.8271484375,
-0.121826171875,
0.57568359375,
-0.59375,
-0.384765625,
0.1434326171875,
0.853515625,
-0.07037353515625,
0.0174713134765625,
0.6181640625,
0.01136016845703125,
-0.04290771484375,
0.023590087890625,
-0.0241241455078125,
0.108642578125,
-0.70166015625,
0.89599609375,
-0.07501220703125,
0.0095672607421875,
-0.27783203125,
0.7431640625,
0.259033203125,
0.62744140625,
-0.1907958984375,
-0.0672607421875,
0.353271484375,
0.97900390625,
0.1573486328125,
0.205078125,
-0.10162353515625,
1.021484375,
0.74560546875,
0.6123046875,
0.5712890625,
0.025177001953125,
0.43115234375,
0.7568359375,
0.1668701171875,
0.380126953125,
0.142333984375,
0.34228515625,
0.40380859375,
0.13134765625,
-0.181884765625,
0.7158203125,
0.018707275390625,
0.34912109375,
-0.49462890625,
0.73193359375,
-0.352294921875,
0.90478515625,
0.2025146484375,
0.36669921875,
-0.31640625,
-0.189697265625,
0.52734375,
0.611328125,
-0.60498046875,
-0.337646484375,
-0.2008056640625,
0.07232666015625,
0.1343994140625,
0.13623046875,
0.1488037109375,
0.951171875,
0.45849609375,
0.37109375,
-0.308349609375,
-0.529296875,
-1.07421875,
-0.4345703125,
-1.0556640625,
-0.1724853515625,
-0.69384765625,
-0.1826171875,
0.55419921875,
-0.97705078125,
0.431640625,
-0.212890625,
-0.25244140625,
0.1724853515625,
-0.93115234375,
0.35888671875,
-0.11187744140625,
0.65185546875,
-0.5478515625,
0.2276611328125,
0.01556396484375,
0.84716796875,
-0.3369140625,
0.055694580078125,
0.09722900390625,
-0.6357421875,
0.380615234375,
0.1290283203125,
0.1722412109375,
-0.222900390625,
-0.9736328125,
-0.9736328125,
-0.5390625,
-0.1651611328125,
-0.5849609375,
-0.07012939453125,
-0.472412109375,
0.7724609375,
0.62646484375,
-0.369873046875,
0.5732421875,
0.81591796875,
-0.73583984375,
0.304931640625,
0.24072265625,
0.2205810546875,
-0.80615234375,
1.134765625,
0.5751953125,
0.380859375,
-0.591796875,
-0.33154296875,
-0.5439453125,
0.0511474609375,
-0.036163330078125,
-0.6640625,
-0.393310546875,
0.67822265625,
0.37255859375,
-0.97900390625,
0.4365234375,
-0.748046875,
-0.654296875,
-0.25390625,
-0.1392822265625,
0.6181640625,
0.90283203125,
0.37548828125,
-0.287841796875,
-0.090576171875,
-0.1119384765625,
0.484619140625,
0.44287109375,
-0.225341796875,
-0.328369140625,
0.8740234375,
-0.051849365234375,
-0.015960693359375,
0.1630859375,
-0.320068359375,
-0.0640869140625,
0.56591796875,
0.3544921875,
0.86474609375,
0.239013671875,
0.2666015625,
0.251708984375,
0.98828125,
-0.78857421875,
-0.49609375,
-0.339111328125,
0.71435546875,
0.33447265625,
0.3427734375,
0.6181640625,
-0.37060546875,
-0.583984375,
-1.201171875,
0.1561279296875,
0.50537109375,
0.68017578125,
-0.61376953125,
0.8486328125,
0.65234375,
-0.443359375,
0.435546875,
-0.5380859375,
0.1990966796875,
0.75244140625,
0.249755859375,
0.9921875,
-0.4755859375,
0.359130859375,
-0.380126953125,
0.364013671875,
1.005859375,
0.2437744140625,
0.59033203125,
-0.72607421875,
-0.646484375,
-0.53564453125,
-0.185791015625,
-0.1273193359375,
-0.1932373046875,
0.3369140625,
-0.390869140625,
-0.154296875,
-0.91357421875,
0.297119140625,
0.56884765625,
0.30517578125,
0.10107421875,
0.52734375,
0.478271484375,
0.55615234375,
0.54541015625,
-0.342041015625,
0.08648681640625,
-0.603515625,
0.8837890625,
0.167724609375,
-0.479248046875,
-0.5185546875,
-0.046600341796875,
-0.003231048583984375,
0.0565185546875,
0.0665283203125,
-0.1998291015625,
-1.12109375,
0.5595703125,
0.005298614501953125,
0.75390625,
-0.258056640625,
-0.28173828125,
-0.1689453125,
0.5146484375,
0.43994140625,
-0.75341796875,
-0.0634765625,
-0.447021484375,
0.56103515625,
0.67041015625,
-0.1678466796875,
-0.276611328125,
-0.22509765625,
-0.7236328125,
-0.62451171875,
0.2235107421875,
1.353515625,
-0.1588134765625,
0.154052734375,
-1.1640625,
0.8525390625,
0.58447265625,
-0.1473388671875,
-0.10565185546875,
0.061737060546875,
0.2398681640625,
0.23291015625,
0.7001953125,
-0.525390625,
-0.96630859375,
0.316162109375,
-1.2392578125,
0.515625,
-0.513671875,
0.15185546875,
0.01219940185546875,
-0.430908203125,
0.0994873046875,
0.603515625,
-0.258544921875,
0.2435302734375,
-0.178466796875,
0.37451171875,
-1.1611328125,
-0.61181640625,
0.07061767578125,
-0.302001953125,
-0.08575439453125,
1.119140625,
-0.41650390625,
-0.52294921875,
0.356689453125,
0.56689453125,
-0.6201171875,
0.4775390625,
-0.298095703125,
0.40869140625,
-0.466552734375,
-0.63818359375,
-0.1689453125,
-0.62158203125,
0.90673828125,
0.075927734375,
-0.8828125,
0.002040863037109375,
-1.064453125,
-0.427734375,
-0.16357421875,
-0.74267578125,
0.202880859375,
0.1988525390625,
-0.07659912109375,
-0.343017578125,
-0.24658203125,
-0.57373046875,
-0.5458984375,
-0.5458984375,
-0.349365234375,
0.400390625,
0.0914306640625,
0.7392578125,
0.1943359375,
-0.3525390625,
-0.07330322265625,
0.0699462890625,
0.071533203125,
-0.5322265625,
0.025238037109375,
-0.30419921875,
-0.291015625,
-0.1668701171875,
-0.180419921875,
-0.0163421630859375,
0.2166748046875,
0.703125,
0.097900390625,
0.53759765625,
0.2052001953125,
-0.80908203125,
0.984375,
0.232666015625,
-0.9248046875,
0.0186920166015625,
0.363525390625,
0.291748046875,
0.393310546875,
0.1375732421875,
-0.95458984375,
-0.50048828125,
-0.7041015625,
0.237060546875,
-0.84423828125,
-0.04254150390625,
-0.888671875,
-0.354736328125,
-0.322021484375,
1.02734375,
-0.15869140625,
-0.68408203125,
0.19091796875,
-1.2333984375,
-0.03338623046875,
-0.70849609375,
-0.234375,
-1.1640625,
-0.66357421875,
-0.377685546875,
0.9130859375,
0.25927734375,
0.03363037109375,
0.254638671875,
-0.279541015625,
0.2841796875,
-0.04290771484375,
-0.6708984375,
-0.291259765625,
-0.425537109375,
-0.1424560546875,
-0.0845947265625,
-0.138916015625,
-0.69287109375,
0.6298828125,
-0.7294921875,
0.2880859375,
-0.09149169921875,
-0.20458984375,
-0.24560546875,
-0.5693359375,
1.1298828125,
-0.339599609375,
-0.32568359375,
-0.6552734375,
0.345703125,
0.8212890625,
-0.3369140625,
-0.329833984375,
-0.673828125,
-0.7939453125,
-1.2236328125,
0.92138671875,
-0.41455078125,
-0.07861328125,
-0.8984375,
-0.41552734375,
1.0234375,
-0.3408203125,
-0.0452880859375,
0.84423828125,
0.3876953125,
0.38134765625,
-0.7607421875,
0.6875,
0.57568359375,
-0.5673828125,
-0.1790771484375,
0.0386962890625,
-0.98291015625,
0.2548828125,
-0.05279541015625,
-1.1982421875,
-0.5244140625,
0.44970703125,
1.31640625,
-0.2408447265625,
0.62255859375,
-0.09619140625,
-1.1943359375,
-0.7216796875,
1.146484375,
0.3203125,
0.25634765625,
0.77392578125,
-0.2401123046875,
-0.314453125,
-0.349609375,
0.02850341796875,
-0.57080078125,
-0.4970703125,
1.001953125,
-0.208740234375,
-0.56982421875,
0.70703125,
0.5947265625,
-1.236328125,
-0.7421875,
0.028900146484375,
0.040496826171875,
0.053924560546875,
-0.53125,
0.09710693359375,
0.640625,
-0.7705078125,
0.0015497207641601562,
0.315673828125,
-0.150390625,
0.5751953125,
0.06561279296875,
0.471923828125,
-0.3466796875,
0.480712890625,
0.58203125,
-0.52587890625,
-0.340087890625,
-1.076171875,
-0.3701171875,
-0.365478515625,
-0.11053466796875,
0.81689453125,
-0.3388671875,
0.4638671875,
0.58740234375,
0.29248046875,
0.619140625,
-0.61083984375,
-0.474853515625,
0.38037109375,
-0.6630859375,
-0.4404296875,
-0.411865234375,
0.52783203125,
-0.408447265625,
0.544921875,
-0.5107421875,
0.376953125,
0.3603515625,
0.1925048828125,
-0.330322265625,
-0.67431640625,
-0.431396484375,
-1.1220703125,
-0.72314453125,
-0.7294921875,
-0.8369140625,
-0.048431396484375,
0.140625,
-0.266357421875,
-0.72216796875,
0.2225341796875,
0.439208984375,
-0.7275390625,
0.96826171875,
-0.74560546875,
0.430419921875,
-0.54052734375,
-0.60302734375,
-0.462646484375,
0.28662109375,
-0.1607666015625,
0.1175537109375,
-0.432861328125,
0.337890625,
-0.02227783203125,
0.81982421875,
-0.08538818359375,
0.438720703125,
-0.403564453125,
-0.307861328125,
-0.212158203125,
-0.12213134765625,
-0.170166015625,
0.69677734375,
0.80712890625,
0.054229736328125,
0.17333984375,
-0.00600433349609375,
-0.390380859375,
-0.57080078125,
0.53125,
0.36376953125,
-0.427490234375,
-0.07452392578125,
-0.424560546875,
0.036376953125,
-0.9794921875,
0.54833984375,
-0.5107421875,
0.03228759765625,
0.46044921875,
0.0014972686767578125,
0.2264404296875,
1.0458984375,
-0.2093505859375,
0.32763671875,
-0.003925323486328125,
0.060760498046875,
0.525390625,
-0.1038818359375,
0.00934600830078125,
0.599609375,
0.41357421875,
-0.455322265625,
0.0885009765625,
0.461669921875,
-0.037078857421875,
0.293701171875,
0.0794677734375,
-1.0419921875,
-1.033203125,
-0.52294921875,
-0.006099700927734375,
0.1827392578125,
0.46044921875,
-0.424072265625,
-0.06500244140625,
-0.1031494140625,
-0.72216796875,
-0.1817626953125,
-1.0185546875,
-0.9970703125,
0.277099609375,
-0.1317138671875,
-0.489013671875,
-0.1651611328125,
-0.271728515625,
-0.05767822265625,
-0.08062744140625,
0.3564453125,
-0.55224609375,
0.385498046875,
-0.293212890625,
0.322509765625,
-0.2998046875,
0.167236328125,
0.08795166015625,
0.6943359375,
-0.358154296875,
-0.61376953125,
-0.1849365234375,
0.71826171875,
0.1680908203125,
-0.177001953125,
-0.28564453125,
0.09857177734375,
0.0007138252258300781,
-0.0246429443359375,
-0.3818359375,
-0.1883544921875,
-0.406982421875,
0.7861328125,
-0.65185546875,
-0.1368408203125,
0.08526611328125,
0.31884765625,
-0.0745849609375,
-0.037872314453125,
-0.43359375,
0.546875,
0.95458984375,
-0.28125,
0.677734375,
0.358154296875,
0.7900390625,
-0.289794921875,
-0.3095703125,
-0.367919921875,
0.6396484375,
0.7509765625,
0.56201171875,
-0.0467529296875,
-0.1300048828125,
0.65576171875,
-0.0916748046875,
-0.43701171875,
0.12237548828125,
0.0875244140625,
0.376708984375,
0.04876708984375,
-0.244384765625,
-0.06854248046875,
0.271484375,
-0.5400390625,
0.74169921875,
-0.57763671875,
-0.296142578125,
-0.21240234375,
-0.51123046875,
0.42529296875,
-0.1513671875,
-0.17919921875,
0.1475830078125,
-0.462158203125,
0.64013671875,
0.22998046875,
0.256591796875,
0.052459716796875,
1.1181640625,
0.87451171875,
0.394775390625,
0.72265625,
0.300048828125,
0.319091796875,
-0.3046875,
0.244140625,
0.0012693405151367188,
-0.438232421875,
-0.2109375,
-0.572265625,
-1.0927734375,
0.17138671875,
-0.364990234375,
-0.49462890625,
0.42578125,
-0.86181640625,
0.22412109375,
-0.39208984375,
0.96630859375,
-0.192138671875,
0.55712890625,
0.51123046875,
-0.53759765625,
-0.59423828125,
0.91357421875,
-0.69775390625,
0.313232421875,
0.11639404296875,
0.85205078125,
0.192626953125,
1.521484375,
0.8623046875,
-0.37158203125,
0.1197509765625,
0.1363525390625,
-0.138671875,
-0.328369140625,
-0.61474609375,
-0.251953125,
0.053466796875,
-0.64453125,
-0.41845703125,
-0.07220458984375,
0.488037109375,
0.1751708984375,
-0.96142578125,
-0.38330078125,
0.43896484375,
-0.9794921875,
0.11212158203125,
0.353759765625,
0.14892578125,
0.1461181640625,
0.1627197265625,
-0.440673828125,
-0.46142578125,
0.302490234375,
-0.76953125,
0.0638427734375,
-0.5380859375,
-0.439697265625,
-0.60400390625,
-0.8896484375,
-0.162841796875,
-0.25390625,
-0.5234375,
-0.93896484375,
0.73974609375,
0.69091796875,
0.4208984375,
0.5693359375,
-0.1868896484375,
0.416259765625,
0.99267578125,
1.052734375,
0.26806640625,
0.56005859375,
0.11138916015625,
-0.439453125,
0.27490234375,
-0.0875244140625,
0.32666015625,
-0.227783203125,
0.436279296875,
-0.64453125,
0.349365234375,
-0.638671875,
-1.4658203125,
0.09820556640625,
0.65576171875,
0.84228515625,
-0.68896484375,
-1.041015625,
-0.0247802734375,
-0.8994140625,
-0.2115478515625,
-0.50634765625,
0.27734375,
-0.239013671875,
0.2462158203125,
-0.2626953125,
-1.1962890625,
4.3828125,
1.0908203125,
1.0185546875,
0.5478515625,
0.2156982421875,
0.962890625,
0.313720703125,
-0.5751953125,
-0.32763671875,
-0.130615234375,
0.7099609375,
-0.50341796875,
-0.006160736083984375,
0.8662109375,
0.4716796875,
0.5380859375,
-0.42724609375,
0.197509765625,
0.347900390625,
-0.982421875,
-0.998046875,
0.30029296875,
0.048248291015625,
0.360107421875,
0.306640625,
0.2354736328125,
0.298095703125,
-0.68603515625,
-0.283935546875,
-0.353271484375,
0.099365234375,
-0.4365234375,
0.93212890625,
-0.07098388671875,
-0.2318115234375,
0.45166015625,
0.173095703125,
-0.26806640625,
-0.041351318359375,
0.26123046875,
-0.0264892578125,
-0.5166015625,
0.71826171875,
-0.8681640625,
-0.517578125,
0.1552734375,
-0.75439453125,
0.71044921875,
-0.3671875,
-0.62890625,
0.943359375,
-0.10595703125,
0.50244140625,
-0.5234375,
-0.80029296875,
0.45458984375,
0.0675048828125,
-0.2220458984375,
-0.10833740234375,
0.7978515625,
0.08184814453125,
0.292236328125,
0.411865234375,
0.466064453125,
-0.89208984375,
1.009765625,
-0.2037353515625,
0.43408203125,
-0.72119140625,
0.068115234375,
-0.033782958984375,
-0.393310546875,
-0.062744140625,
-0.244140625,
0.60546875,
0.4013671875,
-0.0213165283203125,
0.87646484375,
0.260009765625,
-0.72265625,
-0.2178955078125,
-0.0097198486328125,
-0.281005859375,
-0.28955078125,
0.99755859375,
1.1220703125,
-0.6396484375,
-0.22705078125,
-0.34619140625,
0.68603515625,
0.312744140625,
0.209228515625,
-0.06292724609375,
-0.6396484375,
-0.4287109375
] | 6 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A string a of length m is called antipalindromic iff m is even, and for each i (1 ≤ i ≤ m) ai ≠ am - i + 1.
Ivan has a string s consisting of n lowercase Latin letters; n is even. He wants to form some string t that will be an antipalindromic permutation of s. Also Ivan has denoted the beauty of index i as bi, and the beauty of t as the sum of bi among all indices i such that si = ti.
Help Ivan to determine maximum possible beauty of t he can get.
Input
The first line contains one integer n (2 ≤ n ≤ 100, n is even) — the number of characters in s.
The second line contains the string s itself. It consists of only lowercase Latin letters, and it is guaranteed that its letters can be reordered to form an antipalindromic string.
The third line contains n integer numbers b1, b2, ..., bn (1 ≤ bi ≤ 100), where bi is the beauty of index i.
Output
Print one number — the maximum possible beauty of t.
Examples
Input
8
abacabac
1 1 1 1 1 1 1 1
Output
8
Input
8
abaccaba
1 2 3 4 5 6 7 8
Output
26
Input
8
abacabca
1 2 3 4 4 3 2 1
Output
17
Tags: flows, graphs, greedy
Correct Solution:
```
from collections import Counter
r = lambda: map(int, input().split())
def main():
n, = r()
s = input()
cost = list(r())
ans = 0
cnt = Counter()
for i in range(n // 2):
if s[i] == s[n - 1 - i]:
ans += min(cost[i], cost[n - 1 - i])
cnt[s[i]] += 1
total = sum(cnt.values())
if total > 0:
ch, occ = cnt.most_common(1)[0]
avail = []
if occ > total - occ:
for i in range(n // 2):
if s[i] != s[n - 1 - i] and s[i] != ch and s[n - 1 - i] != ch:
avail.append(min(cost[i], cost[n - 1 - i]))
avail.sort()
ans += sum(avail[:2 * occ - total])
print(sum(cost) - ans)
main()
```
| 72,232 | [
0.225341796875,
0.0911865234375,
0.091552734375,
-0.08062744140625,
-0.383056640625,
-0.6552734375,
0.157470703125,
0.061767578125,
0.37353515625,
0.8232421875,
0.89697265625,
-0.051513671875,
-0.158203125,
-1.1025390625,
-0.63525390625,
-0.07977294921875,
-0.501953125,
-0.6318359375,
-0.435791015625,
0.24462890625,
0.245849609375,
-0.27783203125,
-1.466796875,
-0.29296875,
-0.469482421875,
1.193359375,
0.634765625,
0.119384765625,
0.95849609375,
1.2041015625,
-0.143798828125,
-0.325439453125,
0.65625,
-0.9580078125,
-0.5615234375,
-0.1617431640625,
0.38427734375,
-0.69091796875,
0.15380859375,
-0.64794921875,
0.415771484375,
-0.57861328125,
0.333984375,
-0.8125,
-0.92529296875,
-0.002899169921875,
-0.36376953125,
-0.498046875,
-0.306396484375,
-0.732421875,
0.234130859375,
-0.1087646484375,
0.50927734375,
0.1519775390625,
-0.340087890625,
0.427978515625,
0.051177978515625,
-0.35595703125,
-0.43896484375,
0.64453125,
0.12384033203125,
0.060699462890625,
-0.092529296875,
-0.640625,
-0.06060791015625,
0.229736328125,
-0.02288818359375,
0.0311279296875,
0.10369873046875,
-1.1279296875,
-0.43603515625,
0.04132080078125,
-0.294677734375,
-0.38427734375,
-0.1173095703125,
0.11151123046875,
0.1671142578125,
-0.1494140625,
-0.64794921875,
0.58642578125,
-0.0258941650390625,
0.90087890625,
-0.00717926025390625,
0.435546875,
-0.47998046875,
-0.45068359375,
-0.27587890625,
0.340087890625,
-0.060333251953125,
-0.11700439453125,
0.09423828125,
0.47216796875,
-0.482421875,
-0.10882568359375,
0.6015625,
0.8291015625,
-0.59326171875,
0.6025390625,
0.1739501953125,
-0.1553955078125,
0.486083984375,
1.1494140625,
-0.439697265625,
1.046875,
-0.483642578125,
0.07037353515625,
-0.01390838623046875,
0.30419921875,
-0.260498046875,
-0.29931640625,
-0.0560302734375,
-0.0931396484375,
0.32568359375,
0.261474609375,
-0.117431640625,
0.9013671875,
-0.2178955078125,
0.287841796875,
-0.85205078125,
0.140625,
0.09033203125,
0.2327880859375,
0.77294921875,
-0.1822509765625,
-0.055328369140625,
-0.318603515625,
-0.3876953125,
1.1455078125,
-0.990234375,
-0.020751953125,
0.34033203125,
-0.1949462890625,
-0.213623046875,
0.1422119140625,
-0.09783935546875,
0.61572265625,
-0.255615234375,
0.306884765625,
0.978515625,
-0.61181640625,
0.58935546875,
-0.1385498046875,
-0.277099609375,
1.6162109375,
0.419189453125,
0.295166015625,
1.1435546875,
-0.0193328857421875,
-0.60400390625,
0.70654296875,
-0.8095703125,
0.367919921875,
0.0892333984375,
0.333984375,
-0.15966796875,
0.552734375,
-0.003143310546875,
0.1334228515625,
0.189208984375,
-0.007419586181640625,
-0.5087890625,
0.06256103515625,
0.0038318634033203125,
0.91455078125,
-0.486328125,
1.080078125,
-0.60302734375,
-0.6455078125,
0.1007080078125,
-0.484375,
-0.0833740234375,
-0.12353515625,
-0.04071044921875,
0.92724609375,
0.71435546875,
0.8857421875,
0.74853515625,
-0.312744140625,
0.262451171875,
0.12493896484375,
0.03643798828125,
0.295166015625,
0.39697265625,
0.66259765625,
0.26123046875,
-0.056640625,
0.26123046875,
-0.3583984375,
-0.9306640625,
-0.60546875,
-0.345703125,
0.56689453125,
-0.4287109375,
-0.057525634765625,
0.411376953125,
-0.248046875,
-0.93017578125,
-0.47265625,
-0.062255859375,
-1.060546875,
-0.5732421875,
0.8115234375,
-0.08319091796875,
0.6142578125,
-0.57373046875,
-0.419189453125,
0.0953369140625,
0.80908203125,
-0.07879638671875,
0.006771087646484375,
0.650390625,
0.021942138671875,
-0.09576416015625,
-0.01039886474609375,
-0.00936126708984375,
0.10491943359375,
-0.67822265625,
0.90478515625,
-0.0187225341796875,
-0.0255279541015625,
-0.352783203125,
0.736328125,
0.27734375,
0.619140625,
-0.1759033203125,
-0.08331298828125,
0.3447265625,
0.966796875,
0.18310546875,
0.1778564453125,
-0.1435546875,
1.0078125,
0.71923828125,
0.66943359375,
0.5673828125,
0.005687713623046875,
0.390380859375,
0.7890625,
0.196533203125,
0.364013671875,
0.1497802734375,
0.36474609375,
0.39111328125,
0.1259765625,
-0.20263671875,
0.724609375,
0.09130859375,
0.341552734375,
-0.54296875,
0.70458984375,
-0.35009765625,
0.92333984375,
0.1416015625,
0.4375,
-0.2626953125,
-0.1923828125,
0.51513671875,
0.6435546875,
-0.58642578125,
-0.341796875,
-0.252685546875,
0.05999755859375,
0.1483154296875,
0.1363525390625,
0.1669921875,
0.93310546875,
0.430419921875,
0.362548828125,
-0.23388671875,
-0.491943359375,
-1.06640625,
-0.46435546875,
-1.0888671875,
-0.14990234375,
-0.67822265625,
-0.16162109375,
0.48779296875,
-0.99951171875,
0.458984375,
-0.252197265625,
-0.237548828125,
0.136474609375,
-0.90380859375,
0.37744140625,
-0.1002197265625,
0.67626953125,
-0.5009765625,
0.1759033203125,
0.0283050537109375,
0.8232421875,
-0.279541015625,
0.0237579345703125,
0.095703125,
-0.6416015625,
0.389404296875,
0.1429443359375,
0.16552734375,
-0.2364501953125,
-0.9873046875,
-1.0068359375,
-0.56005859375,
-0.158447265625,
-0.5615234375,
-0.08941650390625,
-0.473388671875,
0.79443359375,
0.609375,
-0.345458984375,
0.541015625,
0.84765625,
-0.68896484375,
0.353515625,
0.1693115234375,
0.1884765625,
-0.8349609375,
1.169921875,
0.546875,
0.386962890625,
-0.626953125,
-0.30029296875,
-0.56982421875,
0.0709228515625,
-0.00916290283203125,
-0.62646484375,
-0.33642578125,
0.68212890625,
0.412109375,
-1.0927734375,
0.447509765625,
-0.7705078125,
-0.64892578125,
-0.267822265625,
-0.10736083984375,
0.5634765625,
0.85302734375,
0.340087890625,
-0.3544921875,
-0.0540771484375,
-0.09344482421875,
0.45849609375,
0.469970703125,
-0.172119140625,
-0.270263671875,
0.86572265625,
-0.01459503173828125,
0.007358551025390625,
0.1051025390625,
-0.32958984375,
-0.060455322265625,
0.5966796875,
0.29736328125,
0.85009765625,
0.2161865234375,
0.29443359375,
0.322998046875,
0.9345703125,
-0.76171875,
-0.4619140625,
-0.353515625,
0.7578125,
0.32373046875,
0.35107421875,
0.64111328125,
-0.444091796875,
-0.56103515625,
-1.18359375,
0.181396484375,
0.4697265625,
0.67578125,
-0.5771484375,
0.9033203125,
0.64599609375,
-0.48876953125,
0.405029296875,
-0.54638671875,
0.172119140625,
0.73095703125,
0.2481689453125,
0.921875,
-0.43115234375,
0.383056640625,
-0.352294921875,
0.419921875,
1.0341796875,
0.30419921875,
0.56103515625,
-0.7099609375,
-0.58447265625,
-0.56298828125,
-0.1787109375,
-0.134521484375,
-0.1839599609375,
0.3740234375,
-0.3837890625,
-0.11138916015625,
-0.923828125,
0.265869140625,
0.5634765625,
0.319091796875,
0.06805419921875,
0.56298828125,
0.450927734375,
0.56884765625,
0.59619140625,
-0.295166015625,
0.104736328125,
-0.61865234375,
0.87158203125,
0.1676025390625,
-0.461669921875,
-0.54248046875,
-0.0406494140625,
-0.004299163818359375,
0.09429931640625,
0.08013916015625,
-0.16796875,
-1.1552734375,
0.53125,
0.026123046875,
0.71533203125,
-0.2064208984375,
-0.28662109375,
-0.189208984375,
0.5576171875,
0.47314453125,
-0.74462890625,
-0.1015625,
-0.468994140625,
0.476318359375,
0.66796875,
-0.2314453125,
-0.2705078125,
-0.2396240234375,
-0.68212890625,
-0.63525390625,
0.23486328125,
1.298828125,
-0.16748046875,
0.09295654296875,
-1.1494140625,
0.9091796875,
0.6025390625,
-0.1025390625,
-0.10296630859375,
0.0894775390625,
0.23974609375,
0.2252197265625,
0.658203125,
-0.50390625,
-0.9453125,
0.330810546875,
-1.2490234375,
0.4921875,
-0.497314453125,
0.174560546875,
-0.002201080322265625,
-0.432373046875,
0.0675048828125,
0.5888671875,
-0.29833984375,
0.2491455078125,
-0.19970703125,
0.414306640625,
-1.1787109375,
-0.57177734375,
0.039947509765625,
-0.28466796875,
0.0017042160034179688,
1.16015625,
-0.438720703125,
-0.5439453125,
0.435302734375,
0.568359375,
-0.6357421875,
0.430908203125,
-0.312744140625,
0.406005859375,
-0.420166015625,
-0.65771484375,
-0.12158203125,
-0.63525390625,
0.947265625,
0.0267181396484375,
-0.861328125,
-0.0260467529296875,
-1.0322265625,
-0.463134765625,
-0.1529541015625,
-0.771484375,
0.1951904296875,
0.1951904296875,
-0.11492919921875,
-0.34423828125,
-0.2061767578125,
-0.568359375,
-0.55419921875,
-0.55078125,
-0.309326171875,
0.365234375,
0.12841796875,
0.7294921875,
0.175048828125,
-0.379150390625,
-0.147705078125,
0.08258056640625,
0.038787841796875,
-0.52001953125,
0.004627227783203125,
-0.310791015625,
-0.36572265625,
-0.1650390625,
-0.2098388671875,
-0.01541900634765625,
0.17919921875,
0.6953125,
0.1085205078125,
0.5478515625,
0.21142578125,
-0.8154296875,
1.0146484375,
0.27197265625,
-0.92529296875,
-0.0821533203125,
0.318115234375,
0.345458984375,
0.40087890625,
0.2080078125,
-0.912109375,
-0.490478515625,
-0.6904296875,
0.2076416015625,
-0.82470703125,
-0.0144805908203125,
-0.8837890625,
-0.463623046875,
-0.35986328125,
0.99365234375,
-0.09576416015625,
-0.640625,
0.2244873046875,
-1.30078125,
0.018035888671875,
-0.638671875,
-0.1612548828125,
-1.1806640625,
-0.65625,
-0.318359375,
0.896484375,
0.30615234375,
0.02752685546875,
0.205810546875,
-0.1983642578125,
0.306884765625,
-0.0015621185302734375,
-0.66357421875,
-0.283203125,
-0.42431640625,
-0.08502197265625,
-0.09521484375,
-0.11199951171875,
-0.72802734375,
0.666015625,
-0.73779296875,
0.2734375,
-0.01873779296875,
-0.215087890625,
-0.258544921875,
-0.58642578125,
1.1826171875,
-0.282958984375,
-0.329345703125,
-0.66064453125,
0.3564453125,
0.79541015625,
-0.358642578125,
-0.30810546875,
-0.716796875,
-0.85546875,
-1.228515625,
0.91015625,
-0.363525390625,
-0.06085205078125,
-0.9345703125,
-0.499267578125,
0.94873046875,
-0.34033203125,
-0.055938720703125,
0.84228515625,
0.388671875,
0.3330078125,
-0.8125,
0.7197265625,
0.57470703125,
-0.57763671875,
-0.213623046875,
0.02490234375,
-0.92724609375,
0.237060546875,
0.003787994384765625,
-1.181640625,
-0.492431640625,
0.418212890625,
1.2841796875,
-0.250732421875,
0.62109375,
-0.10162353515625,
-1.2021484375,
-0.73486328125,
1.138671875,
0.3388671875,
0.254150390625,
0.7734375,
-0.1829833984375,
-0.34619140625,
-0.3583984375,
0.049896240234375,
-0.64892578125,
-0.4912109375,
1.033203125,
-0.268798828125,
-0.59423828125,
0.69140625,
0.5791015625,
-1.2353515625,
-0.72998046875,
-0.0168304443359375,
0.0021839141845703125,
-0.007495880126953125,
-0.51904296875,
0.1058349609375,
0.6591796875,
-0.77490234375,
0.00838470458984375,
0.268798828125,
-0.1976318359375,
0.51806640625,
0.121337890625,
0.462646484375,
-0.372802734375,
0.4365234375,
0.55810546875,
-0.5302734375,
-0.340087890625,
-1.0830078125,
-0.396240234375,
-0.39794921875,
-0.1561279296875,
0.8203125,
-0.3759765625,
0.468017578125,
0.59423828125,
0.32373046875,
0.65673828125,
-0.58984375,
-0.53369140625,
0.392822265625,
-0.7099609375,
-0.440673828125,
-0.390380859375,
0.51171875,
-0.41455078125,
0.54345703125,
-0.4931640625,
0.41845703125,
0.3173828125,
0.185302734375,
-0.35498046875,
-0.68798828125,
-0.40234375,
-1.1748046875,
-0.76318359375,
-0.70703125,
-0.89111328125,
-0.0391845703125,
0.1611328125,
-0.291748046875,
-0.72314453125,
0.228271484375,
0.4423828125,
-0.7265625,
0.9365234375,
-0.74658203125,
0.435791015625,
-0.5625,
-0.64208984375,
-0.38720703125,
0.3095703125,
-0.1448974609375,
0.1334228515625,
-0.435546875,
0.328369140625,
-0.00664520263671875,
0.83447265625,
-0.051177978515625,
0.47265625,
-0.427490234375,
-0.288330078125,
-0.2734375,
-0.1241455078125,
-0.119873046875,
0.67529296875,
0.76904296875,
0.07275390625,
0.153564453125,
0.04547119140625,
-0.411865234375,
-0.60595703125,
0.50390625,
0.31884765625,
-0.412353515625,
-0.053131103515625,
-0.468505859375,
0.052703857421875,
-0.94970703125,
0.5859375,
-0.515625,
-0.063232421875,
0.484619140625,
0.0197906494140625,
0.19775390625,
1.025390625,
-0.227783203125,
0.34228515625,
0.08038330078125,
0.04156494140625,
0.44091796875,
-0.07598876953125,
-0.020751953125,
0.525390625,
0.358154296875,
-0.4755859375,
0.07000732421875,
0.4677734375,
-0.039093017578125,
0.301025390625,
0.100830078125,
-0.9814453125,
-1.05859375,
-0.55859375,
0.01959228515625,
0.184326171875,
0.54833984375,
-0.40185546875,
-0.046051025390625,
-0.14013671875,
-0.71337890625,
-0.2493896484375,
-1.052734375,
-1.029296875,
0.300537109375,
-0.15234375,
-0.466064453125,
-0.1749267578125,
-0.2384033203125,
-0.1212158203125,
-0.07232666015625,
0.32275390625,
-0.5146484375,
0.4189453125,
-0.266357421875,
0.35595703125,
-0.28515625,
0.146728515625,
0.07373046875,
0.671875,
-0.328369140625,
-0.64990234375,
-0.208984375,
0.7529296875,
0.1669921875,
-0.197265625,
-0.2744140625,
0.057342529296875,
-0.015228271484375,
0.027099609375,
-0.358154296875,
-0.185791015625,
-0.4140625,
0.814453125,
-0.60888671875,
-0.13818359375,
0.0985107421875,
0.296142578125,
-0.05755615234375,
-0.0711669921875,
-0.499755859375,
0.5546875,
0.94873046875,
-0.286376953125,
0.7294921875,
0.349853515625,
0.80517578125,
-0.301025390625,
-0.302978515625,
-0.37548828125,
0.650390625,
0.7861328125,
0.6240234375,
-0.008544921875,
-0.137939453125,
0.63330078125,
-0.05938720703125,
-0.470703125,
0.146484375,
0.0921630859375,
0.401123046875,
0.06488037109375,
-0.244873046875,
-0.039337158203125,
0.236083984375,
-0.54931640625,
0.7421875,
-0.56982421875,
-0.31884765625,
-0.18896484375,
-0.53662109375,
0.424560546875,
-0.1490478515625,
-0.2025146484375,
0.1893310546875,
-0.50390625,
0.57470703125,
0.205322265625,
0.25048828125,
-0.0292816162109375,
1.1689453125,
0.87548828125,
0.4091796875,
0.6513671875,
0.2802734375,
0.317626953125,
-0.353759765625,
0.224609375,
-0.0082244873046875,
-0.448486328125,
-0.212890625,
-0.58251953125,
-1.0673828125,
0.161865234375,
-0.41748046875,
-0.52880859375,
0.40771484375,
-0.84716796875,
0.1444091796875,
-0.408203125,
0.97265625,
-0.19287109375,
0.57080078125,
0.52294921875,
-0.490234375,
-0.583984375,
0.8583984375,
-0.705078125,
0.352783203125,
0.1458740234375,
0.82666015625,
0.157958984375,
1.4892578125,
0.9013671875,
-0.306884765625,
0.1275634765625,
0.10870361328125,
-0.1064453125,
-0.31298828125,
-0.646484375,
-0.260498046875,
0.007305145263671875,
-0.68408203125,
-0.38427734375,
-0.115478515625,
0.49853515625,
0.1658935546875,
-0.9560546875,
-0.33740234375,
0.43798828125,
-1.0068359375,
0.13916015625,
0.423095703125,
0.179443359375,
0.1318359375,
0.1588134765625,
-0.418212890625,
-0.4208984375,
0.31640625,
-0.748046875,
0.058258056640625,
-0.54345703125,
-0.448486328125,
-0.6455078125,
-0.87939453125,
-0.160888671875,
-0.273681640625,
-0.51318359375,
-0.98388671875,
0.716796875,
0.65771484375,
0.44873046875,
0.58984375,
-0.175537109375,
0.496337890625,
0.9921875,
1.0400390625,
0.277587890625,
0.5673828125,
0.1134033203125,
-0.43603515625,
0.2091064453125,
-0.0927734375,
0.311279296875,
-0.1827392578125,
0.46826171875,
-0.62841796875,
0.333251953125,
-0.61767578125,
-1.4443359375,
0.05810546875,
0.65185546875,
0.86083984375,
-0.7099609375,
-1.0224609375,
-0.077392578125,
-0.822265625,
-0.26806640625,
-0.5107421875,
0.27734375,
-0.209228515625,
0.2342529296875,
-0.27294921875,
-1.1669921875,
4.3828125,
1.0947265625,
1.001953125,
0.55810546875,
0.29541015625,
0.97265625,
0.29296875,
-0.58203125,
-0.2841796875,
-0.0914306640625,
0.73388671875,
-0.4560546875,
-0.01461029052734375,
0.8798828125,
0.46923828125,
0.53173828125,
-0.43798828125,
0.275634765625,
0.322509765625,
-0.9892578125,
-0.984375,
0.3193359375,
-0.00791168212890625,
0.340087890625,
0.33740234375,
0.21728515625,
0.2386474609375,
-0.68017578125,
-0.239501953125,
-0.296630859375,
0.115478515625,
-0.41845703125,
0.89990234375,
-0.07159423828125,
-0.221923828125,
0.4423828125,
0.14697265625,
-0.27490234375,
-0.0185394287109375,
0.196533203125,
0.033416748046875,
-0.50244140625,
0.75439453125,
-0.8486328125,
-0.52392578125,
0.17138671875,
-0.734375,
0.70166015625,
-0.408203125,
-0.61474609375,
0.982421875,
-0.09210205078125,
0.50634765625,
-0.4814453125,
-0.82861328125,
0.350341796875,
0.098388671875,
-0.253662109375,
-0.0736083984375,
0.8037109375,
0.0819091796875,
0.34423828125,
0.439208984375,
0.466064453125,
-0.85595703125,
0.99267578125,
-0.17724609375,
0.415771484375,
-0.763671875,
0.12030029296875,
-0.052154541015625,
-0.399169921875,
-0.06414794921875,
-0.271240234375,
0.599609375,
0.38037109375,
-0.0748291015625,
0.869140625,
0.27978515625,
-0.716796875,
-0.1759033203125,
-0.029022216796875,
-0.293701171875,
-0.24755859375,
0.978515625,
1.1025390625,
-0.6396484375,
-0.2369384765625,
-0.366943359375,
0.66259765625,
0.281494140625,
0.19921875,
-0.05328369140625,
-0.62451171875,
-0.407958984375
] | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.