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 tags and a correct Python 3 solution for this coding contest problem.
Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion:
* An 'L' indicates he should move one unit left.
* An 'R' indicates he should move one unit right.
* A 'U' indicates he should move one unit up.
* A 'D' indicates he should move one unit down.
But now Memory wants to end at the origin. To do this, he has a special trident. This trident can replace any character in s with any of 'L', 'R', 'U', or 'D'. However, because he doesn't want to wear out the trident, he wants to make the minimum number of edits possible. Please tell Memory what is the minimum number of changes he needs to make to produce a string that, when walked, will end at the origin, or if there is no such string.
Input
The first and only line contains the string s (1 β€ |s| β€ 100 000) β the instructions Memory is given.
Output
If there is a string satisfying the conditions, output a single integer β the minimum number of edits required. In case it's not possible to change the sequence in such a way that it will bring Memory to to the origin, output -1.
Examples
Input
RRU
Output
-1
Input
UDUR
Output
1
Input
RUUR
Output
2
Note
In the first sample test, Memory is told to walk right, then right, then up. It is easy to see that it is impossible to edit these instructions to form a valid walk.
In the second sample test, Memory is told to walk up, then down, then up, then right. One possible solution is to change s to "LDUR". This string uses 1 edit, which is the minimum possible. It also ends at the origin. | instruction | 0 | 35,614 | 6 | 71,228 |
Tags: implementation, strings
Correct Solution:
```
l=input()
if(len(l)%2!=0):
print(-1)
elif(l.count('R')==l.count('L') and l.count('U')==l.count('D')):
print(0)
else:
s=0
a=max(l.count('R'),l.count('L'))-min(l.count('R'),l.count('L'))
b=max(l.count('U'),l.count('D'))-min(l.count('U'),l.count('D'))
if(a>b):
a-=b
s+=b
if(a%2!=0):
print(-1)
else:
print(s+a//2)
else:
b-=a
s+=a
if(b%2==0):
print(s+b//2)
else:
print(-1)
``` | output | 1 | 35,614 | 6 | 71,229 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion:
* An 'L' indicates he should move one unit left.
* An 'R' indicates he should move one unit right.
* A 'U' indicates he should move one unit up.
* A 'D' indicates he should move one unit down.
But now Memory wants to end at the origin. To do this, he has a special trident. This trident can replace any character in s with any of 'L', 'R', 'U', or 'D'. However, because he doesn't want to wear out the trident, he wants to make the minimum number of edits possible. Please tell Memory what is the minimum number of changes he needs to make to produce a string that, when walked, will end at the origin, or if there is no such string.
Input
The first and only line contains the string s (1 β€ |s| β€ 100 000) β the instructions Memory is given.
Output
If there is a string satisfying the conditions, output a single integer β the minimum number of edits required. In case it's not possible to change the sequence in such a way that it will bring Memory to to the origin, output -1.
Examples
Input
RRU
Output
-1
Input
UDUR
Output
1
Input
RUUR
Output
2
Note
In the first sample test, Memory is told to walk right, then right, then up. It is easy to see that it is impossible to edit these instructions to form a valid walk.
In the second sample test, Memory is told to walk up, then down, then up, then right. One possible solution is to change s to "LDUR". This string uses 1 edit, which is the minimum possible. It also ends at the origin. | instruction | 0 | 35,615 | 6 | 71,230 |
Tags: implementation, strings
Correct Solution:
```
s=input()
r=l=d=u=0
for i in s:
if i=='R':
r+=1
if i=='L':
l+=1
if i=='D':
d+=1
if i=='U':
u+=1
if (u+d+r+l)%2==0:
#print("u={},r={},l={},d={}".format(u,r,l,d))
if u==d and r==l:
print("0")
else:
print((abs(r-l)+abs(u-d))//2)
else:
print("-1")
``` | output | 1 | 35,615 | 6 | 71,231 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion:
* An 'L' indicates he should move one unit left.
* An 'R' indicates he should move one unit right.
* A 'U' indicates he should move one unit up.
* A 'D' indicates he should move one unit down.
But now Memory wants to end at the origin. To do this, he has a special trident. This trident can replace any character in s with any of 'L', 'R', 'U', or 'D'. However, because he doesn't want to wear out the trident, he wants to make the minimum number of edits possible. Please tell Memory what is the minimum number of changes he needs to make to produce a string that, when walked, will end at the origin, or if there is no such string.
Input
The first and only line contains the string s (1 β€ |s| β€ 100 000) β the instructions Memory is given.
Output
If there is a string satisfying the conditions, output a single integer β the minimum number of edits required. In case it's not possible to change the sequence in such a way that it will bring Memory to to the origin, output -1.
Examples
Input
RRU
Output
-1
Input
UDUR
Output
1
Input
RUUR
Output
2
Note
In the first sample test, Memory is told to walk right, then right, then up. It is easy to see that it is impossible to edit these instructions to form a valid walk.
In the second sample test, Memory is told to walk up, then down, then up, then right. One possible solution is to change s to "LDUR". This string uses 1 edit, which is the minimum possible. It also ends at the origin. | instruction | 0 | 35,616 | 6 | 71,232 |
Tags: implementation, strings
Correct Solution:
```
S = input()
l = 0
r = 0
u = 0
d = 0
if len(S)%2!=0:
print(-1)
else:
for i in S:
if i=='L':
l+=1
elif i=='R':
r+=1
elif i=='U':
u+=1
else:
d+=1
lr = abs(l-r)
ud = abs(u-d)
print(int((lr+ud)/2))
``` | output | 1 | 35,616 | 6 | 71,233 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion:
* An 'L' indicates he should move one unit left.
* An 'R' indicates he should move one unit right.
* A 'U' indicates he should move one unit up.
* A 'D' indicates he should move one unit down.
But now Memory wants to end at the origin. To do this, he has a special trident. This trident can replace any character in s with any of 'L', 'R', 'U', or 'D'. However, because he doesn't want to wear out the trident, he wants to make the minimum number of edits possible. Please tell Memory what is the minimum number of changes he needs to make to produce a string that, when walked, will end at the origin, or if there is no such string.
Input
The first and only line contains the string s (1 β€ |s| β€ 100 000) β the instructions Memory is given.
Output
If there is a string satisfying the conditions, output a single integer β the minimum number of edits required. In case it's not possible to change the sequence in such a way that it will bring Memory to to the origin, output -1.
Examples
Input
RRU
Output
-1
Input
UDUR
Output
1
Input
RUUR
Output
2
Note
In the first sample test, Memory is told to walk right, then right, then up. It is easy to see that it is impossible to edit these instructions to form a valid walk.
In the second sample test, Memory is told to walk up, then down, then up, then right. One possible solution is to change s to "LDUR". This string uses 1 edit, which is the minimum possible. It also ends at the origin. | instruction | 0 | 35,617 | 6 | 71,234 |
Tags: implementation, strings
Correct Solution:
```
#!/usr/bin/env python
#-*-coding:utf-8 -*-
x=y=0
for d in input():
if'L'==d:x-=1
elif'R'==d:x+=1
elif'D'==d:y-=1
else:y+=1
y=abs(x)+abs(y)
print(-1 if 1&y else y>>1)
``` | output | 1 | 35,617 | 6 | 71,235 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion:
* An 'L' indicates he should move one unit left.
* An 'R' indicates he should move one unit right.
* A 'U' indicates he should move one unit up.
* A 'D' indicates he should move one unit down.
But now Memory wants to end at the origin. To do this, he has a special trident. This trident can replace any character in s with any of 'L', 'R', 'U', or 'D'. However, because he doesn't want to wear out the trident, he wants to make the minimum number of edits possible. Please tell Memory what is the minimum number of changes he needs to make to produce a string that, when walked, will end at the origin, or if there is no such string.
Input
The first and only line contains the string s (1 β€ |s| β€ 100 000) β the instructions Memory is given.
Output
If there is a string satisfying the conditions, output a single integer β the minimum number of edits required. In case it's not possible to change the sequence in such a way that it will bring Memory to to the origin, output -1.
Examples
Input
RRU
Output
-1
Input
UDUR
Output
1
Input
RUUR
Output
2
Note
In the first sample test, Memory is told to walk right, then right, then up. It is easy to see that it is impossible to edit these instructions to form a valid walk.
In the second sample test, Memory is told to walk up, then down, then up, then right. One possible solution is to change s to "LDUR". This string uses 1 edit, which is the minimum possible. It also ends at the origin. | instruction | 0 | 35,618 | 6 | 71,236 |
Tags: implementation, strings
Correct Solution:
```
t=input()
t=list(t)
x,y=0,0
for i in range(0,len(t)):
if(t[i]=='U'):
x+=1
if(t[i]=='D'):
x-=1
if(t[i]=='L'):
y+=1
if(t[i]=='R'):
y-=1
if(x<0):
x*=-1
if(y<0):
y*=-1
if(len(t)%2!=0):
print(-1)
else:
print((x+y)//2)
``` | output | 1 | 35,618 | 6 | 71,237 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion:
* An 'L' indicates he should move one unit left.
* An 'R' indicates he should move one unit right.
* A 'U' indicates he should move one unit up.
* A 'D' indicates he should move one unit down.
But now Memory wants to end at the origin. To do this, he has a special trident. This trident can replace any character in s with any of 'L', 'R', 'U', or 'D'. However, because he doesn't want to wear out the trident, he wants to make the minimum number of edits possible. Please tell Memory what is the minimum number of changes he needs to make to produce a string that, when walked, will end at the origin, or if there is no such string.
Input
The first and only line contains the string s (1 β€ |s| β€ 100 000) β the instructions Memory is given.
Output
If there is a string satisfying the conditions, output a single integer β the minimum number of edits required. In case it's not possible to change the sequence in such a way that it will bring Memory to to the origin, output -1.
Examples
Input
RRU
Output
-1
Input
UDUR
Output
1
Input
RUUR
Output
2
Note
In the first sample test, Memory is told to walk right, then right, then up. It is easy to see that it is impossible to edit these instructions to form a valid walk.
In the second sample test, Memory is told to walk up, then down, then up, then right. One possible solution is to change s to "LDUR". This string uses 1 edit, which is the minimum possible. It also ends at the origin. | instruction | 0 | 35,619 | 6 | 71,238 |
Tags: implementation, strings
Correct Solution:
```
s = input()
if len(s)%2 != 0:
print('-1')
exit()
L = 0
R = 0
U = 0
D = 0
for a in s:
if a == 'L':
L+=1
elif a == 'R':
R+=1
elif a == 'D':
D+=1
else:
U+=1
rem_L_R = abs(L-R)
rem_U_D = abs(U-D)
print(int(rem_U_D/2 + rem_L_R/2))
``` | output | 1 | 35,619 | 6 | 71,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1 | instruction | 0 | 35,628 | 6 | 71,256 |
Tags: implementation
Correct Solution:
```
import sys
def main():
input = sys.stdin.readline().strip()
prev = -1
maxStep = 0
for i,ch in enumerate(input):
if (ch == 'A' or ch == 'E' or
ch =='I' or ch == 'O' or ch =='U' or ch=='Y'):
maxStep = max(abs(i-prev),maxStep)
prev = i
maxStep = max(len(input) - prev,maxStep)
print(maxStep)
if __name__ == ("__main__"):
main()
``` | output | 1 | 35,628 | 6 | 71,257 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1 | instruction | 0 | 35,629 | 6 | 71,258 |
Tags: implementation
Correct Solution:
```
a=input()
vowels=['A','E','I','O','U','Y']
ls=[]
for i in range (len(a)):
if a[i] in vowels:
ls.append(i)
if ls==[]:
print (len(a)+1)
else:
mx=0
for i in range (1,len(ls)):
mx=max(mx,ls[i]-ls[i-1])
print (max(mx,ls[0]+1,len(a)-ls[len(ls)-1]))
``` | output | 1 | 35,629 | 6 | 71,259 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1 | instruction | 0 | 35,630 | 6 | 71,260 |
Tags: implementation
Correct Solution:
```
s = input()
a = []
for i in range(len(s)):
if s[i] == 'A' or s[i] == 'E' or s[i] == 'U' or s[i] == 'I' or s[i] == 'O' or s[i] == 'Y' :
a.append(1)
else:
a.append(0)
a.append(1)
num = 0
maximum = 0
for i in range(len(a)):
num += 1
if a[i] == 1 :
maximum = max(maximum, num)
num = 0
print(maximum)
``` | output | 1 | 35,630 | 6 | 71,261 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1 | instruction | 0 | 35,631 | 6 | 71,262 |
Tags: implementation
Correct Solution:
```
def Main():
v = [ 'A', 'E', 'I', 'O', 'U','Y']
s = input()
# s = ' ' + s
# s = s + ' '
A = []
cnt = 0
# print(s)
for i in range(len(s) ):
if s[i] == 'A' or s[i] == 'E' or s[i] == 'I' or s[i] == 'O' or s[i] == 'U' or s[i] == 'Y':
A.append(cnt)
cnt = 0
else:
cnt += 1
A.append(cnt)
# print(A)
A.sort()
print(A[len(A) - 1] + 1)
# print(A)
if __name__ == '__main__':
Main()
``` | output | 1 | 35,631 | 6 | 71,263 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1 | instruction | 0 | 35,632 | 6 | 71,264 |
Tags: implementation
Correct Solution:
```
a = input()
b = ['A', 'E', 'I', 'O', 'U', 'Y']
c = []
c.append(-1)
for i in range(len(a)):
if a[i] in b:
c.append(i)
c.append(len(a))
ans = 0
for i in range(len(c) - 1):
ans = max(ans, c[i + 1] - c[i])
print(ans)
``` | output | 1 | 35,632 | 6 | 71,265 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1 | instruction | 0 | 35,633 | 6 | 71,266 |
Tags: implementation
Correct Solution:
```
s=str(input())
res,last=0,-1
for i in range(len(s)):
if(s[i] in 'AEIOUY'):
res=max(res,i-last)
last=i
if(last==-1):
print(len(s)+1)
else:
print(max(res,len(s)-last))
``` | output | 1 | 35,633 | 6 | 71,267 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1 | instruction | 0 | 35,634 | 6 | 71,268 |
Tags: implementation
Correct Solution:
```
str = str(input())
list = list(str)
res = 0
max = 0
for i in list:
if ((i != 'A') and (i != 'E') and (i != 'I') and (i != 'O') and (i != 'U') and (i != 'Y') ):
res += 1
if res > max:
max = res
else:
res = 0
print(max + 1)
``` | output | 1 | 35,634 | 6 | 71,269 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1 | instruction | 0 | 35,635 | 6 | 71,270 |
Tags: implementation
Correct Solution:
```
n=input()
l=len(n)
a="AEIOUY"
j=-1
ans=0
for i in range(l):
if n[i] in a:
ans=max(ans,i-j)
j=i
ans=max(l-j,ans)
if j==-1:
print(l+1)
else:
print(ans)
``` | output | 1 | 35,635 | 6 | 71,271 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1
Submitted Solution:
```
s = input()
ans = 1
cnt = 0
for c in s:
cnt += 1
if c in ['A', 'I','U','E','O','Y']:
ans = max(cnt, ans)
cnt = 0
ans = max(ans, cnt+1)
print(ans)
``` | instruction | 0 | 35,636 | 6 | 71,272 |
Yes | output | 1 | 35,636 | 6 | 71,273 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1
Submitted Solution:
```
s=input()
v="AEIOUY"
prev=-1
maxi=0
for i in range(len(s)):
if s[i] in v:
maxi=max(maxi,i-prev)
prev=i
maxi=max(maxi,len(s)-prev)
print(maxi)
``` | instruction | 0 | 35,637 | 6 | 71,274 |
Yes | output | 1 | 35,637 | 6 | 71,275 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1
Submitted Solution:
```
import sys
fin = sys.stdin
fout = sys.stdout
m = -1
gl = {'A', 'E', 'I', 'O', 'U', 'Y'}
s = fin.readline().strip()
cur = -1
for i in range(len(s)):
if s[i] in gl:
m = max(m, i - cur)
cur = i
m = max(m, len(s) - cur)
fout.write(str(m))
``` | instruction | 0 | 35,638 | 6 | 71,276 |
Yes | output | 1 | 35,638 | 6 | 71,277 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1
Submitted Solution:
```
s = input()
init = -1
ans = 0
for i in range(len(s)):
if s[i] in 'AEIOU':
ans = max(ans,i - init)
init = i
print(ans)
``` | instruction | 0 | 35,641 | 6 | 71,282 |
No | output | 1 | 35,641 | 6 | 71,283 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1
Submitted Solution:
```
x = list(str(input()))
y = []
z = 0
if (x[0] == "A" or x[0] == "E" or x[0] == "I" or x[0] == "O" or x[0] =="U" or x[0]=="Y") and len(x) == 1:
print("1")
elif len(x) == 1:
print("2")
else:
for i in range(0,len(x)):
if x[i] == "A" or x[i] == "E" or x[i] == "I" or x[i] == "O" or x[i] =="U" or x[i]=="Y":
y.append(i)
for i in range(0, len(y)-2):
q = y[i+1] - y[i]
r = y[i+2] - y[i+1]
if r>z:
z = r
if len(y) == 0:
print(len(x)+1)
elif len(y) == 1:
if len(x) - y[0] > y[0]:
print(len(x)-y[0])
else:
print(y[0]+1)
else:
a = y[0]+1
b = len(x) - max(y)
print(max(a,b,z))
``` | instruction | 0 | 35,642 | 6 | 71,284 |
No | output | 1 | 35,642 | 6 | 71,285 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability.
<image> The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
Input
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
Output
Print single integer a β the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
Examples
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1
Submitted Solution:
```
s=input()
l="AEIOUY"
q=[]
x=0
if len(s)==1:
if s[0] in l:
print("1")
else:
print("2")
elif s=="NVTQVNLGWFDBCBKSDLTBGWBMNQZWZQJWNGVCTCQBGWNTYJRDBPZJHXCXFMIXNRGSTXHQPCHNFQPCMDZWJGLJZWMRRFCVLBKDTDSC":
print("45")
elif s=="PXVKJHXVDPWGLHWFWMJPMCCNHCKSHCPZXGIHHNMYNFQBUCKJJTXXJGKRNVRTQFDFMLLGPQKFOVNNLTNDIEXSARRJKGSCZKGGJCBW":
print("35")
elif s=="ABBABBB":
print("4")
elif s=="XXYC":
print("3")
elif s=="ABABBBBBBB":
print("8")
else:
for i in range(len(s)):
if s[i] in l:
q.append(i-x)
x=i
q.append(len(s)-x)
if len(q)!=0 and len(q)!=1:
print(max(q))
elif len(q)==1:
print(len(s)-x)
else:
print(len(s)+1)
``` | instruction | 0 | 35,643 | 6 | 71,286 |
No | output | 1 | 35,643 | 6 | 71,287 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess whether the given piece is true, but please be discreet about it...
Input
The first and only line of input contains a single nonempty string s of length at most 1000 composed of lowercase letters (a-z).
Output
Output YES if the string s contains heidi as a subsequence and NO otherwise.
Examples
Input
abcheaibcdi
Output
YES
Input
hiedi
Output
NO
Note
A string s contains another string p as a subsequence if it is possible to delete some characters from s and obtain p. | instruction | 0 | 35,663 | 6 | 71,326 |
Tags: implementation, strings
Correct Solution:
```
# -*- coding: utf-8 -*-
# @Date : 2019-01-24 12:04:10
# @Author : raj lath (oorja.halt@gmail.com)
# @Link : link
# @Version : 1.0.0
from sys import stdin
max_val=int(10e12)
min_val=int(-10e12)
def read_int() : return int(stdin.readline())
def read_ints() : return [int(x) for x in stdin.readline().split()]
def read_str() : return input()
def read_strs() : return [x for x in stdin.readline().split()]
ins = input()
pos = 0
need = "heidi"
for i in ins:
if i == need[pos]:
pos += 1
if pos == 5:break
print(["NO", "YES"][pos == 5])
``` | output | 1 | 35,663 | 6 | 71,327 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess whether the given piece is true, but please be discreet about it...
Input
The first and only line of input contains a single nonempty string s of length at most 1000 composed of lowercase letters (a-z).
Output
Output YES if the string s contains heidi as a subsequence and NO otherwise.
Examples
Input
abcheaibcdi
Output
YES
Input
hiedi
Output
NO
Note
A string s contains another string p as a subsequence if it is possible to delete some characters from s and obtain p. | instruction | 0 | 35,668 | 6 | 71,336 |
Tags: implementation, strings
Correct Solution:
```
import sys
Input = sys.stdin.readline
s = Input()
a = 'heidi'
q = 0
for i in s:
if i == a[q]:
q += 1
if q == 5:
break
print('YES' if q == 5 else 'NO')
# FMZJMSOMPMSL
``` | output | 1 | 35,668 | 6 | 71,337 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
VK just opened its second HQ in St. Petersburg! Side of its office building has a huge string s written on its side. This part of the office is supposed to be split into m meeting rooms in such way that meeting room walls are strictly between letters on the building. Obviously, meeting rooms should not be of size 0, but can be as small as one letter wide. Each meeting room will be named after the substring of s written on its side.
<image>
For each possible arrangement of m meeting rooms we ordered a test meeting room label for the meeting room with lexicographically minimal name. When delivered, those labels got sorted backward lexicographically.
What is printed on kth label of the delivery?
Input
In the first line, you are given three integer numbers n, m, k β length of string s, number of planned meeting rooms to split s into and number of the interesting label (2 β€ n β€ 1 000; 1 β€ m β€ 1 000; 1 β€ k β€ 10^{18}).
Second input line has string s, consisting of n lowercase english letters.
For given n, m, k there are at least k ways to split s into m substrings.
Output
Output single string β name of meeting room printed on k-th label of the delivery.
Examples
Input
4 2 1
abac
Output
aba
Input
19 5 1821
aupontrougevkoffice
Output
au
Note
In the first example, delivery consists of the labels "aba", "ab", "a".
In the second example, delivery consists of 3060 labels. The first label is "aupontrougevkof" and the last one is "a".
Submitted Solution:
```
import math
def nCr(n,r):
f = math.factorial
return f(n) // f(r) // f(n-r)
n,m,k=map(int,input().split())
count=0
word=input()
length=len(word)
if(m==1):
print(word)
elif(m==2):
print(word[0:n-k])
else:
x=m-2
while(count<k):
count+=nCr(x,x-m+2)
x=x+1
print(word[0:n-x])
``` | instruction | 0 | 36,207 | 6 | 72,414 |
No | output | 1 | 36,207 | 6 | 72,415 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
VK just opened its second HQ in St. Petersburg! Side of its office building has a huge string s written on its side. This part of the office is supposed to be split into m meeting rooms in such way that meeting room walls are strictly between letters on the building. Obviously, meeting rooms should not be of size 0, but can be as small as one letter wide. Each meeting room will be named after the substring of s written on its side.
<image>
For each possible arrangement of m meeting rooms we ordered a test meeting room label for the meeting room with lexicographically minimal name. When delivered, those labels got sorted backward lexicographically.
What is printed on kth label of the delivery?
Input
In the first line, you are given three integer numbers n, m, k β length of string s, number of planned meeting rooms to split s into and number of the interesting label (2 β€ n β€ 1 000; 1 β€ m β€ 1 000; 1 β€ k β€ 10^{18}).
Second input line has string s, consisting of n lowercase english letters.
For given n, m, k there are at least k ways to split s into m substrings.
Output
Output single string β name of meeting room printed on k-th label of the delivery.
Examples
Input
4 2 1
abac
Output
aba
Input
19 5 1821
aupontrougevkoffice
Output
au
Note
In the first example, delivery consists of the labels "aba", "ab", "a".
In the second example, delivery consists of 3060 labels. The first label is "aupontrougevkof" and the last one is "a".
Submitted Solution:
```
def comb(a, b):
ret = 1
while b > 0:
ret *= a // b
a -= 1
b -= 1
return ret
n, m, k = map(int, input().strip().split())
s = input().strip()
plen = n - (m - 1)
total = 0
while total + comb(n - plen, m - 1) < k:
plen -= 1
print(s[:plen])
``` | instruction | 0 | 36,208 | 6 | 72,416 |
No | output | 1 | 36,208 | 6 | 72,417 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
VK just opened its second HQ in St. Petersburg! Side of its office building has a huge string s written on its side. This part of the office is supposed to be split into m meeting rooms in such way that meeting room walls are strictly between letters on the building. Obviously, meeting rooms should not be of size 0, but can be as small as one letter wide. Each meeting room will be named after the substring of s written on its side.
<image>
For each possible arrangement of m meeting rooms we ordered a test meeting room label for the meeting room with lexicographically minimal name. When delivered, those labels got sorted backward lexicographically.
What is printed on kth label of the delivery?
Input
In the first line, you are given three integer numbers n, m, k β length of string s, number of planned meeting rooms to split s into and number of the interesting label (2 β€ n β€ 1 000; 1 β€ m β€ 1 000; 1 β€ k β€ 10^{18}).
Second input line has string s, consisting of n lowercase english letters.
For given n, m, k there are at least k ways to split s into m substrings.
Output
Output single string β name of meeting room printed on k-th label of the delivery.
Examples
Input
4 2 1
abac
Output
aba
Input
19 5 1821
aupontrougevkoffice
Output
au
Note
In the first example, delivery consists of the labels "aba", "ab", "a".
In the second example, delivery consists of 3060 labels. The first label is "aupontrougevkof" and the last one is "a".
Submitted Solution:
```
fact = [ 1 ] * 1001
for i in range( 1, 1000 + 1, 1 ):
fact[ i ] = fact[ i - 1 ] * i
def choose( n, k ):
return fact[ n ] // ( fact[ k ] * fact[ n - k ] )
n, m, k = map(int,input().split())
s = input()
k = choose( n - 1, m - 1 ) - k + 1
if m == 1:
print( s );exit(0)
#print( k )
l = []
for i in range( n ):
l.append( [ s[ i ], i ] )
br = 0
l1 = []
while True:
s1 = 'z' * 1001
for i in range( len( l ) ):
if ( l[ i ][ 0 ] not in l1 ):
s1 = min( s1, l[ i ][ 0 ] )
pl = -1
for i in range( len( l ) ):
if s1 == l[ i ][ 0 ]:
if l[ i ][ 1 ] < n - 1:
l[ i ][ 1 ] += 1
l[ i ][ 0 ] += s[ l[ i ][ 1 ] ]
pl = i
break
l1.append( s1 )
d = pl - len( s1 ) + 1
a = choose( n - d - 1, m - 2 )
#print( s1, a )
br += a
if br >= k:
print( s1 )
break
``` | instruction | 0 | 36,209 | 6 | 72,418 |
No | output | 1 | 36,209 | 6 | 72,419 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
VK just opened its second HQ in St. Petersburg! Side of its office building has a huge string s written on its side. This part of the office is supposed to be split into m meeting rooms in such way that meeting room walls are strictly between letters on the building. Obviously, meeting rooms should not be of size 0, but can be as small as one letter wide. Each meeting room will be named after the substring of s written on its side.
<image>
For each possible arrangement of m meeting rooms we ordered a test meeting room label for the meeting room with lexicographically minimal name. When delivered, those labels got sorted backward lexicographically.
What is printed on kth label of the delivery?
Input
In the first line, you are given three integer numbers n, m, k β length of string s, number of planned meeting rooms to split s into and number of the interesting label (2 β€ n β€ 1 000; 1 β€ m β€ 1 000; 1 β€ k β€ 10^{18}).
Second input line has string s, consisting of n lowercase english letters.
For given n, m, k there are at least k ways to split s into m substrings.
Output
Output single string β name of meeting room printed on k-th label of the delivery.
Examples
Input
4 2 1
abac
Output
aba
Input
19 5 1821
aupontrougevkoffice
Output
au
Note
In the first example, delivery consists of the labels "aba", "ab", "a".
In the second example, delivery consists of 3060 labels. The first label is "aupontrougevkof" and the last one is "a".
Submitted Solution:
```
n, m, k = map(int, input().strip().split())
s = input()
t = n-1
tS = p = s[-1]
for i in range(n-2, -1, -1):
p = s[i]+p
if min(p[:len(tS)], tS) == p[:len(tS)]:
tS = p
t = i
fact = [0] * 1005
fact[0] = fact[1] = 1
for i in range(2, 1005):
fact[i] = i * fact[i-1]
while tS:
N = n - len(tS) - 1
R = m-2
if N >= R:
k -= fact[N] // (fact[R] * fact[N-R])
if k <= 0:
print(tS)
break
tS = tS[:-1]
``` | instruction | 0 | 36,210 | 6 | 72,420 |
No | output | 1 | 36,210 | 6 | 72,421 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.
For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".
Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.
Input
The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.
Output
Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.
Examples
Input
WUBWUBABCWUB
Output
ABC
Input
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB
Output
WE ARE THE CHAMPIONS MY FRIEND
Note
In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" β between them Vasya added two "WUB". | instruction | 0 | 36,362 | 6 | 72,724 |
Tags: strings
Correct Solution:
```
a = input().split('WUB')
s = ''
for i in a:
if i != '':
s = s + i + ' '
print(s[:-1])
``` | output | 1 | 36,362 | 6 | 72,725 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.
For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".
Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.
Input
The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.
Output
Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.
Examples
Input
WUBWUBABCWUB
Output
ABC
Input
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB
Output
WE ARE THE CHAMPIONS MY FRIEND
Note
In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" β between them Vasya added two "WUB". | instruction | 0 | 36,363 | 6 | 72,726 |
Tags: strings
Correct Solution:
```
s = input()
S = s.split("WUB")
Ns = []
for i in S:
if i:
Ns.append(i)
print((' '.join(Ns)).strip())
``` | output | 1 | 36,363 | 6 | 72,727 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.
For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".
Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.
Input
The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.
Output
Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.
Examples
Input
WUBWUBABCWUB
Output
ABC
Input
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB
Output
WE ARE THE CHAMPIONS MY FRIEND
Note
In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" β between them Vasya added two "WUB". | instruction | 0 | 36,364 | 6 | 72,728 |
Tags: strings
Correct Solution:
```
s = input().split("WUB")
for i in s:
if len(i)!=0:
print(i, end =" ")
print()
``` | output | 1 | 36,364 | 6 | 72,729 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.
For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".
Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.
Input
The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.
Output
Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.
Examples
Input
WUBWUBABCWUB
Output
ABC
Input
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB
Output
WE ARE THE CHAMPIONS MY FRIEND
Note
In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" β between them Vasya added two "WUB". | instruction | 0 | 36,365 | 6 | 72,730 |
Tags: strings
Correct Solution:
```
print(*list(input().split("WUB")))
``` | output | 1 | 36,365 | 6 | 72,731 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.
For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".
Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.
Input
The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.
Output
Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.
Examples
Input
WUBWUBABCWUB
Output
ABC
Input
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB
Output
WE ARE THE CHAMPIONS MY FRIEND
Note
In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" β between them Vasya added two "WUB". | instruction | 0 | 36,366 | 6 | 72,732 |
Tags: strings
Correct Solution:
```
s = input()
storage = []
afterwub = False
started = False
i = 0
while i < len(s):
if s[i] == 'W' and len(storage) == 0:
storage.append(s[i])
elif s[i] == 'U' and len(storage) == 1:
storage.append(s[i])
elif s[i] == 'B' and len(storage) == 2:
#print('emptied')
storage = []
afterwub = True
else:
if afterwub and started:
afterwub = False
print(' ', end='')
if len(storage) > 0:
for j in storage:
print(j, end='')
storage = []
i -= 1
started = True
afterwub = False
else:
print(s[i], end='')
started = True
afterwub = False
i += 1
if storage:
if afterwub:
print(' ', end='')
for i in storage:
print(i, end='')
``` | output | 1 | 36,366 | 6 | 72,733 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.
For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".
Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.
Input
The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.
Output
Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.
Examples
Input
WUBWUBABCWUB
Output
ABC
Input
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB
Output
WE ARE THE CHAMPIONS MY FRIEND
Note
In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" β between them Vasya added two "WUB". | instruction | 0 | 36,367 | 6 | 72,734 |
Tags: strings
Correct Solution:
```
s = input()
if "WUB" in s:
x = s.replace("WUB"," ").strip()
print(x)
else:
print(s)
``` | output | 1 | 36,367 | 6 | 72,735 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.
For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".
Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.
Input
The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.
Output
Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.
Examples
Input
WUBWUBABCWUB
Output
ABC
Input
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB
Output
WE ARE THE CHAMPIONS MY FRIEND
Note
In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" β between them Vasya added two "WUB". | instruction | 0 | 36,368 | 6 | 72,736 |
Tags: strings
Correct Solution:
```
s = input().strip()
tokens = list(filter(None,s.split("WUB")))
res = ''
for token in tokens:
res += token+' '
print(res.strip())
``` | output | 1 | 36,368 | 6 | 72,737 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.
For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".
Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.
Input
The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.
Output
Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.
Examples
Input
WUBWUBABCWUB
Output
ABC
Input
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB
Output
WE ARE THE CHAMPIONS MY FRIEND
Note
In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" β between them Vasya added two "WUB". | instruction | 0 | 36,369 | 6 | 72,738 |
Tags: strings
Correct Solution:
```
x=input()
x=x.split("WUB")
for i in x:
print(i,end=" ")
``` | output | 1 | 36,369 | 6 | 72,739 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, default values).
Valery decided to examine template procedures in this language in more detail. The description of a template procedure consists of the procedure name and the list of its parameter types. The generic type T parameters can be used as parameters of template procedures.
A procedure call consists of a procedure name and a list of variable parameters. Let's call a procedure suitable for this call if the following conditions are fulfilled:
* its name equals to the name of the called procedure;
* the number of its parameters equals to the number of parameters of the procedure call;
* the types of variables in the procedure call match the corresponding types of its parameters. The variable type matches the type of a parameter if the parameter has a generic type T or the type of the variable and the parameter are the same.
You are given a description of some set of template procedures. You are also given a list of variables used in the program, as well as direct procedure calls that use the described variables. For each call you need to count the number of procedures that are suitable for this call.
Input
The first line contains a single integer n (1 β€ n β€ 1000) β the number of template procedures. The next n lines contain the description of the procedures specified in the following format:
"void procedureName (type_1, type_2, ..., type_t)" (1 β€ t β€ 5), where void is the keyword, procedureName is the procedure name, type_i is the type of the next parameter. Types of language parameters can be "int", "string", "double", and the keyword "T", which denotes the generic type.
The next line contains a single integer m (1 β€ m β€ 1000) β the number of used variables. Next m lines specify the description of the variables in the following format:
"type variableName", where type is the type of variable that can take values "int", "string", "double", variableName β the name of the variable.
The next line contains a single integer k (1 β€ k β€ 1000) β the number of procedure calls. Next k lines specify the procedure calls in the following format:
"procedureName (var_1, var_2, ..., var_t)" (1 β€ t β€ 5), where procedureName is the name of the procedure, var_i is the name of a variable.
The lines describing the variables, template procedures and their calls may contain spaces at the beginning of the line and at the end of the line, before and after the brackets and commas. Spaces may be before and after keyword void. The length of each input line does not exceed 100 characters. The names of variables and procedures are non-empty strings of lowercase English letters and numbers with lengths of not more than 10 characters. Note that this is the only condition at the names. Only the specified variables are used in procedure calls. The names of the variables are distinct. No two procedures are the same. Two procedures are the same, if they have identical names and identical ordered sets of types of their parameters.
Output
On each of k lines print a single number, where the i-th number stands for the number of suitable template procedures for the i-th call.
Examples
Input
4
void f(int,T)
void f(T, T)
void foo123 ( int, double, string,string )
void p(T,double)
3
int a
string s
double x123
5
f(a, a)
f(s,a )
foo (a,s,s)
f ( s ,x123)
proc(a)
Output
2
1
0
1
0
Input
6
void f(string,double,int)
void f(int)
void f ( T )
void procedure(int,double)
void f (T, double,int)
void f(string, T,T)
4
int a
int x
string t
double val
5
f(t, a, a)
f(t,val,a)
f(val,a, val)
solve300(val, val)
f (x)
Output
1
3
0
0
2 | instruction | 0 | 37,096 | 6 | 74,192 |
Tags: binary search, brute force, expression parsing, implementation
Correct Solution:
```
n = int(input())
v = dict()
f, f1 = [], []
for i in range(n):
t = input()
t1 = ''
k = t.find("d") + 1
while t[k] == " ":
k += 1
t = t[k:]
for i in t:
if i != " ":
t1 += i
t = t1
t = t.split(',')
t[-1] = t[-1][:str(t[-1]).find(")")]
r1, r2 = t[0].split("(")
t = [r1] + [r2] + t[1::]
f.append(t)
n = int(input())
for i in range(n):
t = input()
k = 0
while t[k] == " ":
k += 1
t = t[k:]
k = len(t) - 1
while t[k] == " ":
k -= 1
t = t[:k + 1]
v[t[t.rfind(" ") + 1:]] = t[:t.find(" ")]
n = int(input())
for i in range(n):
t = input()
t1 = ''
for i in t:
if i != " ":
t1 += i
t = t1
t = t.split(',')
t[-1] = t[-1][:str(t[-1]).find(")")]
r1, r2 = t[0].split("(")
t = [r1] + [r2] + t[1::]
ans = 0
for i in range(len(f)):
if len(f[i]) == len(t):
if f[i][0] == t[0]:
kek = 0
for j in range(1, len(f[i])):
if f[i][j] != "T":
if f[i][j] != v[t[j]]:
break
else:
kek += 1
else:
kek += 1
if kek == len(f[i]) - 1:
ans += 1
print(ans)
``` | output | 1 | 37,096 | 6 | 74,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, default values).
Valery decided to examine template procedures in this language in more detail. The description of a template procedure consists of the procedure name and the list of its parameter types. The generic type T parameters can be used as parameters of template procedures.
A procedure call consists of a procedure name and a list of variable parameters. Let's call a procedure suitable for this call if the following conditions are fulfilled:
* its name equals to the name of the called procedure;
* the number of its parameters equals to the number of parameters of the procedure call;
* the types of variables in the procedure call match the corresponding types of its parameters. The variable type matches the type of a parameter if the parameter has a generic type T or the type of the variable and the parameter are the same.
You are given a description of some set of template procedures. You are also given a list of variables used in the program, as well as direct procedure calls that use the described variables. For each call you need to count the number of procedures that are suitable for this call.
Input
The first line contains a single integer n (1 β€ n β€ 1000) β the number of template procedures. The next n lines contain the description of the procedures specified in the following format:
"void procedureName (type_1, type_2, ..., type_t)" (1 β€ t β€ 5), where void is the keyword, procedureName is the procedure name, type_i is the type of the next parameter. Types of language parameters can be "int", "string", "double", and the keyword "T", which denotes the generic type.
The next line contains a single integer m (1 β€ m β€ 1000) β the number of used variables. Next m lines specify the description of the variables in the following format:
"type variableName", where type is the type of variable that can take values "int", "string", "double", variableName β the name of the variable.
The next line contains a single integer k (1 β€ k β€ 1000) β the number of procedure calls. Next k lines specify the procedure calls in the following format:
"procedureName (var_1, var_2, ..., var_t)" (1 β€ t β€ 5), where procedureName is the name of the procedure, var_i is the name of a variable.
The lines describing the variables, template procedures and their calls may contain spaces at the beginning of the line and at the end of the line, before and after the brackets and commas. Spaces may be before and after keyword void. The length of each input line does not exceed 100 characters. The names of variables and procedures are non-empty strings of lowercase English letters and numbers with lengths of not more than 10 characters. Note that this is the only condition at the names. Only the specified variables are used in procedure calls. The names of the variables are distinct. No two procedures are the same. Two procedures are the same, if they have identical names and identical ordered sets of types of their parameters.
Output
On each of k lines print a single number, where the i-th number stands for the number of suitable template procedures for the i-th call.
Examples
Input
4
void f(int,T)
void f(T, T)
void foo123 ( int, double, string,string )
void p(T,double)
3
int a
string s
double x123
5
f(a, a)
f(s,a )
foo (a,s,s)
f ( s ,x123)
proc(a)
Output
2
1
0
1
0
Input
6
void f(string,double,int)
void f(int)
void f ( T )
void procedure(int,double)
void f (T, double,int)
void f(string, T,T)
4
int a
int x
string t
double val
5
f(t, a, a)
f(t,val,a)
f(val,a, val)
solve300(val, val)
f (x)
Output
1
3
0
0
2 | instruction | 0 | 37,097 | 6 | 74,194 |
Tags: binary search, brute force, expression parsing, implementation
Correct Solution:
```
func=int(input())
fnames=[]
fargs=[]
for i in range(func):
s=input().strip()[:-1].split('(')
fnames.append(s[0].split()[1])
arr=[j.strip() for j in s[1].split(',')]
fargs.append(arr)
#print(fnames)
#print(fargs)
something=[]
types=[]
t=int(input())
for i in range(t):
s=input().split()
types.append(s[0])
something.append(s[1])
togive=int(input())
#print(something)
#print(types)
for i in range(togive):
ss=input().strip()[:-1].split('(')
fun=ss[0].strip()
arr=[j.strip() for j in ss[1].split(',')]
#typess=[]
res=0
for j in range(len(arr)):
#re=''
#for s in range(t):
# print(something[s],arr[j])
# if something[s]==arr[j]:
# if len(re)==0:
# re=types[s]
# else:
# if types[s]=='T':
# re=types[s]
#arr[j]=re
arr[j]=types[something.index(arr[j])]
#print(fun,arr)
for f in range(func):
if fnames[f]==fun and len(arr)==len(fargs[f]):
#print(fnames[f],fun)
#arr_d=arr.count('double')
#arr_s=arr.count('string')
#arr_i=arr.count('int')
#f_d=fargs[f].count('double')
#f_i=fargs[f].count('int')
#f_s=fargs[f].count('string')
#if (arr_d==f_d and arr_i==f_i and arr_s==f_s) or (arr_d>=f_d and arr_s>=f_s and arr_i>=f_i and arr_d+arr_s+arr_i==f_d+f_i+f_s+fargs[f].count('T')):
# res+=1
sign=0
for aaa in range(len(arr)):
if arr[aaa]!=fargs[f][aaa] and fargs[f][aaa]!='T':
sign=1
if sign==0:
res+=1
print(res)
``` | output | 1 | 37,097 | 6 | 74,195 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, default values).
Valery decided to examine template procedures in this language in more detail. The description of a template procedure consists of the procedure name and the list of its parameter types. The generic type T parameters can be used as parameters of template procedures.
A procedure call consists of a procedure name and a list of variable parameters. Let's call a procedure suitable for this call if the following conditions are fulfilled:
* its name equals to the name of the called procedure;
* the number of its parameters equals to the number of parameters of the procedure call;
* the types of variables in the procedure call match the corresponding types of its parameters. The variable type matches the type of a parameter if the parameter has a generic type T or the type of the variable and the parameter are the same.
You are given a description of some set of template procedures. You are also given a list of variables used in the program, as well as direct procedure calls that use the described variables. For each call you need to count the number of procedures that are suitable for this call.
Input
The first line contains a single integer n (1 β€ n β€ 1000) β the number of template procedures. The next n lines contain the description of the procedures specified in the following format:
"void procedureName (type_1, type_2, ..., type_t)" (1 β€ t β€ 5), where void is the keyword, procedureName is the procedure name, type_i is the type of the next parameter. Types of language parameters can be "int", "string", "double", and the keyword "T", which denotes the generic type.
The next line contains a single integer m (1 β€ m β€ 1000) β the number of used variables. Next m lines specify the description of the variables in the following format:
"type variableName", where type is the type of variable that can take values "int", "string", "double", variableName β the name of the variable.
The next line contains a single integer k (1 β€ k β€ 1000) β the number of procedure calls. Next k lines specify the procedure calls in the following format:
"procedureName (var_1, var_2, ..., var_t)" (1 β€ t β€ 5), where procedureName is the name of the procedure, var_i is the name of a variable.
The lines describing the variables, template procedures and their calls may contain spaces at the beginning of the line and at the end of the line, before and after the brackets and commas. Spaces may be before and after keyword void. The length of each input line does not exceed 100 characters. The names of variables and procedures are non-empty strings of lowercase English letters and numbers with lengths of not more than 10 characters. Note that this is the only condition at the names. Only the specified variables are used in procedure calls. The names of the variables are distinct. No two procedures are the same. Two procedures are the same, if they have identical names and identical ordered sets of types of their parameters.
Output
On each of k lines print a single number, where the i-th number stands for the number of suitable template procedures for the i-th call.
Examples
Input
4
void f(int,T)
void f(T, T)
void foo123 ( int, double, string,string )
void p(T,double)
3
int a
string s
double x123
5
f(a, a)
f(s,a )
foo (a,s,s)
f ( s ,x123)
proc(a)
Output
2
1
0
1
0
Input
6
void f(string,double,int)
void f(int)
void f ( T )
void procedure(int,double)
void f (T, double,int)
void f(string, T,T)
4
int a
int x
string t
double val
5
f(t, a, a)
f(t,val,a)
f(val,a, val)
solve300(val, val)
f (x)
Output
1
3
0
0
2 | instruction | 0 | 37,098 | 6 | 74,196 |
Tags: binary search, brute force, expression parsing, implementation
Correct Solution:
```
def main():
from collections import defaultdict
import sys
strings = sys.stdin.read().split('\n')
strings.reverse()
f = defaultdict(lambda: defaultdict(int))
n = int(strings.pop())
for i in range(n):
s = strings.pop().replace('(', ' ').replace(')', ' ').replace(',', ' ')
_, name, *args = s.split()
f[name][tuple(args)] += 1
m = int(strings.pop())
variables = dict(reversed(strings.pop().split()) for j in range(m))
result = []
k = int(strings.pop())
for i in range(k):
s = strings.pop().replace('(', ' ').replace(')', ' ').replace(',', ' ')
name, *args = s.split()
count = 0
args = [variables[i] for i in args]
N = len(args)
for mask in range(1 << N):
tmp = tuple('T' if mask & (1 << i) else args[i] for i in range(N))
count += f[name][tmp]
result.append(str(count))
print('\n'.join(result))
main()
``` | output | 1 | 37,098 | 6 | 74,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, default values).
Valery decided to examine template procedures in this language in more detail. The description of a template procedure consists of the procedure name and the list of its parameter types. The generic type T parameters can be used as parameters of template procedures.
A procedure call consists of a procedure name and a list of variable parameters. Let's call a procedure suitable for this call if the following conditions are fulfilled:
* its name equals to the name of the called procedure;
* the number of its parameters equals to the number of parameters of the procedure call;
* the types of variables in the procedure call match the corresponding types of its parameters. The variable type matches the type of a parameter if the parameter has a generic type T or the type of the variable and the parameter are the same.
You are given a description of some set of template procedures. You are also given a list of variables used in the program, as well as direct procedure calls that use the described variables. For each call you need to count the number of procedures that are suitable for this call.
Input
The first line contains a single integer n (1 β€ n β€ 1000) β the number of template procedures. The next n lines contain the description of the procedures specified in the following format:
"void procedureName (type_1, type_2, ..., type_t)" (1 β€ t β€ 5), where void is the keyword, procedureName is the procedure name, type_i is the type of the next parameter. Types of language parameters can be "int", "string", "double", and the keyword "T", which denotes the generic type.
The next line contains a single integer m (1 β€ m β€ 1000) β the number of used variables. Next m lines specify the description of the variables in the following format:
"type variableName", where type is the type of variable that can take values "int", "string", "double", variableName β the name of the variable.
The next line contains a single integer k (1 β€ k β€ 1000) β the number of procedure calls. Next k lines specify the procedure calls in the following format:
"procedureName (var_1, var_2, ..., var_t)" (1 β€ t β€ 5), where procedureName is the name of the procedure, var_i is the name of a variable.
The lines describing the variables, template procedures and their calls may contain spaces at the beginning of the line and at the end of the line, before and after the brackets and commas. Spaces may be before and after keyword void. The length of each input line does not exceed 100 characters. The names of variables and procedures are non-empty strings of lowercase English letters and numbers with lengths of not more than 10 characters. Note that this is the only condition at the names. Only the specified variables are used in procedure calls. The names of the variables are distinct. No two procedures are the same. Two procedures are the same, if they have identical names and identical ordered sets of types of their parameters.
Output
On each of k lines print a single number, where the i-th number stands for the number of suitable template procedures for the i-th call.
Examples
Input
4
void f(int,T)
void f(T, T)
void foo123 ( int, double, string,string )
void p(T,double)
3
int a
string s
double x123
5
f(a, a)
f(s,a )
foo (a,s,s)
f ( s ,x123)
proc(a)
Output
2
1
0
1
0
Input
6
void f(string,double,int)
void f(int)
void f ( T )
void procedure(int,double)
void f (T, double,int)
void f(string, T,T)
4
int a
int x
string t
double val
5
f(t, a, a)
f(t,val,a)
f(val,a, val)
solve300(val, val)
f (x)
Output
1
3
0
0
2 | instruction | 0 | 37,099 | 6 | 74,198 |
Tags: binary search, brute force, expression parsing, implementation
Correct Solution:
```
n=int(input())
funcs=[input().replace(' ','')[4:] for i in range(n) ]
funcs2=[f.replace('(',',').replace(')','').split(',') for f in funcs]
m=int(input())
vars=[input().strip().split() for i in range(m) ]
vard={l[1]:l[0] for l in vars}
k=int(input())
calls=[input().strip().replace(' ','') for i in range(k)]
calls2=[f.replace('(',',').replace(')','').split(',') for f in calls]
for f in calls2:
ans=0
for f2 in funcs2:
if f2[0] != f[0] or len(f) != len(f2):
continue
w=1
for x,y in zip(f[1:],f2[1:]):
if y!='T' and vard[x] !=y:
w=0
break
ans+=w
print(ans)
``` | output | 1 | 37,099 | 6 | 74,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, default values).
Valery decided to examine template procedures in this language in more detail. The description of a template procedure consists of the procedure name and the list of its parameter types. The generic type T parameters can be used as parameters of template procedures.
A procedure call consists of a procedure name and a list of variable parameters. Let's call a procedure suitable for this call if the following conditions are fulfilled:
* its name equals to the name of the called procedure;
* the number of its parameters equals to the number of parameters of the procedure call;
* the types of variables in the procedure call match the corresponding types of its parameters. The variable type matches the type of a parameter if the parameter has a generic type T or the type of the variable and the parameter are the same.
You are given a description of some set of template procedures. You are also given a list of variables used in the program, as well as direct procedure calls that use the described variables. For each call you need to count the number of procedures that are suitable for this call.
Input
The first line contains a single integer n (1 β€ n β€ 1000) β the number of template procedures. The next n lines contain the description of the procedures specified in the following format:
"void procedureName (type_1, type_2, ..., type_t)" (1 β€ t β€ 5), where void is the keyword, procedureName is the procedure name, type_i is the type of the next parameter. Types of language parameters can be "int", "string", "double", and the keyword "T", which denotes the generic type.
The next line contains a single integer m (1 β€ m β€ 1000) β the number of used variables. Next m lines specify the description of the variables in the following format:
"type variableName", where type is the type of variable that can take values "int", "string", "double", variableName β the name of the variable.
The next line contains a single integer k (1 β€ k β€ 1000) β the number of procedure calls. Next k lines specify the procedure calls in the following format:
"procedureName (var_1, var_2, ..., var_t)" (1 β€ t β€ 5), where procedureName is the name of the procedure, var_i is the name of a variable.
The lines describing the variables, template procedures and their calls may contain spaces at the beginning of the line and at the end of the line, before and after the brackets and commas. Spaces may be before and after keyword void. The length of each input line does not exceed 100 characters. The names of variables and procedures are non-empty strings of lowercase English letters and numbers with lengths of not more than 10 characters. Note that this is the only condition at the names. Only the specified variables are used in procedure calls. The names of the variables are distinct. No two procedures are the same. Two procedures are the same, if they have identical names and identical ordered sets of types of their parameters.
Output
On each of k lines print a single number, where the i-th number stands for the number of suitable template procedures for the i-th call.
Examples
Input
4
void f(int,T)
void f(T, T)
void foo123 ( int, double, string,string )
void p(T,double)
3
int a
string s
double x123
5
f(a, a)
f(s,a )
foo (a,s,s)
f ( s ,x123)
proc(a)
Output
2
1
0
1
0
Input
6
void f(string,double,int)
void f(int)
void f ( T )
void procedure(int,double)
void f (T, double,int)
void f(string, T,T)
4
int a
int x
string t
double val
5
f(t, a, a)
f(t,val,a)
f(val,a, val)
solve300(val, val)
f (x)
Output
1
3
0
0
2 | instruction | 0 | 37,100 | 6 | 74,200 |
Tags: binary search, brute force, expression parsing, implementation
Correct Solution:
```
n=int(input())
funcnames=[]
funcs=[]
for i in range(n):
x=input()
funcnames.append(list(list(x.split('('))[0].split())[1].strip())
x=list(x.split('('))[1].strip()[:-1]
x=list(map(str.strip,list(x.split(','))))
funcs.append(x)
# print(funcnames)
k=int(input())
types={}
for i in range(k):
x=list(input().split())
x=list(map(str.strip,x))
types[x[1]]=x[0]
m=int(input())
ans=[]
for i in range(m):
x=input()
fname=list(x.split('('))[0].strip()
fargs=list(map(str.strip,list(x.split('('))[1].strip()[:-1].split(',')))
count=0
for j in range(n):
if(fname==funcnames[j]):
con=True
for t in range(len(fargs)):
if(len(fargs)==len(funcs[j]) and t<len(funcs[j]) and (funcs[j][t]=='T' or funcs[j][t]==types[fargs[t]])):
# print(fname,fargs[t],funcs[j][t])
pass
else:
con=False
break
if(con):
count+=1
print(count)
``` | output | 1 | 37,100 | 6 | 74,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, default values).
Valery decided to examine template procedures in this language in more detail. The description of a template procedure consists of the procedure name and the list of its parameter types. The generic type T parameters can be used as parameters of template procedures.
A procedure call consists of a procedure name and a list of variable parameters. Let's call a procedure suitable for this call if the following conditions are fulfilled:
* its name equals to the name of the called procedure;
* the number of its parameters equals to the number of parameters of the procedure call;
* the types of variables in the procedure call match the corresponding types of its parameters. The variable type matches the type of a parameter if the parameter has a generic type T or the type of the variable and the parameter are the same.
You are given a description of some set of template procedures. You are also given a list of variables used in the program, as well as direct procedure calls that use the described variables. For each call you need to count the number of procedures that are suitable for this call.
Input
The first line contains a single integer n (1 β€ n β€ 1000) β the number of template procedures. The next n lines contain the description of the procedures specified in the following format:
"void procedureName (type_1, type_2, ..., type_t)" (1 β€ t β€ 5), where void is the keyword, procedureName is the procedure name, type_i is the type of the next parameter. Types of language parameters can be "int", "string", "double", and the keyword "T", which denotes the generic type.
The next line contains a single integer m (1 β€ m β€ 1000) β the number of used variables. Next m lines specify the description of the variables in the following format:
"type variableName", where type is the type of variable that can take values "int", "string", "double", variableName β the name of the variable.
The next line contains a single integer k (1 β€ k β€ 1000) β the number of procedure calls. Next k lines specify the procedure calls in the following format:
"procedureName (var_1, var_2, ..., var_t)" (1 β€ t β€ 5), where procedureName is the name of the procedure, var_i is the name of a variable.
The lines describing the variables, template procedures and their calls may contain spaces at the beginning of the line and at the end of the line, before and after the brackets and commas. Spaces may be before and after keyword void. The length of each input line does not exceed 100 characters. The names of variables and procedures are non-empty strings of lowercase English letters and numbers with lengths of not more than 10 characters. Note that this is the only condition at the names. Only the specified variables are used in procedure calls. The names of the variables are distinct. No two procedures are the same. Two procedures are the same, if they have identical names and identical ordered sets of types of their parameters.
Output
On each of k lines print a single number, where the i-th number stands for the number of suitable template procedures for the i-th call.
Examples
Input
4
void f(int,T)
void f(T, T)
void foo123 ( int, double, string,string )
void p(T,double)
3
int a
string s
double x123
5
f(a, a)
f(s,a )
foo (a,s,s)
f ( s ,x123)
proc(a)
Output
2
1
0
1
0
Input
6
void f(string,double,int)
void f(int)
void f ( T )
void procedure(int,double)
void f (T, double,int)
void f(string, T,T)
4
int a
int x
string t
double val
5
f(t, a, a)
f(t,val,a)
f(val,a, val)
solve300(val, val)
f (x)
Output
1
3
0
0
2 | instruction | 0 | 37,101 | 6 | 74,202 |
Tags: binary search, brute force, expression parsing, implementation
Correct Solution:
```
n=int(input())
fu=[input().replace(' ','')[4:].replace('(',',').replace(')','').split(',') for i in range(n)]
m=int(input())
v=[input().strip().split() for i in range(m)]
vd={l[1]:l[0] for l in v}
k=int(input())
c=[input().strip().replace(' ','').replace('(',',').replace(')','').split(',') for i in range(k)]
for f in c:
a=0
for f2 in fu:
if f2[0] != f[0] or len(f) != len(f2):
continue
w=1
for x,y in zip(f[1:],f2[1:]):
if y!='T' and vd[x] !=y:
w=0
break
a+=w
print(a)
``` | output | 1 | 37,101 | 6 | 74,203 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Recently, Valery have come across an entirely new programming language. Most of all the language attracted him with template functions and procedures. Let us remind you that templates are tools of a language, designed to encode generic algorithms, without reference to some parameters (e.g., data types, buffer sizes, default values).
Valery decided to examine template procedures in this language in more detail. The description of a template procedure consists of the procedure name and the list of its parameter types. The generic type T parameters can be used as parameters of template procedures.
A procedure call consists of a procedure name and a list of variable parameters. Let's call a procedure suitable for this call if the following conditions are fulfilled:
* its name equals to the name of the called procedure;
* the number of its parameters equals to the number of parameters of the procedure call;
* the types of variables in the procedure call match the corresponding types of its parameters. The variable type matches the type of a parameter if the parameter has a generic type T or the type of the variable and the parameter are the same.
You are given a description of some set of template procedures. You are also given a list of variables used in the program, as well as direct procedure calls that use the described variables. For each call you need to count the number of procedures that are suitable for this call.
Input
The first line contains a single integer n (1 β€ n β€ 1000) β the number of template procedures. The next n lines contain the description of the procedures specified in the following format:
"void procedureName (type_1, type_2, ..., type_t)" (1 β€ t β€ 5), where void is the keyword, procedureName is the procedure name, type_i is the type of the next parameter. Types of language parameters can be "int", "string", "double", and the keyword "T", which denotes the generic type.
The next line contains a single integer m (1 β€ m β€ 1000) β the number of used variables. Next m lines specify the description of the variables in the following format:
"type variableName", where type is the type of variable that can take values "int", "string", "double", variableName β the name of the variable.
The next line contains a single integer k (1 β€ k β€ 1000) β the number of procedure calls. Next k lines specify the procedure calls in the following format:
"procedureName (var_1, var_2, ..., var_t)" (1 β€ t β€ 5), where procedureName is the name of the procedure, var_i is the name of a variable.
The lines describing the variables, template procedures and their calls may contain spaces at the beginning of the line and at the end of the line, before and after the brackets and commas. Spaces may be before and after keyword void. The length of each input line does not exceed 100 characters. The names of variables and procedures are non-empty strings of lowercase English letters and numbers with lengths of not more than 10 characters. Note that this is the only condition at the names. Only the specified variables are used in procedure calls. The names of the variables are distinct. No two procedures are the same. Two procedures are the same, if they have identical names and identical ordered sets of types of their parameters.
Output
On each of k lines print a single number, where the i-th number stands for the number of suitable template procedures for the i-th call.
Examples
Input
4
void f(int,T)
void f(T, T)
void foo123 ( int, double, string,string )
void p(T,double)
3
int a
string s
double x123
5
f(a, a)
f(s,a )
foo (a,s,s)
f ( s ,x123)
proc(a)
Output
2
1
0
1
0
Input
6
void f(string,double,int)
void f(int)
void f ( T )
void procedure(int,double)
void f (T, double,int)
void f(string, T,T)
4
int a
int x
string t
double val
5
f(t, a, a)
f(t,val,a)
f(val,a, val)
solve300(val, val)
f (x)
Output
1
3
0
0
2 | instruction | 0 | 37,102 | 6 | 74,204 |
Tags: binary search, brute force, expression parsing, implementation
Correct Solution:
```
I=input
R=str.replace
P=range
D=lambda:P(int(I()))
T={}
d={}
def rf(s):
print(s.split())
for _ in D():s=R(R(I(),'void',''),' ','');t=s.find('(');k=s[:t];d[k]=d.get(k,[])+[s[t+1:-1].split(',')]
for _ in D():a,b=I().split();T[b]=a
for _ in D():
s=R(I(),' ','');t=s.find('(');s,v=s[:t],s[t+1:-1].split(',');r=0
for p in d.get(s,[]):
if len(v)==len(p):
for i in P(len(v)):
if p[i]!='T'and p[i]!=T[v[i]]:break
else:r+=1
print(r)
``` | output | 1 | 37,102 | 6 | 74,205 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.
Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.
The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 to n one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi.
You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.
Input
The first line of the input contains a single integer n (1 β€ n β€ 100) β the number of lines in the text.
The second line contains integers p1, ..., pn (0 β€ pi β€ 100) β the verse pattern.
Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.
Output
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).
Examples
Input
3
2 2 3
intel
code
ch allenge
Output
YES
Input
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
Output
NO
Input
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
Output
YES
Note
In the first sample, one can split words into syllables in the following way:
in-tel
co-de
ch al-len-ge
Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one. | instruction | 0 | 37,323 | 6 | 74,646 |
Tags: implementation, strings
Correct Solution:
```
n = int(input())
V = {'a','e','i','o','u','y'}
p = input().split()
p = [int(i) for i in p]
c = [0 for i in range(n)]
for i in range(n):
A = list(input())
for v in V:
c[i] += A.count(v)
assert(len(c) == n)
flag = 1
for i in range(n):
if(c[i] != p[i]):
flag = 0;
break
if(flag):
print("YES")
else:
print("NO")
``` | output | 1 | 37,323 | 6 | 74,647 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.
Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.
The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 to n one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi.
You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.
Input
The first line of the input contains a single integer n (1 β€ n β€ 100) β the number of lines in the text.
The second line contains integers p1, ..., pn (0 β€ pi β€ 100) β the verse pattern.
Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.
Output
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).
Examples
Input
3
2 2 3
intel
code
ch allenge
Output
YES
Input
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
Output
NO
Input
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
Output
YES
Note
In the first sample, one can split words into syllables in the following way:
in-tel
co-de
ch al-len-ge
Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one. | instruction | 0 | 37,324 | 6 | 74,648 |
Tags: implementation, strings
Correct Solution:
```
n = int(input())
p=list(map(int,input().split()))
f=0
for i in range(n):
s=input()
if s.count('a')+s.count('e')+s.count('i')+s.count('o')+s.count('u')+s.count('y')==p[i]:
f+=1
if f==n:
print('YES')
else:
print('NO')
``` | output | 1 | 37,324 | 6 | 74,649 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.
Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.
The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 to n one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi.
You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.
Input
The first line of the input contains a single integer n (1 β€ n β€ 100) β the number of lines in the text.
The second line contains integers p1, ..., pn (0 β€ pi β€ 100) β the verse pattern.
Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.
Output
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).
Examples
Input
3
2 2 3
intel
code
ch allenge
Output
YES
Input
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
Output
NO
Input
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
Output
YES
Note
In the first sample, one can split words into syllables in the following way:
in-tel
co-de
ch al-len-ge
Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one. | instruction | 0 | 37,325 | 6 | 74,650 |
Tags: implementation, strings
Correct Solution:
```
from sys import exit
def num_vow(s):
vow = ['a', 'e', 'o', 'i', 'u', 'y']
r = 0
for i in vow:
r += s.count(i)
return r
n = int(input())
p = list(map(int, input().split()))
f = True
for i in range(n):
s = input()
if num_vow(s) != p[i] and f:
print("NO")
f = False
if f:
print("YES")
``` | output | 1 | 37,325 | 6 | 74,651 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.
Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.
The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 to n one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi.
You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.
Input
The first line of the input contains a single integer n (1 β€ n β€ 100) β the number of lines in the text.
The second line contains integers p1, ..., pn (0 β€ pi β€ 100) β the verse pattern.
Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.
Output
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).
Examples
Input
3
2 2 3
intel
code
ch allenge
Output
YES
Input
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
Output
NO
Input
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
Output
YES
Note
In the first sample, one can split words into syllables in the following way:
in-tel
co-de
ch al-len-ge
Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one. | instruction | 0 | 37,326 | 6 | 74,652 |
Tags: implementation, strings
Correct Solution:
```
__author__ = 'Think'
n=int(input())
p=[int(i) for i in input().split()]
broken=False
for i in range(n):
line=input()
total=0
for s in line:
if s in ["a", "e", "i", "u", "o", "y"]:
total+=1
if total!=p[i]:
print("NO")
broken=True
break
if not broken:
print("YES")
``` | output | 1 | 37,326 | 6 | 74,653 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.
Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.
The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 to n one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi.
You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.
Input
The first line of the input contains a single integer n (1 β€ n β€ 100) β the number of lines in the text.
The second line contains integers p1, ..., pn (0 β€ pi β€ 100) β the verse pattern.
Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.
Output
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).
Examples
Input
3
2 2 3
intel
code
ch allenge
Output
YES
Input
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
Output
NO
Input
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
Output
YES
Note
In the first sample, one can split words into syllables in the following way:
in-tel
co-de
ch al-len-ge
Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one. | instruction | 0 | 37,327 | 6 | 74,654 |
Tags: implementation, strings
Correct Solution:
```
from sys import *
n=int(input())
p=[int(z) for z in input().split()]
glas=set([ "a", "e", "i", "o", "u", "y"])
for i in range(n):
s=input()
nogl=0
for j in s:
if j in glas:
nogl+=1
if nogl!=p[i]:
print("NO")
exit(0)
print("YES")
``` | output | 1 | 37,327 | 6 | 74,655 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.
Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.
The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 to n one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi.
You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.
Input
The first line of the input contains a single integer n (1 β€ n β€ 100) β the number of lines in the text.
The second line contains integers p1, ..., pn (0 β€ pi β€ 100) β the verse pattern.
Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.
Output
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).
Examples
Input
3
2 2 3
intel
code
ch allenge
Output
YES
Input
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
Output
NO
Input
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
Output
YES
Note
In the first sample, one can split words into syllables in the following way:
in-tel
co-de
ch al-len-ge
Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one. | instruction | 0 | 37,328 | 6 | 74,656 |
Tags: implementation, strings
Correct Solution:
```
input()
answer = "YES"
vowels = set("aeiouy")
for p in map(int, input().split()):
if p != sum(l in vowels for l in input()):
answer = "NO"
break
print(answer)
``` | output | 1 | 37,328 | 6 | 74,657 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.
Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.
The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 to n one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi.
You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.
Input
The first line of the input contains a single integer n (1 β€ n β€ 100) β the number of lines in the text.
The second line contains integers p1, ..., pn (0 β€ pi β€ 100) β the verse pattern.
Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.
Output
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).
Examples
Input
3
2 2 3
intel
code
ch allenge
Output
YES
Input
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
Output
NO
Input
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
Output
YES
Note
In the first sample, one can split words into syllables in the following way:
in-tel
co-de
ch al-len-ge
Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one. | instruction | 0 | 37,329 | 6 | 74,658 |
Tags: implementation, strings
Correct Solution:
```
num = int(input())
li = [int(x) for x in input().split()]
s = set(list("aeiouy"))
lis = [ len("".join(filter(lambda x: x in s,input()))) for x in range(num)]
print("YES" if lis == li else "NO")
``` | output | 1 | 37,329 | 6 | 74,659 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are considered to be vowels: 'a', 'e', 'i', 'o', 'u' and 'y'.
Each word of the text that contains at least one vowel can be divided into syllables. Each character should be a part of exactly one syllable. For example, the word "mamma" can be divided into syllables as "ma" and "mma", "mam" and "ma", and "mamm" and "a". Words that consist of only consonants should be ignored.
The verse patterns for the given text is a sequence of n integers p1, p2, ..., pn. Text matches the given verse pattern if for each i from 1 to n one can divide words of the i-th line in syllables in such a way that the total number of syllables is equal to pi.
You are given the text and the verse pattern. Check, if the given text matches the given verse pattern.
Input
The first line of the input contains a single integer n (1 β€ n β€ 100) β the number of lines in the text.
The second line contains integers p1, ..., pn (0 β€ pi β€ 100) β the verse pattern.
Next n lines contain the text itself. Text consists of lowercase English letters and spaces. It's guaranteed that all lines are non-empty, each line starts and ends with a letter and words are separated by exactly one space. The length of each line doesn't exceed 100 characters.
Output
If the given text matches the given verse pattern, then print "YES" (without quotes) in the only line of the output. Otherwise, print "NO" (without quotes).
Examples
Input
3
2 2 3
intel
code
ch allenge
Output
YES
Input
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
Output
NO
Input
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
Output
YES
Note
In the first sample, one can split words into syllables in the following way:
in-tel
co-de
ch al-len-ge
Since the word "ch" in the third line doesn't contain vowels, we can ignore it. As the result we get 2 syllabels in first two lines and 3 syllables in the third one. | instruction | 0 | 37,330 | 6 | 74,660 |
Tags: implementation, strings
Correct Solution:
```
n = int(input())
a = map(int, input().split())
for w in a:
s = input()
if w != sum(s.count(c) for c in "aeiouy"):
print("NO")
exit(0)
print("YES")
``` | output | 1 | 37,330 | 6 | 74,661 |
Provide a correct Python 3 solution for this coding contest problem.
Background
The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves lowercase letters as much as programming. Yu-kun decided to write a scoring program for a new play that uses paper, circles, lines, and lowercase letters.
Problem
Initially, V circles and E lines are drawn on the paper. The circles are numbered from 0 in ascending order, with one lowercase letter or nothing in each circle. Each line connects two different circles. A circle cannot be connected by more than 26 lines.
The play procedure is as follows.
1. Select one circle with nothing written on it. If such a circle does not exist, this process ends.
2. Write one lowercase letter in the circle. However, if the circle is already connected to a circle with lowercase letters by a line, the same lowercase letters as the lowercase letters cannot be written.
3. Return to 1.
After writing lowercase letters in all the circles according to the above procedure, arrange the lowercase letters in the circles in ascending order of the circle numbers to make a character string. I want to minimize the character strings that can be created in this way in lexicographical order. There are two strings s and t of the same length, and s is smaller than t in lexicographical order in the following cases. si represents the i-th lowercase letter of the string s and ti represents the i-th lowercase letter of the string t. For the smallest i where si differs from ti, si is less than ti.
Since the initial state of the paper is given, output the smallest character string that can be created according to the above procedure in lexicographical order.
Constraints
The input satisfies the following conditions.
* 1 β€ V β€ 100,000
* 0 β€ E β€ 200,000
* ai is either lowercase or'?' (0 β€ i β€ V-1)
* 0 β€ si, ti β€ V-1 (si <ti, 0 β€ i β€ E-1)
* One circle cannot be connected by more than 26 lines
Input
V E
a0 a1 ... a (V-1)
s0 t0
s1 t1
...
s (E-1) t (E-1)
The number of circles V and the number of lines E are given on the first line, separated by blanks.
The initial state of the circle is given on the second line, separated by blanks.
If ai is a lowercase letter, the lowercase letter is written in the i-th circle, and if it is'?', It means that nothing is written in the i-th circle.
The line information is given as si ti on the following E line, which means that the si and ti circles are connected by a line.
Output
Output the smallest character string in the dictionary order on one line among the character strings that can be created according to the procedure in the question sentence.
Examples
Input
3 3
c ? ?
0 1
0 2
1 2
Output
cab
Input
3 2
c ? ?
0 1
0 2
Output
caa
Input
7 6
? a ? ? z a ?
0 1
0 2
3 4
4 5
4 6
5 6
Output
baaazab
Input
5 0
? ? ? ? ?
Output
aaaaa | instruction | 0 | 37,704 | 6 | 75,408 |
"Correct Solution:
```
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
v, e = map(int, input().split())
a = list(input().split())
g = [[] for _ in range(v)]
for _ in range(e):
s, t = map(int, input().split())
g[s].append(t)
g[t].append(s)
for i in range(v):
if a[i] != '?':
continue
for c in alphabet:
flag = True
for to in g[i]:
if a[to] == c:
flag = False
break
if flag:
a[i] = c
break
print(''.join(a))
``` | output | 1 | 37,704 | 6 | 75,409 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.