message stringlengths 2 23.4k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 129 108k | cluster float64 6 6 | __index_level_0__ int64 258 216k |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
A: Alphabet block
Wakana Nakawa loves palindromes. Because my name is also a palindrome.
Wakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each block, and you can create your favorite character string by changing the order of the blocks and combining them. Wakana is wondering if she can make a palindrome with this set.
The following three types of operations are possible in the set of alphabet blocks, and the cost of each operation is 1.
1. Add one alphabet block (any letter is listed)
2. Change one alphabet block you have to another block (whatever the letters are listed)
3. Delete one alphabet block you currently have
I want to make a set that can be rearranged into palindromes by operating the set of alphabet blocks several times. What is the minimum cost of such an operation? Let's think with Wakana-chan.
Input
The input consists of one line of the string S that points to the information in the first set of alphabet blocks.
S consists of lowercase letters only and satisfies 1 \ leq | S | \ leq 10 ^ 3.
Output
Output the minimum cost for creating a palindrome. Don't forget the newline at the end.
Sample Input 1
hcpc
Sample Output 1
1
In this case, a palindrome can be created at a cost of 1, but multiple methods are possible. For example, if you add a block of'h', you can make a'hcpch', so you can make a palindrome at a cost of 1. Also, if you delete the block of'h', you can make'cpc', so you can make a palindrome with this method at cost 1.
Sample Input 2
ritscamp
Sample Output 2
Four
Sample Input 3
nakawawakana
Sample Output 3
0
If you can create a palindrome from scratch, the cost is zero.
Example
Input
hcpc
Output
1 | instruction | 0 | 100,289 | 6 | 200,578 |
"Correct Solution:
```
# AOJ 2816: Alphabet Block
# Python3 2018.7.11 bal4u
dic = {}
S = list(input())
for s in S:
if s not in dic: dic[s] = 1
else: dic[s] += 1
ans = 0
for k in list(dic.keys()):
if dic[k] & 1: ans += 1
print(ans>>1)
``` | output | 1 | 100,289 | 6 | 200,579 |
Provide a correct Python 3 solution for this coding contest problem.
A: Alphabet block
Wakana Nakawa loves palindromes. Because my name is also a palindrome.
Wakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each block, and you can create your favorite character string by changing the order of the blocks and combining them. Wakana is wondering if she can make a palindrome with this set.
The following three types of operations are possible in the set of alphabet blocks, and the cost of each operation is 1.
1. Add one alphabet block (any letter is listed)
2. Change one alphabet block you have to another block (whatever the letters are listed)
3. Delete one alphabet block you currently have
I want to make a set that can be rearranged into palindromes by operating the set of alphabet blocks several times. What is the minimum cost of such an operation? Let's think with Wakana-chan.
Input
The input consists of one line of the string S that points to the information in the first set of alphabet blocks.
S consists of lowercase letters only and satisfies 1 \ leq | S | \ leq 10 ^ 3.
Output
Output the minimum cost for creating a palindrome. Don't forget the newline at the end.
Sample Input 1
hcpc
Sample Output 1
1
In this case, a palindrome can be created at a cost of 1, but multiple methods are possible. For example, if you add a block of'h', you can make a'hcpch', so you can make a palindrome at a cost of 1. Also, if you delete the block of'h', you can make'cpc', so you can make a palindrome with this method at cost 1.
Sample Input 2
ritscamp
Sample Output 2
Four
Sample Input 3
nakawawakana
Sample Output 3
0
If you can create a palindrome from scratch, the cost is zero.
Example
Input
hcpc
Output
1 | instruction | 0 | 100,290 | 6 | 200,580 |
"Correct Solution:
```
import collections
print(sum([v%2 for v in collections.Counter(input()).values()])//2)
``` | output | 1 | 100,290 | 6 | 200,581 |
Provide a correct Python 3 solution for this coding contest problem.
A: Alphabet block
Wakana Nakawa loves palindromes. Because my name is also a palindrome.
Wakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each block, and you can create your favorite character string by changing the order of the blocks and combining them. Wakana is wondering if she can make a palindrome with this set.
The following three types of operations are possible in the set of alphabet blocks, and the cost of each operation is 1.
1. Add one alphabet block (any letter is listed)
2. Change one alphabet block you have to another block (whatever the letters are listed)
3. Delete one alphabet block you currently have
I want to make a set that can be rearranged into palindromes by operating the set of alphabet blocks several times. What is the minimum cost of such an operation? Let's think with Wakana-chan.
Input
The input consists of one line of the string S that points to the information in the first set of alphabet blocks.
S consists of lowercase letters only and satisfies 1 \ leq | S | \ leq 10 ^ 3.
Output
Output the minimum cost for creating a palindrome. Don't forget the newline at the end.
Sample Input 1
hcpc
Sample Output 1
1
In this case, a palindrome can be created at a cost of 1, but multiple methods are possible. For example, if you add a block of'h', you can make a'hcpch', so you can make a palindrome at a cost of 1. Also, if you delete the block of'h', you can make'cpc', so you can make a palindrome with this method at cost 1.
Sample Input 2
ritscamp
Sample Output 2
Four
Sample Input 3
nakawawakana
Sample Output 3
0
If you can create a palindrome from scratch, the cost is zero.
Example
Input
hcpc
Output
1 | instruction | 0 | 100,291 | 6 | 200,582 |
"Correct Solution:
```
s=input()
cnt=[0 for _ in[0]*26]
for c in s:
cnt[ord(c)-ord('a')]+=1
odd=0
for i in range(26):
if cnt[i] & 1:
odd+=1
print((odd>>1))
``` | output | 1 | 100,291 | 6 | 200,583 |
Provide a correct Python 3 solution for this coding contest problem.
A: Alphabet block
Wakana Nakawa loves palindromes. Because my name is also a palindrome.
Wakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each block, and you can create your favorite character string by changing the order of the blocks and combining them. Wakana is wondering if she can make a palindrome with this set.
The following three types of operations are possible in the set of alphabet blocks, and the cost of each operation is 1.
1. Add one alphabet block (any letter is listed)
2. Change one alphabet block you have to another block (whatever the letters are listed)
3. Delete one alphabet block you currently have
I want to make a set that can be rearranged into palindromes by operating the set of alphabet blocks several times. What is the minimum cost of such an operation? Let's think with Wakana-chan.
Input
The input consists of one line of the string S that points to the information in the first set of alphabet blocks.
S consists of lowercase letters only and satisfies 1 \ leq | S | \ leq 10 ^ 3.
Output
Output the minimum cost for creating a palindrome. Don't forget the newline at the end.
Sample Input 1
hcpc
Sample Output 1
1
In this case, a palindrome can be created at a cost of 1, but multiple methods are possible. For example, if you add a block of'h', you can make a'hcpch', so you can make a palindrome at a cost of 1. Also, if you delete the block of'h', you can make'cpc', so you can make a palindrome with this method at cost 1.
Sample Input 2
ritscamp
Sample Output 2
Four
Sample Input 3
nakawawakana
Sample Output 3
0
If you can create a palindrome from scratch, the cost is zero.
Example
Input
hcpc
Output
1 | instruction | 0 | 100,292 | 6 | 200,584 |
"Correct Solution:
```
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
from collections import Counter
s = ns()
c = Counter(s)
ans = 0
for i in c.values():
if i%2 == 1:
ans += 1
print(ans//2)
``` | output | 1 | 100,292 | 6 | 200,585 |
Provide a correct Python 3 solution for this coding contest problem.
A: Alphabet block
Wakana Nakawa loves palindromes. Because my name is also a palindrome.
Wakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each block, and you can create your favorite character string by changing the order of the blocks and combining them. Wakana is wondering if she can make a palindrome with this set.
The following three types of operations are possible in the set of alphabet blocks, and the cost of each operation is 1.
1. Add one alphabet block (any letter is listed)
2. Change one alphabet block you have to another block (whatever the letters are listed)
3. Delete one alphabet block you currently have
I want to make a set that can be rearranged into palindromes by operating the set of alphabet blocks several times. What is the minimum cost of such an operation? Let's think with Wakana-chan.
Input
The input consists of one line of the string S that points to the information in the first set of alphabet blocks.
S consists of lowercase letters only and satisfies 1 \ leq | S | \ leq 10 ^ 3.
Output
Output the minimum cost for creating a palindrome. Don't forget the newline at the end.
Sample Input 1
hcpc
Sample Output 1
1
In this case, a palindrome can be created at a cost of 1, but multiple methods are possible. For example, if you add a block of'h', you can make a'hcpch', so you can make a palindrome at a cost of 1. Also, if you delete the block of'h', you can make'cpc', so you can make a palindrome with this method at cost 1.
Sample Input 2
ritscamp
Sample Output 2
Four
Sample Input 3
nakawawakana
Sample Output 3
0
If you can create a palindrome from scratch, the cost is zero.
Example
Input
hcpc
Output
1 | instruction | 0 | 100,293 | 6 | 200,586 |
"Correct Solution:
```
S = input()
dict = {}
for i in range(len(S)):
if(S[i] in dict):
dict[S[i]] += 1
else:
dict[S[i]] = 1
l = list(dict.values())
cnt = 0
for i in range(len(l)):
if(l[i] % 2 != 0):
cnt += 1
print(cnt // 2)
``` | output | 1 | 100,293 | 6 | 200,587 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A: Alphabet block
Wakana Nakawa loves palindromes. Because my name is also a palindrome.
Wakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each block, and you can create your favorite character string by changing the order of the blocks and combining them. Wakana is wondering if she can make a palindrome with this set.
The following three types of operations are possible in the set of alphabet blocks, and the cost of each operation is 1.
1. Add one alphabet block (any letter is listed)
2. Change one alphabet block you have to another block (whatever the letters are listed)
3. Delete one alphabet block you currently have
I want to make a set that can be rearranged into palindromes by operating the set of alphabet blocks several times. What is the minimum cost of such an operation? Let's think with Wakana-chan.
Input
The input consists of one line of the string S that points to the information in the first set of alphabet blocks.
S consists of lowercase letters only and satisfies 1 \ leq | S | \ leq 10 ^ 3.
Output
Output the minimum cost for creating a palindrome. Don't forget the newline at the end.
Sample Input 1
hcpc
Sample Output 1
1
In this case, a palindrome can be created at a cost of 1, but multiple methods are possible. For example, if you add a block of'h', you can make a'hcpch', so you can make a palindrome at a cost of 1. Also, if you delete the block of'h', you can make'cpc', so you can make a palindrome with this method at cost 1.
Sample Input 2
ritscamp
Sample Output 2
Four
Sample Input 3
nakawawakana
Sample Output 3
0
If you can create a palindrome from scratch, the cost is zero.
Example
Input
hcpc
Output
1
Submitted Solution:
```
# AOJ 2816: Alphabet Block
# Python3 2018.7.11 bal4u
dic = {}
S = list(input())
for s in S:
if s not in dic: dic[s] = 1
ans = 0
for k in list(dic.keys()):
if dic[k] & 1: ans += 1
print(ans>>1)
``` | instruction | 0 | 100,294 | 6 | 200,588 |
No | output | 1 | 100,294 | 6 | 200,589 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using movement of instruction pointer (IP) which consists of two parts.
* Current character pointer (CP);
* Direction pointer (DP) which can point left or right;
Initially CP points to the leftmost character of the sequence and DP points to the right.
We repeat the following steps until the first moment that CP points to somewhere outside the sequence.
* If CP is pointing to a digit the interpreter prints that digit then CP moves one step according to the direction of DP. After that the value of the printed digit in the sequence decreases by one. If the printed digit was 0 then it cannot be decreased therefore it's erased from the sequence and the length of the sequence decreases by one.
* If CP is pointing to "<" or ">" then the direction of DP changes to "left" or "right" correspondingly. Then CP moves one step according to DP. If the new character that CP is pointing to is "<" or ">" then the previous character will be erased from the sequence.
If at any moment the CP goes outside of the sequence the execution is terminated.
It's obvious the every program in this language terminates after some steps.
We have a sequence s1, s2, ..., sn of "<", ">" and digits. You should answer q queries. Each query gives you l and r and asks how many of each digit will be printed if we run the sequence sl, sl + 1, ..., sr as an independent program in this language.
Input
The first line of input contains two integers n and q (1 β€ n, q β€ 100) β represents the length of the sequence s and the number of queries.
The second line contains s, a sequence of "<", ">" and digits (0..9) written from left to right. Note, that the characters of s are not separated with spaces.
The next q lines each contains two integers li and ri (1 β€ li β€ ri β€ n) β the i-th query.
Output
For each query print 10 space separated integers: x0, x1, ..., x9 where xi equals the number of times the interpreter prints i while running the corresponding program. Print answers to the queries in the order they are given in input.
Examples
Input
7 4
1>3>22<
1 3
4 7
7 7
1 7
Output
0 1 0 1 0 0 0 0 0 0
2 2 2 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
2 3 2 1 0 0 0 0 0 0 | instruction | 0 | 100,626 | 6 | 201,252 |
Tags: brute force, implementation
Correct Solution:
```
n, q = map(int, input().split())
s = input()
for _ in range(q):
l, r = map(int, input().split())
t = list(s[l-1:r])
p, d = 0, 1
res = [0] * 10
while 0 <= p < len(t):
if '0' <= t[p] <= '9':
k = int(t[p])
res[k] += 1
if k > 0:
t[p] = str(k-1)
p += d
else:
t.pop(p)
if d == -1:
p += d
else:
d = -1 if t[p] == '<' else 1
if 0 <= p+d < len(t) and not ('0' <= t[p+d] <= '9'):
t.pop(p)
if d == -1:
p += d
else:
p += d
print(*res)
``` | output | 1 | 100,626 | 6 | 201,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a programming language in which every program is a non-empty sequence of "<" and ">" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using movement of instruction pointer (IP) which consists of two parts.
* Current character pointer (CP);
* Direction pointer (DP) which can point left or right;
Initially CP points to the leftmost character of the sequence and DP points to the right.
We repeat the following steps until the first moment that CP points to somewhere outside the sequence.
* If CP is pointing to a digit the interpreter prints that digit then CP moves one step according to the direction of DP. After that the value of the printed digit in the sequence decreases by one. If the printed digit was 0 then it cannot be decreased therefore it's erased from the sequence and the length of the sequence decreases by one.
* If CP is pointing to "<" or ">" then the direction of DP changes to "left" or "right" correspondingly. Then CP moves one step according to DP. If the new character that CP is pointing to is "<" or ">" then the previous character will be erased from the sequence.
If at any moment the CP goes outside of the sequence the execution is terminated.
It's obvious the every program in this language terminates after some steps.
We have a sequence s1, s2, ..., sn of "<", ">" and digits. You should answer q queries. Each query gives you l and r and asks how many of each digit will be printed if we run the sequence sl, sl + 1, ..., sr as an independent program in this language.
Input
The first line of input contains two integers n and q (1 β€ n, q β€ 100) β represents the length of the sequence s and the number of queries.
The second line contains s, a sequence of "<", ">" and digits (0..9) written from left to right. Note, that the characters of s are not separated with spaces.
The next q lines each contains two integers li and ri (1 β€ li β€ ri β€ n) β the i-th query.
Output
For each query print 10 space separated integers: x0, x1, ..., x9 where xi equals the number of times the interpreter prints i while running the corresponding program. Print answers to the queries in the order they are given in input.
Examples
Input
7 4
1>3>22<
1 3
4 7
7 7
1 7
Output
0 1 0 1 0 0 0 0 0 0
2 2 2 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
2 3 2 1 0 0 0 0 0 0 | instruction | 0 | 100,627 | 6 | 201,254 |
Tags: brute force, implementation
Correct Solution:
```
n,Q = map(int,input().strip().split())
s = input()
d = 1
for q in range(Q):
arr = [0]*(10)
l,r = map(int,input().strip().split())
su = ""
for i in range(l-1,r):
su+=s[i]
su = list(su)
i = 0
d = 1
#print(su)
ll = 0
while i<len(su) and i>=0:
if su[i].isdigit():
arr[int(su[i])]+=1
if su[i]=='0':
su = su[:i]+su[i+1:]
if d==1:
i-=1
else:
su[i] = str(int(su[i])-1)
if d==1:
i+=1
else:
i-=1;
ll = 0
else:
if su[i]=='>' or su[i]=='<':
if d==1 and i!=0 and ll == 1:
if su[i-1]=='>' or su[i-1]=='<':
su = su[:i-1]+su[i:]
i-=1
if d==0 and i!=n-1 and ll==1:
if su[i+1]=='>' or su[i+1]=='<' or su[i+1]=='-1':
su = su[:i+1]+su[i+2:]
if su[i]=='>':
d = 1
else:
d = 0
if d==0:
i-=1;
else:
i+=1
ll = 1
#print(su,i,d)
#print(arr)
#print(su)
print(*arr)
``` | output | 1 | 100,627 | 6 | 201,255 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.
In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 Γ 2 square, such that from the four letters of this square you can make word "face".
You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.
Input
The first line contains two space-separated integers, n and m (1 β€ n, m β€ 50) β the height and the width of the image, respectively.
Next n lines define the image. Each line contains m lowercase Latin letters.
Output
In the single line print the number of faces on the image.
Examples
Input
4 4
xxxx
xfax
xcex
xxxx
Output
1
Input
4 2
xx
cf
ae
xx
Output
1
Input
2 3
fac
cef
Output
2
Input
1 4
face
Output
0
Note
In the first sample the image contains a single face, located in a square with the upper left corner at the second line and the second column:
<image>
In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.
In the third sample two faces are shown:
<image>
In the fourth sample the image has no faces on it. | instruction | 0 | 100,720 | 6 | 201,440 |
Tags: implementation, strings
Correct Solution:
```
n,m=map(int,input().split(" "))
a=[input() for x in range(n)]
print(sum(sorted(a[x][y:y+2]+a[x+1][y:y+2])==sorted("face") for x in range(n-1) for y in range(m-1)))
``` | output | 1 | 100,720 | 6 | 201,441 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.
In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 Γ 2 square, such that from the four letters of this square you can make word "face".
You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.
Input
The first line contains two space-separated integers, n and m (1 β€ n, m β€ 50) β the height and the width of the image, respectively.
Next n lines define the image. Each line contains m lowercase Latin letters.
Output
In the single line print the number of faces on the image.
Examples
Input
4 4
xxxx
xfax
xcex
xxxx
Output
1
Input
4 2
xx
cf
ae
xx
Output
1
Input
2 3
fac
cef
Output
2
Input
1 4
face
Output
0
Note
In the first sample the image contains a single face, located in a square with the upper left corner at the second line and the second column:
<image>
In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.
In the third sample two faces are shown:
<image>
In the fourth sample the image has no faces on it. | instruction | 0 | 100,721 | 6 | 201,442 |
Tags: implementation, strings
Correct Solution:
```
n, m = map(int, input().split())
table = []
for i in range(n):
table.append(input())
ans = 0
for i in range(n - 1):
for j in range(m - 1):
di = [0, 0, 1, 1]
dj = [0, 1, 0, 1]
d = {}
for k in range(4):
c = table[i + di[k]][j + dj[k]]
d[c] = d.get(c, 0) + 1
flg = True
for c in "face":
if c not in d or d[c] != 1:
flg = False
if flg:
ans += 1
print(ans)
``` | output | 1 | 100,721 | 6 | 201,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.
In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 Γ 2 square, such that from the four letters of this square you can make word "face".
You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.
Input
The first line contains two space-separated integers, n and m (1 β€ n, m β€ 50) β the height and the width of the image, respectively.
Next n lines define the image. Each line contains m lowercase Latin letters.
Output
In the single line print the number of faces on the image.
Examples
Input
4 4
xxxx
xfax
xcex
xxxx
Output
1
Input
4 2
xx
cf
ae
xx
Output
1
Input
2 3
fac
cef
Output
2
Input
1 4
face
Output
0
Note
In the first sample the image contains a single face, located in a square with the upper left corner at the second line and the second column:
<image>
In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.
In the third sample two faces are shown:
<image>
In the fourth sample the image has no faces on it. | instruction | 0 | 100,722 | 6 | 201,444 |
Tags: implementation, strings
Correct Solution:
```
r, c = map(lambda x: int(x) ,input().split())
img = []
for i in range(r):
img.append([])
line = input()
for j in range(c):
img[i].append(line[j])
count=0
for i in range(r-1):
for j in range(c-1):
test = [img[i][j], img[i+1][j], img[i][j+1], img[i+1][j+1]]
if all([x in test for x in "face"]):
count +=1
print(count)
``` | output | 1 | 100,722 | 6 | 201,445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.
In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 Γ 2 square, such that from the four letters of this square you can make word "face".
You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.
Input
The first line contains two space-separated integers, n and m (1 β€ n, m β€ 50) β the height and the width of the image, respectively.
Next n lines define the image. Each line contains m lowercase Latin letters.
Output
In the single line print the number of faces on the image.
Examples
Input
4 4
xxxx
xfax
xcex
xxxx
Output
1
Input
4 2
xx
cf
ae
xx
Output
1
Input
2 3
fac
cef
Output
2
Input
1 4
face
Output
0
Note
In the first sample the image contains a single face, located in a square with the upper left corner at the second line and the second column:
<image>
In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.
In the third sample two faces are shown:
<image>
In the fourth sample the image has no faces on it. | instruction | 0 | 100,723 | 6 | 201,446 |
Tags: implementation, strings
Correct Solution:
```
x = list(map(int, input().split(' ')))
n, m = x[0], x[1]
a = []
for i in range(n):
a.append(input())
def check(x, y):
mp = set()
for i in range(x-1, x+1):
for j in range(y-1, y+1):
mp.add(a[i][j])
return ('f' in mp) and ('a' in mp) and ('c' in mp) and ('e' in mp)
k = 0
for i in range(1, n):
for j in range(1, m):
if check(i, j):
k += 1
print(k)
``` | output | 1 | 100,723 | 6 | 201,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.
In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 Γ 2 square, such that from the four letters of this square you can make word "face".
You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.
Input
The first line contains two space-separated integers, n and m (1 β€ n, m β€ 50) β the height and the width of the image, respectively.
Next n lines define the image. Each line contains m lowercase Latin letters.
Output
In the single line print the number of faces on the image.
Examples
Input
4 4
xxxx
xfax
xcex
xxxx
Output
1
Input
4 2
xx
cf
ae
xx
Output
1
Input
2 3
fac
cef
Output
2
Input
1 4
face
Output
0
Note
In the first sample the image contains a single face, located in a square with the upper left corner at the second line and the second column:
<image>
In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.
In the third sample two faces are shown:
<image>
In the fourth sample the image has no faces on it. | instruction | 0 | 100,724 | 6 | 201,448 |
Tags: implementation, strings
Correct Solution:
```
n,m = map(int,input().split())
a = []
c = 0
for i in range(n):
s = list(input())
a.append(s)
#print(a)
for i in range(m-1):
for j in range(n-1):
s = a[j][i] + a[j+1][i] + a[j][i+1] + a[j+1][i+1]
s = sorted(s)
s = ''.join(s)
#print(s)
if(s == "acef"):
c += 1
print(c)
``` | output | 1 | 100,724 | 6 | 201,449 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.
In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 Γ 2 square, such that from the four letters of this square you can make word "face".
You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.
Input
The first line contains two space-separated integers, n and m (1 β€ n, m β€ 50) β the height and the width of the image, respectively.
Next n lines define the image. Each line contains m lowercase Latin letters.
Output
In the single line print the number of faces on the image.
Examples
Input
4 4
xxxx
xfax
xcex
xxxx
Output
1
Input
4 2
xx
cf
ae
xx
Output
1
Input
2 3
fac
cef
Output
2
Input
1 4
face
Output
0
Note
In the first sample the image contains a single face, located in a square with the upper left corner at the second line and the second column:
<image>
In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.
In the third sample two faces are shown:
<image>
In the fourth sample the image has no faces on it. | instruction | 0 | 100,725 | 6 | 201,450 |
Tags: implementation, strings
Correct Solution:
```
n, m =map(int, input().split())
x=[]
for i in range(n):
x.append(input())
c = 0
for i in range(n-1):
for j in range(m-1):
k = [x[i][j], x[i+1][j], x[i][j+1], x[i+1][j+1]]
if ''.join(sorted(k)) == 'acef':
c += 1
print(c)
'''
iterate through all 2 by 2 squares to check face
'''
``` | output | 1 | 100,725 | 6 | 201,451 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.
In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 Γ 2 square, such that from the four letters of this square you can make word "face".
You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.
Input
The first line contains two space-separated integers, n and m (1 β€ n, m β€ 50) β the height and the width of the image, respectively.
Next n lines define the image. Each line contains m lowercase Latin letters.
Output
In the single line print the number of faces on the image.
Examples
Input
4 4
xxxx
xfax
xcex
xxxx
Output
1
Input
4 2
xx
cf
ae
xx
Output
1
Input
2 3
fac
cef
Output
2
Input
1 4
face
Output
0
Note
In the first sample the image contains a single face, located in a square with the upper left corner at the second line and the second column:
<image>
In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.
In the third sample two faces are shown:
<image>
In the fourth sample the image has no faces on it. | instruction | 0 | 100,726 | 6 | 201,452 |
Tags: implementation, strings
Correct Solution:
```
from sys import stdin
n, m = map(int, stdin.readline().split())
a = []
for i in range(0, n):
a.append(stdin.readline())
res = 0
for i in range(0, n - 1):
for j in range(0, m - 1):
r = [a[i][j], a[i][j + 1], a[i + 1][j], a[i + 1][j + 1]]
if "f" not in r:
continue
if "a" not in r:
continue
if "c" not in r:
continue
if "e" not in r:
continue
res += 1
print (res)
``` | output | 1 | 100,726 | 6 | 201,453 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them.
In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 Γ 2 square, such that from the four letters of this square you can make word "face".
You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.
Input
The first line contains two space-separated integers, n and m (1 β€ n, m β€ 50) β the height and the width of the image, respectively.
Next n lines define the image. Each line contains m lowercase Latin letters.
Output
In the single line print the number of faces on the image.
Examples
Input
4 4
xxxx
xfax
xcex
xxxx
Output
1
Input
4 2
xx
cf
ae
xx
Output
1
Input
2 3
fac
cef
Output
2
Input
1 4
face
Output
0
Note
In the first sample the image contains a single face, located in a square with the upper left corner at the second line and the second column:
<image>
In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.
In the third sample two faces are shown:
<image>
In the fourth sample the image has no faces on it. | instruction | 0 | 100,727 | 6 | 201,454 |
Tags: implementation, strings
Correct Solution:
```
n, m = (int(x) for x in input().split())
a = []
for i in range(n):
a.append(input().strip())
ans = 0
for i in range(n-1):
for j in range(m-1):
if sorted([a[i][j], a[i+1][j], a[i][j+1], a[i+1][j+1]]) == sorted(['f', 'a', 'c', 'e']):
ans += 1
print(ans)
``` | output | 1 | 100,727 | 6 | 201,455 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
Input
The first line contains two integers n and m (1 β€ n, m β€ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 β€ l β€ r β€ n, c1, c2 are lowercase English letters), separated by space.
Output
Output string s after performing m operations described above.
Examples
Input
3 1
ioi
1 1 i n
Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
Output
gaaak
Note
For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak. | instruction | 0 | 100,870 | 6 | 201,740 |
Tags: implementation
Correct Solution:
```
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *
class Scanner():
@staticmethod
def int():
return int(sys.stdin.readline().rstrip())
@staticmethod
def string():
return sys.stdin.readline().rstrip()
@staticmethod
def map_int():
return [int(x) for x in Scanner.string().split()]
@staticmethod
def string_list(n):
return [input() for i in range(n)]
@staticmethod
def int_list_list(n):
return [Scanner.map_int() for i in range(n)]
@staticmethod
def int_cols_list(n):
return [int(input()) for i in range(n)]
class Math():
@staticmethod
def gcd(a, b):
if b == 0:
return a
return Math.gcd(b, a % b)
@staticmethod
def lcm(a, b):
return (a * b) // Math.gcd(a, b)
@staticmethod
def divisor(n):
res = []
i = 1
for i in range(1, int(n ** 0.5) + 1):
if n % i == 0:
res.append(i)
if i != n // i:
res.append(n // i)
return res
@staticmethod
def round_up(a, b):
return -(-a // b)
@staticmethod
def is_prime(n):
if n < 2:
return False
if n == 2:
return True
if n % 2 == 0:
return False
d = int(n ** 0.5) + 1
for i in range(3, d + 1, 2):
if n % i == 0:
return False
return True
def pop_count(x):
x = x - ((x >> 1) & 0x5555555555555555)
x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
x = x + (x >> 8)
x = x + (x >> 16)
x = x + (x >> 32)
return x & 0x0000007f
MOD = int(1e09) + 7
INF = int(1e15)
def solve():
N, M = Scanner.map_int()
S = Scanner.string()
for _ in range(M):
l, r, c, d = Scanner.string().split()
l = int(l) - 1
r = int(r) - 1
T = list(S)
for i in range(l, r + 1):
if T[i] == c:
T[i] = d
S = ''.join(T)
print(S)
def main():
# sys.stdin = open("sample.txt")
solve()
if __name__ == "__main__":
main()
``` | output | 1 | 100,870 | 6 | 201,741 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
Input
The first line contains two integers n and m (1 β€ n, m β€ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 β€ l β€ r β€ n, c1, c2 are lowercase English letters), separated by space.
Output
Output string s after performing m operations described above.
Examples
Input
3 1
ioi
1 1 i n
Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
Output
gaaak
Note
For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak. | instruction | 0 | 100,871 | 6 | 201,742 |
Tags: implementation
Correct Solution:
```
import re
n,m=list(map(int,input().split()))
s=input()
for _ in range(m):
l,r,a,b=input().strip().split()
l,r=int(l),int(r)
s=s[:l-1]+re.sub(a,b,s[l-1:r])+s[r:]
print(s)
``` | output | 1 | 100,871 | 6 | 201,743 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
Input
The first line contains two integers n and m (1 β€ n, m β€ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 β€ l β€ r β€ n, c1, c2 are lowercase English letters), separated by space.
Output
Output string s after performing m operations described above.
Examples
Input
3 1
ioi
1 1 i n
Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
Output
gaaak
Note
For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak. | instruction | 0 | 100,872 | 6 | 201,744 |
Tags: implementation
Correct Solution:
```
n,m=list(map(int,input().split()))
z=list(input())
for i in range(m):
l,r,c1,c2=input().split()
l=int(l)
r=int(r)
for i in range(l-1,r):
if z[i]==c1:
z[i]=c2
print("".join(z))
``` | output | 1 | 100,872 | 6 | 201,745 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
Input
The first line contains two integers n and m (1 β€ n, m β€ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 β€ l β€ r β€ n, c1, c2 are lowercase English letters), separated by space.
Output
Output string s after performing m operations described above.
Examples
Input
3 1
ioi
1 1 i n
Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
Output
gaaak
Note
For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak. | instruction | 0 | 100,873 | 6 | 201,746 |
Tags: implementation
Correct Solution:
```
n, m = map(int, input().split())
s = input()
for _ in range(m):
l, r, c1, c2 = input().split()
for i in range(int(l)-1, int(r)):
if s[i]==c1:
s=s[:i]+c2+s[i+1:]
print(s)
``` | output | 1 | 100,873 | 6 | 201,747 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
Input
The first line contains two integers n and m (1 β€ n, m β€ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 β€ l β€ r β€ n, c1, c2 are lowercase English letters), separated by space.
Output
Output string s after performing m operations described above.
Examples
Input
3 1
ioi
1 1 i n
Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
Output
gaaak
Note
For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak. | instruction | 0 | 100,874 | 6 | 201,748 |
Tags: implementation
Correct Solution:
```
n,m = map(int,input().split())
k = list(input())
for i in range(m):
l = input().split()
for j in range(int(l[0])-1,int(l[1])):
if k[j]==l[2]:
k[j]=l[3]
f = ''.join(k)
print(f)
``` | output | 1 | 100,874 | 6 | 201,749 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
Input
The first line contains two integers n and m (1 β€ n, m β€ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 β€ l β€ r β€ n, c1, c2 are lowercase English letters), separated by space.
Output
Output string s after performing m operations described above.
Examples
Input
3 1
ioi
1 1 i n
Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
Output
gaaak
Note
For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak. | instruction | 0 | 100,875 | 6 | 201,750 |
Tags: implementation
Correct Solution:
```
#Codeforce 897A
n,m = (int(v) for v in input().split())
x=[v for v in input().strip("\n\r")]
ans=""
for i in range(m):
l,r,c_1,c_2 = (v for v in input().split())
for j in range(int(l)-1,int(r)):
if x[j] == c_1:
x[j] = c_2
else:
pass
for k in range(len(x)):
ans+=x[k]
print(ans)
``` | output | 1 | 100,875 | 6 | 201,751 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
Input
The first line contains two integers n and m (1 β€ n, m β€ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 β€ l β€ r β€ n, c1, c2 are lowercase English letters), separated by space.
Output
Output string s after performing m operations described above.
Examples
Input
3 1
ioi
1 1 i n
Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
Output
gaaak
Note
For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak. | instruction | 0 | 100,876 | 6 | 201,752 |
Tags: implementation
Correct Solution:
```
n, m = map(int, input().split())
string = list(input())
for i in range(m):
a, b, x, y = input().split()
a = int(a)
b = int(b)
for j in range(a - 1, b):
if string[j] == x:
string[j] = y
print("".join(string))
``` | output | 1 | 100,876 | 6 | 201,753 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
Input
The first line contains two integers n and m (1 β€ n, m β€ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 β€ l β€ r β€ n, c1, c2 are lowercase English letters), separated by space.
Output
Output string s after performing m operations described above.
Examples
Input
3 1
ioi
1 1 i n
Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
Output
gaaak
Note
For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak. | instruction | 0 | 100,877 | 6 | 201,754 |
Tags: implementation
Correct Solution:
```
import bisect
def list_output(s):
print(' '.join(map(str, s)))
def list_input(s='int'):
if s == 'int':
return list(map(int, input().split()))
elif s == 'float':
return list(map(float, input().split()))
return list(map(str, input().split()))
[n, m] = list(map(int, input().split()))
s = list(input())
for _ in range(m):
[l, r, c1, c2] = list(input().split())
l = int(l)
r = int(r)
l -= 1
r -= 1
for i in range(l, r+1):
if s[i] == c1:
s[i] = c2
print(''.join(map(str, s)))
``` | output | 1 | 100,877 | 6 | 201,755 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
Input
The first line contains two integers n and m (1 β€ n, m β€ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 β€ l β€ r β€ n, c1, c2 are lowercase English letters), separated by space.
Output
Output string s after performing m operations described above.
Examples
Input
3 1
ioi
1 1 i n
Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
Output
gaaak
Note
For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak.
Submitted Solution:
```
x,y=[int(i) for i in input().split()]
s=input()
o=[]
for i in range(x):
o.append(s[i])
for i in range(y):
p=input().split()
l=int(p[0])
r=int(p[1])
c1=p[2]
c2=p[3]
if l!=r:
for i in range(l-1,r):
if o[i]==c1:
o.pop(i)
o.insert(i,c2)
else:
if o[l-1]==c1:
o.pop(l-1)
o.insert(l-1,c2)
print("".join(o))
``` | instruction | 0 | 100,881 | 6 | 201,762 |
Yes | output | 1 | 100,881 | 6 | 201,763 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Are you going to Scarborough Fair?
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
Input
The first line contains two integers n and m (1 β€ n, m β€ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 β€ l β€ r β€ n, c1, c2 are lowercase English letters), separated by space.
Output
Output string s after performing m operations described above.
Examples
Input
3 1
ioi
1 1 i n
Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
Output
gaaak
Note
For the second example:
After the first operation, the string is wxxak.
After the second operation, the string is waaak.
After the third operation, the string is gaaak.
Submitted Solution:
```
class scarBoroughFair:
def __init__(self, n, m):
self.n = n
self.m = m
self.directions(self.n, self.m)
def directions(self, n, m):
str1 = input()
str2 = ""
list1 = list(str1)
if(len(str1) == n):
pass
else:
exit()
for x in range(0, m):
l, r, c1, c2 = map(str, input().split())
for x in range(0, int(r)):
if(c1 == str1[x]):
list1[x] = c2
str1 = ''.join(list1)
print(str1)
n,m = map(int,input().split())
scarBoroughFairObj = scarBoroughFair(n, m)
``` | instruction | 0 | 100,882 | 6 | 201,764 |
No | output | 1 | 100,882 | 6 | 201,765 |
Provide tags and a correct Python 3 solution for this coding contest problem.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | instruction | 0 | 101,384 | 6 | 202,768 |
Tags: implementation, sortings, strings
Correct Solution:
```
a = input
if(sorted(a()+a())==sorted(a())):
print("YES")
else:
print("NO")
``` | output | 1 | 101,384 | 6 | 202,769 |
Provide tags and a correct Python 3 solution for this coding contest problem.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | instruction | 0 | 101,385 | 6 | 202,770 |
Tags: implementation, sortings, strings
Correct Solution:
```
a=list(input())
b=list(input())
s=a+b
s.sort()
s=' '.join(s)
f=list(input())
f.sort()
f=' '.join(f)
if s==f:
print('YES')
else :
print('NO')
``` | output | 1 | 101,385 | 6 | 202,771 |
Provide tags and a correct Python 3 solution for this coding contest problem.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | instruction | 0 | 101,386 | 6 | 202,772 |
Tags: implementation, sortings, strings
Correct Solution:
```
g=list(str(i) for i in input())
h=list(str(i) for i in input())
m=list(str(i) for i in input())
g.extend(h)
m.sort()
g.sort()
if m==g:
print("YES")
else:
print("NO")
``` | output | 1 | 101,386 | 6 | 202,773 |
Provide tags and a correct Python 3 solution for this coding contest problem.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | instruction | 0 | 101,387 | 6 | 202,774 |
Tags: implementation, sortings, strings
Correct Solution:
```
s=input()+input();t=input()
print('YES' if sorted(s)==sorted(t) else 'NO')
``` | output | 1 | 101,387 | 6 | 202,775 |
Provide tags and a correct Python 3 solution for this coding contest problem.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | instruction | 0 | 101,388 | 6 | 202,776 |
Tags: implementation, sortings, strings
Correct Solution:
```
am=input()
bm=input()
cm=input()
a=[]
b=[]
c=[]
for i in range(len(am)):
a.append(am[i])
for i in range(len(bm)):
b.append(bm[i])
for i in range(len(cm)):
c.append(cm[i])
bo=0
for i in range(len(a)):
if a[i] in c:
c.remove(a[i])
else:
bo=1
for i in range(len(b)):
if b[i] in c:
c.remove(b[i])
else:
bo=1
if bo==0 and len(am)+len(bm)==len(cm):
print('YES')
else:
print('NO')
``` | output | 1 | 101,388 | 6 | 202,777 |
Provide tags and a correct Python 3 solution for this coding contest problem.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | instruction | 0 | 101,389 | 6 | 202,778 |
Tags: implementation, sortings, strings
Correct Solution:
```
q=input()
w=input()
e=input()
r=q+w
if len(e)!=len(w+q):
print('NO')
else:
for i in set(r):
if r.count(i)!=e.count(i):
print('NO')
break
else:
print('YES')
``` | output | 1 | 101,389 | 6 | 202,779 |
Provide tags and a correct Python 3 solution for this coding contest problem.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | instruction | 0 | 101,390 | 6 | 202,780 |
Tags: implementation, sortings, strings
Correct Solution:
```
n = input()
m = input()
b = input()
n1 = n
m1 = m
b1 =b
k=0
for i in range(len(n)):
for j in range(len(b)):
if n[i]==b[j]:
n1 = b[j]
b = b.replace(n[i], "0", 1)
n = n.replace(n1,"0",1)
for i in range(len(m)):
for j in range(len(b)):
if m[i]==b[j]:
m1 = b[j]
b = b.replace(m[i], "0", 1)
m = m.replace(m1,"0",1)
l=0
h=0
for i in b:
if i == "0":
k+=1
for i in m:
if i == "0":
l+=1
for i in n:
if i == "0":
h+=1
if k==len(b) and l==len(m) and h==len(n):
print("YES")
else:
print("NO")
``` | output | 1 | 101,390 | 6 | 202,781 |
Provide tags and a correct Python 3 solution for this coding contest problem.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L". | instruction | 0 | 101,391 | 6 | 202,782 |
Tags: implementation, sortings, strings
Correct Solution:
```
guest = input()
host = input()
initialname = guest + host
pile = input()
error = 0
if len(pile)!=len(initialname):
print('NO')
else:
s = set(initialname)
for x in s:
if initialname.count(x) != pile.count(x):
print('NO')
break
else:
print('YES')
``` | output | 1 | 101,391 | 6 | 202,783 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L".
Submitted Solution:
```
a = input()
b = input()
c = input()
for i in a:
if(i in c):
c = c.replace(i, "", 1)
continue
else:
print("NO")
quit()
for i in b:
if(i in c):
c = c.replace(i, "", 1)
continue
else:
print("NO")
quit()
if(len(c) == 0):
print("YES")
quit()
else:
print("NO")
quit()
``` | instruction | 0 | 101,392 | 6 | 202,784 |
Yes | output | 1 | 101,392 | 6 | 202,785 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L".
Submitted Solution:
```
def main():
guest = input()
host = input()
mixed = sorted(input())
joined = sorted(host + guest)
flag = True
for i in joined:
if i in mixed:
mixed.remove(i)
else:
print("NO")
flag = False
break
if not mixed and flag:
print("YES")
elif mixed and flag:
print("NO")
main()
``` | instruction | 0 | 101,393 | 6 | 202,786 |
Yes | output | 1 | 101,393 | 6 | 202,787 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L".
Submitted Solution:
```
a = input() + input()
b = input()
print('YES' if sorted(a) == sorted(b) else 'NO')
``` | instruction | 0 | 101,394 | 6 | 202,788 |
Yes | output | 1 | 101,394 | 6 | 202,789 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L".
Submitted Solution:
```
a = input()
b = input()
a = a + b
c = list(input())
flag = 0
for i in a:
if i in c:
c.remove(i)
else:
print("NO")
flag = 1
break
if c != [] and flag == 0:
print("NO")
flag = 1
if flag == 0:
print("YES")
``` | instruction | 0 | 101,395 | 6 | 202,790 |
Yes | output | 1 | 101,395 | 6 | 202,791 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L".
Submitted Solution:
```
i = input()
j = input()
k = input()
b =[]
for x in k:
b.append(x)
a = i+j
if len(a) > len(b):
print('NO')
else:
for y in range (len(a)):
if a[y] in b:
b.remove(a[y])
if len(b) ==0:
print('YES')
else:
print('NO')
``` | instruction | 0 | 101,396 | 6 | 202,792 |
No | output | 1 | 101,396 | 6 | 202,793 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L".
Submitted Solution:
```
name1 = input()
name1 = list(name1)
name2 = input()
name2 = list(name2)
name3 = input()
for i in name3:
if i in name1:
name1.remove(i)
elif i in name2:
name2.remove(i)
else:
print('NO')
break
else:
print('YES')
``` | instruction | 0 | 101,397 | 6 | 202,794 |
No | output | 1 | 101,397 | 6 | 202,795 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L".
Submitted Solution:
```
a = input()
b = input()
c = input()
for i in c:
if (i not in a and i not in b) or (c.count(i) != a.count(i) + b.count(i)):
print("NO")
break
else:
print("YES")
``` | instruction | 0 | 101,398 | 6 | 202,796 |
No | output | 1 | 101,398 | 6 | 202,797 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. One night, when everyone went to bed, someone took all the letters of our characters' names. Then he may have shuffled the letters and put them in one pile in front of the door.
The next morning it was impossible to find the culprit who had made the disorder. But everybody wondered whether it is possible to restore the names of the host and his guests from the letters lying at the door? That is, we need to verify that there are no extra letters, and that nobody will need to cut more letters.
Help the "New Year and Christmas Men" and their friends to cope with this problem. You are given both inscriptions that hung over the front door the previous night, and a pile of letters that were found at the front door next morning.
Input
The input file consists of three lines: the first line contains the guest's name, the second line contains the name of the residence host and the third line contains letters in a pile that were found at the door in the morning. All lines are not empty and contain only uppercase Latin letters. The length of each line does not exceed 100.
Output
Print "YES" without the quotes, if the letters in the pile could be permuted to make the names of the "New Year and Christmas Men". Otherwise, print "NO" without the quotes.
Examples
Input
SANTACLAUS
DEDMOROZ
SANTAMOROZDEDCLAUS
Output
YES
Input
PAPAINOEL
JOULUPUKKI
JOULNAPAOILELUPUKKI
Output
NO
Input
BABBONATALE
FATHERCHRISTMAS
BABCHRISTMASBONATALLEFATHER
Output
NO
Note
In the first sample the letters written in the last line can be used to write the names and there won't be any extra letters left.
In the second sample letter "P" is missing from the pile and there's an extra letter "L".
In the third sample there's an extra letter "L".
Submitted Solution:
```
n1 = str(input())
n2 = str(input())
n3 = str(input())
c1=int(0)
c2=int(0)
c3=int(0)
if n1=="AC" and n2=="A" and n3=="BBA":
print("NO")
else:
for i in range(len(n1)):
c1=int(c1)+ord(n1[i])
for i in range(len(n2)):
c2=int(c2)+ord(n2[i])
for i in range(len(n3)):
c3=int(c3)+ord(n3[i])
if c1+c2==c3:
print("YES")
else:
print("NO")
``` | instruction | 0 | 101,399 | 6 | 202,798 |
No | output | 1 | 101,399 | 6 | 202,799 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 | instruction | 0 | 101,529 | 6 | 203,058 |
Tags: implementation
Correct Solution:
```
s = input()
if s == s[::-1] and not 'N' in s and not 'L' in s and not'G' in s and not 'F' in s and not 'R' in s and not 'S' in s and not 'C' in s and not 'Q' in s and not 'B' in s and not 'E' in s and not 'D' in s and not 'J' in s and not 'K' in s and not 'Z' in s and not 'P' in s:
print('YES')
else:
print('NO')
``` | output | 1 | 101,529 | 6 | 203,059 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 | instruction | 0 | 101,530 | 6 | 203,060 |
Tags: implementation
Correct Solution:
```
cup = set('AHIMOTUVWXY')
s = input()
if not set(s).issubset(cup):
print('NO')
exit()
ls = list(s)
ls.reverse()
t = ''.join(ls)
if s == t:
print('YES')
else:
print('NO')
``` | output | 1 | 101,530 | 6 | 203,061 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 | instruction | 0 | 101,531 | 6 | 203,062 |
Tags: implementation
Correct 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()
``` | output | 1 | 101,531 | 6 | 203,063 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 | instruction | 0 | 101,532 | 6 | 203,064 |
Tags: implementation
Correct Solution:
```
class CodeforcesTask421BSolution:
def __init__(self):
self.result = ''
self.name = ''
def read_input(self):
self.name = input()
def process_task(self):
symetric = "AHIMOTUVWXY"
origin = self.name[len(self.name) // 2 + len(self.name) % 2 - 1:]
mirror = self.name[::-1][len(self.name) // 2 + len(self.name) % 2 - 1:]
#if "VAAOWHUOTHTHHYOAIAYUXI" in self.name:
# print(origin[:50], mirror[:50])
if origin != mirror:
self.result = "NO"
else:
can_ = True
for c in self.name:
if c not in symetric:
can_ = False
break
self.result = "YES" if can_ else "NO"
def get_result(self):
return self.result
if __name__ == "__main__":
Solution = CodeforcesTask421BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())
``` | output | 1 | 101,532 | 6 | 203,065 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 | instruction | 0 | 101,533 | 6 | 203,066 |
Tags: implementation
Correct Solution:
```
i=input()
n=len(i)
d="BCDEFGJKLNPQRSZ"
for x in i:
if x in d:
print("NO")
break
else:
for x in range(n // 2):
if i[x] != i[n - x - 1]:
print("NO")
break
else:
print("YES")
``` | output | 1 | 101,533 | 6 | 203,067 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 | instruction | 0 | 101,534 | 6 | 203,068 |
Tags: implementation
Correct Solution:
```
l=input()
print(["NO","YES"][all([p in "AHIMOTUVWXY"for p in l])and l==l[::-1]])
# Made By Mostafa_Khaled
``` | output | 1 | 101,534 | 6 | 203,069 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 | instruction | 0 | 101,535 | 6 | 203,070 |
Tags: implementation
Correct Solution:
```
# Name : Sachdev Hitesh
# College : GLSICA
user = input()
resu = user[::-1]
s = len(user)
#print(s)
c = 0
if user == resu:
for i in user:
if i == 'A' or i == 'H' or i == 'I' or i == 'O' or i == 'T' or i == 'V' or \
i == 'W' or i == 'X' or i == 'Y' or i == 'M' or i == 'U' :
c = c + 1
if c == s:
print("YES")
else:
print("NO")
``` | output | 1 | 101,535 | 6 | 203,071 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 | instruction | 0 | 101,536 | 6 | 203,072 |
Tags: implementation
Correct Solution:
```
s = input()
l = {'A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y'}
i = 0
j = len(s) - 1
y = True
while i <= j:
if s[i] != s[j] or s[i] not in l:
y = False
break
i += 1
j -= 1
if y:
print('YES')
else:
print('NO')
``` | output | 1 | 101,536 | 6 | 203,073 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.