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. Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange. Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be repla...
instruction
0
40,927
6
81,854
Tags: implementation Correct Solution: ``` length = int(input()) word = input() vowels = 'aeiouy' i = 0 while i<length: #print(i,length) if length==1 or i==length-1: break elif word[i] in vowels and word[i+1] in vowels: word = word[:i+1]+word[i+2:] i=0 length-=1 else: i+=1 print(word) ```
output
1
40,927
6
81,855
Provide tags and a correct Python 3 solution for this coding contest problem. Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange. Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be repla...
instruction
0
40,928
6
81,856
Tags: implementation Correct Solution: ``` # https://codeforces.com/problemset/problem/938/A n = input() s = list() vowels = {'a', 'e', 'i', 'o', 'u', 'y'} for i in input(): if not s: s.append(i) else: if s[-1] in vowels and i in vowels: pass else: s.append(i) ...
output
1
40,928
6
81,857
Provide tags and a correct Python 3 solution for this coding contest problem. Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange. Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be repla...
instruction
0
40,929
6
81,858
Tags: implementation Correct Solution: ``` n = int(input()) s = input() counter = 1 myList = ["a", "e", "i", "o", "u", "y"] counter = 0 for i in range(0, len(s) - 1): if s[counter] in myList and s[counter + 1] in myList: s = s[:(counter + 1)] + s[(counter + 2):] else: counter += 1 print(s) ```
output
1
40,929
6
81,859
Provide tags and a correct Python 3 solution for this coding contest problem. Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange. Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be repla...
instruction
0
40,930
6
81,860
Tags: implementation Correct Solution: ``` #This code sucks, you know it and I know it. #Move on and call me an idiot later. n = int(input()) s = input() ans = [] temp = 0 for i in s: if i in 'aeiouy': if temp == 0: temp = 1 ans += [i] else: temp = 0 ans += [i]...
output
1
40,930
6
81,861
Provide tags and a correct Python 3 solution for this coding contest problem. Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange. Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be repla...
instruction
0
40,931
6
81,862
Tags: implementation Correct Solution: ``` import sys vowel = 'aeiouy' n = int(input()) s = list(input()) i = 0 while i < len(s)-1: if s[i] in vowel and s[i+1] in vowel: s.pop(i+1) else: i += 1 print(''.join(s)) ```
output
1
40,931
6
81,863
Provide tags and a correct Python 3 solution for this coding contest problem. Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange. Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be repla...
instruction
0
40,932
6
81,864
Tags: implementation Correct Solution: ``` n=int(input()) s=input() k="" m=False for i in range(n): if s[i] not in ["a","e","i","o","u","y"]: k+=s[i] elif s[i] in ["a","e","i","o","u","y"] and not m: k+=s[i] m=True try: if s[i] in ["a","e","i","o","u","y"] and s[i+...
output
1
40,932
6
81,865
Provide tags and a correct Python 3 solution for this coding contest problem. Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange. Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be repla...
instruction
0
40,933
6
81,866
Tags: implementation Correct Solution: ``` def vovel(c): return c in ['a', 'i', 'o', 'e', 'u', 'y'] n = int(input()) s = input()[:n] if len(s)>0: p = s[0] else: print () exit() res = '' for i in range(1, len(s)): if vovel(p) and vovel(s[i]): continue res +=p p = s[i] res += p print...
output
1
40,933
6
81,867
Provide tags and a correct Python 3 solution for this coding contest problem. Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them. A little later they found a string s, carved on a rock below...
instruction
0
43,069
6
86,138
Tags: binary search, dp, hashing, string suffix structures, strings Correct Solution: ``` def kmp_fail(p): m=len(p) fail=m*[0] k=0 j=1 while j<m: if p[j]==p[k]: fail[j]=k+1 j+=1 k+=1 elif k>0: k=fail[k-1] else: j+=1 ...
output
1
43,069
6
86,139
Provide tags and a correct Python 3 solution for this coding contest problem. Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them. A little later they found a string s, carved on a rock below...
instruction
0
43,070
6
86,140
Tags: binary search, dp, hashing, string suffix structures, strings Correct Solution: ``` s = input() n = len(s) if n==1 or n==2: print("Just a legend") else: lista = [] for i in range(n): lista.append(0) l = 0 lista[0] = 0 i = 1 while i < n: if s[i]==s[l]: l+=1 lista[i] = l i += 1 else: if l...
output
1
43,070
6
86,141
Provide tags and a correct Python 3 solution for this coding contest problem. Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them. A little later they found a string s, carved on a rock below...
instruction
0
43,071
6
86,142
Tags: binary search, dp, hashing, string suffix structures, strings Correct Solution: ``` def Zarr(pat,text): s=pat+"/"+text; z=[0 for i in range(len(s))] L=0;R=0;n=len(s); for i in range(1,len(s)): if i>R: L=R=i while R<n and s[R-L]==s[R]: R+=1 ...
output
1
43,071
6
86,143
Provide tags and a correct Python 3 solution for this coding contest problem. Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them. A little later they found a string s, carved on a rock below...
instruction
0
43,073
6
86,146
Tags: binary search, dp, hashing, string suffix structures, strings Correct Solution: ``` def KMP_pre(texte, longueur): M = [0 for i in range(longueur)] index_deb = 0 M[0] = 0 i = 1 while (i < longueur): if (texte[i] == texte[index_deb]): index_deb += 1 M[i] = index_...
output
1
43,073
6
86,147
Provide tags and a correct Python 3 solution for this coding contest problem. Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them. A little later they found a string s, carved on a rock below...
instruction
0
43,074
6
86,148
Tags: binary search, dp, hashing, string suffix structures, strings Correct Solution: ``` s=input() n=len(s) p=[-1]*n mark=[False]*n q=-1 for i in range(1,n): while q>=0 and s[i]!=s[q+1]: q=p[q] if s[i] == s[q + 1]: q += 1 p[i] = q if q>=0 and i<n-1: mark[q]=True #print(p) q=...
output
1
43,074
6
86,149
Provide tags and a correct Python 3 solution for this coding contest problem. Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them. A little later they found a string s, carved on a rock below...
instruction
0
43,075
6
86,150
Tags: binary search, dp, hashing, string suffix structures, strings Correct Solution: ``` def prefix(s): p = [0] * len(s) for i in range(1, len(s)): k = p[i - 1] while k > 0 and s[k] != s[i]: k = p[k - 1] if s[k] == s[i]: k += 1 p[i] = k return p str...
output
1
43,075
6
86,151
Provide tags and a correct Python 3 solution for this coding contest problem. Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them. A little later they found a string s, carved on a rock below...
instruction
0
43,076
6
86,152
Tags: binary search, dp, hashing, string suffix structures, strings Correct Solution: ``` def kmpTable(s, n): res = [0]*n check_idx = 0 for i in range(1, n): while check_idx > 0 and s[check_idx] != s[i]: check_idx = res[check_idx-1] if s[check_idx] == s[i]: check_idx ...
output
1
43,076
6
86,153
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language. Input This p...
instruction
0
43,325
6
86,650
Tags: *special Correct Solution: ``` n=input() print("INTERCAL") ```
output
1
43,325
6
86,651
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language. Input This p...
instruction
0
43,326
6
86,652
Tags: *special Correct Solution: ``` print('INTERCAL') ```
output
1
43,326
6
86,653
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language. Input This p...
instruction
0
43,327
6
86,654
Tags: *special Correct Solution: ``` # Flamire senpai AK IOI print('INTERCAL') ```
output
1
43,327
6
86,655
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language. Input This p...
instruction
0
43,328
6
86,656
Tags: *special Correct Solution: ``` print("INTERCAL") #233333 ```
output
1
43,328
6
86,657
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language. Input This p...
instruction
0
43,329
6
86,658
Tags: *special Correct Solution: ``` """==================================================================================== ==================================================================================== ___ _______ ___ _______ ___ ___ | /\ | | \ | ...
output
1
43,329
6
86,659
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language. Input This p...
instruction
0
43,330
6
86,660
Tags: *special Correct Solution: ``` print("INTERCAL") # This is my code ```
output
1
43,330
6
86,661
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language. Input This p...
instruction
0
43,331
6
86,662
Tags: *special Correct Solution: ``` print("INTERCAL") aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1 ```
output
1
43,331
6
86,663
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a mysterious language (codenamed "Secret") available in "Custom Invocation" tab. Figure out what this language is and write a program which prints its name. Note that the program must be written in this language. Input This p...
instruction
0
43,332
6
86,664
Tags: *special Correct Solution: ``` n=input();print("INTERCAL") ```
output
1
43,332
6
86,665
Provide a correct Python 3 solution for this coding contest problem. Find the edit distance between given two words s1 and s2. The disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations: * insertion: Insert a character at a pa...
instruction
0
43,789
6
87,578
"Correct Solution: ``` def levenshtein_dist(a,b): a_size = len(a) b_size = len(b) inf = float('inf') dp = [[a_size+b_size for i in range(a_size+1)] for _ in range(b_size+1)] for i in range(b_size+1): dp[i][0] = i for j in range(a_size+1): dp[0][j] = j for i in range(1,b_size...
output
1
43,789
6
87,579
Provide tags and a correct Python 3 solution for this coding contest problem. While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to kno...
instruction
0
44,276
6
88,552
Tags: bitmasks, combinatorics, implementation, strings Correct Solution: ``` import string charset = string.digits + string.ascii_uppercase + string.ascii_lowercase + "-_" def getValue(char): return charset.index(char) def main(): string = input() cnt = 1 dict = {} for i in range(len(charset)...
output
1
44,276
6
88,553
Provide tags and a correct Python 3 solution for this coding contest problem. The tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance. This time, the brothers are dealing with a strange piece of wood marked with their names. This plan...
instruction
0
44,837
6
89,674
Tags: data structures, dp, hashing, number theory Correct Solution: ``` import math a=[] for s in[*open(0)][2::2]: D={};d=k=0 for c in s[:-1]: if c<'K':d+=1 else:k+=1 g=math.gcd(d,k);l=(d/g,k/g);D[l]=D.get(l,0)+1;a+=D[l], print(*a) ```
output
1
44,837
6
89,675
Provide tags and a correct Python 3 solution for this coding contest problem. The tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance. This time, the brothers are dealing with a strange piece of wood marked with their names. This plan...
instruction
0
44,838
6
89,676
Tags: data structures, dp, hashing, number theory Correct Solution: ``` import os import sys from io import BytesIO, IOBase from math import ceil, floor, pow, sqrt, gcd from collections import Counter, defaultdict from itertools import permutations, combinations from time import time, sleep BUFSIZE = 8192 MOD = 100000...
output
1
44,838
6
89,677
Provide tags and a correct Python 3 solution for this coding contest problem. The tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance. This time, the brothers are dealing with a strange piece of wood marked with their names. This plan...
instruction
0
44,839
6
89,678
Tags: data structures, dp, hashing, number theory Correct Solution: ``` import sys input = sys.stdin.readline from math import gcd for _ in range(int(input())): n = int(input()) s = input()[:-1] seen = {} x, y = 0, 0 ans = [] for i, c in enumerate(s): if c == 'D': x += 1 else: y...
output
1
44,839
6
89,679
Provide tags and a correct Python 3 solution for this coding contest problem. The tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance. This time, the brothers are dealing with a strange piece of wood marked with their names. This plan...
instruction
0
44,840
6
89,680
Tags: data structures, dp, hashing, number theory Correct Solution: ``` def gcd(a,b): if b==0: return a return gcd(b,a%b) for _ in range(int(input())): n=int(input()) s=input() ans=[0]*n d=0 ans[0]=1 m={} if s[0]=='D': d=1 m[(1,0)]=1 else: m[(0,1)]...
output
1
44,840
6
89,681
Provide tags and a correct Python 3 solution for this coding contest problem. The tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance. This time, the brothers are dealing with a strange piece of wood marked with their names. This plan...
instruction
0
44,841
6
89,682
Tags: data structures, dp, hashing, number theory Correct Solution: ``` from sys import stdin, stdout def arrin(): return list(map(int, stdin.readline().split())) def num1in(): return int(stdin.readline()) def num2in(): a, b = map(int, stdin.readline().split()) return a, b def num3in(): a, b, c = ma...
output
1
44,841
6
89,683
Provide tags and a correct Python 3 solution for this coding contest problem. The tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance. This time, the brothers are dealing with a strange piece of wood marked with their names. This plan...
instruction
0
44,842
6
89,684
Tags: data structures, dp, hashing, number theory Correct Solution: ``` from math import gcd import sys input = sys.stdin.readline def main(): N = int(input()) S = input() Ans = [] Ratio = dict() D = [] K = [] d = 0 k = 0 for i in range(N): if S[i] == 'D': d += 1 els...
output
1
44,842
6
89,685
Provide tags and a correct Python 3 solution for this coding contest problem. The tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance. This time, the brothers are dealing with a strange piece of wood marked with their names. This plan...
instruction
0
44,843
6
89,686
Tags: data structures, dp, hashing, number theory Correct Solution: ``` import math from collections import defaultdict for _ in range(int(input())): n=int(input()) s=input() d=0;k=0 l=[] c=defaultdict(int) for i in range(n): if s[i]=='D': d+=1 else: k+=1 ...
output
1
44,843
6
89,687
Provide tags and a correct Python 3 solution for this coding contest problem. The tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance. This time, the brothers are dealing with a strange piece of wood marked with their names. This plan...
instruction
0
44,844
6
89,688
Tags: data structures, dp, hashing, number theory Correct Solution: ``` from collections import defaultdict from math import gcd for _ in range(int(input())): n = int(input()) s = input() D = [0] * n K = [0] * n if(s[0] == "D"): D[0] = 1 else: K[0] = 1 for i in range(1, n): ...
output
1
44,844
6
89,689
Provide tags and a correct Python 3 solution for this coding contest problem. After you had helped Fedor to find friends in the Β«Call of Soldiers 3Β» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Alex for help. Alex cam...
instruction
0
44,943
6
89,886
Tags: dfs and similar, dp, graphs, hashing, strings Correct Solution: ``` from collections import defaultdict m = int(input()) num = dict() inp = lambda word: (word.count('R'), len(word), num.setdefault(word, len(num))) text = list(map(inp, input().upper().split())) q = text.copy() n = int(input()) syn = defaultdict(...
output
1
44,943
6
89,887
Provide tags and a correct Python 3 solution for this coding contest problem. After you had helped Fedor to find friends in the Β«Call of Soldiers 3Β» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Alex for help. Alex cam...
instruction
0
44,944
6
89,888
Tags: dfs and similar, dp, graphs, hashing, strings Correct Solution: ``` from sys import stdin from collections import defaultdict def main(): stdin.readline() num = {} stat = lambda word: (word.count('r'), len(word), num.setdefault(word, len(num))) essay = list(map(stat, stdin.readline().lower().split...
output
1
44,944
6
89,889
Provide tags and a correct Python 3 solution for this coding contest problem. After you had helped Fedor to find friends in the Β«Call of Soldiers 3Β» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Alex for help. Alex cam...
instruction
0
44,945
6
89,890
Tags: dfs and similar, dp, graphs, hashing, strings Correct Solution: ``` from collections import defaultdict input() index = {} stat = lambda word: (word.count('r'), len(word), index.setdefault(word, len(index))) essay = list(map(stat, input().lower().split())) queue = essay[:] syn = defaultdict(list) for i in ...
output
1
44,945
6
89,891
Provide tags and a correct Python 3 solution for this coding contest problem. After you had helped Fedor to find friends in the Β«Call of Soldiers 3Β» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Alex for help. Alex cam...
instruction
0
44,946
6
89,892
Tags: dfs and similar, dp, graphs, hashing, strings Correct Solution: ``` import collections def solve(): m = int(input()) essay = [s for s in input().lower().split()] n = int(input()) sti = dict() pack = lambda word: (word.count('r'), len(word), sti.setdefault(word, len(sti))) edge = collections.defaultd...
output
1
44,946
6
89,893
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is a filler word ogo in Oleg's speech...
instruction
0
45,015
6
90,030
Tags: implementation, strings Correct Solution: ``` n=int(input()) s=input() i=0 while i<n: if s[i:i+3]=="ogo": while s[i:i+3]=="ogo": i+=2 print("***",end="") else:print(s[i],end="") i+=1 ```
output
1
45,015
6
90,031
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is a filler word ogo in Oleg's speech...
instruction
0
45,016
6
90,032
Tags: implementation, strings Correct Solution: ``` n = int(input()) s = input() while s.count("ogo") > 0: i = 0 j = 0 while s[i:i + 3] != "ogo": i += 1 if s[i:i + 3] == "ogo": j = i + 3 while j + 2 <= len(s) and s[j:j + 2] == "go": j += 2 s = s[:i] + "***" + ...
output
1
45,016
6
90,033
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is a filler word ogo in Oleg's speech...
instruction
0
45,017
6
90,034
Tags: implementation, strings Correct Solution: ``` if __name__ == '__main__': n, s = int(input()), input() result_array = [] left = 0 while left <= n - 3: if s[left: left + 3] == 'ogo': left += 3 if left >= n: result_array.append('***') brea...
output
1
45,017
6
90,035
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is a filler word ogo in Oleg's speech...
instruction
0
45,018
6
90,036
Tags: implementation, strings Correct Solution: ``` # # Created by Polusummator on 25.10.2020 # --------- Little PyPy Squad --------- # Verdict: # n = int(input()) s = input() # ans = '' # prev = '' first = 'o' + 'go' * n # print(first) while first != 'o': # print(first) s = s.replace(first, '***') n -= 1 ...
output
1
45,018
6
90,037
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is a filler word ogo in Oleg's speech...
instruction
0
45,019
6
90,038
Tags: implementation, strings Correct Solution: ``` import re n = int(input()) s = input() s = s.lower() while 'ogo' in s: s = re.sub('o(go)+', '***', s) print(s) ```
output
1
45,019
6
90,039
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is a filler word ogo in Oleg's speech...
instruction
0
45,020
6
90,040
Tags: implementation, strings Correct Solution: ``` # coding: utf-8 # In[155]: n = int(input()) s = input() # In[156]: def findEnd(s, i): k = i + 2 ans = i+2 while k + 2 < len(s): if s[k+1:k+3] == "go": ans = k+2 else: break k+=2 return ans ...
output
1
45,020
6
90,041
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is a filler word ogo in Oleg's speech...
instruction
0
45,021
6
90,042
Tags: implementation, strings Correct Solution: ``` import re print(re.sub(r'o(go)+',r'***',[*open(0)][1])) ```
output
1
45,021
6
90,043
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is a filler word ogo in Oleg's speech...
instruction
0
45,022
6
90,044
Tags: implementation, strings Correct Solution: ``` s=input() s=input() sogo='og'*50 i=0 while i<len(s): i=s.find('ogo') if i==-1: break k=i+3 while k<len(s)+1 and s[i:k]==sogo[0:k-i]: k=k+2 if k>=len(s) or s[i:k]!=sogo[0:k-i]: srep=s[i:k-2] else: srep=s[i:k] ...
output
1
45,022
6
90,045
Provide a correct Python 3 solution for this coding contest problem. Limak can repeatedly remove one of the first two characters of a string, for example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx. You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) / 2 pairs (S_i, S_j), in how...
instruction
0
45,161
6
90,322
"Correct Solution: ``` import sys import string input = sys.stdin.readline from collections import defaultdict N = int(input()) T = [input()[::-1].strip() for i in range(N)] #N = 100 #M = 10000 #import random #import string #T = [''.join(random.choices(string.ascii_lowercase, k=random.randint(M,M))) for i in range(N)]...
output
1
45,161
6
90,323
Provide a correct Python 3 solution for this coding contest problem. Limak can repeatedly remove one of the first two characters of a string, for example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx. You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) / 2 pairs (S_i, S_j), in how...
instruction
0
45,164
6
90,328
"Correct Solution: ``` class Trie: class Node: def __init__(self,c): self.c=c self.next_c_id={} #self.common=0 self.end=-1 def __init__(self): self.trie=[self.Node('')] def add(self,id,s): i=0 now=0 ary=[0] ...
output
1
45,164
6
90,329
Provide a correct Python 3 solution for this coding contest problem. Limak can repeatedly remove one of the first two characters of a string, for example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx. You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) / 2 pairs (S_i, S_j), in how...
instruction
0
45,165
6
90,330
"Correct Solution: ``` class Trie(): def __init__(self,arrRev): self.node = [ [] for _ in range(len(arrRev)) ] # self.children = [ [ -1 for _ in range(ord('z')-ord('a'))] for _ in range(10**6+1) ] self.children = [ {} for _ in range(10**6+1) ] self.isHeadCharNode = [ False for _ in range( 10**6+1 ) ] nodeNum...
output
1
45,165
6
90,331
Provide tags and a correct Python 3 solution for this coding contest problem. Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase L...
instruction
0
45,639
6
91,278
Tags: greedy Correct Solution: ``` ###################################################### ############Created by Devesh Kumar################### #############devesh1102@gmail.com#################### ##########For CodeForces(Devesh1102)################# #####################2020############################# ############...
output
1
45,639
6
91,279
Provide tags and a correct Python 3 solution for this coding contest problem. Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase L...
instruction
0
45,640
6
91,280
Tags: greedy Correct Solution: ``` s = input() + "#" k = int(input()) arr = [input() for _ in range(k)] res = 0 for t in arr: a, b = 0, 0 for i in range(len(s)): if s[i] == t[0]: a += 1 elif s[i] == t[1]: b += 1 else: if a and b: res +=...
output
1
45,640
6
91,281
Provide tags and a correct Python 3 solution for this coding contest problem. Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase L...
instruction
0
45,641
6
91,282
Tags: greedy Correct Solution: ``` import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush # from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_lef...
output
1
45,641
6
91,283