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.
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother Yusuf came and start... | instruction | 0 | 99,868 | 0 | 199,736 |
Tags: dp
Correct Solution:
```
s = input()
count = 0
for i in range(len(s)):
if s[i] in ["0","4","8"]:
count+=1
for i in range(len(s)-1):
x = s[i:i+2]
if int(x)%4 == 0:
count+= i+1
print(count)
``` | output | 1 | 99,868 | 0 | 199,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Me... | instruction | 0 | 99,869 | 0 | 199,738 |
Yes | output | 1 | 99,869 | 0 | 199,739 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Me... | instruction | 0 | 99,870 | 0 | 199,740 |
Yes | output | 1 | 99,870 | 0 | 199,741 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Me... | instruction | 0 | 99,871 | 0 | 199,742 |
Yes | output | 1 | 99,871 | 0 | 199,743 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Me... | instruction | 0 | 99,872 | 0 | 199,744 |
Yes | output | 1 | 99,872 | 0 | 199,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Me... | instruction | 0 | 99,873 | 0 | 199,746 |
No | output | 1 | 99,873 | 0 | 199,747 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Me... | instruction | 0 | 99,874 | 0 | 199,748 |
No | output | 1 | 99,874 | 0 | 199,749 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Me... | instruction | 0 | 99,875 | 0 | 199,750 |
No | output | 1 | 99,875 | 0 | 199,751 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Me... | instruction | 0 | 99,876 | 0 | 199,752 |
No | output | 1 | 99,876 | 0 | 199,753 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the sam... | instruction | 0 | 100,013 | 0 | 200,026 |
Tags: brute force, implementation, strings
Correct Solution:
```
# -*- coding: utf-8 -*-
import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
"""
created by shhuan at 2017/10/22 18:15
"""
N = int(input())
S = input()
def split(s, wc, pl, n):
ans = []
... | output | 1 | 100,013 | 0 | 200,027 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the sam... | instruction | 0 | 100,014 | 0 | 200,028 |
Tags: brute force, implementation, strings
Correct Solution:
```
import sys
import math
from collections import defaultdict,deque
def is_possible(odd,even):
each = odd*2
if even % each == 0:
return True
return False
n=int(sys.stdin.readline())
s=sys.stdin.readline()[:-1]
dic=defaultdict(int)
for i in range(n):
di... | output | 1 | 100,014 | 0 | 200,029 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the sam... | instruction | 0 | 100,015 | 0 | 200,030 |
Tags: brute force, implementation, strings
Correct Solution:
```
n = int(input())
s = list(input())
d = {}
for char in s:
if char not in d.keys():
d[char] = 1
else:
d[char] += 1
odd = []
even = []
for char in d.keys():
for i in range(d[char] // 2):
even.append(char)
even.app... | output | 1 | 100,015 | 0 | 200,031 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the sam... | instruction | 0 | 100,016 | 0 | 200,032 |
Tags: brute force, implementation, strings
Correct Solution:
```
mp,a,p={},[],[]
n=int(input())
for i in input():
if i in mp:mp[i]+=1
else:mp[i]=1
odd=0
for i in mp:
if mp[i]&1:
a.append(i)
mp[i]-=1
odd+=1
if mp[i]:
p.append(i)
m=max(1,odd)
for i in range(m,n+1):
if n... | output | 1 | 100,016 | 0 | 200,033 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the sam... | instruction | 0 | 100,017 | 0 | 200,034 |
Tags: brute force, implementation, strings
Correct Solution:
```
#!/usr/bin/env python3
def main():
import collections
n = int(input())
s = input()
alph = collections.Counter(s)
odd = sum(x & 0x1 for x in alph.values())
dq = collections.deque()
if odd == 0:
print(1)
for c, ... | output | 1 | 100,017 | 0 | 200,035 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the sam... | instruction | 0 | 100,018 | 0 | 200,036 |
Tags: brute force, implementation, strings
Correct Solution:
```
n=int(input())
s=list(input())
lets={}
for i in s:
try:
lets[i]+=1
except:
lets[i]=1
count=0
centre=[]
rest=[]
for i in lets.keys():
if(lets[i]%2):
centre.append(i)
count+=1
rest+=[i]*(lets[i]//2)
if(count==... | output | 1 | 100,018 | 0 | 200,037 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the sam... | instruction | 0 | 100,019 | 0 | 200,038 |
Tags: brute force, implementation, strings
Correct Solution:
```
n = int(input())
s = list(input())
d = {}
for char in s:
if char not in d.keys():
d[char] = 1
else:
d[char] += 1
odd = []
even = []
for char in d.keys():
for i in range(d[char] // 2):
even.append(char)
even.app... | output | 1 | 100,019 | 0 | 200,039 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the sam... | instruction | 0 | 100,020 | 0 | 200,040 |
Tags: brute force, implementation, strings
Correct Solution:
```
from collections import Counter
n = int(input())
cnt = Counter(input())
odd = []
even = []
for s, c in cnt.items():
if c % 2 == 1:
odd.append([s, c])
else:
even.append([s, c])
k = max(1, len(odd))
for i in range(k, n + 1):
h = n // i
if i ... | output | 1 | 100,020 | 0 | 200,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each ... | instruction | 0 | 100,021 | 0 | 200,042 |
Yes | output | 1 | 100,021 | 0 | 200,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each ... | instruction | 0 | 100,022 | 0 | 200,044 |
Yes | output | 1 | 100,022 | 0 | 200,045 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each ... | instruction | 0 | 100,023 | 0 | 200,046 |
Yes | output | 1 | 100,023 | 0 | 200,047 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each ... | instruction | 0 | 100,024 | 0 | 200,048 |
Yes | output | 1 | 100,024 | 0 | 200,049 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each ... | instruction | 0 | 100,025 | 0 | 200,050 |
No | output | 1 | 100,025 | 0 | 200,051 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each ... | instruction | 0 | 100,026 | 0 | 200,052 |
No | output | 1 | 100,026 | 0 | 200,053 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each ... | instruction | 0 | 100,027 | 0 | 200,054 |
No | output | 1 | 100,027 | 0 | 200,055 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each ... | instruction | 0 | 100,028 | 0 | 200,056 |
No | output | 1 | 100,028 | 0 | 200,057 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.
Unfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremel... | instruction | 0 | 100,848 | 0 | 201,696 |
Tags: dp, hashing, string suffix structures, strings
Correct Solution:
```
s=input()
n=len(s)
def f(s):
n=len(s)
ar=[0]*n
i,j=1,0
while i<n:
if(s[i]==s[j]):
j+=1
ar[i]=j
i+=1
else:
if(j!=0):j=ar[j-1]
else:i+=1
return ar
dp=[... | output | 1 | 100,848 | 0 | 201,697 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ivan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.
Unfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremel... | instruction | 0 | 100,849 | 0 | 201,698 |
Tags: dp, hashing, string suffix structures, strings
Correct Solution:
```
def prefix(s):
p = [0]
for i in range(1, len(s)):
j = p[-1]
while j > 0 and s[j] != s[i]:
j = p[j - 1]
if s[i] == s[j]:
j += 1
p.append(j)
return p
s = input()
n = len(s)
ans ... | output | 1 | 100,849 | 0 | 201,699 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "abb" is a bad string.
You have a strings "a", ... | instruction | 0 | 101,238 | 0 | 202,476 |
Tags: greedy
Correct Solution:
```
a,b,c = map(int,input().split())
print([2*(min(a,b)+c)+1,2*(min(a,b)+c)][a==b])
``` | output | 1 | 101,238 | 0 | 202,477 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "abb" is a bad string.
You have a strings "a", ... | instruction | 0 | 101,239 | 0 | 202,478 |
Tags: greedy
Correct Solution:
```
a,b,c=map(int,input().split())
if a!=b:
print(min(a,b)*2+1+c*2)
else:
print(a+b+c*2)
``` | output | 1 | 101,239 | 0 | 202,479 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "abb" is a bad string.
You have a strings "a", ... | instruction | 0 | 101,240 | 0 | 202,480 |
Tags: greedy
Correct Solution:
```
a, b, c=map(int,input().split())
mn = min(a, b)
mx = max(a, b)
if mx > mn + 1:
mx = mn + 1
print(mn + mx + 2*c)
``` | output | 1 | 101,240 | 0 | 202,481 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "abb" is a bad string.
You have a strings "a", ... | instruction | 0 | 101,241 | 0 | 202,482 |
Tags: greedy
Correct Solution:
```
a, b, c = map(int, input().split())
result = c*2 + min(a, b)*2 + (1 if a != b else 0)
print(result)
``` | output | 1 | 101,241 | 0 | 202,483 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "abb" is a bad string.
You have a strings "a", ... | instruction | 0 | 101,242 | 0 | 202,484 |
Tags: greedy
Correct Solution:
```
from collections import Counter
a, b, c = map(int, input().split())
print((2 * (min(a, b) + c)) + (1 if a>b or b>a else 0))
``` | output | 1 | 101,242 | 0 | 202,485 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "abb" is a bad string.
You have a strings "a", ... | instruction | 0 | 101,243 | 0 | 202,486 |
Tags: greedy
Correct Solution:
```
a,b,c=map(int, input().split())
if a==b:
print(a+b+2*c)
elif a<b:
print(2*a+2*c+1)
else:
print(2*b+2*c+1)
``` | output | 1 | 101,243 | 0 | 202,487 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "abb" is a bad string.
You have a strings "a", ... | instruction | 0 | 101,244 | 0 | 202,488 |
Tags: greedy
Correct Solution:
```
def main():
a, b, c = map(int, input().split())
ans = 2 * c
ans += 2 * min(a, b)
if a != b:
ans += 1
print(ans)
if __name__ == "__main__":
main()
``` | output | 1 | 101,244 | 0 | 202,489 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "abb" is a bad string.
You have a strings "a", ... | instruction | 0 | 101,245 | 0 | 202,490 |
Tags: greedy
Correct Solution:
```
a,b,c=[int(x) for x in input().split()]
if a==b:
print(a+b+2*c)
elif a>b:
print(b*2+2*c+1)
else:
print(a*2+2*c+1)
``` | output | 1 | 101,245 | 0 | 202,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "... | instruction | 0 | 101,246 | 0 | 202,492 |
Yes | output | 1 | 101,246 | 0 | 202,493 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "... | instruction | 0 | 101,247 | 0 | 202,494 |
Yes | output | 1 | 101,247 | 0 | 202,495 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "... | instruction | 0 | 101,248 | 0 | 202,496 |
Yes | output | 1 | 101,248 | 0 | 202,497 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "... | instruction | 0 | 101,249 | 0 | 202,498 |
Yes | output | 1 | 101,249 | 0 | 202,499 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "... | instruction | 0 | 101,250 | 0 | 202,500 |
No | output | 1 | 101,250 | 0 | 202,501 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "... | instruction | 0 | 101,251 | 0 | 202,502 |
No | output | 1 | 101,251 | 0 | 202,503 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "... | instruction | 0 | 101,252 | 0 | 202,504 |
No | output | 1 | 101,252 | 0 | 202,505 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a string good if and only if it consists of only two types of letters β 'a' and 'b' and every two consecutive letters are distinct. For example "baba" and "aba" are good strings and "... | instruction | 0 | 101,253 | 0 | 202,506 |
No | output | 1 | 101,253 | 0 | 202,507 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have c_1 letters 'a', c_2 letters 'b', ..., c_{26} letters 'z'. You want to build a beautiful string of length n from them (obviously, you cannot use the i-th letter more than c_i times). Ea... | instruction | 0 | 101,432 | 0 | 202,864 |
No | output | 1 | 101,432 | 0 | 202,865 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have c_1 letters 'a', c_2 letters 'b', ..., c_{26} letters 'z'. You want to build a beautiful string of length n from them (obviously, you cannot use the i-th letter more than c_i times). Ea... | instruction | 0 | 101,433 | 0 | 202,866 |
No | output | 1 | 101,433 | 0 | 202,867 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have c_1 letters 'a', c_2 letters 'b', ..., c_{26} letters 'z'. You want to build a beautiful string of length n from them (obviously, you cannot use the i-th letter more than c_i times). Ea... | instruction | 0 | 101,434 | 0 | 202,868 |
No | output | 1 | 101,434 | 0 | 202,869 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have c_1 letters 'a', c_2 letters 'b', ..., c_{26} letters 'z'. You want to build a beautiful string of length n from them (obviously, you cannot use the i-th letter more than c_i times). Ea... | instruction | 0 | 101,435 | 0 | 202,870 |
No | output | 1 | 101,435 | 0 | 202,871 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the cost of a string s as the number of index pairs i and j (1 β€ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}.
You are given two positive integers n and k. Among all strings with length n that contain only the first k... | instruction | 0 | 101,436 | 0 | 202,872 |
Tags: brute force, constructive algorithms, graphs, greedy, strings
Correct Solution:
```
from __future__ import division, print_function
import math
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.bu... | output | 1 | 101,436 | 0 | 202,873 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the cost of a string s as the number of index pairs i and j (1 β€ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}.
You are given two positive integers n and k. Among all strings with length n that contain only the first k... | instruction | 0 | 101,437 | 0 | 202,874 |
Tags: brute force, constructive algorithms, graphs, greedy, strings
Correct Solution:
```
n,k=map(int,input().split())
ans=''
for i in range(k):
temp=chr(ord('a')+i)
ans+=temp
for j in range(i+1,k):
ans+=temp+chr(ord('a')+j)
if len(ans)<n:
while(len(ans)<n):
ans+=ans
print(ans[:n])
``` | output | 1 | 101,437 | 0 | 202,875 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's define the cost of a string s as the number of index pairs i and j (1 β€ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}.
You are given two positive integers n and k. Among all strings with length n that contain only the first k... | instruction | 0 | 101,438 | 0 | 202,876 |
Tags: brute force, constructive algorithms, graphs, greedy, strings
Correct Solution:
```
import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
import string
class FastIO(IOBase):
newlines = 0
def __init__(self, fi... | output | 1 | 101,438 | 0 | 202,877 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.