message stringlengths 2 23.8k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 97 109k | cluster float64 0 0 | __index_level_0__ int64 194 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input contains a string s of length between 1 and 10... | instruction | 0 | 85,341 | 0 | 170,682 |
Tags: brute force, dp, greedy, implementation, strings
Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 5 14:48:26 2019
@author: piyus
"""
def foo(string,sub):
ans = []
for i in range(len(string)-len(sub)+1):
for j in range(len(sub)):
if string[i+j]!=sub[j]:
... | output | 1 | 85,341 | 0 | 170,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input contains a string s of length between 1 and 10... | instruction | 0 | 85,342 | 0 | 170,684 |
Tags: brute force, dp, greedy, implementation, strings
Correct Solution:
```
s=input()
l=len(s)
ab=[]
ba=[]
for i in range(l-1):
if s[i:i+2]=="AB":
ab.append(i)
elif s[i:i+2]=="BA":
ba.append(i)
if not ab or not ba:
print("NO")
else:
bk=False
for i in ab:
for j in ba:
... | output | 1 | 85,342 | 0 | 170,685 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input contains a string s of length between 1 and 10... | instruction | 0 | 85,343 | 0 | 170,686 |
Tags: brute force, dp, greedy, implementation, strings
Correct Solution:
```
s = input()
abfound = bafound = -1
for i in range(len(s) - 1):
if abfound == -1 and s[i] == 'A' and s[i + 1] == 'B':
abfound = i
elif bafound == -1 and s[i] == 'B' and s[i + 1] == 'A':
bafound = i
if abfound != -1 ... | output | 1 | 85,343 | 0 | 170,687 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input contains a string s of length between 1 and 10... | instruction | 0 | 85,344 | 0 | 170,688 |
Tags: brute force, dp, greedy, implementation, strings
Correct Solution:
```
st = input()
s1 = st.replace('AB','0',1)
s1 = s1.replace('BA','1',1)
s2 = st.replace('BA','1',1)
s2 = s2.replace('AB','0',1)
if ('0' in s1 and '1' in s1) or ('0' in s2 and '1' in s2):
print('YES')
else:
print('NO')
``` | output | 1 | 85,344 | 0 | 170,689 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input... | instruction | 0 | 85,345 | 0 | 170,690 |
Yes | output | 1 | 85,345 | 0 | 170,691 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input... | instruction | 0 | 85,346 | 0 | 170,692 |
Yes | output | 1 | 85,346 | 0 | 170,693 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input... | instruction | 0 | 85,347 | 0 | 170,694 |
Yes | output | 1 | 85,347 | 0 | 170,695 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input... | instruction | 0 | 85,348 | 0 | 170,696 |
Yes | output | 1 | 85,348 | 0 | 170,697 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input... | instruction | 0 | 85,349 | 0 | 170,698 |
No | output | 1 | 85,349 | 0 | 170,699 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input... | instruction | 0 | 85,350 | 0 | 170,700 |
No | output | 1 | 85,350 | 0 | 170,701 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input... | instruction | 0 | 85,351 | 0 | 170,702 |
No | output | 1 | 85,351 | 0 | 170,703 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
Input
The only line of input... | instruction | 0 | 85,352 | 0 | 170,704 |
No | output | 1 | 85,352 | 0 | 170,705 |
Provide a correct Python 3 solution for this coding contest problem.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = ... | instruction | 0 | 86,313 | 0 | 172,626 |
"Correct Solution:
```
N = int(input())
def standard(n, cur):
if n == 0:
print(''.join(cur))
else:
newC = chr(ord(sorted(cur)[-1]) + 1)
for c in sorted(set(cur + [newC])):
standard(n - 1, cur + [c])
standard(N - 1, ['a'])
``` | output | 1 | 86,313 | 0 | 172,627 |
Provide a correct Python 3 solution for this coding contest problem.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = ... | instruction | 0 | 86,314 | 0 | 172,628 |
"Correct Solution:
```
N = int(input())
def calc(n, L, ma):
if n == 0:
print("".join([chr(a+97) for a in L]))
return L
for i in range(ma+2):
l = calc(n-1, L + [i], max(ma, i))
calc(N, [], -1)
``` | output | 1 | 86,314 | 0 | 172,629 |
Provide a correct Python 3 solution for this coding contest problem.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = ... | instruction | 0 | 86,315 | 0 | 172,630 |
"Correct Solution:
```
def dfs(a='', b=chr(ord('a'))):
if len(a) == N:
print(a)
else:
i = chr(ord('a'))
while i < b:
dfs(a + i, b)
i = chr(ord(i) + 1)
dfs(a + b, chr(ord(b) + 1))
N = int(input())
dfs()
``` | output | 1 | 86,315 | 0 | 172,631 |
Provide a correct Python 3 solution for this coding contest problem.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = ... | instruction | 0 | 86,316 | 0 | 172,632 |
"Correct Solution:
```
N = int(input())
def dfs(s, mx):
if len(s) == N:
print(s)
return
for c in 'abcdefghij'[:(ord(mx)-ord('a'))+1]:
dfs(s+c, chr(ord(mx)+1)) if c == mx else dfs(s+c, mx)
dfs('', 'a')
``` | output | 1 | 86,316 | 0 | 172,633 |
Provide a correct Python 3 solution for this coding contest problem.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = ... | instruction | 0 | 86,317 | 0 | 172,634 |
"Correct Solution:
```
n = int(input())
def dfs(s, mx):
if len(s) == n:
print(''.join([chr(ord('a') + i) for i in s]))
else:
for i in range(mx+1):
dfs(s + [i], mx if i != mx else mx + 1)
dfs([], 0)
``` | output | 1 | 86,317 | 0 | 172,635 |
Provide a correct Python 3 solution for this coding contest problem.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = ... | instruction | 0 | 86,318 | 0 | 172,636 |
"Correct Solution:
```
n = int(input())
a = ord('a')
def dfs(s, m):
# print("dfs", s, chr(m))
if len(s) == n:
print(s)
else:
for i in range(m + 1 - a):
dfs(s + chr(a + i), m + 1 if i == m - a else m)
dfs("", a)
``` | output | 1 | 86,318 | 0 | 172,637 |
Provide a correct Python 3 solution for this coding contest problem.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = ... | instruction | 0 | 86,319 | 0 | 172,638 |
"Correct Solution:
```
n=int(input())
l=[["a"]]+[[] for i in range(9)]
for i in range(9):
for j in l[i]:
k=len(set(list(j)))
for h in range(k+1):
l[i+1].append(j+chr(97+h))
for i in l[n-1]:print(i)
``` | output | 1 | 86,319 | 0 | 172,639 |
Provide a correct Python 3 solution for this coding contest problem.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = ... | instruction | 0 | 86,320 | 0 | 172,640 |
"Correct Solution:
```
n = int(input())
def dfs(s, mx):
if len(s) == n:
print(s)
return
for c in range(ord("a"), mx+2):
dfs(s+chr(c), max(mx, c))
dfs("", ord("a")-1)
``` | output | 1 | 86,320 | 0 | 172,641 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* F... | instruction | 0 | 86,321 | 0 | 172,642 |
Yes | output | 1 | 86,321 | 0 | 172,643 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* F... | instruction | 0 | 86,322 | 0 | 172,644 |
Yes | output | 1 | 86,322 | 0 | 172,645 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* F... | instruction | 0 | 86,323 | 0 | 172,646 |
Yes | output | 1 | 86,323 | 0 | 172,647 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* F... | instruction | 0 | 86,324 | 0 | 172,648 |
Yes | output | 1 | 86,324 | 0 | 172,649 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* F... | instruction | 0 | 86,325 | 0 | 172,650 |
No | output | 1 | 86,325 | 0 | 172,651 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* F... | instruction | 0 | 86,326 | 0 | 172,652 |
No | output | 1 | 86,326 | 0 | 172,653 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* F... | instruction | 0 | 86,327 | 0 | 172,654 |
No | output | 1 | 86,327 | 0 | 172,655 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* F... | instruction | 0 | 86,328 | 0 | 172,656 |
No | output | 1 | 86,328 | 0 | 172,657 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its prefix of even length has an equal amount of letter... | instruction | 0 | 86,688 | 0 | 173,376 |
Tags: strings
Correct Solution:
```
n = int(input())
l = list(input())
count = 0
for i in range(0, n, 2):
if (l[i] == l[i + 1]):
l[i] = chr(1 - ord(l[i]) + 2 * ord('a'))
count += 1
print(count)
print(''.join(l))
``` | output | 1 | 86,688 | 0 | 173,377 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its prefix of even length has an equal amount of letter... | instruction | 0 | 86,689 | 0 | 173,378 |
Tags: strings
Correct Solution:
```
n=int(input())
a=list(input())
k=0
for i in range(n-1):
if((i==n-2) and a[i]==a[i+1]):
k+=1
if(a[i]=="a"):
a[i]="b"
else:
a[i]="a"
elif((i%2!=0) and (a[i]==a[i-1])):
if(a[i]=="a"):
a[i]="b"
else:
a[i]="a"
k+=1
print(k)
print("".join(a))
``` | output | 1 | 86,689 | 0 | 173,379 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its prefix of even length has an equal amount of letter... | instruction | 0 | 86,690 | 0 | 173,380 |
Tags: strings
Correct Solution:
```
n = int(input())
s = input()
ans = 0
for i in range(1, n , 2):
if(s[i] == s[i - 1]):
ans = ans + 1
print(ans)
for i in range(1, n , 2):
print(s[i - 1],end = "")
if(s[i - 1] == s[i]):
if(s[i] == 'a'):
print('b',end = "")
else:
... | output | 1 | 86,690 | 0 | 173,381 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its prefix of even length has an equal amount of letter... | instruction | 0 | 86,691 | 0 | 173,382 |
Tags: strings
Correct Solution:
```
a = int(input())
nlist = input()
str = list(nlist)
i = 0
k = 2
count = 0
while i<=len(str):
n_str = str[i:k]
acnt = n_str.count('a')
bcnt = n_str.count('b')
if acnt!=bcnt:
count +=1
if acnt == 2:
str[i] = 'b'
else:
st... | output | 1 | 86,691 | 0 | 173,383 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its prefix of even length has an equal amount of letter... | instruction | 0 | 86,692 | 0 | 173,384 |
Tags: strings
Correct Solution:
```
n = int(input())
s = list(input())
k = 0
for i in range(0, n, 2):
if(s[i] == s[i+1] and s[i] == "a"):
s[i + 1] = "b"
k += 1
elif(s[i] == s[i+1] and s[i] == "b"):
s[i + 1] = "a"
k += 1
print(k)
print("".join(s))
``` | output | 1 | 86,692 | 0 | 173,385 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its prefix of even length has an equal amount of letter... | instruction | 0 | 86,693 | 0 | 173,386 |
Tags: strings
Correct Solution:
```
import sys
input = sys.stdin.readline
n = int(input())
s = list(input()[:-1])
ans = 0
for i in range(0, n, 2):
if s[i]=='a' and s[i+1]=='a':
s[i] = 'b'
ans += 1
elif s[i]=='b' and s[i+1]=='b':
s[i] = 'a'
ans += 1
print(ans)
print(''.join(s))... | output | 1 | 86,693 | 0 | 173,387 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its prefix of even length has an equal amount of letter... | instruction | 0 | 86,694 | 0 | 173,388 |
Tags: strings
Correct Solution:
```
import sys
import math
#to read string
get_string = lambda: sys.stdin.readline().strip()
#to read list of integers
get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
#to read non spaced string and elements are integers to list of int
get_intList_from_str = ... | output | 1 | 86,694 | 0 | 173,389 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its prefix of even length has an equal amount of letter... | instruction | 0 | 86,695 | 0 | 173,390 |
Tags: strings
Correct Solution:
```
n = int(input())
string = list(input())
count = 0
for i in range(0,n-1, 2):
if string[i] == 'a' and string[i+1] == 'a':
string[i] = 'b'
count+=1
if string[i] == 'b' and string[i+1] == 'b':
string[i] = 'a'
... | output | 1 | 86,695 | 0 | 173,391 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its pref... | instruction | 0 | 86,696 | 0 | 173,392 |
Yes | output | 1 | 86,696 | 0 | 173,393 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its pref... | instruction | 0 | 86,697 | 0 | 173,394 |
Yes | output | 1 | 86,697 | 0 | 173,395 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its pref... | instruction | 0 | 86,698 | 0 | 173,396 |
Yes | output | 1 | 86,698 | 0 | 173,397 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its pref... | instruction | 0 | 86,699 | 0 | 173,398 |
Yes | output | 1 | 86,699 | 0 | 173,399 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its pref... | instruction | 0 | 86,700 | 0 | 173,400 |
No | output | 1 | 86,700 | 0 | 173,401 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its pref... | instruction | 0 | 86,701 | 0 | 173,402 |
No | output | 1 | 86,701 | 0 | 173,403 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its pref... | instruction | 0 | 86,702 | 0 | 173,404 |
No | output | 1 | 86,702 | 0 | 173,405 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nikolay got a string s of even length n, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from 1 to n.
He wants to modify his string so that every its pref... | instruction | 0 | 86,703 | 0 | 173,406 |
No | output | 1 | 86,703 | 0 | 173,407 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad.
A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2...s|s| (where |s| is the length of string s) is string slsl + 1...s... | instruction | 0 | 86,936 | 0 | 173,872 |
Tags: data structures, strings
Correct Solution:
```
# -*- coding:utf-8 -*-
"""
created by shuangquan.huang at 1/7/20
"""
import collections
import time
import os
import sys
import bisect
import heapq
from typing import List
def solve(S, B, K):
MOD = (1 << 50) + 9
s = set()
N = len(S)
pow = [... | output | 1 | 86,936 | 0 | 173,873 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad.
A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2...s|s| (where |s| is the length of string s) is string slsl + 1...s... | instruction | 0 | 86,937 | 0 | 173,874 |
Tags: data structures, strings
Correct Solution:
```
s = input()
a = input()
k = int(input())
S=sorted(s[i:] for i in range(len(s)))
p=''
r=0
for e in S:
t=0
s=0
for i in range(len(e)):
if i >= len(p) or e[i] != p[i]: s=1
t+=a[ord(e[i])-ord('a')]=='0'
if t > k:break
if s: r+=... | output | 1 | 86,937 | 0 | 173,875 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad.
A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2...s|s| (where |s| is the length of string s) is string slsl + 1...s... | instruction | 0 | 86,938 | 0 | 173,876 |
Tags: data structures, strings
Correct Solution:
```
s = input()
l = input()
k = int(input())
no_bad = []
curr = 0
p =31
m = 67280421310721
hashes = []
currh = 0
cnt = 0
P = [pow(p,i,m) for i in range(len(s)+2)]
for i in s:
currh+=(P[cnt]*ord(i))%m
cnt+=1
hashes.append(currh)
if(l[ord(i) - ord('a')] ==... | output | 1 | 86,938 | 0 | 173,877 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad.
A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2...s|s| (where |s| is the length of string s) is string slsl + 1...s... | instruction | 0 | 86,939 | 0 | 173,878 |
Tags: data structures, strings
Correct Solution:
```
s = input()
a = input()
k = int(input())
d = sorted(s[i:] for i in range(len(s)))
c = ''
r = 0
for j in d:
pos = 0
s = 0
for i in range(len(j)):
if i >= len(c) or j[i] != c[i]:
s = 1
if a[ord(j[i]) - ord('a')] == '0':
pos += 1
if pos > k:
break
... | output | 1 | 86,939 | 0 | 173,879 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad.
A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2...s|s| (where |s| is the length of string s) is string slsl + 1...s... | instruction | 0 | 86,940 | 0 | 173,880 |
Tags: data structures, strings
Correct Solution:
```
def index(c):
return ord(c) - ord('a')
class Trie:
def __init__(self):
self._children = {}
self.mark = False
def get(self, c):
i = index(c)
if i not in self._children:
self._children[i] = Trie()
retu... | output | 1 | 86,940 | 0 | 173,881 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad.
A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2...s|s| (where |s| is the length of string s) is string slsl + 1...s... | instruction | 0 | 86,941 | 0 | 173,882 |
Tags: data structures, strings
Correct Solution:
```
import sys
input=sys.stdin.readline
s=input().rstrip()
flag=input().rstrip()
k=int(input())
n=len(s)
ss=[s[i:] for i in range(n)]
ss.sort()
pre=""
ans=0
for e in ss:
veri,cnt_bad=0,0
for i in range(len(e)):
if i>=len(pre) or e[i]!=pre[i]:veri=1
cnt_bad+=f... | output | 1 | 86,941 | 0 | 173,883 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.