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.
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,439 | 0 | 202,878 |
Tags: brute force, constructive algorithms, graphs, greedy, strings
Correct Solution:
```
n,k=map(int,input().split())
out=[]
for i in range(k):
out.append(chr(97+i))
for j in range(i+1,k):
out.append(chr(97+i))
out.append(chr(97+j))
while len(out)<n:
out+=out
print("".join(out[:n]))
``` | output | 1 | 101,439 | 0 | 202,879 |
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,440 | 0 | 202,880 |
Tags: brute force, constructive algorithms, graphs, greedy, strings
Correct Solution:
```
n, k = [int(s) for s in input().split(" ")]
s = ""
for i in range(k):
s += chr(i+97)
for j in range(i+1, k):
s += chr(i+97) + chr(j+97)
while len(s) < n:
s *= 2
print(s[:n])
``` | output | 1 | 101,440 | 0 | 202,881 |
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,441 | 0 | 202,882 |
Tags: brute force, constructive algorithms, graphs, greedy, strings
Correct Solution:
```
import sys,heapq,math
from collections import defaultdict
input=sys.stdin.readline
n,k=map(int,input().split())
countarr=[[0 for _ in range(k)] for _ in range(k)]
res=['a'] #'a'->97
for i in range(1,n):
row=ord(res[-1]... | output | 1 | 101,441 | 0 | 202,883 |
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,442 | 0 | 202,884 |
Tags: brute force, constructive algorithms, graphs, greedy, strings
Correct Solution:
```
n, k = map(int,input().split())
s = 'abcdefghijklmnopqrstuvwxyz'
s = s[:k]
dic = {}
#for c1 in s:
# for c2 in s:
# dic[c1+c2] = 0
ans = ""
for i in range(k):
ans += chr(97+i)
for j in range(i+1,k):
... | output | 1 | 101,442 | 0 | 202,885 |
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,443 | 0 | 202,886 |
Tags: brute force, constructive algorithms, graphs, greedy, strings
Correct Solution:
```
a = list('abcdefghijklmnopqrstuvwxyz')
n, k = map(int, input().split())
if k >= n:
print(*a[0:n], sep = '')
else:
ans = ''
for i in range(k):
ans += a[i]
for j in range(i + 1, k): ans += a[i] + a[j]
... | output | 1 | 101,443 | 0 | 202,887 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 stri... | instruction | 0 | 101,444 | 0 | 202,888 |
Yes | output | 1 | 101,444 | 0 | 202,889 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 stri... | instruction | 0 | 101,445 | 0 | 202,890 |
Yes | output | 1 | 101,445 | 0 | 202,891 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 stri... | instruction | 0 | 101,446 | 0 | 202,892 |
Yes | output | 1 | 101,446 | 0 | 202,893 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 stri... | instruction | 0 | 101,447 | 0 | 202,894 |
Yes | output | 1 | 101,447 | 0 | 202,895 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 stri... | instruction | 0 | 101,448 | 0 | 202,896 |
No | output | 1 | 101,448 | 0 | 202,897 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 stri... | instruction | 0 | 101,449 | 0 | 202,898 |
No | output | 1 | 101,449 | 0 | 202,899 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 stri... | instruction | 0 | 101,450 | 0 | 202,900 |
No | output | 1 | 101,450 | 0 | 202,901 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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 stri... | instruction | 0 | 101,451 | 0 | 202,902 |
No | output | 1 | 101,451 | 0 | 202,903 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q questions about this song. Each question is about a subsegment of the song starting from the l-th letter t... | instruction | 0 | 101,452 | 0 | 202,904 |
Tags: dp, implementation, strings
Correct Solution:
```
n, q = map(int, input().split())
s = input()
ps = [0 for i in range(n+1)]
for i in range(n):
ps[i+1] += ps[i]+ord(s[i]) % 96
for _ in range(q):
l, r = map(int, input().split())
print(ps[r]-ps[l-1])
``` | output | 1 | 101,452 | 0 | 202,905 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q questions about this song. Each question is about a subsegment of the song starting from the l-th letter t... | instruction | 0 | 101,453 | 0 | 202,906 |
Tags: dp, implementation, strings
Correct Solution:
```
n,q=[int(x) for x in input().split()]
l=input()
s=[]
s.append(ord(l[0])-96)
for i in range(1,n):
s.append(s[i-1]+ord(l[i])-96)
while q:
a,b=[int(x) for x in input().split()]
if a!=1:
print(s[b-1]-s[a-2])
else:
print(s[b-1])
q-=1... | output | 1 | 101,453 | 0 | 202,907 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q questions about this song. Each question is about a subsegment of the song starting from the l-th letter t... | instruction | 0 | 101,454 | 0 | 202,908 |
Tags: dp, implementation, strings
Correct Solution:
```
import sys
import math
import random
from queue import PriorityQueue as PQ
from bisect import bisect_left as BSL
from bisect import bisect_right as BSR
from collections import OrderedDict as OD
from collections import Counter
from itertools import permutations
fro... | output | 1 | 101,454 | 0 | 202,909 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q questions about this song. Each question is about a subsegment of the song starting from the l-th letter t... | instruction | 0 | 101,455 | 0 | 202,910 |
Tags: dp, implementation, strings
Correct Solution:
```
from string import ascii_lowercase as asc
alphabet = {asc[i]:i+1 for i in range(len(asc))}
n,q = [int(x) for x in input().split()]
stroke = input()
sums = []
for i in stroke:
sums.append(sums[-1]+alphabet[i] if sums != [] else alphabet[i])
for i in range(q)... | output | 1 | 101,455 | 0 | 202,911 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q questions about this song. Each question is about a subsegment of the song starting from the l-th letter t... | instruction | 0 | 101,456 | 0 | 202,912 |
Tags: dp, implementation, strings
Correct Solution:
```
n,q=input().split()
string=str(input())
L=[]
answer=0
for i in range(len(string)):
answer+=(ord(string[i])-96)
L.append(answer)
for i in range(int(q)):
a,b=input().split()
if(int(a)==1):
print(L[int(b)-1])
else:
print(L[int(b)-1... | output | 1 | 101,456 | 0 | 202,913 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q questions about this song. Each question is about a subsegment of the song starting from the l-th letter t... | instruction | 0 | 101,457 | 0 | 202,914 |
Tags: dp, implementation, strings
Correct Solution:
```
n, t = map(int, input().split())
s = input()
arr = [0]
for x in s:
arr.append(arr[-1] + (ord(x) - ord('a') + 1))
for _ in range(t):
a, b = map(int, input().split())
print(arr[b] - arr[a - 1])
``` | output | 1 | 101,457 | 0 | 202,915 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q questions about this song. Each question is about a subsegment of the song starting from the l-th letter t... | instruction | 0 | 101,458 | 0 | 202,916 |
Tags: dp, implementation, strings
Correct Solution:
```
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
s=input()
temp=[0]
for i in range(len(s)):
temp.append(temp[-1]+ord(s[i])-ord('a')+1)
while q>0:
q-=1
l,r=map(int,input().split())
print(temp[r]-temp[l-1])
``` | output | 1 | 101,458 | 0 | 202,917 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q questions about this song. Each question is about a subsegment of the song starting from the l-th letter t... | instruction | 0 | 101,459 | 0 | 202,918 |
Tags: dp, implementation, strings
Correct Solution:
```
n,q = map(int,input().split())
s = input()
dp = []
ans = 0
for i in range(1,n+1):
dp.append(ans)
ans+=ord(s[i-1])-96
dp.append(ans)
for _ in range(q):
left,right = map(int,input().split())
print(dp[right]-dp[left-1])
``` | output | 1 | 101,459 | 0 | 202,919 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each... | instruction | 0 | 101,657 | 0 | 203,314 |
Tags: constructive algorithms, greedy, implementation, strings
Correct Solution:
```
x=input()
y=list(x)
i=0
d=-1
for c in x:
if c=='a':
if d!=-1:
break
i+=1
continue
if d==-1:
d=i
y[i]=chr(ord(y[i])-1)
i+=1
if d==-1:
y[-1]='z'
print("".join(y))
``` | output | 1 | 101,657 | 0 | 203,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each... | instruction | 0 | 101,658 | 0 | 203,316 |
Tags: constructive algorithms, greedy, implementation, strings
Correct Solution:
```
from sys import stdin
phrase=input()
i=0
while i<len(phrase) and phrase[i]=='a':
i+=1
j=i
while j<len(phrase) and phrase[j]!='a':
j+=1
if i>=len(phrase):
print(phrase[:-1]+"z")
else:
nouvellePhrase=phrase[:i]
for... | output | 1 | 101,658 | 0 | 203,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each... | instruction | 0 | 101,659 | 0 | 203,318 |
Tags: constructive algorithms, greedy, implementation, strings
Correct Solution:
```
letters = ['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']
dataIn = str(input())
data = []
for i in dataIn:
data.append(i)
count = 0
begin = 0
if... | output | 1 | 101,659 | 0 | 203,319 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each... | instruction | 0 | 101,660 | 0 | 203,320 |
Tags: constructive algorithms, greedy, implementation, strings
Correct Solution:
```
s1=input()
s=list(s1)
start=-1
end=-1
for i in range(len(s)):
if(s[i]>'a' and start==-1):
start=i
elif(s[i]=='a' and start!=-1):
end=i
break;
if(end==-1):
end=len(s)
if(start==-1):
s[len(s)-1... | output | 1 | 101,660 | 0 | 203,321 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each... | instruction | 0 | 101,661 | 0 | 203,322 |
Tags: constructive algorithms, greedy, implementation, strings
Correct Solution:
```
s = input()
i = 0; b = False
while i < len(s) and s[i] == 'a': i += 1
while i < len(s) and s[i] != 'a':
s = s[:i] + chr(ord(s[i]) - 1) + s[i + 1:]
i += 1
b = True
print(s if b else 'a' * (len(s) - 1) + 'z')
``` | output | 1 | 101,661 | 0 | 203,323 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each... | instruction | 0 | 101,662 | 0 | 203,324 |
Tags: constructive algorithms, greedy, implementation, strings
Correct Solution:
```
def findNot(string, char):
for i in range(len(string)):
if string[i] != char:
return i
return len(string) - 1
s = input()
beg = findNot(s, "a")
res = s[0:beg]
for i in range(beg, len(s)):
if i != beg an... | output | 1 | 101,662 | 0 | 203,325 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each... | instruction | 0 | 101,663 | 0 | 203,326 |
Tags: constructive algorithms, greedy, implementation, strings
Correct Solution:
```
# You lost the game.
s = str(input())
n = len(s)
i = 0
A = "abcdefghijklmnopqrstuvwxyz"
while i < n and s[i] == 'a':
i += 1
if i == n:
print(s[:n-1]+"z")
else:
d = i
while i < n and s[i] != 'a':
i += 1
r = "... | output | 1 | 101,663 | 0 | 203,327 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b' <image> 'a' <image> 'z'. In other words, each... | instruction | 0 | 101,664 | 0 | 203,328 |
Tags: constructive algorithms, greedy, implementation, strings
Correct Solution:
```
s = [i for i in input()]
flag = False
for i in range(len(s)):
if s[i] > "a":
flag = True
s[i] = chr(ord(s[i])-1)
elif flag:
break
if not flag:
s[-1] = "z"
print(*s, sep="")
``` | output | 1 | 101,664 | 0 | 203,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b... | instruction | 0 | 101,665 | 0 | 203,330 |
Yes | output | 1 | 101,665 | 0 | 203,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b... | instruction | 0 | 101,666 | 0 | 203,332 |
Yes | output | 1 | 101,666 | 0 | 203,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b... | instruction | 0 | 101,667 | 0 | 203,334 |
Yes | output | 1 | 101,667 | 0 | 203,335 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b... | instruction | 0 | 101,668 | 0 | 203,336 |
Yes | output | 1 | 101,668 | 0 | 203,337 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b... | instruction | 0 | 101,669 | 0 | 203,338 |
No | output | 1 | 101,669 | 0 | 203,339 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b... | instruction | 0 | 101,670 | 0 | 203,340 |
No | output | 1 | 101,670 | 0 | 203,341 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b... | instruction | 0 | 101,671 | 0 | 203,342 |
No | output | 1 | 101,671 | 0 | 203,343 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' <image> 'y' <image> 'x' <image> 'b... | instruction | 0 | 101,672 | 0 | 203,344 |
No | output | 1 | 101,672 | 0 | 203,345 |
Provide a correct Python 3 solution for this coding contest problem.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 β€ length of T β€ 1000000
* 1 β€ length of P β€ 10000
* The input consists of alphabetical characters and digits... | instruction | 0 | 102,003 | 0 | 204,006 |
"Correct Solution:
```
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.read... | output | 1 | 102,003 | 0 | 204,007 |
Provide a correct Python 3 solution for this coding contest problem.
Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 β€ length of T β€ 1000000
* 1 β€ length of P β€ 10000
* The input consists of alphabetical characters and digits... | instruction | 0 | 102,006 | 0 | 204,012 |
"Correct Solution:
```
t = input()
p = input()
t_len = len(t)
p_len = len(p)
for i in range(0, t_len - p_len + 1):
if t[i:i + p_len] == p:
print(i)
``` | output | 1 | 102,006 | 0 | 204,013 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function... | instruction | 0 | 102,425 | 0 | 204,850 |
Tags: greedy, implementation
Correct Solution:
```
S = input()
N = int(input())
X = list(map(int, input().split()))
MAX = max(X)
SUM = 0
for i in range(len(S)):
SUM += X[ord(S[i]) - 97] * (i + 1)
for i in range(1, N + 1):
SUM += (len(S) + i) * MAX
print(SUM)
``` | output | 1 | 102,425 | 0 | 204,851 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function... | instruction | 0 | 102,426 | 0 | 204,852 |
Tags: greedy, implementation
Correct Solution:
```
s=input()
k=int(input())
n=len(s)
l=list(map(int,input().split()))
m=max(l)
c=0
for i in range(n):
x=ord(s[i])-97
c=c+l[x]*(i+1)
for i in range(n+1,n+k+1):
c=c+(i*m)
print(c)
``` | output | 1 | 102,426 | 0 | 204,853 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function... | instruction | 0 | 102,427 | 0 | 204,854 |
Tags: greedy, implementation
Correct Solution:
```
a=input()
n=int(input())
l=list(map(int,input().split()))
letters='abcdefghijklmnopqrstuvwxyz'
b=l.index(max(l))
a+=n*letters[b]
t=[]
for i in a:
t.append(l[letters.index(i)])
s=0
for i in range(1,len(a)+1):
s+=i*t[i-1]
print(s)
``` | output | 1 | 102,427 | 0 | 204,855 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function... | instruction | 0 | 102,428 | 0 | 204,856 |
Tags: greedy, implementation
Correct Solution:
```
str = list(input())
N = int(input())
A = list(map(int, input().split()))
total = 0
maxu = max(A)
for i in range(len(str)):
total += (i+1) * (A[ord(str[i]) - 97])
for j in range(N):
total += (j+len(str)+1)*maxu
print(total)
``` | output | 1 | 102,428 | 0 | 204,857 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function... | instruction | 0 | 102,429 | 0 | 204,858 |
Tags: greedy, implementation
Correct Solution:
```
s=str(input())
k=int(input())
wlist=[int(w) for w in input().split()]
letter=max(wlist)
alphabet='abcdefghijklmnopqrstuvwxyz'
summ=0
for i in range(len(s)):
summ+=wlist[alphabet.index(s[i])]*(i+1)
print(summ+letter*(k*len(s)+(k+k**2)//2))
``` | output | 1 | 102,429 | 0 | 204,859 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function... | instruction | 0 | 102,430 | 0 | 204,860 |
Tags: greedy, implementation
Correct Solution:
```
import sys
import math
def fn(s,k,w):
l = ['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']
x = [[0]*2]*26
for i in range(len(x)):
x[i] = [l[i],int(w[i])]
y = x.copy()
x.sort(key = lam... | output | 1 | 102,430 | 0 | 204,861 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function... | instruction | 0 | 102,431 | 0 | 204,862 |
Tags: greedy, implementation
Correct Solution:
```
# Description of the problem can be found at http://codeforces.com/problemset/problem/447/B
s = input()
k = int(input())
l_n = list(map(int, input().split()))
m = max(l_n)
t = 0
for i in range(len(s)):
t += (i + 1)*l_n[ord(s[i]) - ord('a')]
print(m * ((len(s) +... | output | 1 | 102,431 | 0 | 204,863 |
Provide tags and a correct Python 3 solution for this coding contest problem.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function... | instruction | 0 | 102,432 | 0 | 204,864 |
Tags: greedy, implementation
Correct Solution:
```
s = input()
n = eval(input())
value = list(map(eval,input().split()))
ans = 0
for i in range(len(s)):
ans += value[ord(s[i])-ord('a')]*(i+1)
maxn = max(map(lambda x:x,value))
ans += (len(s)*2+n+1)*n*maxn/2
print(int(ans))
``` | output | 1 | 102,432 | 0 | 204,865 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the ... | instruction | 0 | 102,433 | 0 | 204,866 |
Yes | output | 1 | 102,433 | 0 | 204,867 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the ... | instruction | 0 | 102,434 | 0 | 204,868 |
Yes | output | 1 | 102,434 | 0 | 204,869 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the ... | instruction | 0 | 102,435 | 0 | 204,870 |
Yes | output | 1 | 102,435 | 0 | 204,871 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.