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.
Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.
Lesha chooses an arbitrary (pos... | instruction | 0 | 41,455 | 0 | 82,910 |
Tags: dp, greedy, implementation, strings
Correct Solution:
```
s = input()
cs = ['']
ans = []
last = ['']
poped = False
for c in s[::-1]:
if not poped and c == cs[-1] and c > last[-2]:
cs.pop()
if (not cs) or c != cs[-1]:
last.pop()
poped = True
else:
poped = False
... | output | 1 | 41,455 | 0 | 82,911 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm is as follows.
Lesha chooses an arbitrary (pos... | instruction | 0 | 41,456 | 0 | 82,912 |
Tags: dp, greedy, implementation, strings
Correct Solution:
```
import os
import sys
import io
import functools
import copy
import math
# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline # 神奇快读,无法运行调试
GANS = []
# def print(*args): # 神奇快写,最后得写上os.write
# global GANS
# for i in args:
# GAN... | output | 1 | 41,456 | 0 | 82,913 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm ... | instruction | 0 | 41,457 | 0 | 82,914 |
Yes | output | 1 | 41,457 | 0 | 82,915 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm ... | instruction | 0 | 41,458 | 0 | 82,916 |
Yes | output | 1 | 41,458 | 0 | 82,917 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm ... | instruction | 0 | 41,459 | 0 | 82,918 |
Yes | output | 1 | 41,459 | 0 | 82,919 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm ... | instruction | 0 | 41,460 | 0 | 82,920 |
Yes | output | 1 | 41,460 | 0 | 82,921 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm ... | instruction | 0 | 41,461 | 0 | 82,922 |
No | output | 1 | 41,461 | 0 | 82,923 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm ... | instruction | 0 | 41,462 | 0 | 82,924 |
No | output | 1 | 41,462 | 0 | 82,925 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm ... | instruction | 0 | 41,463 | 0 | 82,926 |
No | output | 1 | 41,463 | 0 | 82,927 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Some time ago Lesha found an entertaining string s consisting of lowercase English letters. Lesha immediately developed an unique algorithm for this string and shared it with you. The algorithm ... | instruction | 0 | 41,464 | 0 | 82,928 |
No | output | 1 | 41,464 | 0 | 82,929 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You should process m queries over a set D of strings. Each query is one of three kinds:
1. Add a string s to the set D. It is guaranteed that the string s was not added before.
2. Delete a... | instruction | 0 | 41,689 | 0 | 83,378 |
No | output | 1 | 41,689 | 0 | 83,379 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time... | instruction | 0 | 41,736 | 0 | 83,472 |
Tags: brute force, implementation, strings
Correct Solution:
```
lens = input().split()
s1 = input()
s2 = input()
min_count = int(lens[0])
min_answer = list()
for start in range(int(lens[1]) - int(lens[0]) + 1):
diff = 0
answer = list()
for i in range(int(lens[0])):
if (s1[i] != s2[start+i]):
... | output | 1 | 41,736 | 0 | 83,473 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time... | instruction | 0 | 41,737 | 0 | 83,474 |
Tags: brute force, implementation, strings
Correct Solution:
```
I = lambda: map(int, input().split())
n, m = I()
s, t = input(), input()
res = 0
res_details = []
for i in range(m-n+1):
#print(t[i:i+n])
eq = 0
detail = []
for j in range(i,i+n):
if not (ord(s[j-i]) - ord(t[j])):
eq +=... | output | 1 | 41,737 | 0 | 83,475 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time... | instruction | 0 | 41,738 | 0 | 83,476 |
Tags: brute force, implementation, strings
Correct Solution:
```
n, m = map(int, input().split())
a = input()
b = input()
L = len(a)
res1 = []
res2 = 9999999999
for i in range(0, m - n + 1):
ia = iter(a)
ib = iter(b[i:i + L])
ans1 = []
ans2 = 0
try:
j = 1
while True:
if next(ia) != next(ib):
ans1.append... | output | 1 | 41,738 | 0 | 83,477 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time... | instruction | 0 | 41,739 | 0 | 83,478 |
Tags: brute force, implementation, strings
Correct Solution:
```
I = lambda: list(map(int, input().split()))
n, m = I()
s = input()
t = input()
def diff(s, t, tpos):
ans = []
for e, [i, j] in enumerate(zip(s, t[tpos:][:len(s)])):
if i!='?' and i!=j:
ans.append(e + 1)
return ans
repl = ... | output | 1 | 41,739 | 0 | 83,479 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time... | instruction | 0 | 41,740 | 0 | 83,480 |
Tags: brute force, implementation, strings
Correct Solution:
```
import sys
def main():
n,m = map(int,sys.stdin.readline().split())
s = sys.stdin.readline().rstrip()
t = sys.stdin.readline().rstrip()
r = 10000
res = []
for i in range(m-n+1):
p = []
c = 0
for j in r... | output | 1 | 41,740 | 0 | 83,481 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time... | instruction | 0 | 41,741 | 0 | 83,482 |
Tags: brute force, implementation, strings
Correct Solution:
```
n, m = input().split()
s = input()
t = input()
n = int(n)
m = int(m)
k = n + 1
pos = []
aux = []
for i in range(m - n + 1):
x = n
aux=[]
for j in range(len(s)):
if(t[i + j] == s[j]):
x -= 1
else:
aux.append(str(j+1))
j += ... | output | 1 | 41,741 | 0 | 83,483 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time... | instruction | 0 | 41,742 | 0 | 83,484 |
Tags: brute force, implementation, strings
Correct Solution:
```
n, m = map(int, input().split())
s = input()
t = input()
ans = [i for i in range(1, n + 1)]
for i in range(m - n + 1):
pos = []
for j in range(n):
if s[j] != t[i + j]:
pos.append(j + 1)
if len(pos) < len(ans):
ans ... | output | 1 | 41,742 | 0 | 83,485 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time... | instruction | 0 | 41,743 | 0 | 83,486 |
Tags: brute force, implementation, strings
Correct Solution:
```
a,b=map(int,input().split())
c=input()
d=input()
maxi=a
ko=[]
for i in range(b-a+1):
premax=0
po=[]
for j in range(a):
if c[j]!=d[j+i]:
premax+=1
po.append("%s"%(j+1))... | output | 1 | 41,743 | 0 | 83,487 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to represent s as a concatenation of several non-emp... | instruction | 0 | 42,157 | 0 | 84,314 |
Tags: dp, strings
Correct Solution:
```
n, a, b = map(int, input().split())
s = input()
lcp = [[0]*n for _ in ' '*n]
for i in range(n-1, -1, -1):
for r in range(n-1, -1, -1):
if s[i] == s[r]:
if i == n - 1 or r == n - 1:
lcp[i][r] = 1
else:
lcp[i][r] ... | output | 1 | 42,157 | 0 | 84,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to represent s as a concatenation of several non-emp... | instruction | 0 | 42,158 | 0 | 84,316 |
Tags: dp, strings
Correct Solution:
```
import collections
# The first line contains three positive integers, separated by spaces:
# n, a and b (1≤n,a,b≤5000) — the length of the string, the cost to compress a one-character string
# and the cost to compress a string that appeared before.
n, a, b = map(int, input().sp... | output | 1 | 42,158 | 0 | 84,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to represent s as a concatenation of several non-emp... | instruction | 0 | 42,159 | 0 | 84,318 |
Tags: dp, strings
Correct Solution:
```
def f(x):
z=[0 for i in range(len(x))]
l=0
r=0
for i in range(1,len(x)):
if i<=r:
z[i]=min(z[i-l],r-i+1)
while i+z[i]<len(x) and x[z[i]]==x[i+z[i]]:
z[i]+=1
if i+z[i]-1>r:
l,r=i,i+z[i]-1
return z
a=li... | output | 1 | 42,159 | 0 | 84,319 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to represent s as a concatenation of several non-emp... | instruction | 0 | 42,160 | 0 | 84,320 |
Tags: dp, strings
Correct Solution:
```
import sys
sys.setrecursionlimit(10 ** 8)
n, a, b = map(int,input().split())
s = input()
def calc(j):
if (j >= n): return 0
if (dp[j] != -1): return dp[j]
dp[j] = a + calc(j + 1)
lo = j
hi = n
farthest = -1
# finding best string to reach from a gi... | output | 1 | 42,160 | 0 | 84,321 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to re... | instruction | 0 | 42,161 | 0 | 84,322 |
No | output | 1 | 42,161 | 0 | 84,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to re... | instruction | 0 | 42,162 | 0 | 84,324 |
No | output | 1 | 42,162 | 0 | 84,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to re... | instruction | 0 | 42,163 | 0 | 84,326 |
No | output | 1 | 42,163 | 0 | 84,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to re... | instruction | 0 | 42,164 | 0 | 84,328 |
No | output | 1 | 42,164 | 0 | 84,329 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at least once.
A contiguous substring of string s is ... | instruction | 0 | 42,237 | 0 | 84,474 |
Tags: binary search, dp, implementation, two pointers
Correct Solution:
```
t=int(input())
while t:
t=t-1
s=input()
se=set(s)
if len(se)<3:
print(0)
continue
a1=-1
a2=-1
a3=-1
out=len(s)
for i in range(len(s)):
if s[i]=='1':
a1=i
... | output | 1 | 42,237 | 0 | 84,475 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at least once.
A contiguous substring of string s is ... | instruction | 0 | 42,238 | 0 | 84,476 |
Tags: binary search, dp, implementation, two pointers
Correct Solution:
```
t = int(input())
for i1 in range(t):
s = [int(i) for i in input()]
pointer = [0, 0]
advance = 1
result = len(s) + 1
if len(set(s)) < 3:
print(0)
continue
c = [0, 0, 0, 0]
c[s[0]] += 1
while True:
... | output | 1 | 42,238 | 0 | 84,477 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at least once.
A contiguous substring of string s is ... | instruction | 0 | 42,239 | 0 | 84,478 |
Tags: binary search, dp, implementation, two pointers
Correct Solution:
```
tes=int(input())
def check(arr):
for i in arr:
if i<=0:
return False
return True
for q in range(tes):
a=input()
s={'1':0,'2':0,'3':0}
left=right=0
for c,i in enumerate(a):
s[i]+=1
if 0 not in s.values():
right=c
break
if ... | output | 1 | 42,239 | 0 | 84,479 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at least once.
A contiguous substring of string s is ... | instruction | 0 | 42,240 | 0 | 84,480 |
Tags: binary search, dp, implementation, two pointers
Correct Solution:
```
import math as m
t=int(input())
for _ in range(t):
a=input()
n=len(a)
b=[]
i=-1
j=-1
k=-1
for l in range(n):
if a[l]=="1":
i=l
elif a[l]=="2":
j=l
elif a[l]=="3":
... | output | 1 | 42,240 | 0 | 84,481 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at least once.
A contiguous substring of string s is ... | instruction | 0 | 42,241 | 0 | 84,482 |
Tags: binary search, dp, implementation, two pointers
Correct Solution:
```
T = int(input())
def findMin(s):
k = 3
n = len(s)
st = 0
end = 0
cnt = {'1':0, '2':0, '3': 0}
di = 0
currlen =0
minlen = n
startInd = -1
while (end < n):
cnt[s[end]] += 1
if (c... | output | 1 | 42,241 | 0 | 84,483 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at least once.
A contiguous substring of string s is ... | instruction | 0 | 42,242 | 0 | 84,484 |
Tags: binary search, dp, implementation, two pointers
Correct Solution:
```
def find(arr, ind):
s = 0
e = len(arr)-1
ans = -1
while s <= e:
# print(s, e)
mid = (s+e)//2
if arr[mid] > ind:
ans = arr[mid]
e = mid-1
else:
s = mid+1
return ans
t = int(input())
for _ in range(t):
s = input()
a, b, c... | output | 1 | 42,242 | 0 | 84,485 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at least once.
A contiguous substring of string s is ... | instruction | 0 | 42,243 | 0 | 84,486 |
Tags: binary search, dp, implementation, two pointers
Correct Solution:
```
t=int(input())
for i in range(t):
s=input()
a=-1
b=-1
c=-1
ans=len(s)
cur=[]
if s.count('1')==0 or s.count('2')==0 or s.count('3')==0:
print(0)
else:
for i in range(len(s)):
if s[... | output | 1 | 42,243 | 0 | 84,487 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at least once.
A contiguous substring of string s is ... | instruction | 0 | 42,244 | 0 | 84,488 |
Tags: binary search, dp, implementation, two pointers
Correct Solution:
```
from sys import stdin,stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I=lambda: map(int,stdin.readline().split())
I1=lambda: stdin.readline()
#(a/b)%m =((a%m)*pow(b,m-2)%m)%m
for _ in range(... | output | 1 | 42,244 | 0 | 84,489 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at leas... | instruction | 0 | 42,245 | 0 | 84,490 |
Yes | output | 1 | 42,245 | 0 | 84,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at leas... | instruction | 0 | 42,246 | 0 | 84,492 |
Yes | output | 1 | 42,246 | 0 | 84,493 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at leas... | instruction | 0 | 42,247 | 0 | 84,494 |
Yes | output | 1 | 42,247 | 0 | 84,495 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at leas... | instruction | 0 | 42,248 | 0 | 84,496 |
Yes | output | 1 | 42,248 | 0 | 84,497 |
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at leas... | instruction | 0 | 42,249 | 0 | 84,498 |
Yes | output | 1 | 42,249 | 0 | 84,499 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at leas... | instruction | 0 | 42,250 | 0 | 84,500 |
No | output | 1 | 42,250 | 0 | 84,501 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at leas... | instruction | 0 | 42,251 | 0 | 84,502 |
No | output | 1 | 42,251 | 0 | 84,503 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at leas... | instruction | 0 | 42,252 | 0 | 84,504 |
No | output | 1 | 42,252 | 0 | 84,505 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string s such that each its character is either 1, 2, or 3. You have to choose the shortest contiguous substring of s such that it contains each of these three characters at leas... | instruction | 0 | 42,253 | 0 | 84,506 |
No | output | 1 | 42,253 | 0 | 84,507 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters.
In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string s_j (j may be equal to i). You may perform this... | instruction | 0 | 42,261 | 0 | 84,522 |
Tags: greedy, strings
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
lst = []
for i in range(n):
lst.append(input())
cnt = [0 for i in range(27)]
# print(lst)
for i in range(len(lst)):
s1 = lst[i]
for j in range(len(s1)):
#... | output | 1 | 42,261 | 0 | 84,523 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters.
In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string s_j (j may be equal to i). You may perform this... | instruction | 0 | 42,262 | 0 | 84,524 |
Tags: greedy, strings
Correct Solution:
```
import sys
input = sys.stdin.readline
t = int(input())
for tt in range(t):
n = int(input())
count = [0 for i in range(1000)]
for i in range(n):
s = input()
for i in range(len(s)):
count[ord(s[i])] += 1
flag = True
for i in rang... | output | 1 | 42,262 | 0 | 84,525 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters.
In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string s_j (j may be equal to i). You may perform this... | instruction | 0 | 42,263 | 0 | 84,526 |
Tags: greedy, strings
Correct Solution:
```
n = int(input())
def helper(m):
arr = [0] * 26
for i in range(m):
my_str = input()
for tmp in my_str:
arr[ord(tmp) - 97] += 1
for i in range(26):
if (arr[i] % m != 0):
return "NO"
return "YES"
for _ in ran... | output | 1 | 42,263 | 0 | 84,527 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters.
In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string s_j (j may be equal to i). You may perform this... | instruction | 0 | 42,264 | 0 | 84,528 |
Tags: greedy, strings
Correct Solution:
```
for _ in range(int(input())):
n = int(input())
dic = {}
for sentence in range(n):
s = list(input())
for i in s:
if i not in dic:
dic[i] = 0
dic[i] += 1
flag = True
for i in dic:
if dic[i]%n !=... | output | 1 | 42,264 | 0 | 84,529 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters.
In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string s_j (j may be equal to i). You may perform this... | instruction | 0 | 42,265 | 0 | 84,530 |
Tags: greedy, strings
Correct Solution:
```
import sys
import math
from collections import Counter,defaultdict
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
def case():
n = IN()
d = {}
for i in range(n):
s=S()
for i in ... | output | 1 | 42,265 | 0 | 84,531 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n strings s_1, s_2, …, s_n consisting of lowercase Latin letters.
In one operation you can remove a character from a string s_i and insert it to an arbitrary position in a string s_j (j may be equal to i). You may perform this... | instruction | 0 | 42,266 | 0 | 84,532 |
Tags: greedy, strings
Correct Solution:
```
for t in range(int(input())):
a=int(input())
d={}
for i in range(a):
s1=input()
for j in s1:
if j not in d:
d[j]=1
else:
d[j]+=1
flag=0
for i in d.values():
if i%a>0:
... | output | 1 | 42,266 | 0 | 84,533 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.