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.
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exact... | instruction | 0 | 76,784 | 6 | 153,568 |
Tags: implementation, strings
Correct Solution:
```
for _ in range(int(input())):
a=input()
b=input()
flag=True
l1=[]
c=1
s=a[0]
for i in a[1:]:
if i==s:
c+=1
else:
l1.append([s,c])
c=1
s=i
l1.append([s,c])
l2=[]
c=1
s=b[0]
for i in b[1:]:
if i==s:
c+=1
else:
l2.append([s,c])
... | output | 1 | 76,784 | 6 | 153,569 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exact... | instruction | 0 | 76,785 | 6 | 153,570 |
Tags: implementation, strings
Correct Solution:
```
n=int(input())
for i in range(n):
a=input()
b=input()
if(len(b)<len(a)):
print("NO")
continue
ans1=[]
c=1
for i in range(len(a)-1):
if(a[i]!=a[i+1]):
ans1.append([a[i],c])
c=1
else:
... | output | 1 | 76,785 | 6 | 153,571 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exact... | instruction | 0 | 76,786 | 6 | 153,572 |
Tags: implementation, strings
Correct Solution:
```
def initialChar(x):
past = x[0]
num = []
y = []
count = 0
for i in x:
if i != past:
y.append(past)
num.append(count)
count = 0
count += 1
past = i
y.append(past)
num.append(count)
... | output | 1 | 76,786 | 6 | 153,573 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exact... | instruction | 0 | 76,787 | 6 | 153,574 |
Tags: implementation, strings
Correct Solution:
```
n=int(input())
for _ in range(n):
scorrect=input()
sreal=input()
if len(scorrect)>len(sreal):
print('NO')
continue
ic=0
ir=0
f=1
while ic<len(scorrect) and ir<len(sreal):
current=scorrect[ic]
if sreal[ir]!=cu... | output | 1 | 76,787 | 6 | 153,575 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exact... | instruction | 0 | 76,788 | 6 | 153,576 |
Tags: implementation, strings
Correct Solution:
```
import sys
n=int(input())
for _ in range(n):
s=sys.stdin.readline().split("\n")[0]
t=sys.stdin.readline().split("\n")[0]
ss='$'
c=1
if s[0]!=t[0] or len(s)>len(t):
print("NO")
else:
ss=s[0]
tt=t[0]
i=1
j=... | output | 1 | 76,788 | 6 | 153,577 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exact... | instruction | 0 | 76,789 | 6 | 153,578 |
Tags: implementation, strings
Correct Solution:
```
n=int(input())
for _ in range(n):
s=input()+"@"
l=len(s)
s1=input()+"$"
l1=len(s1)
ans="YES"
i=0
j=0
while(ans=="YES"):
if(s1[j]=="$"):
if(s[i]=="@"):break
ans="NO"
break
if s[i] == s1[j]:
i+=1
j+=1
elif s[i] !... | output | 1 | 76,789 | 6 | 153,579 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exact... | instruction | 0 | 76,790 | 6 | 153,580 |
Tags: implementation, strings
Correct Solution:
```
# def gns():
# return list(map(int,input().split()))
# a,b,c,d=gns()
# abc=[a,b,c]
# abc.sort()
# d1=abc[1]-abc[0]
# d2=abc[2]-abc[1]
# d1=max(d-d1,0)
# d2=max(d-d2,0)
# print(d1+d2)
t=int(input())
for ti in range(t):
a=input()
b=input()
def g(s):
... | output | 1 | 76,790 | 6 | 153,581 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exact... | instruction | 0 | 76,791 | 6 | 153,582 |
Tags: implementation, strings
Correct Solution:
```
def solve(src, tgt):
si = 0
ti = 0
ans = "YES"
while si < len(src) and ti < len(tgt):
if src[si] == tgt[ti]:
si += 1
ti += 1
else:
if ti >= 1:
if tgt[ti] == tgt[ti-1]:
... | output | 1 | 76,791 | 6 | 153,583 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.
Two young parents abac and bbad think what name to give to their first-born child. The... | instruction | 0 | 77,762 | 6 | 155,524 |
Tags: greedy, strings
Correct Solution:
```
from sys import stdin, stdout
words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
s = stdin.readline().strip()
f = stdin.readline().strip()
ans = -1
d = {}
for v in s:
if v in d:
... | output | 1 | 77,762 | 6 | 155,525 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.
Two young parents abac and bbad think what name to give to their first-born child. The... | instruction | 0 | 77,763 | 6 | 155,526 |
Tags: greedy, strings
Correct Solution:
```
def findmin(lcopy, toexceed):
toex = ord(toexceed) - 97
for each in lcopy[(toex+1):]:
if each > 0:
return True
return False
def arrange(lcopy, toexceed = None):
if toexceed is None:
ans = ""
for i in range(26):
... | output | 1 | 77,763 | 6 | 155,527 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.
Two young parents abac and bbad think w... | instruction | 0 | 77,764 | 6 | 155,528 |
No | output | 1 | 77,764 | 6 | 155,529 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:
1. They are equal.
2. If we split string a into two halves of t... | instruction | 0 | 77,856 | 6 | 155,712 |
Tags: divide and conquer, hashing, sortings, strings
Correct Solution:
```
A, B = '', ''
def process(string):
if len(string) % 2 != 1:
m = int(len(string)/2)
l = process(string[:m])
r = process(string[m:])
if l < r:
return l + r
return r + l
return string
def entrypoint():
global A, B... | output | 1 | 77,856 | 6 | 155,713 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:
1. They are equal.
2. If we split string a into two halves of t... | instruction | 0 | 77,857 | 6 | 155,714 |
Tags: divide and conquer, hashing, sortings, strings
Correct Solution:
```
def divide_letras(palavra):
tamanho = len(palavra)
if (tamanho % 2 == 1):
return palavra
tamanho = tamanho // 2
esquerda = divide_letras(palavra[:tamanho])
direita = divide_letras(palavra[tamanho:])
if... | output | 1 | 77,857 | 6 | 155,715 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:
1. They are equal.
2. If we split string a into two halves of t... | instruction | 0 | 77,858 | 6 | 155,716 |
Tags: divide and conquer, hashing, sortings, strings
Correct Solution:
```
def sim(x):
if len(x) % 2:
return x
x1 = sim(x[:len(x)//2])
x2 = sim(x[len(x)//2:])
return x1 + x2 if x1 < x2 else x2 + x1
print("YES" if sim(input()) == sim(input()) else "NO")
``` | output | 1 | 77,858 | 6 | 155,717 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:
1. They are equal.
2. If we split string a into two halves of t... | instruction | 0 | 77,859 | 6 | 155,718 |
Tags: divide and conquer, hashing, sortings, strings
Correct Solution:
```
def equivalentStrings(string):
if len(string) & 1: return string
a = equivalentStrings(string[ : len(string) >> 1])
b = equivalentStrings(string[len(string) >> 1 : ])
return a + b if a < b else b + a
print('YES' if equivalen... | output | 1 | 77,859 | 6 | 155,719 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:
1. They are equal.
2. If we split string a into two halves of t... | instruction | 0 | 77,862 | 6 | 155,724 |
Tags: divide and conquer, hashing, sortings, strings
Correct Solution:
```
def main():
def f(lo, hi):
if not ((hi - lo) & 1):
mi = (hi + lo) // 2
f(lo, mi)
f(mi, hi)
if a[mi:hi] < a[lo:mi]:
a[lo:mi], a[mi:hi] = a[mi:hi], a[lo:mi]
if... | output | 1 | 77,862 | 6 | 155,725 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:
1. They are equal.
2. If we split string a into two halves of t... | instruction | 0 | 77,863 | 6 | 155,726 |
Tags: divide and conquer, hashing, sortings, strings
Correct Solution:
```
def solve(s):
sz = len(s)
if(sz % 2 == 1):
return s
a = solve(s[:int(sz / 2)])
b = solve(s[int(sz / 2):])
if a < b:
return a + b
else:
return b + a
def main():
a = input()
b = input(... | output | 1 | 77,863 | 6 | 155,727 |
Provide a correct Python 3 solution for this coding contest problem.
Problem Statement
We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not more than 26 letters. So one of us mapped each letter to a... | instruction | 0 | 78,245 | 6 | 156,490 |
"Correct Solution:
```
def add_edge(node, adj_lst, s1, s2):
ind = 0
max_len = min(len(s1), len(s2))
while ind < max_len and s1[ind] == s2[ind]:
ind += 1
if ind == max_len:
return max_len < len(s1)
c1 = ord(s1[ind]) - ord("a")
c2 = ord(s2[ind]) - ord("a")
adj_lst[c1].add(c2)
node.add(c1)
node.... | output | 1 | 78,245 | 6 | 156,491 |
Provide a correct Python 3 solution for this coding contest problem.
Problem Statement
We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not more than 26 letters. So one of us mapped each letter to a... | instruction | 0 | 78,246 | 6 | 156,492 |
"Correct Solution:
```
def add_edge(node, adj_lst, adj_rev, s1, s2):
ind = 0
max_len = min(len(s1), len(s2))
while ind < max_len and s1[ind] == s2[ind]:
ind += 1
if ind == max_len:
if max_len < len(s1):
return True
return False
c1 = ord(s1[ind]) - ord("a")
c2 = ord(s2[ind]) - ord("a")
ad... | output | 1 | 78,246 | 6 | 156,493 |
Provide a correct Python 3 solution for this coding contest problem.
Problem Statement
We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not more than 26 letters. So one of us mapped each letter to a... | instruction | 0 | 78,247 | 6 | 156,494 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int... | output | 1 | 78,247 | 6 | 156,495 |
Provide a correct Python 3 solution for this coding contest problem.
Problem Statement
We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not more than 26 letters. So one of us mapped each letter to a... | instruction | 0 | 78,248 | 6 | 156,496 |
"Correct Solution:
```
def add_edge(node, adj_lst, adj_rev, s1, s2):
ind = 0
max_len = min(len(s1), len(s2))
while ind < max_len and s1[ind] == s2[ind]:
ind += 1
if ind == max_len:
if max_len < len(s1):
return True
return False
c1 = ord(s1[ind]) - ord("a")
c2 = ord(s2[ind]) - ord("a")
ad... | output | 1 | 78,248 | 6 | 156,497 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem Statement
We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not mo... | instruction | 0 | 78,249 | 6 | 156,498 |
No | output | 1 | 78,249 | 6 | 156,499 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i... | instruction | 0 | 78,339 | 6 | 156,678 |
Tags: greedy, implementation
Correct Solution:
```
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(input())
a = input()
b = input()
al = [[] for i in range(27)]
bl = [[] for i in range(27)]
for i in range(n):
if a[i] == "?":
al[26].append(i+1)
else:
al[ord(a[i])-ord... | output | 1 | 78,339 | 6 | 156,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i... | instruction | 0 | 78,340 | 6 | 156,680 |
Tags: greedy, implementation
Correct Solution:
```
n = int(input())
l = input()
r = input()
rr = {'?':[]}
for i in range(n):
if r[i] in rr:
rr[r[i]].append(i)
else:
rr[r[i]] = [i]
ll = []
for i in range(n):
if l[i] == '?':
ll.append(i)
q = []
res = []
for i in range(n):
c = l[i]
... | output | 1 | 78,340 | 6 | 156,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i... | instruction | 0 | 78,341 | 6 | 156,682 |
Tags: greedy, implementation
Correct Solution:
```
from collections import defaultdict
n = int(input())
l = input()
r = input()
dl = defaultdict(list)
dr = defaultdict(list)
for i in range(n):
dl[l[i]].append(1+i)
for i in range(n):
dr[r[i]].append(1+i)
ans = []
s='abcdefghijklmnopqrstuvwxyz'
for i in s:
... | output | 1 | 78,341 | 6 | 156,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i... | instruction | 0 | 78,342 | 6 | 156,684 |
Tags: greedy, implementation
Correct Solution:
```
n = int(input())
la, ra = {}, {}
lq, rq = [], []
s = input()
for i in range(len(s)):
if s[i] != "?":
if s[i] not in la:
la[s[i]] = []
la[s[i]].append(i)
else:
lq.append(i)
s = input()
for i in range(len(s)):
if s[i] != "?":
if s[i] not in ra:
ra[s[i]] ... | output | 1 | 78,342 | 6 | 156,685 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i... | instruction | 0 | 78,343 | 6 | 156,686 |
Tags: greedy, implementation
Correct Solution:
```
n = int(input())
s1 = input()
s2 = input()
a1 = []
a2 = []
mas = []
ch = 0
q1 = 0
q2 = 0
for i in range(n):
a1.append([s1[i], i + 1])
a2.append([s2[i], i + 1])
if s1[i] == '?':
q1 += 1
if s2[i] == '?':
q2 += 1
a1.sort()
a2.sort()
i = n -... | output | 1 | 78,343 | 6 | 156,687 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i... | instruction | 0 | 78,344 | 6 | 156,688 |
Tags: greedy, implementation
Correct Solution:
```
from sys import stdin
from collections import defaultdict
input = stdin.readline
n = int(input())
l = input().rstrip()
r = input().rstrip()
ll = defaultdict(list)
rr = defaultdict(list)
for i in range(n):
ll[l[i]].append(i)
rr[r[i]].append(i)
ans = []
for k ... | output | 1 | 78,344 | 6 | 156,689 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i... | instruction | 0 | 78,345 | 6 | 156,690 |
Tags: greedy, implementation
Correct Solution:
```
n, s1, s2 = int(input()), input(), input()
dl, dr = {'?':0}, {'?':0}
indl ,indr = {'?':[]}, {'?':[]}
for i in range(n):
if s1[i] not in dl:
dl[s1[i]] = dr[s1[i]] = 0
indl[s1[i]], indr[s1[i]] = [], []
if s2[i] not in dl:
dl[s2[i]] = dr[s2[i]] = 0
indl[s2[i]], ... | output | 1 | 78,345 | 6 | 156,691 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i... | instruction | 0 | 78,346 | 6 | 156,692 |
Tags: greedy, implementation
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode... | output | 1 | 78,346 | 6 | 156,693 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two li... | instruction | 0 | 78,355 | 6 | 156,710 |
Tags: data structures, greedy, strings
Correct Solution:
```
from collections import defaultdict
vow = "aeoiu"
def vowels(word):
c = 0
for i in word:
if i in vow:
c += 1
return c
def last_vov(word):
for i in reversed(word):
if i in vow:
return i
dic = defau... | output | 1 | 78,355 | 6 | 156,711 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two li... | instruction | 0 | 78,356 | 6 | 156,712 |
Tags: data structures, greedy, strings
Correct Solution:
```
from collections import Counter
n = int(input())
d = {}
cnt = Counter()
for _ in range(n):
w = input()
last_vow = ""
nb = 0
for i in w:
if i in "aeiou":
nb += 1
last_vow = i
if nb in d:
if last_vow in d[nb]:
d[nb][last_vow].append(w)
els... | output | 1 | 78,356 | 6 | 156,713 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two li... | instruction | 0 | 78,357 | 6 | 156,714 |
Tags: data structures, greedy, strings
Correct Solution:
```
import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations
... | output | 1 | 78,357 | 6 | 156,715 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two li... | instruction | 0 | 78,358 | 6 | 156,716 |
Tags: data structures, greedy, strings
Correct Solution:
```
n=int(input())
a=[None]*n
d=dict()
vov=list("aeiou")
for i in range(n):
a[i]=input()
vc=0
lv="a"
for j in a[i]:
if j in vov:
vc+=1
lv=j
try:
d[vc][lv].append(a[i])
except:
d[vc]={'a': []... | output | 1 | 78,358 | 6 | 156,717 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two li... | instruction | 0 | 78,359 | 6 | 156,718 |
Tags: data structures, greedy, strings
Correct Solution:
```
from collections import deque
if True:
N = int(input())
# X = [[[] for _ in range(5)] for i in range(500001)]
X = {}
def calc(t):
c = 0
v = 0
for u in reversed(t):
if u == "a" or u == "i" or u == "u" or u =... | output | 1 | 78,359 | 6 | 156,719 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two li... | instruction | 0 | 78,360 | 6 | 156,720 |
Tags: data structures, greedy, strings
Correct Solution:
```
vowels = ['a', 'e', 'i', 'o', 'u']
class word():
def __init__(self, p):
o = ([int(p[i] in vowels) for i in range(len(p))])
self.nov = sum(o)
o.reverse()
self.lastvow = p[len(p) - 1 - o.index(1)]
n = int(input())
ug = {}
ma... | output | 1 | 78,360 | 6 | 156,721 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two li... | instruction | 0 | 78,361 | 6 | 156,722 |
Tags: data structures, greedy, strings
Correct Solution:
```
from sys import stdin
from collections import deque
mod = 10**9 + 7
import sys
sys.setrecursionlimit(10**5)
from queue import PriorityQueue
# def rl():
# return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import ... | output | 1 | 78,361 | 6 | 156,723 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n words, each of which consists of lowercase alphabet letters. Each word contains at least one vowel. You are going to choose some of the given words and make as many beautiful lyrics as possible.
Each lyric consists of two li... | instruction | 0 | 78,362 | 6 | 156,724 |
Tags: data structures, greedy, strings
Correct Solution:
```
def countvowels(s):
count = 0
for i in s:
if i in vowels:
count += 1
last = i
return count,last
n = int(input())
a = []
count = {}
vowels = {"a",'e','i','o','u'}
last = {}
for i in range(n):
s = input()
d,l = countvowels(s)
if d not in count:
... | output | 1 | 78,362 | 6 | 156,725 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particula... | instruction | 0 | 78,617 | 6 | 157,234 |
Tags: implementation, strings
Correct Solution:
```
z=['?']*100000;s=0
for _ in " "*int(input()):
t=list(map(str,input().replace(""," ").split()))
s=len(t)
for i in range(len(t)):
if z[i]=="@" or z[i]==t[i]=="?":continue
if t[i]!="?" and z[i]=="?":z[i]=t[i]
elif t[i]!="?" and z[i]!=... | output | 1 | 78,617 | 6 | 157,235 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particula... | instruction | 0 | 78,618 | 6 | 157,236 |
Tags: implementation, strings
Correct Solution:
```
from sys import stdin
n = int(input())
ips = []
for _ in range(n):
arr = stdin.readline().rstrip()
ips.append(arr)
output = ['?'] * len(ips[0])
for i in range(len(ips[0])):
countSet = set()
for j in range(n):
if ips[j][i] != '?':
... | output | 1 | 78,618 | 6 | 157,237 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particula... | instruction | 0 | 78,619 | 6 | 157,238 |
Tags: implementation, strings
Correct Solution:
```
for S in zip(*(input() for _ in range(int(input())))):
L = set(S) - {'?'}
if len(L) > 1:
print('?', end='')
elif len(L) > 0:
print(*L, end='')
else:
print('a', end='')
``` | output | 1 | 78,619 | 6 | 157,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particula... | instruction | 0 | 78,620 | 6 | 157,240 |
Tags: implementation, strings
Correct Solution:
```
import sys
import itertools
WILDCARD = '?'
FILL = 'x'
def main():
pattern_count = int(sys.stdin.readline())
patterns = itertools.islice(sys.stdin, pattern_count)
result = intersect_patterns(p.strip() for p in patterns)
print(result)
def intersect_... | output | 1 | 78,620 | 6 | 157,241 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particula... | instruction | 0 | 78,621 | 6 | 157,242 |
Tags: implementation, strings
Correct Solution:
```
n, t = int(input()), list(input())
for i in range(n - 1):
for j, c in enumerate(input()):
if t[j] == '!' or c == '?': continue
if t[j] == '?': t[j] = c
elif t[j] != c: t[j] = '!'
print(''.join(t).replace('?', 'x').replace('!', '?'))
``` | output | 1 | 78,621 | 6 | 157,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particula... | instruction | 0 | 78,622 | 6 | 157,244 |
Tags: implementation, strings
Correct Solution:
```
n = int(input())
s = input()
str_len = len(s)
good = []
for ch in s:
if ch == '?':
good.append('$')
else:
good.append(ch)
r = range(n - 1)
for i in r:
s = input()
j = int(0)
while j < str_len:
if (s[j] == '?') and (good[j] =... | output | 1 | 78,622 | 6 | 157,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particula... | instruction | 0 | 78,623 | 6 | 157,246 |
Tags: implementation, strings
Correct Solution:
```
from collections import Counter
def best(t):
cnt = Counter(t)
if len(cnt) == 0:
return 'a'
if len(cnt) == 1:
return t[0]
return '?'
n = int(input())
l = []
for i in range(n):
l.append(input())
print(''.join(best([c for c in t if c != '?']) for t in zip(*l))... | output | 1 | 78,623 | 6 | 157,247 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particula... | instruction | 0 | 78,624 | 6 | 157,248 |
Tags: implementation, strings
Correct Solution:
```
import sys
input = sys.stdin.readline
'''
'''
n = int(input())
res = list(input().rstrip())
good = [1] * len(res)
for _ in range(n-1):
p = input().rstrip()
for i, char in enumerate(p):
if char == "?" or char == res[i]:
continue
... | output | 1 | 78,624 | 6 | 157,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.
For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For this reason, two words "ulyana" a... | instruction | 0 | 78,814 | 6 | 157,628 |
Tags: implementation
Correct Solution:
```
n = int(input())
ans = set()
for i in range(n):
s = str(input())
s = s.replace("u", "oo")
# print(s)
while "kh" in s:
s = s.replace("kh", "h")
# print(s)
ans.add(s)
print(len(ans))
# print(ans)
``` | output | 1 | 78,814 | 6 | 157,629 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.
For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For this reason, two words "ulyana" a... | instruction | 0 | 78,815 | 6 | 157,630 |
Tags: implementation
Correct Solution:
```
d = {}
n = int(input())
def simpler(word):
p = 0
while p <= len(word):
if word[p:p+1] == "u":
word = word[:p] + "oo" + word[p+1:]
p = 0
elif word[p:p+2] == "kh":
word = word[:p] + "h" + word[p+2:]
p = 0... | output | 1 | 78,815 | 6 | 157,631 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.
For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For this reason, two words "ulyana" a... | instruction | 0 | 78,816 | 6 | 157,632 |
Tags: implementation
Correct Solution:
```
def conv(s):
s = s.replace('u','oo')
while 'kh' in s:
s = s.replace('kh','h')
#print(s)
return s
n = int(input())
arr = set()
for i in range(n):
s = input()
arr.add(conv(s))
print(len(arr))
``` | output | 1 | 78,816 | 6 | 157,633 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.
For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For this reason, two words "ulyana" a... | instruction | 0 | 78,817 | 6 | 157,634 |
Tags: implementation
Correct Solution:
```
n=int(input())
arr=[]
count=0
for i in range(n):
x=input()
while "kh" in x:
x=x.replace("kh","h")
while "u" in x:
x=x.replace("u","oo")
if x not in arr:
count+=1
arr.append(x)
print(count)
``` | output | 1 | 78,817 | 6 | 157,635 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.