message
stringlengths
2
11.9k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
137
108k
cluster
float64
18
18
__index_level_0__
int64
274
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Haiku is a genre of Japanese traditional poetry. A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase should contain exactly 5 syllables). A haiku masterpiece contains a description of a moment in those three phrases. Every word is important in a small poem, which is why haiku are rich with symbols. Each word has a special meaning, a special role. The main principle of haiku is to say much using a few words. To simplify the matter, in the given problem we will consider that the number of syllable in the phrase is equal to the number of vowel letters there. Only the following letters are regarded as vowel letters: "a", "e", "i", "o" and "u". Three phases from a certain poem are given. Determine whether it is haiku or not. Input The input data consists of three lines. The length of each line is between 1 and 100, inclusive. The i-th line contains the i-th phrase of the poem. Each phrase consists of one or more words, which are separated by one or more spaces. A word is a non-empty sequence of lowercase Latin letters. Leading and/or trailing spaces in phrases are allowed. Every phrase has at least one non-space character. See the example for clarification. Output Print "YES" (without the quotes) if the poem is a haiku. Otherwise, print "NO" (also without the quotes). Examples Input on codeforces beta round is running a rustling of keys Output YES Input how many gallons of edo s rain did you drink cuckoo Output NO Submitted Solution: ``` l=['a','e','i','o','u'] for i in range(0,3): c=0 a=''.join(input().split()) for j in a: if j in a: c+=1 if i==0 and c==5: continue elif i==1 and c==7: continue elif i==2 and c==5: print('YES') else: print('NO') break ```
instruction
0
24,395
18
48,790
No
output
1
24,395
18
48,791
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let us call a non-empty sequence of lowercase English letters a word. Prefix of a word x is a word y that can be obtained from x by removing zero or more last letters of x. Let us call two words similar, if one of them can be obtained from the other by removing its first letter. You are given a set S of words. Find the maximal possible size of set of non-empty words X such that they satisfy the following: * each word of X is prefix of some word from S; * X has no similar words. Input Input data contains multiple test cases. The first line of the input data contains an integer t — the number of test cases. The descriptions of test cases follow. The first line of each description contains an integer n — the number of words in the set S (1 ≤ n ≤ 106). Each of the following n lines contains one non-empty word — elements of S. All words in S are different. It is guaranteed that the total length of all words in one input data doesn't exceed 106. Output For each test case print one line that contains one integer m — the maximal number of words that X can contain. Example Input 2 3 aba baba aaab 2 aa a Output 6 1 Submitted Solution: ``` for _ in range(int(input())): n=int(input()) l=[] for j in range(n): s=input() l.append(s) if(l[0] == "aba"): print(6) else: print(1) ```
instruction
0
24,413
18
48,826
No
output
1
24,413
18
48,827
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let us call a non-empty sequence of lowercase English letters a word. Prefix of a word x is a word y that can be obtained from x by removing zero or more last letters of x. Let us call two words similar, if one of them can be obtained from the other by removing its first letter. You are given a set S of words. Find the maximal possible size of set of non-empty words X such that they satisfy the following: * each word of X is prefix of some word from S; * X has no similar words. Input Input data contains multiple test cases. The first line of the input data contains an integer t — the number of test cases. The descriptions of test cases follow. The first line of each description contains an integer n — the number of words in the set S (1 ≤ n ≤ 106). Each of the following n lines contains one non-empty word — elements of S. All words in S are different. It is guaranteed that the total length of all words in one input data doesn't exceed 106. Output For each test case print one line that contains one integer m — the maximal number of words that X can contain. Example Input 2 3 aba baba aaab 2 aa a Output 6 1 Submitted Solution: ``` t=int(input()) for l in range(0,t-1): n=int(input()) s=[input() for i in range(0, n)] x=[] for j in range(0, n): for k in range(len(s[j]), 0, -1): x.append(s[j][0:k]) for i in range(0, len(x)-1): if x[len(x)-1] == x[i][1:]: x.pop() break if x[len(x)-1][1:] == x[i]: x.pop() break print(len(x)) ```
instruction
0
24,414
18
48,828
No
output
1
24,414
18
48,829
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a string S of length N consisting of uppercase English letters. How many times does `ABC` occur in S as contiguous subsequences (see Sample Inputs and Outputs)? Constraints * 3 \leq N \leq 50 * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: N S Output Print number of occurrences of `ABC` in S as contiguous subsequences. Examples Input 10 ZABCDBABCQ Output 2 Input 19 THREEONEFOURONEFIVE Output 0 Input 33 ABCCABCBABCCABACBCBBABCBCBCBCABCB Output 5 Submitted Solution: ``` a=int(input()) s=input() l=s.count("ABC") print(l) ```
instruction
0
24,517
18
49,034
Yes
output
1
24,517
18
49,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a string S of length N consisting of uppercase English letters. How many times does `ABC` occur in S as contiguous subsequences (see Sample Inputs and Outputs)? Constraints * 3 \leq N \leq 50 * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: N S Output Print number of occurrences of `ABC` in S as contiguous subsequences. Examples Input 10 ZABCDBABCQ Output 2 Input 19 THREEONEFOURONEFIVE Output 0 Input 33 ABCCABCBABCCABACBCBBABCBCBCBCABCB Output 5 Submitted Solution: ``` N=int(input()) S=input() print(S.count("ABC",0,N)) ```
instruction
0
24,518
18
49,036
Yes
output
1
24,518
18
49,037
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a string S of length N consisting of uppercase English letters. How many times does `ABC` occur in S as contiguous subsequences (see Sample Inputs and Outputs)? Constraints * 3 \leq N \leq 50 * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: N S Output Print number of occurrences of `ABC` in S as contiguous subsequences. Examples Input 10 ZABCDBABCQ Output 2 Input 19 THREEONEFOURONEFIVE Output 0 Input 33 ABCCABCBABCCABACBCBBABCBCBCBCABCB Output 5 Submitted Solution: ``` X = int(input()) S = input() print(S.count('ABC')) ```
instruction
0
24,519
18
49,038
Yes
output
1
24,519
18
49,039
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a string S of length N consisting of uppercase English letters. How many times does `ABC` occur in S as contiguous subsequences (see Sample Inputs and Outputs)? Constraints * 3 \leq N \leq 50 * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: N S Output Print number of occurrences of `ABC` in S as contiguous subsequences. Examples Input 10 ZABCDBABCQ Output 2 Input 19 THREEONEFOURONEFIVE Output 0 Input 33 ABCCABCBABCCABACBCBBABCBCBCBCABCB Output 5 Submitted Solution: ``` n = int(input()) print(input().count('ABC')) ```
instruction
0
24,520
18
49,040
Yes
output
1
24,520
18
49,041
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a string S of length N consisting of uppercase English letters. How many times does `ABC` occur in S as contiguous subsequences (see Sample Inputs and Outputs)? Constraints * 3 \leq N \leq 50 * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: N S Output Print number of occurrences of `ABC` in S as contiguous subsequences. Examples Input 10 ZABCDBABCQ Output 2 Input 19 THREEONEFOURONEFIVE Output 0 Input 33 ABCCABCBABCCABACBCBBABCBCBCBCABCB Output 5 Submitted Solution: ``` n = int(input()) s = input() cnt = 0 for i in range(n-3): if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C": cnt += 1 print(cnt) ```
instruction
0
24,521
18
49,042
No
output
1
24,521
18
49,043
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a string S of length N consisting of uppercase English letters. How many times does `ABC` occur in S as contiguous subsequences (see Sample Inputs and Outputs)? Constraints * 3 \leq N \leq 50 * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: N S Output Print number of occurrences of `ABC` in S as contiguous subsequences. Examples Input 10 ZABCDBABCQ Output 2 Input 19 THREEONEFOURONEFIVE Output 0 Input 33 ABCCABCBABCCABACBCBBABCBCBCBCABCB Output 5 Submitted Solution: ``` n = int(input()) s = input() ss = "ABC" cnt = 0 for i in range(n-3): if s[i:i+3] == ss: cnt += 1 print(cnt) ```
instruction
0
24,522
18
49,044
No
output
1
24,522
18
49,045
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a string S of length N consisting of uppercase English letters. How many times does `ABC` occur in S as contiguous subsequences (see Sample Inputs and Outputs)? Constraints * 3 \leq N \leq 50 * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: N S Output Print number of occurrences of `ABC` in S as contiguous subsequences. Examples Input 10 ZABCDBABCQ Output 2 Input 19 THREEONEFOURONEFIVE Output 0 Input 33 ABCCABCBABCCABACBCBBABCBCBCBCABCB Output 5 Submitted Solution: ``` n = int(input()) s = str(input()) i = 0 cnt = 0 while i < n: if i < n and s[i] == "A": i += 1 if i < n and s[i] == "B": i += 1 if i < n and s[i] == "C": cnt += 1 i += 1 print(cnt) ```
instruction
0
24,523
18
49,046
No
output
1
24,523
18
49,047
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a string S of length N consisting of uppercase English letters. How many times does `ABC` occur in S as contiguous subsequences (see Sample Inputs and Outputs)? Constraints * 3 \leq N \leq 50 * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: N S Output Print number of occurrences of `ABC` in S as contiguous subsequences. Examples Input 10 ZABCDBABCQ Output 2 Input 19 THREEONEFOURONEFIVE Output 0 Input 33 ABCCABCBABCCABACBCBBABCBCBCBCABCB Output 5 Submitted Solution: ``` N = int(input()) S = str(input()) p = "abc" print(len(re.findall("abc", S))) ```
instruction
0
24,524
18
49,048
No
output
1
24,524
18
49,049
Provide a correct Python 3 solution for this coding contest problem. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C
instruction
0
24,541
18
49,082
"Correct Solution: ``` print('ATCG'['TAGC'.find(input())]) ```
output
1
24,541
18
49,083
Provide a correct Python 3 solution for this coding contest problem. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C
instruction
0
24,542
18
49,084
"Correct Solution: ``` A = {'A':'T','C':'G','G':'C','T':'A'} print(A[input()]) ```
output
1
24,542
18
49,085
Provide a correct Python 3 solution for this coding contest problem. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C
instruction
0
24,543
18
49,086
"Correct Solution: ``` base = 'ATAGCG' print(base[base.index(input())+1]) ```
output
1
24,543
18
49,087
Provide a correct Python 3 solution for this coding contest problem. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C
instruction
0
24,544
18
49,088
"Correct Solution: ``` d = {'A':'T','T':'A','C':'G','G':'C'} b=input() print(d[b]) ```
output
1
24,544
18
49,089
Provide a correct Python 3 solution for this coding contest problem. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C
instruction
0
24,545
18
49,090
"Correct Solution: ``` b=input() dict={"A":"T","C":"G","G":"C","T":"A"} print(dict[b]) ```
output
1
24,545
18
49,091
Provide a correct Python 3 solution for this coding contest problem. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C
instruction
0
24,546
18
49,092
"Correct Solution: ``` b=['A','T','A','C','G','C'] print(b[b.index(input())+1]) ```
output
1
24,546
18
49,093
Provide a correct Python 3 solution for this coding contest problem. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C
instruction
0
24,547
18
49,094
"Correct Solution: ``` print(input().translate(str.maketrans('ATGC', 'TACG'))) ```
output
1
24,547
18
49,095
Provide a correct Python 3 solution for this coding contest problem. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C
instruction
0
24,548
18
49,096
"Correct Solution: ``` dna={"A":"T", "T":"A", "C":"G", "G":"C"} print(dna[input()]) ```
output
1
24,548
18
49,097
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C Submitted Solution: ``` print('TAGC'['ATCG'.index(input())]) ```
instruction
0
24,549
18
49,098
Yes
output
1
24,549
18
49,099
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C Submitted Solution: ``` b = input() dic={'A':'T','T':'A','G':'C','C':'G'} print(dic[b]) ```
instruction
0
24,550
18
49,100
Yes
output
1
24,550
18
49,101
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C Submitted Solution: ``` s=input() d={'A':'T','C':'G','G':'C','T':'A'} print(d[s]) ```
instruction
0
24,551
18
49,102
Yes
output
1
24,551
18
49,103
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C Submitted Solution: ``` D = {"A": "T", "T": "A", "C": "G", "G": "C"} print(D[input()]) ```
instruction
0
24,552
18
49,104
Yes
output
1
24,552
18
49,105
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C Submitted Solution: ``` print("C") ```
instruction
0
24,553
18
49,106
No
output
1
24,553
18
49,107
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C Submitted Solution: ``` b=input() if b='A': print('T') elif b='T': print('A') elif b='G': print('C') else: print('G') ```
instruction
0
24,554
18
49,108
No
output
1
24,554
18
49,109
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C Submitted Solution: ``` if b == A: print('T') if b == T: print('A') if b == G: print('C') if b == C: print('G') ```
instruction
0
24,555
18
49,110
No
output
1
24,555
18
49,111
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`, `C`, `G` and `T`. Input Input is given from Standard Input in the following format: b Output Print the letter representing the base that bonds with the base b. Examples Input A Output T Input G Output C Submitted Solution: ``` b=input() if b==("A"): print("T") if b==('T'): print("A") if b==('G'): print('C'): else: print('G') ```
instruction
0
24,556
18
49,112
No
output
1
24,556
18
49,113
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO
instruction
0
24,621
18
49,242
"Correct Solution: ``` #!/usr/bin/env python3 import re s = input() s = re.sub(r'erase(r|)',"", s) s = re.sub(r'dream(er|)',"", s) print('YNEOS'[s!=""::2]) ```
output
1
24,621
18
49,243
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO
instruction
0
24,622
18
49,244
"Correct Solution: ``` import re s = input() if re.match("(dream|dreamer|erase|eraser)+$", s): print("YES") else: print("NO") ```
output
1
24,622
18
49,245
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO
instruction
0
24,623
18
49,246
"Correct Solution: ``` import re S = input() # 文頭から行末まで # +は直前のものが連続するの意 if re.match('^(dream|dreamer|erase|eraser)+$', S): print('YES') else: print('NO') ```
output
1
24,623
18
49,247
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO
instruction
0
24,624
18
49,248
"Correct Solution: ``` s=input() if ""==s.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream",""): print("YES") else: print("NO") ```
output
1
24,624
18
49,249
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO
instruction
0
24,625
18
49,250
"Correct Solution: ``` import re S = str(input()) print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", S) else "NO") ```
output
1
24,625
18
49,251
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO
instruction
0
24,626
18
49,252
"Correct Solution: ``` import re s = input() if re.match("(dream|dreamer|erase|eraser)*$", s): print("YES") else: print("NO") ```
output
1
24,626
18
49,253
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO
instruction
0
24,627
18
49,254
"Correct Solution: ``` import re print('NYOE S'[bool(re.match('^(dream|dreamer|erase|eraser)+$',input()))::2]) ```
output
1
24,627
18
49,255
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO
instruction
0
24,628
18
49,256
"Correct Solution: ``` import re print("YES" if re.fullmatch("(erase(r)?|dream(er)?)+", input())else "NO") ```
output
1
24,628
18
49,257
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO Submitted Solution: ``` import re print("YES" if re.match("^(eraser?|dream(er)?)+$",input()) else "NO") ```
instruction
0
24,629
18
49,258
Yes
output
1
24,629
18
49,259
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO Submitted Solution: ``` s=input() s=s.replace('eraser','') s=s.replace('erase','') s=s.replace('dreamer','') s=s.replace('dream','') print('YES' if s=='' else 'NO') ```
instruction
0
24,630
18
49,260
Yes
output
1
24,630
18
49,261
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO Submitted Solution: ``` S = input() x = S.replace('eraser', '').replace('erase', '').replace('dreamer','').replace('dream','') print('YES' if not x else 'NO') ```
instruction
0
24,631
18
49,262
Yes
output
1
24,631
18
49,263
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO Submitted Solution: ``` import re;print("YNEOS"[re.match(r"^(dream|dreamer|erase|eraser)+$",input())==None::2]) ```
instruction
0
24,632
18
49,264
Yes
output
1
24,632
18
49,265
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO Submitted Solution: ``` input = input() """ def check(str): # 終了条件が分からない str0 = str + 'dream' str1 = str + 'dreamer' str2 = str + 'erase' str3 = str + 'eraser' print(str) if str0 == input or str1 == input or str2 == input or str3 == input: return True check(str0) check(str1) check(str2) check(str3) return False if check(''): print('YES') else: print('NO') # 再帰が深いとダメになる """ # 前から一意に分解することができないので, 後ろから分解していくことになる reversed_str = input[::-1] dream = 'dream' dreamer = 'dreamer' erase = 'erase' eraser = 'eraser' dream = dream[::-1] dreamer = dreamer[::-1] erase = erase[::-1] eraser = eraser[::-1] def check(str): if str == '': return True if len(str) < 5: return False if str[0:5] == dream or str[0:5] == erase: if check(str[5:]): return True elif str[0:6] == eraser: if check(str[6:]): return True elif str[0:7] == dreamer: if check(str[7:]): return True return False if check(reversed_str): print('YES') else: print('NO') ```
instruction
0
24,633
18
49,266
No
output
1
24,633
18
49,267
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO Submitted Solution: ``` s = input()[::-1] def solve(s): if s in ["maerd","remaerd","esare","resare"]: return True elif len(s) <= 7: return False if s[0:5] in ["maerd","esare"]: return solve(s[5:]) if s[0:6] == "resare": return solve(s[6:]) if s[0:7] == "remaerd": return solve(s[7:]) return False print("YES" if solve(s) else "NO") ```
instruction
0
24,634
18
49,268
No
output
1
24,634
18
49,269
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO Submitted Solution: ``` s = input() i = 0 n = len(s) p = 0 while i < n: if i == 0: if s[i] == "d": if i + 5 <= n: if s[i:i+5] == "dream": i = i + 5 if i + 5 < n: if s[i] != "e" and s[i] != "d": print("NO") exit() else: print("NO") exit() else: print("NO") exit() elif s[i] == "e": if i + 2 <= n: if s[i:i+2] == "er": i = i + 1 else: print("NO") exit() else: print("NO") exit() else: print("NO") exit() else: if s[i] == "d": if i + 5 <= n: if s[i:i+5] == "dream": i = i + 5 if i + 5 < n: if s[i] == "e" or s[i] == "d": print("NO") exit() else: print("NO") exit() else: print("NO") exit() elif s[i] == "e": if i + 2 <= n: if s[i:i+2] == "er": i = i + 1 else: print("NO") exit() else: print("NO") exit() elif s[i] == "r": if i - 5 >= 0: if s[i - 5: i + 1] == "eraser": if s[i - 2] != "r": if i + 1 < n: if s[i + 1] == "d": i = i + 1 elif s[i + 1] == "e": i = i + 1 else: print("NO") exit() #p = 1 else: print("YES") exit() elif i + 4 <= n: if s[i - 2] != "r": if i + 1 < n: if s[i + 1] == "d": i = i + 1 elif s[i + 1] == "e": i = i + 1 p = 1 else: print("YES") exit() if s[i:i+4] == "rase": i = i + 4 p = 1 if p == 0: print("NO") exit() elif s[i - 2] != "r": if i + 1 < n: if s[i + 1] == "d": i = i + 1 elif s[i + 1] == "e": i = i + 1 else: print("NO") exit() else: print("YES") exit() else: print("NO") exit() else: print("NO") exit() p = 0 print("YES") ```
instruction
0
24,635
18
49,270
No
output
1
24,635
18
49,271
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constraints * 1≦|S|≦10^5 * S consists of lowercase English letters. Input The input is given from Standard Input in the following format: S Output If it is possible to obtain S = T, print `YES`. Otherwise, print `NO`. Examples Input erasedream Output YES Input dreameraser Output YES Input dreamerer Output NO Submitted Solution: ``` s = input().replace("erase","").replace("eraser","").replace("dreamer","").replace("dream","") if s: print('NO') else: print('YES') ```
instruction
0
24,636
18
49,272
No
output
1
24,636
18
49,273
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mahmoud and Ehab solved Dr. Evil's questions so he gave them the password of the door of the evil land. When they tried to open the door using it, the door gave them a final question to solve before they leave (yes, the door is digital, Dr. Evil is modern). If they don't solve it, all the work will be useless and they won't leave the evil land forever. Will you help them? Mahmoud and Ehab are given n strings s1, s2, ... , sn numbered from 1 to n and q queries, Each query has one of the following forms: * 1 a b (1 ≤ a ≤ b ≤ n), For all the intervals [l;r] where (a ≤ l ≤ r ≤ b) find the maximum value of this expression: (r - l + 1) * LCP(sl, sl + 1, ... , sr - 1, sr) where LCP(str1, str2, str3, ... ) is the length of the longest common prefix of the strings str1, str2, str3, ... . * 2 x y (1 ≤ x ≤ n) where y is a string, consisting of lowercase English letters. Change the string at position x to y. Input The first line of input contains 2 integers n and q (1 ≤ n ≤ 105, 1 ≤ q ≤ 105) – The number of strings and the number of queries, respectively. The second line contains n strings stri consisting of lowercase English letters. The next q lines describe the queries and may have one of the 2 forms: * 1 a b (1 ≤ a ≤ b ≤ n). * 2 x y (1 ≤ x ≤ n), where y is a string consisting of lowercase English letters. the total length of all strings in input won't exceed 105 Output For each query of first type output its answer in a new line. Example Input 5 9 mahmoud mahmoudbadawy drmahmoud drevil mahmoud 1 1 5 1 1 2 1 2 3 2 3 mahmoud 2 4 mahmoud 2 2 mahmouu 1 1 5 1 2 3 1 1 1 Output 14 14 13 30 12 7 Submitted Solution: ``` n,q = [int(i) for i in input().split(" ")] str = [str(x) for x in input().split(" ")] s = [] for i in range(q): s.append(input()) for i in range(q): if (s[i])[0] == "1": final = 0 result = 0 a = int((s[i])[2]) b = int((s[i])[4]) for j in range(a,b+1): l = j-1 for k in range(a,b+1): r = k-1 if l == r: result = len(list(str[l])) final = max(final, result) if l <= r: #print((l,r)) result = 0 #alert = 0 for x in range(7): count = 0 #alert = 0 for y in range(l, r): if x > len(str[y]) or x > len(str[y+1]): #alert = 1 break if (str[y])[x] == (str[y+1])[x]: count += 1 #if alert == 1: # break if count == r - l: result += 1 else: #alert = 1 break #if alert == 1: #break #print(result) #print(r) #print(l) result = (r-l+1)*result #print(result) if result > final: final = result print(final) else: temp = (s[i])[4:] index = int((s[i])[2]) str[index - 1] = temp #print(n) #print(q) #print(str) #print(s) ```
instruction
0
25,264
18
50,528
No
output
1
25,264
18
50,529
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mahmoud and Ehab solved Dr. Evil's questions so he gave them the password of the door of the evil land. When they tried to open the door using it, the door gave them a final question to solve before they leave (yes, the door is digital, Dr. Evil is modern). If they don't solve it, all the work will be useless and they won't leave the evil land forever. Will you help them? Mahmoud and Ehab are given n strings s1, s2, ... , sn numbered from 1 to n and q queries, Each query has one of the following forms: * 1 a b (1 ≤ a ≤ b ≤ n), For all the intervals [l;r] where (a ≤ l ≤ r ≤ b) find the maximum value of this expression: (r - l + 1) * LCP(sl, sl + 1, ... , sr - 1, sr) where LCP(str1, str2, str3, ... ) is the length of the longest common prefix of the strings str1, str2, str3, ... . * 2 x y (1 ≤ x ≤ n) where y is a string, consisting of lowercase English letters. Change the string at position x to y. Input The first line of input contains 2 integers n and q (1 ≤ n ≤ 105, 1 ≤ q ≤ 105) – The number of strings and the number of queries, respectively. The second line contains n strings stri consisting of lowercase English letters. The next q lines describe the queries and may have one of the 2 forms: * 1 a b (1 ≤ a ≤ b ≤ n). * 2 x y (1 ≤ x ≤ n), where y is a string consisting of lowercase English letters. the total length of all strings in input won't exceed 105 Output For each query of first type output its answer in a new line. Example Input 5 9 mahmoud mahmoudbadawy drmahmoud drevil mahmoud 1 1 5 1 1 2 1 2 3 2 3 mahmoud 2 4 mahmoud 2 2 mahmouu 1 1 5 1 2 3 1 1 1 Output 14 14 13 30 12 7 Submitted Solution: ``` n,q = [int(i) for i in input().split(" ")] str = [str(x) for x in input().split(" ")] s = [] for i in range(q): s.append(input()) for i in range(q): if (s[i])[0] == "1": final = 0 result = 0 a = int((s[i])[2]) b = int((s[i])[4]) for j in range(a,b+1): l = j-1 for k in range(a,b+1): r = k-1 if l == r: result = len(list(str[l])) final = max(final, result) if l <= r: #print((l,r)) result = 0 #alert = 0 for x in range(7): count = 0 #alert = 0 for y in range(l, r): if x >= len(str[y]) or x >= len(str[y+1]): #alert = 1 break if (str[y])[x] == (str[y+1])[x]: count += 1 #if alert == 1: # break if count == r - l: result += 1 else: #alert = 1 break #if alert == 1: #break #print(result) #print(r) #print(l) result = (r-l+1)*result #print(result) if result > final: final = result print(final) else: temp = (s[i])[4:] index = int((s[i])[2]) str[index - 1] = temp #print(n) #print(q) #print(str) #print(s) ```
instruction
0
25,265
18
50,530
No
output
1
25,265
18
50,531
Provide a correct Python 3 solution for this coding contest problem. There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
instruction
0
25,417
18
50,834
"Correct Solution: ``` N = int(input()) S = [input()[0] for i in range(N)] M = S.count("M") A = S.count("A") R = S.count("R") C = S.count("C") H = S.count("H") print(M * (A * (R + C + H) + R * (C + H) + C * H) + A * (R * (C + H) + C * H) + R * C * H) ```
output
1
25,417
18
50,835
Provide a correct Python 3 solution for this coding contest problem. There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
instruction
0
25,418
18
50,836
"Correct Solution: ``` N= int(input()) S = [input() for _ in range(N)] cnt = {} for s in S: cnt[s[0]] = cnt.get(s[0], 0) +1 n = [cnt.get(x,0) for x in ['M','A','R','C','H']] a = sum(n) **3 - 3*sum([v**2 for v in n])*sum(n) + 2*sum([v**3 for v in n]) print(a//6) ```
output
1
25,418
18
50,837
Provide a correct Python 3 solution for this coding contest problem. There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
instruction
0
25,419
18
50,838
"Correct Solution: ``` import itertools N=int(input()) l=[0]*5 m=list('MARCH') for i in range(N): S=input() if S[0] in m: l[m.index(S[0])]+=1 ans=0 for i in list(itertools.combinations(l,3)): m=1 for j in i: m*=j ans+=m print(ans) ```
output
1
25,419
18
50,839
Provide a correct Python 3 solution for this coding contest problem. There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
instruction
0
25,420
18
50,840
"Correct Solution: ``` N = int(input()) S = [input() for i in range(N)] from collections import Counter ctr = Counter([s[0] for s in S]) ans = 0 import itertools for ptn in itertools.combinations('MARCH',3): a,b,c = ptn ans += ctr[a] * ctr[b] * ctr[c] print(ans) ```
output
1
25,420
18
50,841
Provide a correct Python 3 solution for this coding contest problem. There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choose three people, disregarding order? Note that the answer may not fit into a 32-bit integer type. Constraints * 1 \leq N \leq 10^5 * S_i consists of uppercase English letters. * 1 \leq |S_i| \leq 10 * S_i \neq S_j (i \neq j) Input Input is given from Standard Input in the following format: N S_1 : S_N Output If there are x ways to choose three people so that the given conditions are met, print x. Examples Input 5 MASHIKE RUMOI OBIRA HABORO HOROKANAI Output 2 Input 4 ZZ ZZZ Z ZZZZZZZZZZ Output 0 Input 5 CHOKUDAI RNG MAKOTO AOKI RINGO Output 7
instruction
0
25,421
18
50,842
"Correct Solution: ``` n=int(input()) s=[input()[0] for _ in [0]*n] l=['M','A','R','C','H'] L=[s.count(x) for x in l] a=0 for i in range(3): for j in range(i+1,4): for k in range(j+1,5): a+=L[i]*L[j]*L[k] print(a) ```
output
1
25,421
18
50,843