message stringlengths 2 11.9k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 137 108k | cluster float64 18 18 | __index_level_0__ int64 274 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.
Constraints
* The length of the input string < 1200
Input
A string is given in a line.
Output
Print the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.
Example
Input
fAIR, LATER, OCCASIONALLY CLOUDY.
Output
Fair, later, occasionally cloudy.
Submitted Solution:
```
str = " ";
print(str.swapcase())
``` | instruction | 0 | 26,553 | 18 | 53,106 |
No | output | 1 | 26,553 | 18 | 53,107 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the end of the word, the resulting word must be prefix of at least one string from the group. A player loses if he cannot move.
Andrew and Alex decided to play this game k times. The player who is the loser of the i-th game makes the first move in the (i + 1)-th game. Guys decided that the winner of all games is the player who wins the last (k-th) game. Andrew and Alex already started the game. Fedor wants to know who wins the game if both players will play optimally. Help him.
Input
The first line contains two integers, n and k (1 ≤ n ≤ 105; 1 ≤ k ≤ 109).
Each of the next n lines contains a single non-empty string from the given group. The total length of all strings from the group doesn't exceed 105. Each string of the group consists only of lowercase English letters.
Output
If the player who moves first wins, print "First", otherwise print "Second" (without the quotes).
Examples
Input
2 3
a
b
Output
First
Input
3 1
a
b
c
Output
First
Input
1 2
ab
Output
Second
Submitted Solution:
```
N = 10000
Z = 26
#别用这玩意儿: trie = [[0] * Z] * N 巨坑!https://www.cnblogs.com/PyLearn/p/7795552.html
trie = [[0 for i in range(N)] for j in range(Z)]
n = 0
k = 0
nodeNum = 0
def insertNode():
u = 0
string = input()
global nodeNum
for i in range(len(string)):
c = ord(string[i]) - ord('a')
if trie[u][c] == 0:
nodeNum += 1
trie[u][c] = nodeNum
u = trie[u][c]
print(u)
stateWin = [False for i in range(N)]
stateLose = [False for i in range(N)]
def dfs(u):
leaf = True
for c in range(Z):
if (trie[u][c]) != 0:
leaf = False
dfs(trie[u][c])
stateWin[u] |= (not(stateWin[trie[u][c]]))
stateLose[u] |= (not(stateLose[trie[u][c]]))
if leaf == True:
stateWin[u] = False
stateLose[u] = True
n,k = map(int,input().split())
for i in range(n):
insertNode()
dfs(0)
# print(stateWin[0])
# print(stateLose[0])
if (stateWin[0] and (stateLose[0] or (k % 2 == 1) )):
print("First")
else:
print("Second")
``` | instruction | 0 | 26,896 | 18 | 53,792 |
No | output | 1 | 26,896 | 18 | 53,793 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the end of the word, the resulting word must be prefix of at least one string from the group. A player loses if he cannot move.
Andrew and Alex decided to play this game k times. The player who is the loser of the i-th game makes the first move in the (i + 1)-th game. Guys decided that the winner of all games is the player who wins the last (k-th) game. Andrew and Alex already started the game. Fedor wants to know who wins the game if both players will play optimally. Help him.
Input
The first line contains two integers, n and k (1 ≤ n ≤ 105; 1 ≤ k ≤ 109).
Each of the next n lines contains a single non-empty string from the given group. The total length of all strings from the group doesn't exceed 105. Each string of the group consists only of lowercase English letters.
Output
If the player who moves first wins, print "First", otherwise print "Second" (without the quotes).
Examples
Input
2 3
a
b
Output
First
Input
3 1
a
b
c
Output
First
Input
1 2
ab
Output
Second
Submitted Solution:
```
# https://codeforces.com/contest/455/problem/B
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
class Trie:
def __init__(self):
self.arr = {}
self.end = False
def insert(self, word):
root = self
for x in word:
if x not in root.arr:
root.arr[x] = Trie()
root = root.arr[x]
root.end = False
root.end = True
def dfs(self):
if self.end == True:
return False
flag = True
for x in self.arr:
flag = flag and self.arr[x].dfs()
return not flag
# do magic here
T = Trie()
n, k = map(int, input().split())
for _ in range(n):
T.insert(input())
ans = T.dfs()
# print(ans)
if ans:
print("First")
else:
print("Second")
``` | instruction | 0 | 26,897 | 18 | 53,794 |
No | output | 1 | 26,897 | 18 | 53,795 |
Provide a correct Python 3 solution for this coding contest problem.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0 | instruction | 0 | 28,220 | 18 | 56,440 |
"Correct Solution:
```
base = 127
mask = (1 << 32) - 1
def calc_hash(lstr, pl, tl):
dl = tl - pl
tmp = set()
d = 1
for _ in range(pl):
d = (d * base) & mask
e = 0
for i in range(pl):
e = (e * base + lstr[i]) & mask
for i in range(dl):
tmp.add(e)
e = (e * base - d * lstr[i] + lstr[i + pl]) & mask
tmp.add(e)
return tmp
t = [ord(c) for c in input().strip()]
tl = len(t)
q = int(input())
ps = [input().strip() for _ in range(q)]
h = dict()
dic = dict()
a = []
for pp in ps:
if pp in dic:
a.append(dic[pp])
continue
p = [ord(c) for c in pp]
pl = len(p)
if pl > tl:
a.append(0)
continue
bs = min(19, pl)
keys = calc_hash(p, bs, pl)
if bs not in h:
h[bs] = calc_hash(t, bs, tl)
# print("hb", keys, h[bs])
a.append(1 if keys.issubset(h[bs]) else 0) #keysがh[bs]に含まれるか
dic[pp] = a[-1]
print('\n'.join(map(str, a)))
``` | output | 1 | 28,220 | 18 | 56,441 |
Provide a correct Python 3 solution for this coding contest problem.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0 | instruction | 0 | 28,221 | 18 | 56,442 |
"Correct Solution:
```
from collections import Counter
from math import floor, ceil, log
from heapq import heapreplace, heappush
import time
class TreeIndex:
CACHESIZE = 65535
class Node:
__slots__ = ('level', 'keys', 'values', 'keylen')
def __init__(self, level):
self.level = level
self.values = []
self.keys = {}
self.keylen = 2 ** self.level
def add(self, text, value):
if len(text) == 0:
self.values.append(value)
return self
pre = text[:self.keylen]
post = text[self.keylen:]
if pre not in self.keys:
self.keys[pre] = self.__class__(self.level+1)
return self.keys[pre].add(post, value)
def find(self, text):
if len(text) == 0:
return self
pre = text[:self.keylen]
post = text[self.keylen:]
if pre in self.keys:
return self.keys[pre].find(post)
else:
return None
def __contains__(self, text):
if len(text) > self.keylen:
pre = text[:self.keylen]
post = text[self.keylen:]
return (pre in self.keys and post in self.keys[pre])
else:
return any(key.startswith(text) for key in self.keys)
def __str__(self):
return ('(' + ','.join(["{}->{}".format(k, v)
for k, v in self.keys.items()]) + ')')
def __init__(self, text):
self.text = text
self._init_cache()
self._keylen()
self._create_index()
def _keylen(self):
chars = Counter(list(self.text))
ent = 0.0
total = len(self.text)
base = len(chars) + 1
for c, cnt in chars.items():
p = cnt / total
ent -= p * log(p, base)
self.keylen = max(2 ** ceil(10 * (1 - ent)) - 1, 3)
def _create_index(self):
self.tree = self.Node(0)
length = len(self.text)
for i in range(length):
self.add(self.text[i:i+self.keylen], i)
def _init_cache(self):
self._cache = {}
self._cacheq = []
def _set_cache(self, text, node):
if text not in self._cache:
if len(self._cacheq) > self.CACHESIZE:
_, txt = heapreplace(self._cacheq, (time.clock(), text))
del self._cache[txt]
else:
heappush(self._cacheq, (time.clock(), text))
self._cache[text] = node
def _get_cache(self, text):
if text in self._cache:
return self._cache[text]
else:
return None
def index(self, text):
node = self._get_cache(text)
if node is None:
node = self.tree.find(text)
if node is None:
return []
else:
self._set_cache(text, node)
return node.values
def add(self, text, value):
node = self._get_cache(text)
if node is None:
node = self.tree.add(text, value)
self._set_cache(text, node)
else:
node.add('', value)
def match(self, search_text):
def _match_partial(lo, hi):
split = self.keylen
if search_text[lo+split:hi] in self.tree:
for i in self.index(search_text[lo:lo+split]):
if (self.text[i+split:i+hi-lo]
== search_text[lo+split:hi]):
yield i
def _match(lo, hi):
length = hi - lo
if length == self.keylen:
return (i for i in self.index(search_text[lo:hi]))
elif length < self.keylen*2:
return _match_partial(lo, hi)
mid = lo + length // 2
pre = _match(lo, mid)
post = _match(mid, hi)
return _merge(pre, post, mid-lo)
def _merge(idx1, idx2, shift):
i2 = next(idx2)
for i1 in idx1:
while i1 + shift > i2:
i2 = next(idx2)
if i1 + shift == i2:
yield i1
length = len(search_text)
if length < self.keylen:
return search_text in self.tree
# align by key length
k = floor(log(length/self.keylen, 2))
b = self.keylen * 2**k
if length - self.keylen < b < length and k > 0:
b = self.keylen * 2**(k-1)
try:
if b + self.keylen < length:
match = _merge(_match(0, b), _match(b, length), b)
else:
match = _match(0, length)
next(match)
return True
except StopIteration:
return False
def run():
s1 = input()
n = int(input())
index = TreeIndex(s1)
for _ in range(n):
s2 = input()
if index.match(s2):
print(1)
else:
print(0)
if __name__ == '__main__':
run()
``` | output | 1 | 28,221 | 18 | 56,443 |
Provide a correct Python 3 solution for this coding contest problem.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0 | instruction | 0 | 28,222 | 18 | 56,444 |
"Correct Solution:
```
#!/usr/bin/env python3
import sys
def lms(t, i):
return i > 0 and not t[i-1] and t[i]
def induced_sort(s, k, t, lmss):
sa = [-1] * len(s)
cbin = [0]*k
for c in s:
cbin[c] += 1
ssum = 0
for i in range(k):
ssum += cbin[i]
cbin[i] = ssum
count = [0] * k
for i in reversed(lmss):
c = s[i]
sa[cbin[c]-1 - count[c]] = i
count[c] += 1
count = [0] * k
for i in sa:
if i <= 0 or t[i-1]:
continue
c = s[i-1]
sa[cbin[c-1] + count[c]] = i-1
count[c] += 1
count = [0] * k
for i in reversed(sa):
if i <= 0 or not t[i-1]:
continue
c = s[i-1]
sa[cbin[c]-1 - count[c]] = i-1
count[c] += 1
return sa
def sa_is(s, k):
slen = len(s)
t = [True] * slen # S -> True, T -> False
for i in range(slen-2, -1, -1):
#if s[i] < s[i+1]: t[i] = True #'S'
if s[i] > s[i+1]:
t[i] = False # 'L'
elif s[i] == s[i+1]:
t[i] = t[i+1]
lmss = []
for i in range(1,slen):
if not t[i-1] and t[i]: # lms(t, i):
lmss.append(i)
seed = lmss
sa = induced_sort(s, k, t, seed)
new_sa = []
for i in sa:
if lms(t, i): new_sa.append(i)
nums = dict() # nums = [[]] * (max(new_sa)+1)
nums[new_sa[0]] = 0
num = 0
for o in range(len(new_sa)-1):
i, j = new_sa[o], new_sa[o+1]
diff, d = False, 0
for d in range(slen):
if s[i+d] != s[j+d] or lms(t, i+d) != lms(t, j+d):
diff = True
break
elif d > 0 and (lms(t, i+d) or lms(t, j+d)):
break
if diff:
num += 1
nums[j] = num
# for i in range(len(nums)-1,-1,-1):
# if not nums[i]: nums.pop(i)
nums = list(map(lambda x: x[1], sorted(nums.items())))
if num + 1 < len(nums):
sa = sa_is(nums, num+1)
else:
sa = [[]] * (max(nums)+1)
for i, c in enumerate(nums):
sa[c] = i
seed = list(map(lambda x:lmss[x], sa))
sa = induced_sort(s, k, t, seed)
return sa
def strcmp(a, b):
for i, bi in enumerate(b):
if a[i] == bi: continue
return a[i]-bi
return 0
def search(s, sa, slen, q):
ss = 0
ee = slen
while ss <= ee:
mid = (ss+ee)//2
if mid >= slen: break
rr = strcmp(s[sa[mid]:], q)
if rr==0: return 1
if rr >= 0:
ee = mid-1
else:
ss = mid+1
return 0
if __name__ == '__main__':
b = sys.stdin.readline().rstrip()
b = (b+'$').encode()
sa = sa_is(b, 128) #ord('z'))
n = int(sys.stdin.readline())
for _ in range(n):
q = sys.stdin.readline().rstrip().encode()
if search(b, sa, len(b), q) > 0:
print(1)
else:
print(0)
``` | output | 1 | 28,222 | 18 | 56,445 |
Provide a correct Python 3 solution for this coding contest problem.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0 | instruction | 0 | 28,223 | 18 | 56,446 |
"Correct Solution:
```
import sys
readline = sys.stdin.readline
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
dl = tl - pl
tmp = set()
t = 1
for _ in range(pl):
t = (t * base) & mask
e = 0
for i in range(pl):
e = (e * base + f[i]) & mask
for i in range(dl):
tmp.add(e)
e = (e * base - t * f[i] + f[i + pl]) & mask
tmp.add(e)
return tmp
t = tuple(ord(c) for c in input())
tl = len(t)
q = int(input())
h = dict()
c = dict()
a = []
for _ in range(q):
p = readline().strip()
if p in c:
a.append(c[p])
continue
p = tuple(ord(c) for c in p)
pl = len(p)
if pl > tl:
a.append(0)
continue
bs = min(19, pl)
keys = calc_hash(p, bs, pl)
if bs not in h:
h[bs] = calc_hash(t, bs, tl)
a.append(1 if keys.issubset(h[bs]) else 0)
print('\n'.join(map(str, a)))
``` | output | 1 | 28,223 | 18 | 56,447 |
Provide a correct Python 3 solution for this coding contest problem.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0 | instruction | 0 | 28,224 | 18 | 56,448 |
"Correct Solution:
```
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
dl = tl - pl
tmp = set()
t = 1
for _ in range(pl):
t = (t * base) & mask
e = 0
for i in range(pl):
e = (e * base + f[i]) & mask
for i in range(dl):
tmp.add(e)
e = (e * base - t * f[i] + f[i + pl]) & mask
tmp.add(e)
return tmp
t = [ord(c) for c in input().strip()]
tl = len(t)
q = int(input())
ps = [input().strip() for _ in range(q)]
h = dict()
a = []
hash_len = 20
for p in ps:
p = [ord(c) for c in p]
pl = len(p)
if pl > tl:
a.append(0)
continue
bs = min(hash_len, pl)
keys = calc_hash(p, bs, pl)
if bs not in h:
h[bs] = calc_hash(t, bs, tl)
a.append(1 if keys.issubset(h[bs]) else 0)
print('\n'.join(map(str, a)))
``` | output | 1 | 28,224 | 18 | 56,449 |
Provide a correct Python 3 solution for this coding contest problem.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0 | instruction | 0 | 28,225 | 18 | 56,450 |
"Correct Solution:
```
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
dl = tl - pl
tmp = set()
t = 1
for _ in range(pl):
t = (t * base) & mask
e = 0
for i in range(pl):
e = (e * base + f[i]) & mask
for i in range(dl):
tmp.add(e)
e = (e * base - t * f[i] + f[i + pl]) & mask
tmp.add(e)
return tmp
t = tuple(ord(c) for c in input())
tl = len(t)
q = int(input())
h = dict()
c = dict()
a = []
for _ in range(q):
p = input()
if p in c:
a.append(c[p])
continue
p = tuple(ord(c) for c in p)
pl = len(p)
if pl > tl:
a.append("0")
continue
bs = min(19, pl)
keys = calc_hash(p, bs, pl)
if bs not in h:
h[bs] = calc_hash(t, bs, tl)
a.append("1" if keys.issubset(h[bs]) else "0")
print('\n'.join(a))
``` | output | 1 | 28,225 | 18 | 56,451 |
Provide a correct Python 3 solution for this coding contest problem.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0 | instruction | 0 | 28,226 | 18 | 56,452 |
"Correct Solution:
```
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
dl = tl - pl
tmp = set()
t = 1
for _ in range(pl):
t = (t * base) & mask
e = 0
for i in range(pl):
e = (e * base + f[i]) & mask
for i in range(dl):
tmp.add(e)
e = (e * base - t * f[i] + f[i + pl]) & mask
tmp.add(e)
return tmp
t = tuple(ord(c) for c in input())
tl = len(t)
q = int(input())
h = dict()
c = dict()
a = []
for _ in range(q):
p = input()
if p in c:
a.append(c[p])
continue
p = tuple(ord(c) for c in p)
pl = len(p)
if pl > tl:
a.append("0")
continue
bs = min(19, pl)
keys = calc_hash(p, bs, pl)
if bs not in h:
h[bs] = calc_hash(t, bs, tl)
a.append("1" if keys <= h[bs] else "0")
print('\n'.join(a))
``` | output | 1 | 28,226 | 18 | 56,453 |
Provide a correct Python 3 solution for this coding contest problem.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0 | instruction | 0 | 28,227 | 18 | 56,454 |
"Correct Solution:
```
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
dl = tl - pl
tmp = set()
t = 1
for _ in range(pl):
t = (t * base) & mask
e = 0
for i in range(pl):
e = (e * base + f[i]) & mask
for i in range(dl):
tmp.add(e)
e = (e * base - t * f[i] + f[i + pl]) & mask
tmp.add(e)
return tmp
t = tuple(ord(c) for c in input())
tl = len(t)
q = int(input())
h = dict()
c = dict()
a = []
for _ in range(q):
p = input()
if p in c:
a.append(c[p])
continue
p = tuple(ord(c) for c in p)
pl = len(p)
if pl > tl:
a.append(0)
continue
bs = min(19, pl)
keys = calc_hash(p, bs, pl)
if bs not in h:
h[bs] = calc_hash(t, bs, tl)
a.append(1 if keys.issubset(h[bs]) else 0)
print('\n'.join(map(str, a)))
``` | output | 1 | 28,227 | 18 | 56,455 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0
Submitted Solution:
```
from collections import Counter
import time
def SL(S):
t = ["S"]*len(S)
for i in range(len(S)-2,-1,-1):
if S[i] > S[i+1] or (S[i] == S[i+1] and t[i+1] == "L"):
t[i] = "L"
return t
def LMS(t):
lms = [False]*len(t)
for i in range(1,len(t)):
if t[i-1] == "L" and t[i] == "S":
lms[i] = True
return lms
def Bucket(S):
bucket = Counter(S)
tmp = 0
for i in sorted(bucket):
bucket[i] = {"chead":tmp,"ctail":tmp+bucket[i]-1}
tmp = bucket[i]["ctail"]+1
return bucket
def STEP2(S,t,bucket,SA):
for i in range(len(SA)):
tmp = SA[i]-1
if t[tmp] == "L" and tmp > -1:
head = bucket[S[tmp]]["chead"]
SA[head] = tmp
bucket[S[tmp]]["chead"]+=1
def STEP3(S,t,SA):
bucket = Bucket(S)
for i in range(len(SA)-1,-1,-1):
tmp = SA[i]-1
if t[tmp] == "S" and tmp > -1:
tail = bucket[S[tmp]]["ctail"]
SA[tail] = tmp
bucket[S[tmp]]["ctail"]-=1
def InducedSorting(S):
l = len(S)
t = SL(S)
lms = LMS(t)
bucket = Bucket(S)
SA=[-1]*l
P1 = [i for i in range(l) if lms[i]]
#STEP1
for i,j in enumerate(lms):
if j:
tail = bucket[S[i]]["ctail"]
SA[tail] = i
bucket[S[i]]["ctail"] -= 1
#STEP2
STEP2(S,t,bucket,SA)
#STEP3
STEP3(S,t,SA)
#Construct S1 from pseudoSA
prev = None
Name = [None]*l
name = 0
S1 = []
for i in SA:
if lms[i]:
if prev and not i == len(S)-1:
j = 0
while(True):
if not S[i+j] == S[prev+j] or not t[i+j] == t[prev+j]:
name+=1
break
if j>0 and lms[i+j]:
break
j+=1
Name[i] = name
prev = i
for i in Name:
if not i == None:
S1.append(i)
#Construct SA1 from S1
uniq = True
dtmp = {}
#for i in Counter(S1):
# if Counter(S1)[i] > 1:
# uniq = False
# break
for i in S1:
if i in dtmp:
uniq = False
break
else:
dtmp[i] = True
if uniq:
SA1 = [None]*len(S1)
for i,j in enumerate(S1):
SA1[j] = i
else:
SA1 = InducedSorting(S1)
#Inducing SA from SA1 STEP1
bucket = Bucket(S)
SA=[-1]*l
for i in SA1[::-1]:
p = P1[i]
tail = bucket[S[p]]["ctail"]
SA[tail] = p
bucket[S[p]]["ctail"] -= 1
#Inducing SA from SA1 STEP2
STEP2(S,t,bucket,SA)
#Inducing SA from SA1 STEP3
STEP3(S,t,SA)
return SA
def contain(T,sa,P):
a = 0
b = len(T)
while(b-a > 1):
c = (a+b)//2
if T[sa[c]:sa[c]+len(P)] < P:
a = c
else:
b = c
return P == T[sa[b]:sa[b]+len(P)]
T = input()
Q = int(input())
P = [input() for _ in range(Q)]
SA = InducedSorting(T+"$")
for i in P:
if contain(T,SA,i):
print(1)
else:
print(0)
``` | instruction | 0 | 28,228 | 18 | 56,456 |
Yes | output | 1 | 28,228 | 18 | 56,457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0
Submitted Solution:
```
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
dl = tl - pl
tmp = set()
t = 1
for _ in range(pl):
t = (t * base) & mask
e = 0
for i in range(pl):
e = (e * base + f[i]) & mask
for i in range(dl):
tmp.add(e)
e = (e * base - t * f[i] + f[i + pl]) & mask
tmp.add(e)
return tmp
t = [ord(c) for c in input().strip()]
tl = len(t)
q = int(input())
ps = [input().strip() for _ in range(q)]
h = dict()
a = []
hash_len = 19
for p in ps:
p = [ord(c) for c in p]
pl = len(p)
if pl > tl:
a.append(0)
continue
bs = min(hash_len, pl)
keys = calc_hash(p, bs, pl)
if bs not in h:
h[bs] = calc_hash(t, bs, tl)
a.append(1 if keys.issubset(h[bs]) else 0)
print('\n'.join(map(str, a)))
``` | instruction | 0 | 28,229 | 18 | 56,458 |
Yes | output | 1 | 28,229 | 18 | 56,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0
Submitted Solution:
```
base = 127
mask = (1 << 32) - 1
def calc_hash(f, pl, tl):
dl = tl - pl
tmp = set()
t = 1
for _ in range(pl):
t = (t * base) & mask
e = 0
for i in range(pl):
e = (e * base + f[i]) & mask
for i in range(dl):
tmp.add(e)
e = (e * base - t * f[i] + f[i + pl]) & mask
tmp.add(e)
return tmp
t = [ord(c) for c in input().strip()]
tl = len(t)
q = int(input())
ps = [input().strip() for _ in range(q)]
h = dict()
c = dict()
a = []
for p in ps:
if p in c:
a.append(c[p])
continue
p = [ord(c) for c in p]
pl = len(p)
if pl > tl:
a.append(0)
continue
bs = min(19, pl)
keys = calc_hash(p, bs, pl)
if bs not in h:
h[bs] = calc_hash(t, bs, tl)
a.append(1 if keys.issubset(h[bs]) else 0)
print('\n'.join(map(str, a)))
``` | instruction | 0 | 28,230 | 18 | 56,460 |
Yes | output | 1 | 28,230 | 18 | 56,461 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0
Submitted Solution:
```
from typing import Dict, List
def calc_hash(input_v: List[int], target_len: int, input_len: int) -> set:
global base, mask
diff_len = input_len - target_len
hash_set = set()
bit_mask = 1
for _ in range(target_len):
bit_mask = (bit_mask * base) & mask
hash_v = 0
for i in range(target_len):
hash_v = (hash_v * base + input_v[i]) & mask
for i in range(diff_len):
hash_set.add(hash_v)
hash_v = (hash_v * base - bit_mask * input_v[i]
+ input_v[i + target_len]) & mask
hash_set.add(hash_v)
return hash_set
if __name__ == "__main__":
base = 123 # Ascii code after 'z'
mask = (1 << 32) - 1 # Mask.
input_v = [ord(s) for s in input()]
input_len = len(input_v)
checked_dict: Dict[int, set] = {}
num_target = int(input())
for _ in range(num_target):
target_v = [ord(s) for s in input()]
target_len = len(target_v)
if input_len < target_len:
print(0)
continue
magic_len = min(19, target_len) # Magic number to reduce calc time.
key = calc_hash(target_v, magic_len, target_len)
if magic_len not in checked_dict:
checked_dict[magic_len] = calc_hash(input_v, magic_len, input_len)
if key.issubset(checked_dict[magic_len]):
print(1)
else:
print(0)
``` | instruction | 0 | 28,231 | 18 | 56,462 |
Yes | output | 1 | 28,231 | 18 | 56,463 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0
Submitted Solution:
```
# coding: utf-8
original_string = list(map(ord, list(input())))
check_string_count = int(input())
checkers = [list(map(ord,list(input()))) for i in range(check_string_count)]
for checker in checkers:
found = False
sum_of_checker = sum(checker)
if len(checker) > len(original_string):
print(0)
continue
for index in range(0, len(original_string)):
if (len(original_string)-len(checker)) < index:
break
if original_string[index] == checker[0]:
found = True
sum_of_origin = sum(original_string[index:index+len(checker)])
if sum_of_origin != sum_of_checker:
found = False
if found:
print(1)
break
if not found:
print(0)
``` | instruction | 0 | 28,232 | 18 | 56,464 |
No | output | 1 | 28,232 | 18 | 56,465 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0
Submitted Solution:
```
s=input()
for _ in range(int(input())):print(int(input() in s))
``` | instruction | 0 | 28,233 | 18 | 56,466 |
No | output | 1 | 28,233 | 18 | 56,467 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0
Submitted Solution:
```
# coding: utf-8
import re
original_string = input()
check_string_count = int(input())
for count in range(check_string_count):
checker = input()
print(1 if re.search(checker, original_string) else 0)
``` | instruction | 0 | 28,234 | 18 | 56,468 |
No | output | 1 | 28,234 | 18 | 56,469 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. In the following Q lines, the patterns P_i are given respectively.
Output
For each question, print 1 if the text includes P_i, or print 0 otherwise.
Example
Input
aabaaa
4
aa
ba
bb
xyz
Output
1
1
0
0
Submitted Solution:
```
T = input()
n = int(input())
for i in range(n):
p = input()
print(1 if p in T else 0)
``` | instruction | 0 | 28,235 | 18 | 56,470 |
No | output | 1 | 28,235 | 18 | 56,471 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters.
Output
Output "YES", if the string is a pangram and "NO" otherwise.
Examples
Input
12
toosmallword
Output
NO
Input
35
TheQuickBrownFoxJumpsOverTheLazyDog
Output
YES
Submitted Solution:
```
n = int(input())
word = input()[:n]
small = "abcdefghijklmnopqrstuvwxyz"
st = []
for w in word.lower():
if w in small:
st.append(w)
st = set(st)
if len(st) >= 26:
print("YES")
else:print("NO")
#35
#TheuoxOrezyo
``` | instruction | 0 | 28,644 | 18 | 57,288 |
Yes | output | 1 | 28,644 | 18 | 57,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters.
Output
Output "YES", if the string is a pangram and "NO" otherwise.
Examples
Input
12
toosmallword
Output
NO
Input
35
TheQuickBrownFoxJumpsOverTheLazyDog
Output
YES
Submitted Solution:
```
n = int(input())
if len({_.lower() for _ in input()}) == 26:
print('YES')
else:
print('NO')
``` | instruction | 0 | 28,645 | 18 | 57,290 |
Yes | output | 1 | 28,645 | 18 | 57,291 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters.
Output
Output "YES", if the string is a pangram and "NO" otherwise.
Examples
Input
12
toosmallword
Output
NO
Input
35
TheQuickBrownFoxJumpsOverTheLazyDog
Output
YES
Submitted Solution:
```
n=int(input())
line=list(input().lower())
v=[]
for k in range(0, 25+1, 1):
v.append(0)
letra=0
for i in range(len(line)):
letra=ord(line[i])
v[letra-97]=1
for k in range(len(v)):
if v[k]==0:
print("NO")
break
if k==len(v)-1:
print("YES")
``` | instruction | 0 | 28,646 | 18 | 57,292 |
Yes | output | 1 | 28,646 | 18 | 57,293 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters.
Output
Output "YES", if the string is a pangram and "NO" otherwise.
Examples
Input
12
toosmallword
Output
NO
Input
35
TheQuickBrownFoxJumpsOverTheLazyDog
Output
YES
Submitted Solution:
```
input()
s = set(input().lower())
if len(s) == 26:
print('YES')
else:
print('NO')
``` | instruction | 0 | 28,647 | 18 | 57,294 |
Yes | output | 1 | 28,647 | 18 | 57,295 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters.
Output
Output "YES", if the string is a pangram and "NO" otherwise.
Examples
Input
12
toosmallword
Output
NO
Input
35
TheQuickBrownFoxJumpsOverTheLazyDog
Output
YES
Submitted Solution:
```
l = int(input())
string = input()
def pangram(string):
alphabets = 'abcdefghijklmnopqrstuvwxyz'
for char in alphabets:
if char not in string.lower():
return False
return True
if pangram(string) == True:
print('YES')
else:
print('FALSE')
``` | instruction | 0 | 28,648 | 18 | 57,296 |
No | output | 1 | 28,648 | 18 | 57,297 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters.
Output
Output "YES", if the string is a pangram and "NO" otherwise.
Examples
Input
12
toosmallword
Output
NO
Input
35
TheQuickBrownFoxJumpsOverTheLazyDog
Output
YES
Submitted Solution:
```
def compute():
n = int(input())
s = input().lower()
a = list(set(x for x in s))
a.sort()
index = 97
for i in a:
if ord(i) == index:
index += 1
else:
return 'NO'
return 'YES'
def main():
print(compute())
if __name__ == '__main__':
main()
``` | instruction | 0 | 28,649 | 18 | 57,298 |
No | output | 1 | 28,649 | 18 | 57,299 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters.
Output
Output "YES", if the string is a pangram and "NO" otherwise.
Examples
Input
12
toosmallword
Output
NO
Input
35
TheQuickBrownFoxJumpsOverTheLazyDog
Output
YES
Submitted Solution:
```
n=int(input())
s=input()
k=len(set(s))
if(k==26):
print("YES")
else:
print("NO")
``` | instruction | 0 | 28,650 | 18 | 57,300 |
No | output | 1 | 28,650 | 18 | 57,301 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters.
Output
Output "YES", if the string is a pangram and "NO" otherwise.
Examples
Input
12
toosmallword
Output
NO
Input
35
TheQuickBrownFoxJumpsOverTheLazyDog
Output
YES
Submitted Solution:
```
x=int(input())
y="qwertyuiopasdfghjklzxcvbnm"
z=input()
j=0
z=z.lower()
for i in y:
j+=1
if i not in z:
print("NO")
break
if j==26:
print("YES")
``` | instruction | 0 | 28,651 | 18 | 57,302 |
No | output | 1 | 28,651 | 18 | 57,303 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
Constraints
* 1 \leq k \leq 15
* S is a string of length k consisting of `o` and `x`.
Input
Input is given from Standard Input in the following format:
S
Output
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` otherwise.
Examples
Input
oxoxoxoxoxoxox
Output
YES
Input
xxxxxxxx
Output
NO | instruction | 0 | 28,892 | 18 | 57,784 |
"Correct Solution:
```
S = input()
print(["NO", "YES"][8 <= 15-len(S)+S.count("o")])
``` | output | 1 | 28,892 | 18 | 57,785 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
Constraints
* 1 \leq k \leq 15
* S is a string of length k consisting of `o` and `x`.
Input
Input is given from Standard Input in the following format:
S
Output
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` otherwise.
Examples
Input
oxoxoxoxoxoxox
Output
YES
Input
xxxxxxxx
Output
NO | instruction | 0 | 28,893 | 18 | 57,786 |
"Correct Solution:
```
s = list(input())
win = s.count('x')
print('NO' if win >= 8 else 'YES')
``` | output | 1 | 28,893 | 18 | 57,787 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
Constraints
* 1 \leq k \leq 15
* S is a string of length k consisting of `o` and `x`.
Input
Input is given from Standard Input in the following format:
S
Output
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` otherwise.
Examples
Input
oxoxoxoxoxoxox
Output
YES
Input
xxxxxxxx
Output
NO | instruction | 0 | 28,894 | 18 | 57,788 |
"Correct Solution:
```
S = input()
if 15 - S.count("x") >= 8:
print("YES")
else:
print("NO")
``` | output | 1 | 28,894 | 18 | 57,789 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
Constraints
* 1 \leq k \leq 15
* S is a string of length k consisting of `o` and `x`.
Input
Input is given from Standard Input in the following format:
S
Output
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` otherwise.
Examples
Input
oxoxoxoxoxoxox
Output
YES
Input
xxxxxxxx
Output
NO | instruction | 0 | 28,895 | 18 | 57,790 |
"Correct Solution:
```
S = input()
if S.count('x') <= 7:
print("YES")
else:
print("NO")
``` | output | 1 | 28,895 | 18 | 57,791 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
Constraints
* 1 \leq k \leq 15
* S is a string of length k consisting of `o` and `x`.
Input
Input is given from Standard Input in the following format:
S
Output
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` otherwise.
Examples
Input
oxoxoxoxoxoxox
Output
YES
Input
xxxxxxxx
Output
NO | instruction | 0 | 28,896 | 18 | 57,792 |
"Correct Solution:
```
S = input()
ans = 'NO' if S.count('x')>=8 else 'YES'
print(ans)
``` | output | 1 | 28,896 | 18 | 57,793 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
Constraints
* 1 \leq k \leq 15
* S is a string of length k consisting of `o` and `x`.
Input
Input is given from Standard Input in the following format:
S
Output
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` otherwise.
Examples
Input
oxoxoxoxoxoxox
Output
YES
Input
xxxxxxxx
Output
NO | instruction | 0 | 28,897 | 18 | 57,794 |
"Correct Solution:
```
if str(input()).count("x") <= 7:
print("YES")
else:
print("NO")
``` | output | 1 | 28,897 | 18 | 57,795 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
Constraints
* 1 \leq k \leq 15
* S is a string of length k consisting of `o` and `x`.
Input
Input is given from Standard Input in the following format:
S
Output
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` otherwise.
Examples
Input
oxoxoxoxoxoxox
Output
YES
Input
xxxxxxxx
Output
NO | instruction | 0 | 28,898 | 18 | 57,796 |
"Correct Solution:
```
S = input()
print('YES' if 15 - len(S) + S.count('o') >= 8 else 'NO')
``` | output | 1 | 28,898 | 18 | 57,797 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.
The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
Constraints
* 1 \leq k \leq 15
* S is a string of length k consisting of `o` and `x`.
Input
Input is given from Standard Input in the following format:
S
Output
Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` otherwise.
Examples
Input
oxoxoxoxoxoxox
Output
YES
Input
xxxxxxxx
Output
NO | instruction | 0 | 28,899 | 18 | 57,798 |
"Correct Solution:
```
#23 M-SOLUTIONS
s=input()
x=s.count("x")
print("YES" if x<=7 else "NO")
``` | output | 1 | 28,899 | 18 | 57,799 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No | instruction | 0 | 29,083 | 18 | 58,166 |
"Correct Solution:
```
s = input()
p = input()
s = s + s
print('Yes' if p in s else 'No')
``` | output | 1 | 29,083 | 18 | 58,167 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No | instruction | 0 | 29,084 | 18 | 58,168 |
"Correct Solution:
```
s = input()
p = input()
s *= 2
if s.count(p):
print('Yes')
else:
print('No')
``` | output | 1 | 29,084 | 18 | 58,169 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No | instruction | 0 | 29,085 | 18 | 58,170 |
"Correct Solution:
```
s=input()
p=input()
w=(s+s)
if p in w:
print('Yes')
else:
print('No')
``` | output | 1 | 29,085 | 18 | 58,171 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No | instruction | 0 | 29,086 | 18 | 58,172 |
"Correct Solution:
```
s=input()
p=input()
s=s+s
a=s.find(p)
if a==-1:
print('No')
else:
print('Yes')
``` | output | 1 | 29,086 | 18 | 58,173 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No | instruction | 0 | 29,087 | 18 | 58,174 |
"Correct Solution:
```
word = input()*2
p = input()
if p in word:
print('Yes')
else:
print('No')
``` | output | 1 | 29,087 | 18 | 58,175 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No | instruction | 0 | 29,088 | 18 | 58,176 |
"Correct Solution:
```
s,p=input()*2,input()
print(['No','Yes'][p in s])
``` | output | 1 | 29,088 | 18 | 58,177 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No | instruction | 0 | 29,089 | 18 | 58,178 |
"Correct Solution:
```
s = input()
f = input()
s = s + s
if f in s:
print("Yes")
else:
print("No")
``` | output | 1 | 29,089 | 18 | 58,179 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No | instruction | 0 | 29,090 | 18 | 58,180 |
"Correct Solution:
```
S = input()
P = input()
SS = S + S
print('Yes') if SS.count(P) > 0 else print('No')
``` | output | 1 | 29,090 | 18 | 58,181 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No
Submitted Solution:
```
s=input()
p=input()
s=s+s
if s.find(p)==-1:
print('No')
else:
print('Yes')
``` | instruction | 0 | 29,091 | 18 | 58,182 |
Yes | output | 1 | 29,091 | 18 | 58,183 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No
Submitted Solution:
```
a = input()
a *= 2
b = input()
if b in a:
print("Yes")
else:
print("No")
``` | instruction | 0 | 29,092 | 18 | 58,184 |
Yes | output | 1 | 29,092 | 18 | 58,185 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No
Submitted Solution:
```
r=input()
p=input()
r=r*2
if r.find(p)==-1:
print("No")
else:
print("Yes")
``` | instruction | 0 | 29,093 | 18 | 58,186 |
Yes | output | 1 | 29,093 | 18 | 58,187 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No
Submitted Solution:
```
s = input()*5
p = input()
if p in s:
print('Yes')
else:
print('No')
``` | instruction | 0 | 29,094 | 18 | 58,188 |
Yes | output | 1 | 29,094 | 18 | 58,189 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No
Submitted Solution:
```
sam = input()
ans = input()
for i in range(len(ans)) :
if (ans[:i] in sam) == False : break
if ((ans[i - 1 :]) in sam[:len(ans[i-1:])])== True and len(ans) != 1 : print('Yes')
elif (ans in sam) == True : print('Yes')
else : print('No')
``` | instruction | 0 | 29,095 | 18 | 58,190 |
No | output | 1 | 29,095 | 18 | 58,191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No
Submitted Solution:
```
s = input()
p = input()
S = s+s
index = S.find(str(p))
if index == 0:
print ("Yes")
else:
print("No")
``` | instruction | 0 | 29,096 | 18 | 58,192 |
No | output | 1 | 29,096 | 18 | 58,193 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the second line, the pattern $p$ is given.
Output
If $p$ is in $s$, print Yes in a line, otherwise No.
Examples
Input
vanceknowledgetoad
advance
Output
Yes
Input
vanceknowledgetoad
advanced
Output
No
Submitted Solution:
```
s = input().lower()
p = input().lower()
s *= 2
if s.find(p) != -1:
print('yes')
else:
print("no")
``` | instruction | 0 | 29,097 | 18 | 58,194 |
No | output | 1 | 29,097 | 18 | 58,195 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.