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.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of... | instruction | 0 | 19,438 | 0 | 38,876 |
Tags: constructive algorithms, strings
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 ... | output | 1 | 19,438 | 0 | 38,877 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of... | instruction | 0 | 19,439 | 0 | 38,878 |
Tags: constructive algorithms, strings
Correct Solution:
```
from sys import stdin,stdout,exit,setrecursionlimit
def sin():
return stdin.readline().rstrip()
def listInput():
return list(map(int,sin().split()))
def printBS(li):
if not li: return
for i in range(len(li)-1):
stdout.write("%d "%(li[i]))
stdout.write... | output | 1 | 19,439 | 0 | 38,879 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of... | instruction | 0 | 19,440 | 0 | 38,880 |
Tags: constructive algorithms, strings
Correct Solution:
```
import math
n = int(input())
s = input()
dic = {}
for x in s:
if x in dic.keys():
dic[x]+=1
else:
dic.update({x:1})
res = ''
for x in dic.keys():
a = dic[x]
res+=a*x
print(res)
``` | output | 1 | 19,440 | 0 | 38,881 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of... | instruction | 0 | 19,441 | 0 | 38,882 |
Tags: constructive algorithms, strings
Correct Solution:
```
n = int(input())
print(''.join(sorted(input())))
``` | output | 1 | 19,441 | 0 | 38,883 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of... | instruction | 0 | 19,442 | 0 | 38,884 |
Tags: constructive algorithms, strings
Correct Solution:
```
#!/usr/bin/python3.7
from collections import Counter
n = int(input())
for x, y in Counter(input()).items():
print(''.join([x] * y), sep='', end='')
print()
``` | output | 1 | 19,442 | 0 | 38,885 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of... | instruction | 0 | 19,443 | 0 | 38,886 |
Tags: constructive algorithms, strings
Correct Solution:
```
input();print("".join(sorted(input())))
``` | output | 1 | 19,443 | 0 | 38,887 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of... | instruction | 0 | 19,444 | 0 | 38,888 |
Tags: constructive algorithms, strings
Correct Solution:
```
n=int(input())
s=input()
s=sorted(s)
print(*s,sep='')
``` | output | 1 | 19,444 | 0 | 38,889 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "... | instruction | 0 | 19,445 | 0 | 38,890 |
Yes | output | 1 | 19,445 | 0 | 38,891 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "... | instruction | 0 | 19,446 | 0 | 38,892 |
Yes | output | 1 | 19,446 | 0 | 38,893 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "... | instruction | 0 | 19,447 | 0 | 38,894 |
Yes | output | 1 | 19,447 | 0 | 38,895 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "... | instruction | 0 | 19,448 | 0 | 38,896 |
Yes | output | 1 | 19,448 | 0 | 38,897 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "... | instruction | 0 | 19,449 | 0 | 38,898 |
No | output | 1 | 19,449 | 0 | 38,899 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "... | instruction | 0 | 19,450 | 0 | 38,900 |
No | output | 1 | 19,450 | 0 | 38,901 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "... | instruction | 0 | 19,451 | 0 | 38,902 |
No | output | 1 | 19,451 | 0 | 38,903 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "... | instruction | 0 | 19,452 | 0 | 38,904 |
No | output | 1 | 19,452 | 0 | 38,905 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any character from p, erase it from p and insert it into... | instruction | 0 | 19,522 | 0 | 39,044 |
Tags: implementation, strings
Correct Solution:
```
import sys
from collections import defaultdict
input = lambda: sys.stdin.readline().strip()
print = lambda x: sys.stdout.write(f"{x}\n")
sys.setrecursionlimit(200000)
dp = 0
def LCS(str1, str2):
XY=0
global dp
_max=-1
len1,len2=len(str1),len(str2)
... | output | 1 | 19,522 | 0 | 39,045 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any character from p, erase it from p and insert it into... | instruction | 0 | 19,523 | 0 | 39,046 |
Tags: implementation, strings
Correct Solution:
```
for _ in range(int(input())):
s, t, p = [input() for i in range(3)]
j = -1
flag = 0
for i in s:
j += 1
if j == len(t):
flag = 1
break
while t[j] != i:
j += 1
if j == len(t):
flag = 1
break
if flag:
break
if flag:
print('NO')
con... | output | 1 | 19,523 | 0 | 39,047 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any character from p, erase it from p and insert it into... | instruction | 0 | 19,524 | 0 | 39,048 |
Tags: implementation, strings
Correct Solution:
```
from collections import Counter
from collections import defaultdict
x = int(input())
for i in range(x):
s = input()
t = input()
p = input()
val = Counter(p)
match = defaultdict(int)
index = 0
for j in range(len(t)):
if(index<len(s) ... | output | 1 | 19,524 | 0 | 39,049 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any character from p, erase it from p and insert it into... | instruction | 0 | 19,525 | 0 | 39,050 |
Tags: implementation, strings
Correct Solution:
```
q = int(input())
for _ in range(q):
s = input()
t = input()
p = input()
pl = {}
for x in p:
if not pl.get(x):
pl[x] = 1
else:
pl[x] += 1
i = 0
j = 0
flag = True
while(i<len(s) and j<len(t)):
... | output | 1 | 19,525 | 0 | 39,051 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any character from p, erase it from p and insert it into... | instruction | 0 | 19,526 | 0 | 39,052 |
Tags: implementation, strings
Correct Solution:
```
q=int(input())
for bagai in range(q):
s=input()
t=input()
p=input()
i,j=0,0
while j<len(t) and i<len(s):
if s[i]==t[j]:
i+=1
j+=1
else:
j+=1
if i!=len(s):
print("NO")
continue
... | output | 1 | 19,526 | 0 | 39,053 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any character from p, erase it from p and insert it into... | instruction | 0 | 19,527 | 0 | 39,054 |
Tags: implementation, strings
Correct Solution:
```
import sys
from collections import defaultdict
input = lambda: sys.stdin.readline().strip()
print = lambda x: sys.stdout.write(f"{x}\n")
dp = 0
def LCS(str1, str2):
XY=0
global dp
_max=-1
len1,len2=len(str1),len(str2)
dp=[[ 0 for x in range(len1+... | output | 1 | 19,527 | 0 | 39,055 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any character from p, erase it from p and insert it into... | instruction | 0 | 19,528 | 0 | 39,056 |
Tags: implementation, strings
Correct Solution:
```
q = int(input())
for _ in range(q):
s = input()
t = input()
p = input()
j = 0
for i in range(len(t)):
if j == len(s):
break
if t[i] == s[j]:
j += 1
if j != len(s):
print("NO")
else:
di... | output | 1 | 19,528 | 0 | 39,057 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any character from p, erase it from p and insert it into... | instruction | 0 | 19,529 | 0 | 39,058 |
Tags: implementation, strings
Correct Solution:
```
n = input()
for i in range(int(n)):
s = input()
t = input()
p = input()
counter = 0
load = []
for k in list(t):
if (counter < len(s)):
if (s[counter] == k):
counter += 1
else:
load... | output | 1 | 19,529 | 0 | 39,059 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any chara... | instruction | 0 | 19,530 | 0 | 39,060 |
Yes | output | 1 | 19,530 | 0 | 39,061 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any chara... | instruction | 0 | 19,531 | 0 | 39,062 |
Yes | output | 1 | 19,531 | 0 | 39,063 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any chara... | instruction | 0 | 19,532 | 0 | 39,064 |
Yes | output | 1 | 19,532 | 0 | 39,065 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any chara... | instruction | 0 | 19,533 | 0 | 39,066 |
Yes | output | 1 | 19,533 | 0 | 39,067 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any chara... | instruction | 0 | 19,534 | 0 | 39,068 |
No | output | 1 | 19,534 | 0 | 39,069 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any chara... | instruction | 0 | 19,535 | 0 | 39,070 |
No | output | 1 | 19,535 | 0 | 39,071 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any chara... | instruction | 0 | 19,536 | 0 | 39,072 |
No | output | 1 | 19,536 | 0 | 39,073 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three strings s, t and p consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any chara... | instruction | 0 | 19,537 | 0 | 39,074 |
No | output | 1 | 19,537 | 0 | 39,075 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a robot on a coordinate plane. Initially, the robot is located at the point (0, 0). Its path is described as a string s of length n consisting of characters 'L', 'R', 'U', 'D'.
Each of these characters corresponds to some move:
... | instruction | 0 | 19,558 | 0 | 39,116 |
Tags: data structures, implementation
Correct Solution:
```
from collections import *
for _ in range(int(input())):
n = int(input())
s = input()
d = {}
d[0] = {}
d[0][0] = 0
l = -1
r = -1
x = 0
y = 0
mn = 1e18
for i in range(len(s)):
if(s[i] == "L"):
... | output | 1 | 19,558 | 0 | 39,117 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a robot on a coordinate plane. Initially, the robot is located at the point (0, 0). Its path is described as a string s of length n consisting of characters 'L', 'R', 'U', 'D'.
Each of these characters corresponds to some move:
... | instruction | 0 | 19,559 | 0 | 39,118 |
Tags: data structures, implementation
Correct Solution:
```
t=int(input())
for _ in range(t):
n=int(input())
s=input()
hor=0;ver=0;minim=1000000;sml=0;lar=0
prev={}
prev[(0,0)]=0
for ind in range(len(s)):
i=s[ind]
if i=='L':
hor-=1
x=(hor, ver)
eli... | output | 1 | 19,559 | 0 | 39,119 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a robot on a coordinate plane. Initially, the robot is located at the point (0, 0). Its path is described as a string s of length n consisting of characters 'L', 'R', 'U', 'D'.
Each of these characters corresponds to some move:
... | instruction | 0 | 19,560 | 0 | 39,120 |
Tags: data structures, implementation
Correct Solution:
```
import sys
import os
from io import IOBase, BytesIO
# import heapq
import math
# import collections
# import itertools
# import bisect
mod = 10 ** 9 + 7
pie = 3.1415926536
# import resource
# resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLI... | output | 1 | 19,560 | 0 | 39,121 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a robot on a coordinate plane. Initially, the robot is located at the point (0, 0). Its path is described as a string s of length n consisting of characters 'L', 'R', 'U', 'D'.
Each of these characters corresponds to some move:
... | instruction | 0 | 19,561 | 0 | 39,122 |
Tags: data structures, implementation
Correct Solution:
```
from sys import stdin
input=stdin.readline
t=int(input())
for _ in range(t):
n=int(input())
s=input()
t=set()
y=0
x=0
dc={0:0}
m=10**18
ans=(-1,-1)
for i in range(n):
if s[i]=="L":
x-=1
elif s[i]=="R":
x+=1
elif s[i]==... | output | 1 | 19,561 | 0 | 39,123 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a robot on a coordinate plane. Initially, the robot is located at the point (0, 0). Its path is described as a string s of length n consisting of characters 'L', 'R', 'U', 'D'.
Each of these characters corresponds to some move:
... | instruction | 0 | 19,562 | 0 | 39,124 |
Tags: data structures, implementation
Correct Solution:
```
import math
for _ in range(int(input())):
d = dict()
x, y = 0, 0
move = 0
d[(x,y)] = move
n = int(input())
bestmove = math.inf
bl, br = -1, -1
for c in input():
move += 1
if c == 'L':
x -= 1
elif c == 'R':
x += 1
elif c == 'U':
y += 1
... | output | 1 | 19,562 | 0 | 39,125 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a robot on a coordinate plane. Initially, the robot is located at the point (0, 0). Its path is described as a string s of length n consisting of characters 'L', 'R', 'U', 'D'.
Each of these characters corresponds to some move:
... | instruction | 0 | 19,563 | 0 | 39,126 |
Tags: data structures, implementation
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
s = input()
position_to_step = {(0, 0): 0}
len_of_min = n+1
ans = (0, 0)
pos = (0, 0)
for i in range(n):
item = s[i]
if item == "U":
pos = (pos[0], pos[1]+1)
elif item == "D":
pos = (p... | output | 1 | 19,563 | 0 | 39,127 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a robot on a coordinate plane. Initially, the robot is located at the point (0, 0). Its path is described as a string s of length n consisting of characters 'L', 'R', 'U', 'D'.
Each of these characters corresponds to some move:
... | instruction | 0 | 19,564 | 0 | 39,128 |
Tags: data structures, implementation
Correct Solution:
```
# HEY STALKER
from collections import Counter
for trt in range(int(input())):
n = int(input())
l = list(input())
x = Counter(l)
flag = 0
for t in x:
if x[t] == n:
print(-1)
flag = 1
break
if f... | output | 1 | 19,564 | 0 | 39,129 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a robot on a coordinate plane. Initially, the robot is located at the point (0, 0). Its path is described as a string s of length n consisting of characters 'L', 'R', 'U', 'D'.
Each of these characters corresponds to some move:
... | instruction | 0 | 19,565 | 0 | 39,130 |
Tags: data structures, implementation
Correct Solution:
```
T=int(input())
t=0
while t<T:
N=int(input())
s=input()
x=0
y=0
risultato=float('INF')
trovato= False
P={(x,y):0}
n=0
a=N
b=N
while n<N:
c=s[n]
if c=='U':
y+=1
if c=='D':
... | output | 1 | 19,565 | 0 | 39,131 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one.
Ivan knows some information about the string s. Na... | instruction | 0 | 19,954 | 0 | 39,908 |
Tags: data structures, greedy, sortings, strings
Correct Solution:
```
import math as mt
import sys,string
input=sys.stdin.readline
print=sys.stdout.write
import random
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split... | output | 1 | 19,954 | 0 | 39,909 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one.
Ivan knows some information about the string s. Na... | instruction | 0 | 19,955 | 0 | 39,910 |
Tags: data structures, greedy, sortings, strings
Correct Solution:
```
from sys import stdin, stdout
sze = 10 ** 6 + 1
n = int(stdin.readline())
challengers = []
strings = []
sze = 10 ** 6 + 1
cnt = [[] for i in range(sze)]
for i in range(n):
s = stdin.readline().strip().split()
num = int(s[1])
valu... | output | 1 | 19,955 | 0 | 39,911 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one.
Ivan knows some information about the string s. Na... | instruction | 0 | 19,956 | 0 | 39,912 |
Tags: data structures, greedy, sortings, strings
Correct Solution:
```
from sys import stdin, stdout
sze = 10 ** 6 + 1
n = int(stdin.readline())
challengers = []
strings = []
sze = 10 ** 6 + 1
cnt = [0 for i in range(sze)]
for i in range(n):
s = stdin.readline().strip().split()
num = int(s[1])
value... | output | 1 | 19,956 | 0 | 39,913 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a binary string s (each character of this string is either 0 or 1).
Let's denote the cost of string t as the number of occurences of s in t. For example, if s is 11 and t is 11101... | instruction | 0 | 20,000 | 0 | 40,000 |
No | output | 1 | 20,000 | 0 | 40,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a binary string s (each character of this string is either 0 or 1).
Let's denote the cost of string t as the number of occurences of s in t. For example, if s is 11 and t is 11101... | instruction | 0 | 20,001 | 0 | 40,002 |
No | output | 1 | 20,001 | 0 | 40,003 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s of length n, which consists only of the first k letters of the Latin alphabet. All letters in string s are uppercase.
A subsequence of string s is a string that can be derived from s by deleting some of its symbols ... | instruction | 0 | 20,280 | 0 | 40,560 |
Tags: implementation, strings
Correct Solution:
```
n, k = (int(x) for x in input().split())
s = list(input())
al = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
al = al[:k]
c = []
for i in range(k):
c.append(s.count(al[i]))
print(min(c)*k)
``` | output | 1 | 20,280 | 0 | 40,561 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s of length n, which consists only of the first k letters of the Latin alphabet. All letters in string s are uppercase.
A subsequence of string s is a string that can be derived from s by deleting some of its symbols ... | instruction | 0 | 20,281 | 0 | 40,562 |
Tags: implementation, strings
Correct Solution:
```
n, k = map(int, input().split())
line = input()
line_2 = [0] * 30
for elem in line:
line_2[ord(elem) - 65] += 1
m = 10**5
for i in range(k):
m = min(m, line_2[i])
print(m * k)
``` | output | 1 | 20,281 | 0 | 40,563 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s of length n, which consists only of the first k letters of the Latin alphabet. All letters in string s are uppercase.
A subsequence of string s is a string that can be derived from s by deleting some of its symbols ... | instruction | 0 | 20,282 | 0 | 40,564 |
Tags: implementation, strings
Correct Solution:
```
a = [int(x) for x in input().split()]
n = a[0]
k = a[1]
s = input()
d = {}
for ch in s:
if ch in d:
d[ch] += 1
else:
d[ch] = 1
min = min(d.values())
if len(d) == k:
print(min * k)
else:
print(0)
``` | output | 1 | 20,282 | 0 | 40,565 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s of length n, which consists only of the first k letters of the Latin alphabet. All letters in string s are uppercase.
A subsequence of string s is a string that can be derived from s by deleting some of its symbols ... | instruction | 0 | 20,283 | 0 | 40,566 |
Tags: implementation, strings
Correct Solution:
```
import sys
n, k = map(int, input().split())
s = input()
d = {}
for i in range(n):
if s[i] in d:
d[s[i]] += 1
else:
d[s[i]] = 1
if len(d) < k:
print(0)
sys.exit(0)
min = float('inf')
for key in d.keys():
if d[key] < min:
... | output | 1 | 20,283 | 0 | 40,567 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s of length n, which consists only of the first k letters of the Latin alphabet. All letters in string s are uppercase.
A subsequence of string s is a string that can be derived from s by deleting some of its symbols ... | instruction | 0 | 20,284 | 0 | 40,568 |
Tags: implementation, strings
Correct Solution:
```
from collections import Counter
n, k = map(int, input().split())
a = list(input())
s = Counter(a)
res = 0
if len(s.keys()) == k:
cur = s.values()
cur = sorted(cur)
res = cur[0] * k
print(res)
``` | output | 1 | 20,284 | 0 | 40,569 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a string s of length n, which consists only of the first k letters of the Latin alphabet. All letters in string s are uppercase.
A subsequence of string s is a string that can be derived from s by deleting some of its symbols ... | instruction | 0 | 20,285 | 0 | 40,570 |
Tags: implementation, strings
Correct Solution:
```
H=list(map(int,input().split()))
n=H[0]
k=H[1]
A=input()
B=[]
t=ord('A')
for i in range(k):
B.append(chr(ord('A')+i))
C=[0]*k
for i in range(n):
C[ord(A[i])-t]+=1
print(min(C)*k)
``` | output | 1 | 20,285 | 0 | 40,571 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.