input stringlengths 1 8.57k | output stringlengths 2 5.65k |
|---|---|
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Codehorses has just hosted the second Codehorses Cup. This year, the same as the previous one, organizers are giving T-shirts for the winners.
The valid sizes of T-shirts are either "M" or from 0 to 3 "X" followed by "S" or "L". For example, sizes "M", "XXS", "L", "XXXL" are valid and "XM", "Z", "XXXXL" are not.
There are n winners to the cup for both the previous year and the current year. Ksenia has a list with the T-shirt sizes printed for the last year cup and is yet to send the new list to the printing office.
Organizers want to distribute the prizes as soon as possible, so now Ksenia is required not to write the whole list from the scratch but just make some changes to the list of the previous year. In one second she can choose arbitrary position in any word and replace its character with some uppercase Latin letter. Ksenia can't remove or add letters in any of the words.
What is the minimal number of seconds Ksenia is required to spend to change the last year list to the current one?
The lists are unordered. That means, two lists are considered equal if and only if the number of occurrences of any string is the same in both lists.
Input
The first line contains one integer n (1 ≤ n ≤ 100) — the number of T-shirts.
The i-th of the next n lines contains a_i — the size of the i-th T-shirt of the list for the previous year.
The i-th of the next n lines contains b_i — the size of the i-th T-shirt of the list for the current year.
It is guaranteed that all the sizes in the input are valid. It is also guaranteed that Ksenia can produce list b from the list a.
Output
Print the minimal number of seconds Ksenia is required to spend to change the last year list to the current one. If the lists are already equal, print 0.
Examples
Input
3
XS
XS
M
XL
S
XS
Output
2
Input
2
XXXL
XXL
XXL
XXXS
Output
1
Input
2
M
XS
XS
M
Output
0
Note
In the first example Ksenia can replace "M" with "S" and "S" in one of the occurrences of "XS" with "L".
In the second example Ksenia should replace "L" in "XXXL" with "S".
In the third example lists are equal.
Submitted Solution:
```
n = int(input())
ls1 = list()
ls2 = list()
ls1div = list()
ls2div = list()
count = 0
for i in range(0,n):
ls1.append(input())
for i in range(0,n):
ls2.append(input())
for i in range(1,4):
ls1div.append([x[-1] for x in ls1 if len(x) == i])
ls2div.append([x[-1] for x in ls2 if len(x) == i])
count += abs(ls1div[i-1].count('S')-ls2div[i-1].count('S'))+abs(ls1div[i-1].count('M')-ls2div[i-1].count('M'))+abs(ls1div[i-1].count('L')-ls2div[i-1].count('L'))
print(int(count/2))
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Codehorses has just hosted the second Codehorses Cup. This year, the same as the previous one, organizers are giving T-shirts for the winners.
The valid sizes of T-shirts are either "M" or from 0 to 3 "X" followed by "S" or "L". For example, sizes "M", "XXS", "L", "XXXL" are valid and "XM", "Z", "XXXXL" are not.
There are n winners to the cup for both the previous year and the current year. Ksenia has a list with the T-shirt sizes printed for the last year cup and is yet to send the new list to the printing office.
Organizers want to distribute the prizes as soon as possible, so now Ksenia is required not to write the whole list from the scratch but just make some changes to the list of the previous year. In one second she can choose arbitrary position in any word and replace its character with some uppercase Latin letter. Ksenia can't remove or add letters in any of the words.
What is the minimal number of seconds Ksenia is required to spend to change the last year list to the current one?
The lists are unordered. That means, two lists are considered equal if and only if the number of occurrences of any string is the same in both lists.
Input
The first line contains one integer n (1 ≤ n ≤ 100) — the number of T-shirts.
The i-th of the next n lines contains a_i — the size of the i-th T-shirt of the list for the previous year.
The i-th of the next n lines contains b_i — the size of the i-th T-shirt of the list for the current year.
It is guaranteed that all the sizes in the input are valid. It is also guaranteed that Ksenia can produce list b from the list a.
Output
Print the minimal number of seconds Ksenia is required to spend to change the last year list to the current one. If the lists are already equal, print 0.
Examples
Input
3
XS
XS
M
XL
S
XS
Output
2
Input
2
XXXL
XXL
XXL
XXXS
Output
1
Input
2
M
XS
XS
M
Output
0
Note
In the first example Ksenia can replace "M" with "S" and "S" in one of the occurrences of "XS" with "L".
In the second example Ksenia should replace "L" in "XXXL" with "S".
In the third example lists are equal.
Submitted Solution:
```
n = int(input())
old = []
new = []
out = False
for i in range(n):
old.append(input().strip())
if n == 100 and i == 0 and old[i] == 'S':
out = True
for i in range(n):
new.append(input().strip())
old = sorted(old)
new = sorted(new)
answer = 0
for i in range(n):
if old[i] != new[i]:
answer += 1
if out:
for i in range(0, 49):
print(old[i], end=' ')
print("END OF OUTPUT")
for i in range(50, 99):
print(old[i], end=' ')
print("END OF OUTPUT")
for i in range(0, 49):
print(new[i], end=' ')
print("END OF OUTPUT")
for i in range(50, 99):
print(new[i], end=' ')
print("END OF OUTPUT")
print(answer)
```
### Response:
| No |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
### Response:
| "Correct Solution:
```
a=int(input())
b=input()
if a<3200:
print("red")
else:
print(b)
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
### Response:
| "Correct Solution:
```
f=input;print('red' if int(f())<3200 else f())
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
### Response:
| "Correct Solution:
```
A = int(input())
S = input()
ans = S if A >= 3200 else 'red'
print(ans)
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
### Response:
| "Correct Solution:
```
a = int(input())
s = input()
if a < 3200:
s = 'red'
print(s)
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
### Response:
| "Correct Solution:
```
a,s=open(0);print(s*(a>'32')or'red')
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
### Response:
| "Correct Solution:
```
a=int(input())
s=str(input())
if a<3200:
print('red')
else:
print(s)
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
### Response:
| "Correct Solution:
```
a = int(input())
s = input()
print("red" if a<3200 else s)
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
### Response:
| "Correct Solution:
```
a = int(input())
print("red" if a < 3200 else input())
``` |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
Submitted Solution:
```
n=int(input()); k=input(); print(k) if n>=3200 else print('red')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
Submitted Solution:
```
n = int(input())
m = input()
print(m if n >= 3200 else "red")
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
Submitted Solution:
```
if (int(input()) < 3200):
print('red')
else:
print(input())
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
Submitted Solution:
```
a = int(input())
print(input() if a >= 3200 else "red")
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
Submitted Solution:
```
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)
def geta(fn=lambda s: s.decode()):
return map(fn, readline().split())
def gete(fn=lambda s: s.decode()):
return fn(readline().rstrip())
def main():
a = gete(int)
s = gete()
if s < 3200:
print(a)
else:
print('red')
if __name__ == "__main__":
main()
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
Submitted Solution:
```
import sys
a = input()[0]
s = input()[1]
if a < 3200:
print("red")
else:
print(s)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
Submitted Solution:
```
if int(input) >= 3200:
print(input())
else:
print("red")
exit()
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You will be given an integer a and a string s consisting of lowercase English letters as input.
Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200.
Constraints
* 2800 \leq a < 5000
* s is a string of length between 1 and 10 (inclusive).
* Each character of s is a lowercase English letter.
Input
Input is given from Standard Input in the following format:
a
s
Output
If a is not less than 3200, print s; if a is less than 3200, print `red`.
Examples
Input
3200
pink
Output
pink
Input
3199
pink
Output
red
Input
4049
red
Output
red
Submitted Solution:
```
data = [input() for i in range(2)]
if data[0]>=3200:
print(data[1])
else:
print("red")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You will receive 5 points for solving this problem.
Manao has invented a new operation on strings that is called folding. Each fold happens between a pair of consecutive letters and places the second part of the string above first part, running in the opposite direction and aligned to the position of the fold. Using this operation, Manao converts the string into a structure that has one more level than there were fold operations performed. See the following examples for clarity.
We will denote the positions of folds with '|' characters. For example, the word "ABRACADABRA" written as "AB|RACA|DAB|RA" indicates that it has been folded three times: first, between the leftmost pair of 'B' and 'R' letters; second, between 'A' and 'D'; and third, between the rightmost pair of 'B' and 'R' letters. Here are several examples of folded strings:
"ABCDEF|GHIJK" | "A|BCDEFGHIJK" | "AB|RACA|DAB|RA" | "X|XXXXX|X|X|XXXXXX"
| | | XXXXXX
KJIHG | KJIHGFEDCB | AR | X
ABCDEF | A | DAB | X
| | ACAR | XXXXX
| | AB | X
One last example for "ABCD|EFGH|IJ|K":
K
IJ
HGFE
ABCD
Manao noticed that each folded string can be viewed as several piles of letters. For instance, in the previous example, there are four piles, which can be read as "AHI", "BGJK", "CF", and "DE" from bottom to top. Manao wonders what is the highest pile of identical letters he can build using fold operations on a given word. Note that the pile should not contain gaps and should start at the bottom level. For example, in the rightmost of the four examples above, none of the piles would be considered valid since each of them has gaps, starts above the bottom level, or both.
Input
The input will consist of one line containing a single string of n characters with 1 ≤ n ≤ 1000 and no spaces. All characters of the string will be uppercase letters.
This problem doesn't have subproblems. You will get 5 points for the correct submission.
Output
Print a single integer — the size of the largest pile composed of identical characters that can be seen in a valid result of folding operations on the given string.
Examples
Input
ABRACADABRA
Output
3
Input
ABBBCBDB
Output
3
Input
AB
Output
1
Note
Consider the first example. Manao can create a pile of three 'A's using the folding "AB|RACAD|ABRA", which results in the following structure:
ABRA
DACAR
AB
In the second example, Manao can create a pile of three 'B's using the following folding: "AB|BB|CBDB".
CBDB
BB
AB
Another way for Manao to create a pile of three 'B's with "ABBBCBDB" is the following folding: "AB|B|BCBDB".
BCBDB
B
AB
In the third example, there are no folds performed and the string is just written in one line.
Submitted Solution:
```
a = str(input())
anss = []
for i in range(len(a)):
anss.append(a.count(a[i]))
print(max(anss)//2+1)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Marina loves strings of the same length and Vasya loves when there is a third string, different from them in exactly t characters. Help Vasya find at least one such string.
More formally, you are given two strings s1, s2 of length n and number t. Let's denote as f(a, b) the number of characters in which strings a and b are different. Then your task will be to find any string s3 of length n, such that f(s1, s3) = f(s2, s3) = t. If there is no such string, print - 1.
Input
The first line contains two integers n and t (1 ≤ n ≤ 105, 0 ≤ t ≤ n).
The second line contains string s1 of length n, consisting of lowercase English letters.
The third line contain string s2 of length n, consisting of lowercase English letters.
Output
Print a string of length n, differing from string s1 and from s2 in exactly t characters. Your string should consist only from lowercase English letters. If such string doesn't exist, print -1.
Examples
Input
3 2
abc
xyc
Output
ayd
Input
1 0
c
b
Output
-1
Submitted Solution:
```
n, t = [int(x) for x in input().split()]
s1 = list(input())
s2 = list(input())
z1 = n - t
z2 = n - t
o = []
m = set([])
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
for i, c in enumerate(s1):
m.add(c)
if z1 > 0:
o.append(c)
z1 -= 1
if c == s2[i]:
z2 -= 1
elif z2 > 0:
o.append(s2[i])
z2 -= 1
if c == s2[i]:
z1 -= 1
for oi, oc in enumerate(o):
if oc == s1[oi] and oc != s2[oi]:
r = ""
for a_i in range(0, len(alphabet)):
r = alphabet[a_i]
if r not in m:
break
o[oi] = r
z1 += 1
else:
r = ""
for a_i in range(0, len(alphabet)):
r = alphabet[a_i]
if r not in m:
break
o.append(r)
if len(list(m)) == len(alphabet) and t != 0:
print(-1)
elif z1 == 0 and z2 == 0:
print("".join(o))
else:
print(-1)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.
Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, <image>, and <image>.
Limak gives you a nice string s and an integer k. He challenges you to find any nice string s' that <image>. Find any s' satisfying the given conditions, or print "-1" if it's impossible to do so.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 106).
The second line contains a string s of length n, consisting of lowercase English letters.
Output
If there is no string satisfying the given conditions then print "-1" (without the quotes).
Otherwise, print any nice string s' that <image>.
Examples
Input
4 26
bear
Output
roar
Input
2 7
af
Output
db
Input
3 1000
hey
Output
-1
Submitted Solution:
```
N, K = map(int, input().split())
S = input()
dmax = [0 for _ in range(N)]
for i in range(N):
dmax[i] = max(abs(ord(S[i]) - 97), abs(25 - ord(S[i]) + 97))
dsum = sum(dmax)
if dsum < K:
print(-1)
else:
j = 0
for i in range(dsum + 1):
if dsum == K:
break
if dmax[j] == 0:
j += 1
dmax[j] -= 1
dsum -= 1
res = []
for i in range(N):
if ord(S[i]) - 97 + dmax[i] < 26:
res.append(chr(ord(S[i]) + dmax[i]))
else:
res.append(chr(ord(S[i]) - dmax[i]))
print(''.join(res))
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.
Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, <image>, and <image>.
Limak gives you a nice string s and an integer k. He challenges you to find any nice string s' that <image>. Find any s' satisfying the given conditions, or print "-1" if it's impossible to do so.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 106).
The second line contains a string s of length n, consisting of lowercase English letters.
Output
If there is no string satisfying the given conditions then print "-1" (without the quotes).
Otherwise, print any nice string s' that <image>.
Examples
Input
4 26
bear
Output
roar
Input
2 7
af
Output
db
Input
3 1000
hey
Output
-1
Submitted Solution:
```
a,b=map(int,input().split())
str1=input()
str2=""
for i in range(0,a):
x=ord(str1[i])
x=x-97
if(x<=12):
z=min((25-x),(b))
zz=x+z+97
str3=chr(zz)
str2=str2[0:]+str3[0:]
b=b-z
else:
z=min((x-0),(b))
zz=x-z+97
str3=chr(zz)
str2=str2[0:]+str3[0:]
b=b-z
if(b>0):
print(-1)
else:
print(str2)
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.
Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, <image>, and <image>.
Limak gives you a nice string s and an integer k. He challenges you to find any nice string s' that <image>. Find any s' satisfying the given conditions, or print "-1" if it's impossible to do so.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 106).
The second line contains a string s of length n, consisting of lowercase English letters.
Output
If there is no string satisfying the given conditions then print "-1" (without the quotes).
Otherwise, print any nice string s' that <image>.
Examples
Input
4 26
bear
Output
roar
Input
2 7
af
Output
db
Input
3 1000
hey
Output
-1
Submitted Solution:
```
if __name__ == '__main__':
# print(ord('a'), ord('m'), ord('n'), ord('z'))
# 97 109 110 122
n, k = input().split()
n = int(n)
k = int(k)
s = input()
ans = ''
hasAnswer = False
for i in range(n):
if k == 0:
hasAnswer = True
break
m = ord(s[i])
if m <= 109:
if k >= 122 - m:
k -= 122-m
ans += 'z'
else:
if m + k < 122:
ans += chr(m + k)
else:
ans += chr(m - k)
hasAnswer = True
break
if m >= 110:
if k >= m - 97:
k -= m - 97
ans += 'a'
else:
if m + k < 122:
ans += chr(m + k)
else:
ans += chr(m - k)
hasAnswer = True
break
if hasAnswer or k == 0:
print(ans + s[len(ans):])
else:
print(-1)
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.
Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, <image>, and <image>.
Limak gives you a nice string s and an integer k. He challenges you to find any nice string s' that <image>. Find any s' satisfying the given conditions, or print "-1" if it's impossible to do so.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 106).
The second line contains a string s of length n, consisting of lowercase English letters.
Output
If there is no string satisfying the given conditions then print "-1" (without the quotes).
Otherwise, print any nice string s' that <image>.
Examples
Input
4 26
bear
Output
roar
Input
2 7
af
Output
db
Input
3 1000
hey
Output
-1
Submitted Solution:
```
n,k = map(int,input().split())
s = input()
alth = "abcdefghijklmnopqrstuvwxyz"
num2 = 0
s2 = ""
for i in s:
num2 = alth.find(i)
if k == 0:
s2 += i
else:
if num2 > 12:
num3 = min(num2,k)
s2 += alth[num2-num3]
k -= num3
else:
num3 = min(25-num2,k)
s2 += alth[num2+num3]
k -= num3
if k > 0:
print(-1)
else:
print(s2)
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.
Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, <image>, and <image>.
Limak gives you a nice string s and an integer k. He challenges you to find any nice string s' that <image>. Find any s' satisfying the given conditions, or print "-1" if it's impossible to do so.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 106).
The second line contains a string s of length n, consisting of lowercase English letters.
Output
If there is no string satisfying the given conditions then print "-1" (without the quotes).
Otherwise, print any nice string s' that <image>.
Examples
Input
4 26
bear
Output
roar
Input
2 7
af
Output
db
Input
3 1000
hey
Output
-1
Submitted Solution:
```
letters = list('abcdefghijklmnopqrstuvwxyz')
def get_largest_distance(char):
if letters.index(char) > 13:
return 'a'
return 'z'
def get_fixed_distance(char, amount):
return letters[abs(letters.index(char) - amount)]
def dist(a, b):
return abs(letters.index(a) - letters.index(b))
line = input()
word_length, final_distance = line.split()
word_length, final_distance = int(word_length), int(final_distance)
word = input()
active_total = 0
built_string = ''
did_break = False
for charactor in word:
largest_distance_char = get_largest_distance(charactor)
current_dist = dist(charactor, largest_distance_char)
if active_total + current_dist > final_distance:
sub_distance = get_fixed_distance(charactor, final_distance - active_total)
active_total = active_total + dist(charactor, sub_distance)
built_string = built_string + sub_distance
did_break = True
break
else:
active_total = active_total + current_dist
built_string = built_string + largest_distance_char
if active_total < final_distance:
print(-1)
elif did_break == True:
for char in range(len(built_string), len(word)):
built_string = built_string + word[char]
print(built_string)
else:
print(built_string)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.
Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, <image>, and <image>.
Limak gives you a nice string s and an integer k. He challenges you to find any nice string s' that <image>. Find any s' satisfying the given conditions, or print "-1" if it's impossible to do so.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 106).
The second line contains a string s of length n, consisting of lowercase English letters.
Output
If there is no string satisfying the given conditions then print "-1" (without the quotes).
Otherwise, print any nice string s' that <image>.
Examples
Input
4 26
bear
Output
roar
Input
2 7
af
Output
db
Input
3 1000
hey
Output
-1
Submitted Solution:
```
n,k = map(int, input().split())
s = input()
p = []
ans = 0
s1 = ''
p1 = []
for i in range(len(s)):
p.append(ord(s[i]) - 96)
ans+=max(p[i],26 - p[i])
if ans < k:
print(-1)
else:
for i in range(len(s)):
if p[i] > 13:
if k >= p[i]:
s1+='a'
p1.append(1)
k-=p[i]
else:
p[i]-=k
k = 0
s1+=chr(p[i] + 96)
p1.append(p[i])
else:
if k >= 26 - p[i]:
s1+='z'
p1.append(26)
k-=26 - p[i]
else:
s1+=chr(p[i] + k + 96)
p1.append(p[i] + k)
k = 0
print(s1)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.
Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, <image>, and <image>.
Limak gives you a nice string s and an integer k. He challenges you to find any nice string s' that <image>. Find any s' satisfying the given conditions, or print "-1" if it's impossible to do so.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 106).
The second line contains a string s of length n, consisting of lowercase English letters.
Output
If there is no string satisfying the given conditions then print "-1" (without the quotes).
Otherwise, print any nice string s' that <image>.
Examples
Input
4 26
bear
Output
roar
Input
2 7
af
Output
db
Input
3 1000
hey
Output
-1
Submitted Solution:
```
import sys
n,k=map(int,sys.stdin.readline().split())
s=sys.stdin.readline()
ans=""
for i in s:
a=ord("z")-ord(i)
b=ord(i)-ord("a")
if k==0:
ans+=i
continue
if a>=b:
if a>=k:
ans+=chr(ord(i)+k)
k=0
else:
ans+="z"
k=k-a
else:
if b>=k:
ans+=chr(ord(i)-k)
k=0
else:
ans+="a"
k=k-b
if k==0:
print(ans)
else:
print(-1)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.
Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, <image>, and <image>.
Limak gives you a nice string s and an integer k. He challenges you to find any nice string s' that <image>. Find any s' satisfying the given conditions, or print "-1" if it's impossible to do so.
As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.
Input
The first line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 106).
The second line contains a string s of length n, consisting of lowercase English letters.
Output
If there is no string satisfying the given conditions then print "-1" (without the quotes).
Otherwise, print any nice string s' that <image>.
Examples
Input
4 26
bear
Output
roar
Input
2 7
af
Output
db
Input
3 1000
hey
Output
-1
Submitted Solution:
```
alepha = ["a", "b", "c", "d",
"e", "f", "g", "h", "i",
"j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t",
"u", "v", "w", "x", "y", "z"]
a, b = map(int, input().split())
s = input()
ans = ""
if b / a > 25:
print(-1)
else:
for i in range(a):
if b == 0:
ans += s[i]
continue
idx = alepha.index(s[i])
if idx > 13:
if b > 13:
ans += alepha[0]
b -= idx
else:
ans += alepha[idx - b]
b = 0
else:
if b > 13:
ans += alepha[25]
b -= 25 - idx
else:
ans += alepha[idx + b]
b = 0
if b==0:
print(ans)
else:
print(-1)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:
* transform lowercase letters to uppercase and vice versa;
* change letter «O» (uppercase latin letter) to digit «0» and vice versa;
* change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other.
For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.
You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.
Input
The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50 — the login itself.
The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins.
The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.
Output
Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it.
Otherwise print «No» (without quotes).
Examples
Input
1_wat
2
2_wat
wat_1
Output
Yes
Input
000
3
00
ooA
oOo
Output
No
Input
_i_
3
__i_
_1_
I
Output
No
Input
La0
3
2a0
La1
1a0
Output
No
Input
abc
1
aBc
Output
No
Input
0Lil
2
LIL0
0Ril
Output
Yes
Note
In the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.
In the third sample case the new login is similar with the second one.
Submitted Solution:
```
s = input()
n = int(input())
for i in range(n):
t = input()
if len(s) != len(t):
continue
for j in range(len(t)):
if t[j].lower() == s[j].lower():
continue
if t[j] in '0Oo' and s[j] in '0Oo':
continue
if s[j] in '1lILi' and t[j] in '1lILi':
continue
# print(s[j], t[j], s, t, i)
break
else:
print('No')
exit(0)
print('Yes')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:
* transform lowercase letters to uppercase and vice versa;
* change letter «O» (uppercase latin letter) to digit «0» and vice versa;
* change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other.
For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.
You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.
Input
The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50 — the login itself.
The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins.
The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.
Output
Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it.
Otherwise print «No» (without quotes).
Examples
Input
1_wat
2
2_wat
wat_1
Output
Yes
Input
000
3
00
ooA
oOo
Output
No
Input
_i_
3
__i_
_1_
I
Output
No
Input
La0
3
2a0
La1
1a0
Output
No
Input
abc
1
aBc
Output
No
Input
0Lil
2
LIL0
0Ril
Output
Yes
Note
In the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.
In the third sample case the new login is similar with the second one.
Submitted Solution:
```
s = input()
n = int(input())
b = False
for i in range(n):
col = 0
s1 = input()
if len(s1) == len(s):
for i in range(len(s1)):
if s1[i].upper() == s[i].upper():
col += 1
if s1[i].upper() == 'O' and s[i] == '0':
col += 1
if s1[i] == '0' and s[i].upper() == 'O':
col += 1
if s1[i].upper() == 'I' and s[i] == '1':
col += 1
if s1[i].upper() == 'L' and s[i] == '1':
col += 1
if s1[i] == '1' and s[i].upper() == 'I':
col += 1
if s1[i] == '1' and s[i].upper() == 'L':
col += 1
if s1[i].upper() == 'I' and s[i].upper() == 'L':
col += 1
if s[i].upper() == 'I' and s1[i].upper() == 'L':
col += 1
if col == len(s1):
b = True
break
if b:
print("No")
else:
print("Yes")
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:
* transform lowercase letters to uppercase and vice versa;
* change letter «O» (uppercase latin letter) to digit «0» and vice versa;
* change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other.
For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.
You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.
Input
The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50 — the login itself.
The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins.
The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.
Output
Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it.
Otherwise print «No» (without quotes).
Examples
Input
1_wat
2
2_wat
wat_1
Output
Yes
Input
000
3
00
ooA
oOo
Output
No
Input
_i_
3
__i_
_1_
I
Output
No
Input
La0
3
2a0
La1
1a0
Output
No
Input
abc
1
aBc
Output
No
Input
0Lil
2
LIL0
0Ril
Output
Yes
Note
In the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.
In the third sample case the new login is similar with the second one.
Submitted Solution:
```
def transform(log):
return log.replace('O', '0').replace('o', '0').replace('l', '1').replace('I', '1').\
replace('L', '1').replace('i', '1').lower()
login = transform(input())
n = int(input())
logins = []
check = False
for i in range(n):
if login == transform(input()):
print('No')
check = True
if not check:
print('Yes')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:
* transform lowercase letters to uppercase and vice versa;
* change letter «O» (uppercase latin letter) to digit «0» and vice versa;
* change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other.
For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.
You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.
Input
The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50 — the login itself.
The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins.
The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.
Output
Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it.
Otherwise print «No» (without quotes).
Examples
Input
1_wat
2
2_wat
wat_1
Output
Yes
Input
000
3
00
ooA
oOo
Output
No
Input
_i_
3
__i_
_1_
I
Output
No
Input
La0
3
2a0
La1
1a0
Output
No
Input
abc
1
aBc
Output
No
Input
0Lil
2
LIL0
0Ril
Output
Yes
Note
In the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.
In the third sample case the new login is similar with the second one.
Submitted Solution:
```
alpha = 'qwertyupasdfghjkzxcvbnmQWERTYUPASDFGHJKZXCVBNM'
alikes = []
for i in range(len(alpha)):
alikes.append(set(alpha[i]))
alikes[-1].add(alpha[(i + 23)%46])
alikes.append(set(['0', 'o', 'O']))
alikes.append(set(['l', 'L', 'i', 'I', '1']))
for i in range(2, 10):
alikes.append(set(str(i)))
alikes.append(set('_'))
a = input()
check = False
for i in range(int(input())):
b = input()
if len(a) != len(b) or check:
continue
for j in range(len(a)):
newCheck = False
for k in alikes:
if a[j] in k:
if b[j] not in k:
newCheck = True
break
if newCheck:
break
check = (j == len(a) - 1)
print('No' if check else 'Yes')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:
* transform lowercase letters to uppercase and vice versa;
* change letter «O» (uppercase latin letter) to digit «0» and vice versa;
* change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other.
For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.
You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.
Input
The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50 — the login itself.
The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins.
The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.
Output
Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it.
Otherwise print «No» (without quotes).
Examples
Input
1_wat
2
2_wat
wat_1
Output
Yes
Input
000
3
00
ooA
oOo
Output
No
Input
_i_
3
__i_
_1_
I
Output
No
Input
La0
3
2a0
La1
1a0
Output
No
Input
abc
1
aBc
Output
No
Input
0Lil
2
LIL0
0Ril
Output
Yes
Note
In the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.
In the third sample case the new login is similar with the second one.
Submitted Solution:
```
def f(login1,login2):
s1 = login1.lower()
s2 = login2.lower()
if len(login1) != len(login2):
return False
else:
p = 0
for i in range(len(login1)):
if (s1[i] == s2[i])or((s1[i] == "o")and(s2[i] == "0"))or((s1[i] == "0")and(s2[i] == "o"))or((login1[i] == "1")and(login2[i] == "l"))or((login1[i] == "1")and(login2[i] == "I"))or((login2[i] == "1")and(s1[i] == "l"))or((login2[i] == "1")and(s1[i] == "i"))or((login2[i] == "l")and(s1[i] == "i"))or((s1[i] == "l")and(login2[i] == "I")):
p += 1
if p == len(s1):
return True
else:
return False
login = input()
n = int(input())
a =[]
q = True
for i in range(n):
new = input()
if f(login,new):
print("No")
q = False
break
if q:
print("Yes")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:
* transform lowercase letters to uppercase and vice versa;
* change letter «O» (uppercase latin letter) to digit «0» and vice versa;
* change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other.
For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.
You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.
Input
The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50 — the login itself.
The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins.
The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.
Output
Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it.
Otherwise print «No» (without quotes).
Examples
Input
1_wat
2
2_wat
wat_1
Output
Yes
Input
000
3
00
ooA
oOo
Output
No
Input
_i_
3
__i_
_1_
I
Output
No
Input
La0
3
2a0
La1
1a0
Output
No
Input
abc
1
aBc
Output
No
Input
0Lil
2
LIL0
0Ril
Output
Yes
Note
In the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.
In the third sample case the new login is similar with the second one.
Submitted Solution:
```
x=input()
x=x.lower()
n=int(input())
for i in range(n):
s1=input()
s1=s1.lower()
if len(s1) != len(x):
continue
for i in range(len(s1)):
if s1[i] != x[i]:
if x[i] == "0" and s1[i] == "o" or s1[i] == "o" and x[i] == "0":
continue
elif x[i] == "1" and (s1[i] == "l" or s1[i]=='i') or s1[i] == "1" and (x[i] == "l" or x[i]=='i'):
continue
else:
break
else:
print("No")
break
else:
print("Yes")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:
* transform lowercase letters to uppercase and vice versa;
* change letter «O» (uppercase latin letter) to digit «0» and vice versa;
* change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other.
For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.
You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.
Input
The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50 — the login itself.
The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins.
The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.
Output
Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it.
Otherwise print «No» (without quotes).
Examples
Input
1_wat
2
2_wat
wat_1
Output
Yes
Input
000
3
00
ooA
oOo
Output
No
Input
_i_
3
__i_
_1_
I
Output
No
Input
La0
3
2a0
La1
1a0
Output
No
Input
abc
1
aBc
Output
No
Input
0Lil
2
LIL0
0Ril
Output
Yes
Note
In the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.
In the third sample case the new login is similar with the second one.
Submitted Solution:
```
def corrector(w, p):
if w.upper() == p or w.lower() == p:
return "OK"
mas_0 = ["0", "O", "o"]
if (w in mas_0) and (p in mas_0):
return "OK"
mas_1 = ["1", "L", "l", "I", "i"]
if (w in mas_1) and (p in mas_1):
return "OK"
return "NOT"
def progress(present, wish):
position = 0
while position < len(present):
w = wish[position]
p = present[position]
ans = corrector(w, p)
if ans == "NOT":
return 1 # не смогли поменять букву
position += 1
return 0 # смогли поменять все букву
def main():
wish = str(input())
kol = int(input())
for i in range(kol):
present = str(input())
if present == wish:
print("No")
return 0
if len(present) == len(wish):
if progress(present, wish) == 0:
print("No")
return 0
else:
print("CHECk")
continue
print("Yes")
if __name__ == '__main__':
main()
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:
* transform lowercase letters to uppercase and vice versa;
* change letter «O» (uppercase latin letter) to digit «0» and vice versa;
* change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other.
For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.
You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.
Input
The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50 — the login itself.
The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins.
The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.
Output
Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it.
Otherwise print «No» (without quotes).
Examples
Input
1_wat
2
2_wat
wat_1
Output
Yes
Input
000
3
00
ooA
oOo
Output
No
Input
_i_
3
__i_
_1_
I
Output
No
Input
La0
3
2a0
La1
1a0
Output
No
Input
abc
1
aBc
Output
No
Input
0Lil
2
LIL0
0Ril
Output
Yes
Note
In the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.
In the third sample case the new login is similar with the second one.
Submitted Solution:
```
def can_exist(login, existing_logins):
for word in existing_logins:
if len(word) == len(login):
for i in range(len(word)):
if word[i] == login[i]:
continue
elif word[i].replace('o', '0').replace('l', '1').replace('i', '1') ==\
login[i].replace('o', '0').replace('l', '1').replace('i', '1'):
continue
break
else:
return "No"
return "Yes"
if __name__ == '__main__':
login = input()
n = int(input())
existing_logins = list()
for i in range(n):
existing_logins.append(input().lower())
print(can_exist(login, existing_logins))
```
### Response:
| No |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
### Response:
| "Correct Solution:
```
s = input()
print('First' if (len(s)%2) ^ (s[0] == s[-1]) else 'Second')
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
### Response:
| "Correct Solution:
```
S = input()
print('First' if (S[0] == S[-1]) ^ (len(S) % 2) else 'Second')
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
### Response:
| "Correct Solution:
```
s=input()
n=len(s)
if s[0]==s[n-1] and n%2==0 or s[0]!=s[n-1] and n%2==1:
print("First")
else:
print("Second")
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
### Response:
| "Correct Solution:
```
S = input()
if (len(S)%2)^(S[0]==S[-1]):
print("First")
else:
print("Second")
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
### Response:
| "Correct Solution:
```
s = input()
if (s[0] == s[-1] and len(s) % 2 == 0) or (s[0] != s[-1] and len(s) % 2 == 1):
print("First")
else:
print("Second")
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
### Response:
| "Correct Solution:
```
s = input()
ans=0
if s[0] == s[-1]:
ans +=1
ans = (len(s)-ans) %2
if ans == 0:
print("Second")
else:
print("First")
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
### Response:
| "Correct Solution:
```
s=input()
if s[0]==s[-1]:
print("Second" if len(s)%2 else "First")
else:
print("Second" if not len(s)%2 else "First")
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
### Response:
| "Correct Solution:
```
S = input()
L = len(S)%2==1
if S[0] != S[-1]:
print("Second" if not L else "First")
else:
print("Second" if L else "First")
``` |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
Submitted Solution:
```
S = input()
if S[0] != S[-1]:
if len(S) % 2 == 1:
print('First')
else:
print('Second')
else:
if len(S) % 2 == 1:
print('Second')
else:
print('First')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
Submitted Solution:
```
s=list(input())
n=len(s)
n=n-2
if s[0]==s[-1]:
n-=1
if n%2==0:
print("Second")
else:
print("First")
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
Submitted Solution:
```
s = input()
if s[0] == s[-1] and len(s) % 2 == 1 or s[0] != s[-1] and len(s) % 2 == 0: print('Second')
else: print('First')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
Submitted Solution:
```
s = input()
N = len(s)
f, l = (s[0], s[N-1])
if f == l:
if N%2 == 0:
print("First")
else:
print("Second")
else:
if N%2 == 0:
print("Second")
else:
print("First")
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
Submitted Solution:
```
s = list(input())
str_count = 0
for char in s:
if char == s[0] or char == s[-1]:
str_count += 1
if s[0] == s[-1]:
available_char_num = len(s) - str_count -1
else:
available_char_num = len(s) - 2
if available_char_num % 2 == 0:
print("Second")
else:
print("First")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
Submitted Solution:
```
S = input()
N = len(S)
x = S[0]
y = S[1]
for i in range(2, N):
if i % 2 == 0:
if S[i] != x:
break
else:
if S[i] != y:
break
else:
print("Second")
exit()
if N % 2 == 0:
print("Second")
else:
print("First")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
Submitted Solution:
```
s = input()
n = len(s)
n -= 1
print(n)
if s[0] == s[n-1]:
print("First" if (n % 2 == 0) else "Second")
else:
print("First" if (n % 2 == 1) else "Second")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string s of length 3 or greater. No two neighboring characters in s are equal.
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
* 3 ≤ |s| ≤ 10^5
* s consists of lowercase English letters.
* No two neighboring characters in s are equal.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
Examples
Input
aba
Output
Second
Input
abc
Output
First
Input
abcab
Output
First
Submitted Solution:
```
import sys
import numpy as np
def main():
s = input()
n = len(s)
if s[0] == s[n - 1] and n % 2 == 1:
print("Second")
else:
print("First")
main()
```
### Response:
| No |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
Twins
square1001 and E869120 are twins.
Please output the one that was born first.
input
No input is given.
output
Output the correct character string on one line.
However, insert a line break at the end.
Output example 1
square1001
Example
Input
Output
### Response:
| "Correct Solution:
```
print('square1001')
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
Twins
square1001 and E869120 are twins.
Please output the one that was born first.
input
No input is given.
output
Output the correct character string on one line.
However, insert a line break at the end.
Output example 1
square1001
Example
Input
Output
### Response:
| "Correct Solution:
```
print("square1001")
``` |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.
There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.
Input
The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:
<image>
Output
Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).
Examples
Input
AHA
Output
YES
Input
Z
Output
NO
Input
XO
Output
NO
Submitted Solution:
```
def isMirror(s):
x = s[::-1]
if(x != s):
return False
n = s.count('A') + s.count('H') + s.count('I') + s.count('M') + s.count('O') + s.count('T') + s.count('U') + s.count('V') + s.count('W') + s.count('X') + s.count('Y')
if(n != len(s)):
return False
return True
s = input()
if(isMirror(s) == True):
print('YES')
else:
print('NO')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.
There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.
Input
The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:
<image>
Output
Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).
Examples
Input
AHA
Output
YES
Input
Z
Output
NO
Input
XO
Output
NO
Submitted Solution:
```
import string
def is_palindrome(s):
for i in range(len(s) // 2):
k = len(s) - 1 - i
if s[i] != s[k]:
return False
return True
#
def main_function():
s = input()
is_answer_found = False
mirror_letter = ['B', 'C', 'D', 'E', 'F', 'G', 'J', 'K', 'L', 'N', 'P', 'Q', 'R', 'S', 'Z']
hash_table = [0 for i in range(150)]
if not is_palindrome(s):
print("NO")
else:
for i in s:
hash_table[ord(i)] += 1
for i in range(len(mirror_letter)):
order = ord(mirror_letter[i])
if hash_table[order] != 0:
print("NO")
is_answer_found = True
break
if not is_answer_found:
print("YES")
#
#
#
#
main_function()
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.
There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.
Input
The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:
<image>
Output
Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).
Examples
Input
AHA
Output
YES
Input
Z
Output
NO
Input
XO
Output
NO
Submitted Solution:
```
def main():
name = input()
s = ('B', 'C', 'D', 'E', 'F', 'G', 'J', 'K', 'L', 'N', 'P', 'Q', 'R', 'S', 'Z')
for ch in s:
if ch in name:
print('NO')
return
if name[:len(name) // 2] != name[::-1][:len(name) // 2]:
print('NO')
return
print('YES')
main()
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.
There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.
Input
The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:
<image>
Output
Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).
Examples
Input
AHA
Output
YES
Input
Z
Output
NO
Input
XO
Output
NO
Submitted Solution:
```
def isPalindrome(s):
return(s == s[::-1])
s=input()
l=['A','H','I','M','O','T','U','V','W','X','Y']
bool=[1 for i in s if i not in l]
if isPalindrome(s) and len(bool)==0:
print("YES")
else:
print("NO")
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.
There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.
Input
The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:
<image>
Output
Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).
Examples
Input
AHA
Output
YES
Input
Z
Output
NO
Input
XO
Output
NO
Submitted Solution:
```
import sys
a = input()
b = "".join(reversed(a))
if "H" in a or "A" in a or "U" in a or "V" in a or "W" in a or "X" in a or "I" in a or "T" in a or "M" in a or "Y" in a:
if "B" not in a and "C" not in a and "D" not in a and "E" not in a and "F" not in a and "G" not in a and "J" not in a and "K" not in a and "L" not in a and "N" not in a and "P" not in a and "Q" not in a and "R" not in a and "S" not in a and "Z" not in a:
if a == b:
print("YES")
sys.exit()
print("NO")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.
There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.
Input
The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:
<image>
Output
Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).
Examples
Input
AHA
Output
YES
Input
Z
Output
NO
Input
XO
Output
NO
Submitted Solution:
```
x = input()
array1=[]
array2=[]
for i in x:
array1.append(i)
array2.append(i)
array2.reverse()
if (array1==array2) and (len(x)>1):print('YES')
else:print('NO')
#
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.
There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.
Input
The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:
<image>
Output
Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).
Examples
Input
AHA
Output
YES
Input
Z
Output
NO
Input
XO
Output
NO
Submitted Solution:
```
import sys
import math
st = sys.stdin.readline()
l = len(st) - 1
dct = {'A' : 1, 'B': 0, 'C': 0, 'D': 0, 'E': 0, 'F': 0, 'G': 0, 'H': 1, 'I': 1,
'J': 0, 'K': 0, 'L': 0, 'M': 1, 'N': 0, 'O': 1, 'P': 0, 'Q': 0, 'R': 0, 'S': 1,
'T': 1, 'U': 1, 'V': 1, 'W': 1, 'X': 1, 'Y': 1, 'Z': 0 }
if(l == 1 and dct[st[0]] == 0):
print("NO")
exit()
j = l
for i in range(int(l / 2)):
if(st[i] != st[j - 1] or dct[st[i]] == 0):
print("NO")
exit()
j -= 1
print("YES")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.
There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.
Input
The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:
<image>
Output
Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).
Examples
Input
AHA
Output
YES
Input
Z
Output
NO
Input
XO
Output
NO
Submitted Solution:
```
s = input()
t = ['B', 'C', 'Z', 'Q', 'E', 'R', 'P', 'L', 'K', 'J', 'G', 'F', 'D', 'S', 'N']
k = 0
for i in range(len(s)):
if s[i] in t:
k+=1
print("YES" if k==0 else "NO")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Each employee of the "Blake Techologies" company uses a special messaging app "Blake Messenger". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many users want to be able to search through the message history. It was already announced that the new feature will appear in the nearest update, when developers faced some troubles that only you may help them to solve.
All the messages are represented as a strings consisting of only lowercase English letters. In order to reduce the network load strings are represented in the special compressed form. Compression algorithm works as follows: string is represented as a concatenation of n blocks, each block containing only equal characters. One block may be described as a pair (li, ci), where li is the length of the i-th block and ci is the corresponding letter. Thus, the string s may be written as the sequence of pairs <image>.
Your task is to write the program, that given two compressed string t and s finds all occurrences of s in t. Developers know that there may be many such occurrences, so they only ask you to find the number of them. Note that p is the starting position of some occurrence of s in t if and only if tptp + 1...tp + |s| - 1 = s, where ti is the i-th character of string t.
Note that the way to represent the string in compressed form may not be unique. For example string "aaaa" may be given as <image>, <image>, <image>...
Input
The first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of blocks in the strings t and s, respectively.
The second line contains the descriptions of n parts of string t in the format "li-ci" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.
The second line contains the descriptions of m parts of string s in the format "li-ci" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.
Output
Print a single integer — the number of occurrences of s in t.
Examples
Input
5 3
3-a 2-b 4-c 3-a 2-c
2-a 2-b 1-c
Output
1
Input
6 1
3-a 6-b 7-a 4-c 8-e 2-a
3-a
Output
6
Input
5 5
1-h 1-e 1-l 1-l 1-o
1-w 1-o 1-r 1-l 1-d
Output
0
Note
In the first sample, t = "aaabbccccaaacc", and string s = "aabbc". The only occurrence of string s in string t starts at position p = 2.
In the second sample, t = "aaabbbbbbaaaaaaacccceeeeeeeeaa", and s = "aaa". The occurrences of s in t start at positions p = 1, p = 10, p = 11, p = 12, p = 13 and p = 14.
Submitted Solution:
```
n,m = map(int, input().split())
a = list(map(str,input().split()))
b = list(map(str,input().split()))
str1 = ''
str2 = ''
for i in a:
x = int(i[0])
c = i[2]
str1 += (c*x)
for i in b:
x = int(i[0])
c = i[2]
str2 += (c*x)
i = 0
ans = 0
while (True):
r = str1.find(str2,i)
if r!=-1:
ans +=1
i = r+1
else:
break
print(ans)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Each employee of the "Blake Techologies" company uses a special messaging app "Blake Messenger". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many users want to be able to search through the message history. It was already announced that the new feature will appear in the nearest update, when developers faced some troubles that only you may help them to solve.
All the messages are represented as a strings consisting of only lowercase English letters. In order to reduce the network load strings are represented in the special compressed form. Compression algorithm works as follows: string is represented as a concatenation of n blocks, each block containing only equal characters. One block may be described as a pair (li, ci), where li is the length of the i-th block and ci is the corresponding letter. Thus, the string s may be written as the sequence of pairs <image>.
Your task is to write the program, that given two compressed string t and s finds all occurrences of s in t. Developers know that there may be many such occurrences, so they only ask you to find the number of them. Note that p is the starting position of some occurrence of s in t if and only if tptp + 1...tp + |s| - 1 = s, where ti is the i-th character of string t.
Note that the way to represent the string in compressed form may not be unique. For example string "aaaa" may be given as <image>, <image>, <image>...
Input
The first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of blocks in the strings t and s, respectively.
The second line contains the descriptions of n parts of string t in the format "li-ci" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.
The second line contains the descriptions of m parts of string s in the format "li-ci" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.
Output
Print a single integer — the number of occurrences of s in t.
Examples
Input
5 3
3-a 2-b 4-c 3-a 2-c
2-a 2-b 1-c
Output
1
Input
6 1
3-a 6-b 7-a 4-c 8-e 2-a
3-a
Output
6
Input
5 5
1-h 1-e 1-l 1-l 1-o
1-w 1-o 1-r 1-l 1-d
Output
0
Note
In the first sample, t = "aaabbccccaaacc", and string s = "aabbc". The only occurrence of string s in string t starts at position p = 2.
In the second sample, t = "aaabbbbbbaaaaaaacccceeeeeeeeaa", and s = "aaa". The occurrences of s in t start at positions p = 1, p = 10, p = 11, p = 12, p = 13 and p = 14.
Submitted Solution:
```
def main():
input().split()
ts = []
for _ in 0, 1:
tmp = input().split()
a, x, l = tmp[0][-1], 0, []
for st in tmp:
y = int(st[:-2])
b = st[-1]
if a != b:
l.append(((x, a)))
x, a = y, b
else:
x += y
l.append(((x, a)))
ts.append(l)
t, s = ts
res, m, x, a, y, b = 0, len(s), *s[0], *s[-1]
if m == 1:
res = sum(y - x + 1 for y, b in t if a == b and x <= y)
elif m == 2:
i, u = 0, ' '
for j, v in t:
if a == u and b == v and x <= i and y <= j:
res += 1
else:
t[:0] = s[1: -1] + [(0, ' ')]
tmp = [0] * len(t)
for i, j in zip(range(1, len(t)), tmp):
while j > 0 and t[i] != t[j]:
j = tmp[j - 1]
tmp[i] = j + 1 if t[i] == t[j] else j
m -= 2
del tmp[-1]
for i, q in enumerate(tmp):
if q == m:
i, u, j, v = *t[i - q], *t[i + 1]
if a == u and b == v and x <= i and y <= j:
res += 1
print(res)
if __name__ == '__main__':
main()
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Each employee of the "Blake Techologies" company uses a special messaging app "Blake Messenger". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many users want to be able to search through the message history. It was already announced that the new feature will appear in the nearest update, when developers faced some troubles that only you may help them to solve.
All the messages are represented as a strings consisting of only lowercase English letters. In order to reduce the network load strings are represented in the special compressed form. Compression algorithm works as follows: string is represented as a concatenation of n blocks, each block containing only equal characters. One block may be described as a pair (li, ci), where li is the length of the i-th block and ci is the corresponding letter. Thus, the string s may be written as the sequence of pairs <image>.
Your task is to write the program, that given two compressed string t and s finds all occurrences of s in t. Developers know that there may be many such occurrences, so they only ask you to find the number of them. Note that p is the starting position of some occurrence of s in t if and only if tptp + 1...tp + |s| - 1 = s, where ti is the i-th character of string t.
Note that the way to represent the string in compressed form may not be unique. For example string "aaaa" may be given as <image>, <image>, <image>...
Input
The first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of blocks in the strings t and s, respectively.
The second line contains the descriptions of n parts of string t in the format "li-ci" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.
The second line contains the descriptions of m parts of string s in the format "li-ci" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.
Output
Print a single integer — the number of occurrences of s in t.
Examples
Input
5 3
3-a 2-b 4-c 3-a 2-c
2-a 2-b 1-c
Output
1
Input
6 1
3-a 6-b 7-a 4-c 8-e 2-a
3-a
Output
6
Input
5 5
1-h 1-e 1-l 1-l 1-o
1-w 1-o 1-r 1-l 1-d
Output
0
Note
In the first sample, t = "aaabbccccaaacc", and string s = "aabbc". The only occurrence of string s in string t starts at position p = 2.
In the second sample, t = "aaabbbbbbaaaaaaacccceeeeeeeeaa", and s = "aaa". The occurrences of s in t start at positions p = 1, p = 10, p = 11, p = 12, p = 13 and p = 14.
Submitted Solution:
```
def Z_function(L, l):
Z = []
for i in range(len(L)):
if i == 0:
Z.append(0)
else:
c = 0
for j in range(i, len(L)):
if L[j][1] == L[j - i][1]:
if l == 1 and L[j][0] > L[j - i][0]:
c = L[j][0] - L[j - i][0] + 1
elif (L[j][0] == L[j - i][0] or ((j - i == 0 or j - i == l - 1) and L[j][0] >= L[j - i][0])):
c += 1
else:
break
else:
break
Z.append(c)
return Z
def parse_string(string):
L = []
L = string.split(' ')
for i in range(len(L)):
L[i] = [int(L[i][0]), L[i][-1]]
i = 0
while i < len(L)-1:
if L[i][1] == L[i+1][1]:
L[i][0] += L[i+1][0]
L.remove(L[i+1])
i+=1
return L
def get_count_entering(t,s):
count = 0
#Creating United List
UL = s[:]
UL.append([0,'$'])
UL.extend(t)
#End of Creating
len_s = len(s)
Z = Z_function(UL, len_s)
for z in Z:
if len_s == 1:
count+=z
elif z == len_s:
count+=1
return count
def main():
nm = input()
del nm
#
string = input()
t = parse_string(string)
string = input()
s = parse_string(string)
print(get_count_entering(t,s))
if __name__ == '__main__':
main()
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Each employee of the "Blake Techologies" company uses a special messaging app "Blake Messenger". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many users want to be able to search through the message history. It was already announced that the new feature will appear in the nearest update, when developers faced some troubles that only you may help them to solve.
All the messages are represented as a strings consisting of only lowercase English letters. In order to reduce the network load strings are represented in the special compressed form. Compression algorithm works as follows: string is represented as a concatenation of n blocks, each block containing only equal characters. One block may be described as a pair (li, ci), where li is the length of the i-th block and ci is the corresponding letter. Thus, the string s may be written as the sequence of pairs <image>.
Your task is to write the program, that given two compressed string t and s finds all occurrences of s in t. Developers know that there may be many such occurrences, so they only ask you to find the number of them. Note that p is the starting position of some occurrence of s in t if and only if tptp + 1...tp + |s| - 1 = s, where ti is the i-th character of string t.
Note that the way to represent the string in compressed form may not be unique. For example string "aaaa" may be given as <image>, <image>, <image>...
Input
The first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of blocks in the strings t and s, respectively.
The second line contains the descriptions of n parts of string t in the format "li-ci" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.
The second line contains the descriptions of m parts of string s in the format "li-ci" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.
Output
Print a single integer — the number of occurrences of s in t.
Examples
Input
5 3
3-a 2-b 4-c 3-a 2-c
2-a 2-b 1-c
Output
1
Input
6 1
3-a 6-b 7-a 4-c 8-e 2-a
3-a
Output
6
Input
5 5
1-h 1-e 1-l 1-l 1-o
1-w 1-o 1-r 1-l 1-d
Output
0
Note
In the first sample, t = "aaabbccccaaacc", and string s = "aabbc". The only occurrence of string s in string t starts at position p = 2.
In the second sample, t = "aaabbbbbbaaaaaaacccceeeeeeeeaa", and s = "aaa". The occurrences of s in t start at positions p = 1, p = 10, p = 11, p = 12, p = 13 and p = 14.
Submitted Solution:
```
n,m = map(int, input().split())
a = list(map(str,input().split()))
b = list(map(str,input().split()))
str1 = ''
str2 = ''
for i in a:
x = int(i[0])
c = i[2]
str1 += (c*x)
for i in b:
x = int(i[0])
c = i[2]
str2 += (c*x)
i = 0
ans = 0
while (True):
r = str1.rfind(str2,i)
if r!=-1:
ans +=1
i = r+1
else:
break
print(ans)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.
A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.
Input
The first and single line contains string s (1 ≤ |s| ≤ 15).
Output
Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
Examples
Input
abccaa
Output
YES
Input
abbcca
Output
NO
Input
abcda
Output
YES
Submitted Solution:
```
li= input()
b = len(li)//2
count = 0
for i in range(b):
if li[i] != li[-(i+1)]:
count += 1
if count == 1: print('YES')
elif count ==0 and len(li) & 1: print('YES')
else: print("NO")
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.
A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.
Input
The first and single line contains string s (1 ≤ |s| ≤ 15).
Output
Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
Examples
Input
abccaa
Output
YES
Input
abbcca
Output
NO
Input
abcda
Output
YES
Submitted Solution:
```
s=input()
if len(s)==1:
print('YES')
else:
l=list(s)
l.reverse()
t=''.join(l)
l=[0]*len(s)
for i in range(len(s)):
if s[i]!=t[i]:
l[i]=1
r=''.join([str(i) for i in l])
if r.count('1')==2 or r.count('1')==0 and len(s)%2==1:
print('YES')
else:
print('NO')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.
A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.
Input
The first and single line contains string s (1 ≤ |s| ≤ 15).
Output
Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
Examples
Input
abccaa
Output
YES
Input
abbcca
Output
NO
Input
abcda
Output
YES
Submitted Solution:
```
from math import ceil
n = input()
ln = ceil(len(n)/2)
f = 0
if n != n[::-1] :
for i in range(0,ln):
if n[i] != n[-(i+1)]:
if f == 0:
f = 1
else:
print('NO')
f = 0
break
elif len(n)%2==1: print('YES')
else: print('NO')
if f==1: print('YES')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.
A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.
Input
The first and single line contains string s (1 ≤ |s| ≤ 15).
Output
Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
Examples
Input
abccaa
Output
YES
Input
abbcca
Output
NO
Input
abcda
Output
YES
Submitted Solution:
```
s=input()
i=0
j=len(s)-1
b=0
t=0
if len(s)==1:
print('YES')
exit()
s1=s[0]
if len(s)%2:
if s[:j//2]==s[j//2+1:][::-1]:
print('YES')
exit()
while i<j:
if s[i]!=s[j]:
b+=1
if b>1:
print('NO')
exit()
i+=1
j-=1
print('YES') if b==1 else print('NO')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.
A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.
Input
The first and single line contains string s (1 ≤ |s| ≤ 15).
Output
Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
Examples
Input
abccaa
Output
YES
Input
abbcca
Output
NO
Input
abcda
Output
YES
Submitted Solution:
```
s=input()
p=0
for i in range(len(s)//2):
if (s[i]!=s[-i-1]):
p+=1
if p>1 or p==0:
print("NO")
else :
print("YES")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.
A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.
Input
The first and single line contains string s (1 ≤ |s| ≤ 15).
Output
Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
Examples
Input
abccaa
Output
YES
Input
abbcca
Output
NO
Input
abcda
Output
YES
Submitted Solution:
```
s=input()
r=0
while(r<2 and len(s)>3):
if(s[0]!=s[-1]):
r+=1
s=s.replace(s[0],'',1)
s=s[::-1]
s=s.replace(s[0],'',1)
s=s[::-1]
if(len(s)==2 and s[0]!=s[-1]):
r+=1
print(['YES','NO'][r==2])
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.
A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.
Input
The first and single line contains string s (1 ≤ |s| ≤ 15).
Output
Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
Examples
Input
abccaa
Output
YES
Input
abbcca
Output
NO
Input
abcda
Output
YES
Submitted Solution:
```
string = input()
counter = 0
for i in range(len(string) // 2):
l = i
r = len(string) - i - 1
counter += string[l] != string[r]
print("YES" if counter == 1 else "NO")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.
A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.
Input
The first and single line contains string s (1 ≤ |s| ≤ 15).
Output
Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.
Examples
Input
abccaa
Output
YES
Input
abbcca
Output
NO
Input
abcda
Output
YES
Submitted Solution:
```
s = input()
length = len(s)
if length % 2 == 0:
count = 0
for i in range(length//2):
if s[i] != s[length - i -1]:
count += 1
if count == 1:
print("YES")
else:
print("NO")
else:
count = 0
for i in range((length - 1)//2):
if s[i] != s[length - i - 1]:
count += 1
if count == 1:
print("YES")
else:
print("NO")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.
After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.
Ujan has two distinct strings s and t of length n consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions i and j (1 ≤ i,j ≤ n, the values i and j can be equal or different), and swaps the characters s_i and t_j. Can he succeed?
Note that he has to perform this operation exactly once. He has to perform this operation.
Input
The first line contains a single integer k (1 ≤ k ≤ 10), the number of test cases.
For each of the test cases, the first line contains a single integer n (2 ≤ n ≤ 10^4), the length of the strings s and t.
Each of the next two lines contains the strings s and t, each having length exactly n. The strings consist only of lowercase English letters. It is guaranteed that strings are different.
Output
For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.
You can print each letter in any case (upper or lower).
Example
Input
4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca
Output
Yes
No
No
No
Note
In the first test case, Ujan can swap characters s_1 and t_4, obtaining the word "house".
In the second test case, it is not possible to make the strings equal using exactly one swap of s_i and t_j.
Submitted Solution:
```
# from debug import debug
import sys;input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
s1, s2 = list(input().strip()), list(input().strip())
dis = 0
diff = []
for i in range(n):
if s1[i] != s2[i]: dis+=1; diff.append(i)
if dis == 2 and s1[diff[0]] == s1[diff[1]] and s2[diff[1]] == s2[diff[0]]: print("YES")
elif dis == 0: print("YES")
else: print("NO")
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.
After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.
Ujan has two distinct strings s and t of length n consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions i and j (1 ≤ i,j ≤ n, the values i and j can be equal or different), and swaps the characters s_i and t_j. Can he succeed?
Note that he has to perform this operation exactly once. He has to perform this operation.
Input
The first line contains a single integer k (1 ≤ k ≤ 10), the number of test cases.
For each of the test cases, the first line contains a single integer n (2 ≤ n ≤ 10^4), the length of the strings s and t.
Each of the next two lines contains the strings s and t, each having length exactly n. The strings consist only of lowercase English letters. It is guaranteed that strings are different.
Output
For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.
You can print each letter in any case (upper or lower).
Example
Input
4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca
Output
Yes
No
No
No
Note
In the first test case, Ujan can swap characters s_1 and t_4, obtaining the word "house".
In the second test case, it is not possible to make the strings equal using exactly one swap of s_i and t_j.
Submitted Solution:
```
tes=int(input())
for j in range(0,tes):
size=int(input())
s=input()
t=input()
arr=[]
l=0
k=0
for i in range(0,size):
if(s[i]!=t[i]):
arr.append(i)
l=l+1
if(l>2):
print("NO")
k=1
break
if(l==2 and s[arr[0]]==s[arr[1]] and t[arr[0]]==t[arr[1]]):
print("YES")
elif (l<2 or k==0):
print("NO")
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.
After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.
Ujan has two distinct strings s and t of length n consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions i and j (1 ≤ i,j ≤ n, the values i and j can be equal or different), and swaps the characters s_i and t_j. Can he succeed?
Note that he has to perform this operation exactly once. He has to perform this operation.
Input
The first line contains a single integer k (1 ≤ k ≤ 10), the number of test cases.
For each of the test cases, the first line contains a single integer n (2 ≤ n ≤ 10^4), the length of the strings s and t.
Each of the next two lines contains the strings s and t, each having length exactly n. The strings consist only of lowercase English letters. It is guaranteed that strings are different.
Output
For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.
You can print each letter in any case (upper or lower).
Example
Input
4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca
Output
Yes
No
No
No
Note
In the first test case, Ujan can swap characters s_1 and t_4, obtaining the word "house".
In the second test case, it is not possible to make the strings equal using exactly one swap of s_i and t_j.
Submitted Solution:
```
import sys
def read_numbers():
return [int(x) for x in sys.stdin.readline()[:-1].split(" ")]
def read_str():
return sys.stdin.readline()[:-1]
def test_case():
str_len = read_numbers()[0]
str_a = list(read_str())
str_b = list(read_str())
not_common_a = list()
not_common_b = list()
for i in range(str_len):
if str_a[i] != str_b[i]:
not_common_a.append(str_a[i])
not_common_b.append(str_b[i])
if len(not_common_a) > 2:
return False
# print(not_common_a)
# print(not_common_b)
if len(not_common_a) != 2:
return False
return not_common_a[0] == not_common_a[1] and not_common_b[0] == not_common_b[1]
def main():
test_cases = read_numbers()[0]
for i in range(test_cases):
print("Yes" if test_case() else "No")
if __name__ == '__main__':
main()
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.
After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.
Ujan has two distinct strings s and t of length n consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions i and j (1 ≤ i,j ≤ n, the values i and j can be equal or different), and swaps the characters s_i and t_j. Can he succeed?
Note that he has to perform this operation exactly once. He has to perform this operation.
Input
The first line contains a single integer k (1 ≤ k ≤ 10), the number of test cases.
For each of the test cases, the first line contains a single integer n (2 ≤ n ≤ 10^4), the length of the strings s and t.
Each of the next two lines contains the strings s and t, each having length exactly n. The strings consist only of lowercase English letters. It is guaranteed that strings are different.
Output
For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.
You can print each letter in any case (upper or lower).
Example
Input
4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca
Output
Yes
No
No
No
Note
In the first test case, Ujan can swap characters s_1 and t_4, obtaining the word "house".
In the second test case, it is not possible to make the strings equal using exactly one swap of s_i and t_j.
Submitted Solution:
```
import sys
import itertools
import math
import collections
from collections import Counter
#########################
# imgur.com/Pkt7iIf.png #
#########################
def sieve(n):
prime = [True for i in range(n + 1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * 2, n + 1, p):
prime[i] = False
p += 1
prime[0] = prime[1] = False
r = [p for p in range(n + 1) if prime[p]]
return r
def divs(n, start=1):
r = []
for i in range(start, int(math.sqrt(n) + 1)):
if (n % i == 0):
if (n / i == i):
r.append(i)
else:
r.extend([i, n // i])
return r
def ceil(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def prr(a, sep=' '): print(sep.join(map(str, a)))
def dd(): return collections.defaultdict(int)
t = ii()
for _ in range(t):
n = ii()
a = input()
b = input()
col = []
for i in range(n):
if a[i] != b[i]:
col.append(i)
if len(col) == 0:
print('Yes')
continue
if len(col) != 2:
print('No')
continue
if a[col[0]] == a[col[1]] and b[col[0]] == b[col[1]]:
print('Yes')
else:
print('No')
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.
After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.
Ujan has two distinct strings s and t of length n consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions i and j (1 ≤ i,j ≤ n, the values i and j can be equal or different), and swaps the characters s_i and t_j. Can he succeed?
Note that he has to perform this operation exactly once. He has to perform this operation.
Input
The first line contains a single integer k (1 ≤ k ≤ 10), the number of test cases.
For each of the test cases, the first line contains a single integer n (2 ≤ n ≤ 10^4), the length of the strings s and t.
Each of the next two lines contains the strings s and t, each having length exactly n. The strings consist only of lowercase English letters. It is guaranteed that strings are different.
Output
For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.
You can print each letter in any case (upper or lower).
Example
Input
4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca
Output
Yes
No
No
No
Note
In the first test case, Ujan can swap characters s_1 and t_4, obtaining the word "house".
In the second test case, it is not possible to make the strings equal using exactly one swap of s_i and t_j.
Submitted Solution:
```
def gt(x,y,r):
v=[]
q=[]
e=0
for i in range(r):
if x[i]==y[i]:
None
else:
e+=1
v.append(x[i])
q.append(y[i])
if e==0:
return "Yes"
elif e==2:
if set(v)==set(l):
return "Yes"
else:
return "No"
return "No"
k=int(input())
l=[]
for i in range(k):
rd=int(input())
xd=input()
yd=input()
print(gt(xd,yd,rd))
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.
After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.
Ujan has two distinct strings s and t of length n consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions i and j (1 ≤ i,j ≤ n, the values i and j can be equal or different), and swaps the characters s_i and t_j. Can he succeed?
Note that he has to perform this operation exactly once. He has to perform this operation.
Input
The first line contains a single integer k (1 ≤ k ≤ 10), the number of test cases.
For each of the test cases, the first line contains a single integer n (2 ≤ n ≤ 10^4), the length of the strings s and t.
Each of the next two lines contains the strings s and t, each having length exactly n. The strings consist only of lowercase English letters. It is guaranteed that strings are different.
Output
For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.
You can print each letter in any case (upper or lower).
Example
Input
4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca
Output
Yes
No
No
No
Note
In the first test case, Ujan can swap characters s_1 and t_4, obtaining the word "house".
In the second test case, it is not possible to make the strings equal using exactly one swap of s_i and t_j.
Submitted Solution:
```
q = int(input())
for i in range(q):
n = int(input())
s1 = input()
s2 = input()
dp1, dp2 = [ ],[ ]
while(i<len(s1)):
if(s1[i]!=s2[i]):
dp1.append(s1[i])
dp2.append(s2[i])
i+=1
if(len(dp1)!=2):
print("No")
elif(dp1[0]==dp1[1] and dp2[0]==dp2[1]):
print("Yes")
else:
print("No")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.
After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.
Ujan has two distinct strings s and t of length n consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions i and j (1 ≤ i,j ≤ n, the values i and j can be equal or different), and swaps the characters s_i and t_j. Can he succeed?
Note that he has to perform this operation exactly once. He has to perform this operation.
Input
The first line contains a single integer k (1 ≤ k ≤ 10), the number of test cases.
For each of the test cases, the first line contains a single integer n (2 ≤ n ≤ 10^4), the length of the strings s and t.
Each of the next two lines contains the strings s and t, each having length exactly n. The strings consist only of lowercase English letters. It is guaranteed that strings are different.
Output
For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.
You can print each letter in any case (upper or lower).
Example
Input
4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca
Output
Yes
No
No
No
Note
In the first test case, Ujan can swap characters s_1 and t_4, obtaining the word "house".
In the second test case, it is not possible to make the strings equal using exactly one swap of s_i and t_j.
Submitted Solution:
```
for _ in range(int(input())):
n = int(input())
s = input()
t = input()
count = 0
for i in range(n):
if s[i] != t[i]:
count+=1
if count == 2:
print("Yes")
else:
print("No")
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.
After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.
Ujan has two distinct strings s and t of length n consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions i and j (1 ≤ i,j ≤ n, the values i and j can be equal or different), and swaps the characters s_i and t_j. Can he succeed?
Note that he has to perform this operation exactly once. He has to perform this operation.
Input
The first line contains a single integer k (1 ≤ k ≤ 10), the number of test cases.
For each of the test cases, the first line contains a single integer n (2 ≤ n ≤ 10^4), the length of the strings s and t.
Each of the next two lines contains the strings s and t, each having length exactly n. The strings consist only of lowercase English letters. It is guaranteed that strings are different.
Output
For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.
You can print each letter in any case (upper or lower).
Example
Input
4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca
Output
Yes
No
No
No
Note
In the first test case, Ujan can swap characters s_1 and t_4, obtaining the word "house".
In the second test case, it is not possible to make the strings equal using exactly one swap of s_i and t_j.
Submitted Solution:
```
T = int(input())
for t in range(T):
n = int(input())
s1 = list(input())
s2 = list(input())
freq = [0]*26
for i in s1:
freq[ord(i)-ord('a')] += 1
for i in s2:
freq[ord(i) - ord('a')] += 1
ok = 1
for i in range(26):
if freq[i]&1:
ok = 0
if ok==0:
print('No')
continue
else:
print('Yes')
freqa = [0]*26
mapa = [[] for i in range(26)]
mapb = [[] for i in range(26)]
for i in range(n):
mapa[ord(s1[i])-ord('a')].append(i)
mapb[ord(s2[i])-ord('a')].append(i)
excessa = [[] for i in range(26)]
excessb = [[] for i in range(26)]
for i in range(26):
if len(mapa[i]) > (freq[i])//2:
for j in range(freq[i]//2, len(mapa[i])):
excessa[i].append(mapa[i][j])
if len(mapb[i]) > (freq[i])//2:
for j in range(freq[i]//2, len(mapb[i])):
excessb[i].append(mapb[i][j])
alla = []
for i in range(26):
for j in excessa[i]:
alla.append(j)
allb = []
for i in range(26):
for j in excessb[i]:
allb.append(j)
op = []
for i in range(len(alla)):
op.append((alla[i]+1, allb[i]+1))
s1[alla[i]], s2[allb[i]] = s2[allb[i]], s1[alla[i]]
#print('0', s1, s2)
for i in range(n):
if s1[i] == s2[i]:
continue
found = 0
for j in range(i-1, -1, -1):
if (s1[j] == s2[i]) and (s1[j] != s2[j]):
found = 1
#print('Found', s2[i], 'at', j, i)
#print(j+1, i+1)
#s1[j], s2[i] = s2[i], s1[j]
op.append((j+1, j+1))
s1[j], s2[j] = s2[j], s1[j]
op.append((j+1, i+1))
s1[j], s2[i] = s2[i], s1[j]
if found:
break
if found == 0:
for j in range(i+1, n):
if (s1[j] == s2[i]) and (s1[j] != s2[j]):
found = 1
#print('Found', s2[i], 'at', j, i)
#print(j+1, i+1)
#s1[j], s2[i] = s2[i], s1[j]
op.append((j+1, j+1))
s1[j], s2[j] = s2[j], s1[j]
op.append((j+1, i+1))
s1[j], s2[i] = s2[i], s1[j]
if found:
break
print(len(op))
for i in op:
print(*i)
```
### Response:
| No |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
### Response:
| "Correct Solution:
```
# coding: utf-8
# Your code here!
import re
while True:
name,type = input().split()
if type == "X":
break
if "_" in name:
X = name.split("_")
else:
tmp = name.upper()
name = tmp[0]+name[1:]
X = re.findall('[A-Z][^A-Z]*',name)
if type == "U":
for i in range(len(X)):
X[i] = X[i].capitalize()
elif type == "L":
X[0] = X[0].lower()
for i in range(1,len(X)):
X[i] = X[i].capitalize()
else:
X[0] = X[0].lower()
for i in range(1,len(X)):
X[i] = "_"+X[i].lower()
print("".join(X))
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
### Response:
| "Correct Solution:
```
def Upper(s) :
New = []
i = 0
while True :
if i == 0 :
New.append(s[i].upper())
elif s[i] == "_" :
i += 1
New.append(s[i].upper())
elif 65 <= ord(s[i]) <= 90 :
New.append(s[i].upper())
else :
New.append(s[i].lower())
i += 1
if i >= len(s) :
break
return New
def Lower(s) :
New = []
i = 0
while True :
if s[i] == "_" :
i += 1
New.append(s[i].upper())
elif 65 <= ord(s[i]) <= 90 and i != 0:
New.append(s[i].upper())
else :
New.append(s[i].lower())
i += 1
if i >= len(s) :
break
return New
def Under_Score(s) :
New = []
i = 0
while True :
if 65 <= ord(s[i]) <= 90 and i != 0:
New.append("_")
New.append(s[i].lower())
else :
New.append(s[i].lower())
i += 1
if i >= len(s) :
break
return New
while True :
l, x = map(str, input().split())
if x == "X" :
break
elif x == "U" :
print(*Upper(l), sep="")
elif x == "L" :
print(*Lower(l), sep="")
elif x == "D" :
print(*Under_Score(l), sep="")
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
### Response:
| "Correct Solution:
```
import re
while True:
n,t=input().split()
if t=='X':
break
if '_'in t:
ans=s.split('_')
else :
ans=re.findall(r'[a-z]+|[A-Z][a-z]*',n)
if t=='D':
ans='_'.join(map(str.lower,ans))
else :
ans=''.join(map(str.capitalize,ans))
if t=='L':
ans=ans[0].lower()+ans[1:]
print(ans)
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
### Response:
| "Correct Solution:
```
large = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
small = list("abcdefghijklmnopqrstuvwxyz")
while 1:
word, alpha = input().split()
if alpha == "X":
break
word = list(word)
ans = ""
if alpha == "L":
first = word.pop(0)
if first in large:
ans += small[large.index(first)]
else:
ans += first
while word != []:
w = word.pop(0)
if w == "_":
target = word.pop(0)
if target in small:
ans += large[small.index(target)]
else:
ans += target
else:
ans += w
elif alpha == "U":
first = word.pop(0)
if first in small:
ans += large[small.index(first)]
else:
ans += first
while word != []:
w = word.pop(0)
if w == "_":
target = word.pop(0)
if target in small:
ans += large[small.index(target)]
else:
ans += target
else:
ans += w
elif alpha == "D":
first = word.pop(0)
if first in large:
ans += small[large.index(first)]
else:
ans += first
while word != []:
w = word.pop(0)
if w in large:
ans += "_" + small[large.index(w)]
else:
ans += w
print(ans)
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
### Response:
| "Correct Solution:
```
while True :
name, type = map(str, input().split())
if type == "X" :
break
else :
N = list(name)
if "_" in N :
if type == "U" or type == "L" :
cnt = 0
for i in range(len(N)) :
if i == 0 and type == "U" :
N[i] = N[i].upper()
elif N[i] == "_" :
cnt += 1
elif cnt == 1 :
N[i] = N[i].upper()
cnt = 0
N = [i for i in N if i != "_"]
elif type == "U" :
N[0] = N[0].upper()
elif type == "L" :
N[0] = N[0].lower()
else :
s = 0
for i in range(len(N)) :
if i == 0 :
N[s] = N[s].lower()
s += 1
elif N[s].isupper() :
N[s] = N[s].lower()
N.insert(s, "_")
s += 2
else :
s += 1
for i in range(len(N)) :
if i == len(N) - 1 :
print(N[i])
else :
print(N[i], end = "")
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
### Response:
| "Correct Solution:
```
while True:
s=list(map(str,input().split(' ')))
if s[1]=='X':
break
name=list(s[0])
der=0
n=[]
for i in range(1,len(name)):
if name[i].isupper()==True:
n.append(i)
if name[i]=='_':
n.append(i-der)
der+=1
if s[1]=='U':
name[0]=name[0].upper()
for u in range(len(n)):
if name[n[u]]=='_':
name.pop(n[u])
name[n[u]]=name[n[u]].upper()
print(''.join(name))
if s[1]=='L':
name[0]=name[0].lower()
for l in range(len(n)):
if name[n[l]]=='_':
name.pop(n[l])
name[n[l]]=name[n[l]].upper()
print(''.join(name))
if s[1]=='D':
if '_' in name:
print(''.join(name))
else:
name[0]=name[0].lower()
der=0
for d in range(len(n)):
name[n[d]+der]=name[n[d]+der].lower()
name.insert(n[d]+der,'_')
der+=1
print(''.join(name))
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
### Response:
| "Correct Solution:
```
while True:
a, b = map(str,input().split())
if b=='X':
break
if '_' in a:
c = a.split('_')
else:
c=[]
k = 0
for i in range(1,len(a)):
if a[i].isupper():
c.append(a[k:i])
k = i
c.append(a[k:])
if b=='D':
c = '_'.join(map(str.lower,c))
else:
c = ''.join(map(str.capitalize,c))
if b =='L':
c = c[0].lower() + c[1:]
print(c)
``` |
### Instruction:
Provide a correct Python 3 solution for this coding contest problem.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
### Response:
| "Correct Solution:
```
import re
while True:
n,t=map(str,input().split())
if t == 'X':
break
if '_' in n :
if t == 'D':
print(n)
else:
m = n.title()
l= re.sub('_', '',m)
if t == 'U':
print(l)
elif t == 'L':
p = l[0].lower() + l[1:]
print(p)
else:
q = n[0].upper() + n[1:]
r = re.findall('[A-Z][a-z]*',q)
if t == 'D':
s = '_'.join(r)
print(s.lower())
elif t == 'U':
print("".join(r))
elif t == 'L':
u = "".join(r)
v = u[0].lower() + u[1:]
print(v)
``` |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
Submitted Solution:
```
while True:
name,typ = input().split()
if typ=="X": break
ans = []
if "_" in name:
ans = name.split("_")
else:
j = 0
for i in range(1,len(name)):
if name[i].isupper():
ans.append(name[j:i])
j = i
ans.append(name[j:])
if typ=="D":
ans = map(str.lower, ans)
print(*ans,sep="_")
else:
ans = "".join(map(str.capitalize, ans))
if typ=="L":
ans = ans[0].lower() + ans[1:]
print(ans)
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
Submitted Solution:
```
while True:
n, t = input().split()
if t == "X":
break
if "_" in n:
names = n.split("_")
else:
n = list(n)
for i, c in enumerate(n):
if c.isupper():
if i:
n[i] = "#" + c.lower()
else:
n[i] = c.lower()
names = "".join(n).split("#")
if t == "U":
print(*[name.title() for name in names], sep="")
elif t == "L":
print(*[name.title() if i != 0 else name for i, name in enumerate(names)], sep="")
else:
print(*names, sep="_")
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
Submitted Solution:
```
while True:
Name, Type = input().split()
if Type=='X':
break
if '_' in Name:
Name_ = Name
_n_ = [0]
i = 0
while True:
Namelist_ = list(Name_)
n_ = Name_.find('_')
if n_==-1:
break
_n_.append(n_+_n_[i])
i += 1
del(Namelist_[0:n_+1])
Name_ = ''.join(Namelist_)
Name = ''.join(Name.split('_'))
Namelist = list(Name)
for i in range(len(_n_)):
o = str(Namelist[_n_[i]])
O = o.upper()
Namelist.pop(_n_[i])
Namelist.insert(_n_[i],O)
Name = ''.join(Namelist)
if Type=='U':
NameLIST = list(Name)
o = str(NameLIST[0])
O = o.upper()
NameLIST.pop(0)
NameLIST.insert(0,O)
NAME = ''.join(NameLIST)
if Type=='L':
NameLIST = list(Name)
O = str(NameLIST[0])
o = O.lower()
NameLIST.pop(0)
NameLIST.insert(0,o)
NAME = ''.join(NameLIST)
if Type=='D':
NameLIST = list(Name)
_T_ = []
t = 0
for i in range(len(NameLIST)):
T = str(NameLIST[i])
if T.isupper()==False:
pass
if T.isupper()==True:
if i==0:
pass
if i>0:
_T_.append(i+t)
t += 1
Tt = T.lower()
NameLIST.pop(i)
NameLIST.insert(i,Tt)
for i in range(len(_T_)):
NameLIST.insert(_T_[i],'_')
NAME = ''.join(NameLIST)
print(NAME)
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
Submitted Solution:
```
while True:
s = input()
s, order = s.split()
if order == 'X':
break
if '_' in s:
if order == 'U':
s = s.split('_')
a = ''
for i in s:
a += i.capitalize()
print(a)
elif order == 'L':
s = s.split('_')
a = ''
a += s[0].lower()
for i in s[1:]:
a += i.capitalize()
print(a)
else:
print(s.lower())
else:
if order == 'U':
if s[0].isupper():
print(s)
else:
s = s[0].upper() + s[1:]
print(s)
elif order == 'L':
if s[0].islower():
print(s)
else:
s = s[0].lower() + s[1:]
print(s)
else:
index = []
c = 0
for i in range(len(s[1:])):
if s[i+1].isupper():
index.append(i + 1+c)
c += 1
for j in index:
s = s[: j] + '_' + s[j:]
print(s.lower())
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
Submitted Solution:
```
import re
while True:
c, t = input().split()
if t == "X":
break
if t == "U":
if "_" in c:
tmp = c.split("_")
hoge = ""
for t in tmp:
hoge += t[0].upper() + t[1:]
c = hoge
else:
c = c[0].upper() + c[1:]
elif t == "L":
if "_" in c:
tmp = c.split("_")
flag = True if len(tmp) > 1 else False
hoge = ""
for t in tmp:
hoge += t[0].upper() + t[1:]
if flag:
hoge = hoge[0].lower() + hoge[1:]
c = hoge
else:
c = c[0].lower() + c[1:]
else:
tmp = re.findall('[a-zA-Z][a-z]+', c)
hoge = ""
for t in tmp:
hoge += t[0].lower() + t[1:] + "_"
c = hoge[:-1]
print(c)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upper CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word.
Example: GetUserName
* Set to Lower CamelCase
Connect words directly to form a compound word, and capitalize only the first letter of each word. However, the first letter of the compound word should be lowercase.
Example: getUserName
* Connect with underscore
Words are concatenated with underscores to form a compound word. Make all letters of the word lowercase.
Example: get_user_name
Create a program that outputs the given identifier by applying the specified naming convention. It is assumed that any of the above naming conventions has already been applied to the identifier given.
Input
Multiple datasets are given as input. Each dataset is given in the following format:
name type (identifier, naming convention: space-separated strings and characters)
type is a character indicating the naming convention and is as shown in the table below:
type | Naming convention
--- | ---
U | Upper CamelCase
L | Lower CamelCase
D | Connect with underscore
The number of characters in the given identifier is 1 or more and 100 or less.
End of input when type is'X'. Do not output to this input.
Output
For each dataset, print the identifier with the naming convention on one line.
Example
Input
get_user_name L
getUserName U
GetUserName D
EndOfInput X
Output
getUserName
GetUserName
get_user_name
Submitted Solution:
```
import re
while True:
c, t = input().split()
if t == "X":
break
if t == "U":
if "_" in c:
tmp = c.split("_")
hoge = ""
for t in tmp:
hoge += t[0].upper() + t[1:]
c = hoge
else:
c = c[0].upper() + c[1:]
elif t == "L":
if "_" in c:
tmp = c.split("_")
flag = True if len(tmp) > 1 else False
hoge = ""
for t in tmp:
hoge += t[0].upper() + t[1:]
if flag:
hoge = hoge[0].lower() + hoge[1:]
c = hoge
else:
if re.match('[A-Z]', c):
c = c[0].lower() + c[1:]
else:
c = c[0].upper() + c[1:]
else:
tmp = re.findall('[a-zA-Z][a-z]+', c)
hoge = ""
for t in tmp:
hoge += t[0].lower() + t[1:] + "_"
c = hoge[:-1]
print(c)
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listening to "The White Buttons" and their hit song "Dacan the Baker", he met another robot for whom he was sure is the love of his life. Well, his summer, at least. Anyway, R3D3 was too shy to approach his potential soulmate, so he decided to write her a love letter. However, he stumbled upon a problem. Due to a terrorist threat, the Intergalactic Space Police was monitoring all letters sent in the area. Thus, R3D3 decided to invent his own alphabet, for which he was sure his love would be able to decipher.
There are n letters in R3D3’s alphabet, and he wants to represent each letter as a sequence of '0' and '1', so that no letter’s sequence is a prefix of another letter's sequence. Since the Intergalactic Space Communications Service has lately introduced a tax for invented alphabets, R3D3 must pay a certain amount of money for each bit in his alphabet’s code (check the sample test for clarifications). He is too lovestruck to think clearly, so he asked you for help.
Given the costs c0 and c1 for each '0' and '1' in R3D3’s alphabet, respectively, you should come up with a coding for the alphabet (with properties as above) with minimum total cost.
Input
The first line of input contains three integers n (2 ≤ n ≤ 108), c0 and c1 (0 ≤ c0, c1 ≤ 108) — the number of letters in the alphabet, and costs of '0' and '1', respectively.
Output
Output a single integer — minimum possible total a cost of the whole alphabet.
Example
Input
4 1 2
Output
12
Note
There are 4 letters in the alphabet. The optimal encoding is "00", "01", "10", "11". There are 4 zeroes and 4 ones used, so the total cost is 4·1 + 4·2 = 12.
Submitted Solution:
```
import math
k,l,r=map(int,input().split())
print('%g'%(math.factorial(k)/2**(r-l)))
```
### Response:
| No |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length n which satisfies the following requirements:
* There is at least one digit in the string,
* There is at least one lowercase (small) letter of the Latin alphabet in the string,
* There is at least one of three listed symbols in the string: '#', '*', '&'.
<image>
Considering that these are programming classes it is not easy to write the password.
For each character of the password we have a fixed string of length m, on each of these n strings there is a pointer on some character. The i-th character displayed on the screen is the pointed character in the i-th string. Initially, all pointers are on characters with indexes 1 in the corresponding strings (all positions are numbered starting from one).
During one operation Dasha can move a pointer in one string one character to the left or to the right. Strings are cyclic, it means that when we move the pointer which is on the character with index 1 to the left, it moves to the character with the index m, and when we move it to the right from the position m it moves to the position 1.
You need to determine the minimum number of operations necessary to make the string displayed on the screen a valid password.
Input
The first line contains two integers n, m (3 ≤ n ≤ 50, 1 ≤ m ≤ 50) — the length of the password and the length of strings which are assigned to password symbols.
Each of the next n lines contains the string which is assigned to the i-th symbol of the password string. Its length is m, it consists of digits, lowercase English letters, and characters '#', '*' or '&'.
You have such input data that you can always get a valid password.
Output
Print one integer — the minimum number of operations which is necessary to make the string, which is displayed on the screen, a valid password.
Examples
Input
3 4
1**2
a3*0
c4**
Output
1
Input
5 5
#*&#*
*a1c&
&q2w*
#a3c#
*&#*&
Output
3
Note
In the first test it is necessary to move the pointer of the third string to one left to get the optimal answer.
<image>
In the second test one of possible algorithms will be:
* to move the pointer of the second symbol once to the right.
* to move the pointer of the third symbol twice to the right.
<image>
Submitted Solution:
```
import math, sys, itertools
alpha = list('abcdefghijklmnopqrstuvwxyz')
digit = list('1234567890')
spec = ['*', '&', '#']
def find(s):
dpos = 10000
apos = 10000
spos = 10000
m = len(s)
for i in range(len(s)):
if s[i] in alpha:
if apos>min(m-i,i):
apos = min(m-i,i)
if s[i] in digit:
if dpos>min(m-i,i):
dpos = min(m-i,i)
if s[i] in spec:
if spos>min(m-i,i):
spos = min(m-i,i)
return apos, dpos, spos
def main():
n,m = map(int, input().split())
st = []
for i in range(n):
st.append(input())
al = []
dig = []
spec = []
for i in range(n):
a, d, s = (find(st[i]))
al.append(a)
dig.append(d)
spec.append(s)
sumn = 10000
for a in range(n):
for d in range(n):
for s in range(n):
if a!=d!=s:
if sumn>al[a]+dig[d]+spec[s]:
sumn = al[a]+dig[d]+spec[s]
print(sumn)
if __name__=="__main__":
main()
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length n which satisfies the following requirements:
* There is at least one digit in the string,
* There is at least one lowercase (small) letter of the Latin alphabet in the string,
* There is at least one of three listed symbols in the string: '#', '*', '&'.
<image>
Considering that these are programming classes it is not easy to write the password.
For each character of the password we have a fixed string of length m, on each of these n strings there is a pointer on some character. The i-th character displayed on the screen is the pointed character in the i-th string. Initially, all pointers are on characters with indexes 1 in the corresponding strings (all positions are numbered starting from one).
During one operation Dasha can move a pointer in one string one character to the left or to the right. Strings are cyclic, it means that when we move the pointer which is on the character with index 1 to the left, it moves to the character with the index m, and when we move it to the right from the position m it moves to the position 1.
You need to determine the minimum number of operations necessary to make the string displayed on the screen a valid password.
Input
The first line contains two integers n, m (3 ≤ n ≤ 50, 1 ≤ m ≤ 50) — the length of the password and the length of strings which are assigned to password symbols.
Each of the next n lines contains the string which is assigned to the i-th symbol of the password string. Its length is m, it consists of digits, lowercase English letters, and characters '#', '*' or '&'.
You have such input data that you can always get a valid password.
Output
Print one integer — the minimum number of operations which is necessary to make the string, which is displayed on the screen, a valid password.
Examples
Input
3 4
1**2
a3*0
c4**
Output
1
Input
5 5
#*&#*
*a1c&
&q2w*
#a3c#
*&#*&
Output
3
Note
In the first test it is necessary to move the pointer of the third string to one left to get the optimal answer.
<image>
In the second test one of possible algorithms will be:
* to move the pointer of the second symbol once to the right.
* to move the pointer of the third symbol twice to the right.
<image>
Submitted Solution:
```
from sys import stdin, exit, setrecursionlimit
from collections import deque
from string import ascii_lowercase
from itertools import *
from math import *
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()
mod = 10**9+7
n, m = mi()
s = [si() for i in range(n)]
alle = []
for i in range(n):
e = [float("inf"), float("inf"), float("inf")]
for j in range(m):
if s[i][j] in "1234567890":
e[0] = min(e[0], j)
elif s[i][j] in ascii_lowercase:
e[1] = min(e[1], j)
elif s[i][j] in "#*&":
e[2] = min(e[2], j)
cnt = 0
for j in range(0, -m, -1):
if s[i][j] in "1234567890":
e[0] = min(e[0], cnt)
elif s[i][j] in ascii_lowercase:
e[1] = min(e[1], cnt)
elif s[i][j] in "#*&":
e[2] = min(e[2], cnt)
cnt += 1
alle.append(e)
ans = float("inf")
for i in range(n):
for j in range(n):
if i == j: continue
for k in range(n):
if k == i or k == j:
continue
ans = min(alle[i][0] + alle[j][1] + alle[k][2], ans)
print(ans)
```
### Response:
| Yes |
### Instruction:
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length n which satisfies the following requirements:
* There is at least one digit in the string,
* There is at least one lowercase (small) letter of the Latin alphabet in the string,
* There is at least one of three listed symbols in the string: '#', '*', '&'.
<image>
Considering that these are programming classes it is not easy to write the password.
For each character of the password we have a fixed string of length m, on each of these n strings there is a pointer on some character. The i-th character displayed on the screen is the pointed character in the i-th string. Initially, all pointers are on characters with indexes 1 in the corresponding strings (all positions are numbered starting from one).
During one operation Dasha can move a pointer in one string one character to the left or to the right. Strings are cyclic, it means that when we move the pointer which is on the character with index 1 to the left, it moves to the character with the index m, and when we move it to the right from the position m it moves to the position 1.
You need to determine the minimum number of operations necessary to make the string displayed on the screen a valid password.
Input
The first line contains two integers n, m (3 ≤ n ≤ 50, 1 ≤ m ≤ 50) — the length of the password and the length of strings which are assigned to password symbols.
Each of the next n lines contains the string which is assigned to the i-th symbol of the password string. Its length is m, it consists of digits, lowercase English letters, and characters '#', '*' or '&'.
You have such input data that you can always get a valid password.
Output
Print one integer — the minimum number of operations which is necessary to make the string, which is displayed on the screen, a valid password.
Examples
Input
3 4
1**2
a3*0
c4**
Output
1
Input
5 5
#*&#*
*a1c&
&q2w*
#a3c#
*&#*&
Output
3
Note
In the first test it is necessary to move the pointer of the third string to one left to get the optimal answer.
<image>
In the second test one of possible algorithms will be:
* to move the pointer of the second symbol once to the right.
* to move the pointer of the third symbol twice to the right.
<image>
Submitted Solution:
```
def func(s):
a = 100000
for i in range(len(s)+1):
if(i==len(s)):
i = 100000
break
if(s[i].isalpha()):
break
for j in range(len(s)+1):
if(j==len(s)):
j = 100000
break
if(s[-j].isalpha()):
break
a = min(i, j)
b = 100000
for i in range(len(s)+1):
if(i==len(s)):
i = 100000
break
try:
n = int(s[i])
break
except:
continue
for j in range(len(s)+1):
if(j==len(s)):
j = 100000
break
try:
n = int(s[-j])
break
except:
continue
b = min(i, j)
c = 100000
for i in range(len(s)+1):
if(i==len(s)):
i = 100000
break
if(s[i]=='#' or s[i]=='&' or s[i]=='*'):
break
for j in range(len(s)+1):
if(j==len(s)):
j = 100000
break
if(s[-j]=='#' or s[-j]=='&' or s[-j]=='*'):
break
c = min(i, j)
return [a, b, c]
n, m = map(int, input().split())
x = []
for i in range(n):
s = input()
x += [func(s)]
mn = 1000000
for i in range(n):
for j in range(i+1, n):
for k in range(j+1, n):
a = x[i]
b = x[j]
c = x[k]
mn = min([mn, a[0]+b[1]+c[2], a[0]+b[2]+c[1], a[1]+b[0]+c[2], a[1]+b[2]+c[0], a[2]+b[1]+c[0], a[2]+b[0]+c[1]])
print(mn)
```
### Response:
| Yes |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.