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 a correct Python 3 solution for this coding contest problem. Problem J String Puzzle Amazing Coding Magazine is popular among young programmers for its puzzle solving contests offering catchy digital gadgets as the prizes. The magazine for programmers naturally encourages the readers to solve the puzzles by w...
instruction
0
47,893
0
95,786
"Correct Solution: ``` from bisect import bisect n, a, b, q = map(int, input().split()) W = [input().split() for i in range(a)] X = [int(x) for x, c in W] C = [c for x, c in W] P = [list(map(int, input().split())) for i in range(b)] Y = [y for y, h in P] + [n+1] D = [0]*b for i in range(b): y0, h = P[i]; y1 = Y[...
output
1
47,893
0
95,787
Provide tags and a correct Python 3 solution for this coding contest problem. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overlapping) substrings of length k, * all charac...
instruction
0
47,968
0
95,936
Tags: brute force, implementation, strings Correct Solution: ``` n,k=map(int,input().split()) s=input() s=s+'\0' s2=set(s) max=0 dic={} count=0 for i in range(n): count=count+1 if s[i]!=s[i+1]: if s[i] in dic: dic[s[i]]=dic[s[i]]+count//k else: dic[s[i]]=count//k ...
output
1
47,968
0
95,937
Provide tags and a correct Python 3 solution for this coding contest problem. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overlapping) substrings of length k, * all charac...
instruction
0
47,969
0
95,938
Tags: brute force, implementation, strings Correct Solution: ``` s1 = input().split() n = int(s1[0]) k = int(s1[1]) string = input() estimc = string[0] cnt = 0 lit = dict({estimc:0}) for c in string: if(c == estimc): cnt+=1 if(cnt == k): cnt = 0 if(estimc in lit): ...
output
1
47,969
0
95,939
Provide tags and a correct Python 3 solution for this coding contest problem. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overlapping) substrings of length k, * all charac...
instruction
0
47,970
0
95,940
Tags: brute force, implementation, strings Correct Solution: ``` n,k= map(int,input().split()) s = list(input()) 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"] ma =0 for i in l: t=0 c=0 te =s[0] for j in s: if(j==i): ...
output
1
47,970
0
95,941
Provide tags and a correct Python 3 solution for this coding contest problem. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overlapping) substrings of length k, * all charac...
instruction
0
47,971
0
95,942
Tags: brute force, implementation, strings Correct Solution: ``` from collections import defaultdict as dd n, k=map(int,input().split()) s=input() res=dd(int) pr=s[0] cc=1 for c in s[1:]: if c == pr: cc+=1 else: res[pr] += cc//k pr = c cc=1 res[pr]+=cc//k print(max(res.values())) ```
output
1
47,971
0
95,943
Provide tags and a correct Python 3 solution for this coding contest problem. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overlapping) substrings of length k, * all charac...
instruction
0
47,972
0
95,944
Tags: brute force, implementation, strings Correct Solution: ``` x=[int(s) for s in input().split()] y=x[1] s=input() r=[] c=1 m=0 d="_" for i in s: if i==d: c+=1 elif d=="_": d=i else: r.append((c,d)) c=1 d=i r.append((c,d)) for i in "abcdefghijklmnopqrstuvwxyz": tm=0 for f,l in r: if f>=y and i==l: ...
output
1
47,972
0
95,945
Provide tags and a correct Python 3 solution for this coding contest problem. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overlapping) substrings of length k, * all charac...
instruction
0
47,973
0
95,946
Tags: brute force, implementation, strings Correct Solution: ``` n, k = map(int, input().split()) s = input() prev = s[0] d = {} count = 1 for i in range(1, n): if s[i] == prev: count += 1 else: if not d.get(prev): d[prev] = [count] else: d[prev].append(count) ...
output
1
47,973
0
95,947
Provide tags and a correct Python 3 solution for this coding contest problem. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overlapping) substrings of length k, * all charac...
instruction
0
47,974
0
95,948
Tags: brute force, implementation, strings Correct Solution: ``` k = int(input().split()[1]) result = {} prev = 0 value = 0 STR = input() + '$' for letter in STR: if letter != prev: result[prev] = result.get(prev, 0) + value//k prev = letter value = 0 value+=1 print(max(result.values()...
output
1
47,974
0
95,949
Provide tags and a correct Python 3 solution for this coding contest problem. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overlapping) substrings of length k, * all charac...
instruction
0
47,975
0
95,950
Tags: brute force, implementation, strings Correct Solution: ``` def check(s,i,k): for j in range(i+1,i+k): if s[j]!=s[i]: return j return None n,k=map(int,input().split()) s=input() i=0 l=[0]*26 while i<n-k+1: if check(s,i,k)==None: l[ord(s[i])-97]+=1 i+=k else: i=check(s,i,k) if len(l)!=0: print(...
output
1
47,975
0
95,951
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overl...
instruction
0
47,976
0
95,952
Yes
output
1
47,976
0
95,953
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overl...
instruction
0
47,977
0
95,954
Yes
output
1
47,977
0
95,955
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overl...
instruction
0
47,978
0
95,956
Yes
output
1
47,978
0
95,957
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overl...
instruction
0
47,979
0
95,958
Yes
output
1
47,979
0
95,959
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overl...
instruction
0
47,980
0
95,960
No
output
1
47,980
0
95,961
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overl...
instruction
0
47,981
0
95,962
No
output
1
47,981
0
95,963
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overl...
instruction
0
47,982
0
95,964
No
output
1
47,982
0
95,965
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a string s of length n and integer k (1 ≤ k ≤ n). The string s has a level x, if x is largest non-negative integer, such that it's possible to find in s: * x non-intersecting (non-overl...
instruction
0
47,983
0
95,966
No
output
1
47,983
0
95,967
Provide tags and a correct Python 3 solution for this coding contest problem. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integer i such that a_i = b_i). For example: * 10...
instruction
0
48,083
0
96,166
Tags: constructive algorithms, strings Correct Solution: ``` T = int(input().rstrip()) for test in range(T): n = int(input().rstrip()) input_str = input().rstrip() foo = "" for idx in range(len(input_str)): if idx % 2 == 0: foo = foo + input_str[idx] print(foo) ```
output
1
48,083
0
96,167
Provide tags and a correct Python 3 solution for this coding contest problem. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integer i such that a_i = b_i). For example: * 10...
instruction
0
48,084
0
96,168
Tags: constructive algorithms, strings Correct Solution: ``` def main(): t = int(input()) while t: n = int(input()) s = input() ans = "" i = 0 while i < 2 * n - 1: ans += s[i] i += 2 print(ans) t -= 1 if __name__ == "__main__": ...
output
1
48,084
0
96,169
Provide tags and a correct Python 3 solution for this coding contest problem. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integer i such that a_i = b_i). For example: * 10...
instruction
0
48,085
0
96,170
Tags: constructive algorithms, strings Correct Solution: ``` t = int(input()) while t: n = int(input()) inp = str(input()) print(inp[::2]) t -= 1 ```
output
1
48,085
0
96,171
Provide tags and a correct Python 3 solution for this coding contest problem. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integer i such that a_i = b_i). For example: * 10...
instruction
0
48,086
0
96,172
Tags: constructive algorithms, strings Correct Solution: ``` t=input() t=int(t) while(t>0): n=input() s=input() d=1 for i in s: if(d%2!=0): print(i,end="") d=d+1; t=t-1 print() ```
output
1
48,086
0
96,173
Provide tags and a correct Python 3 solution for this coding contest problem. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integer i such that a_i = b_i). For example: * 10...
instruction
0
48,087
0
96,174
Tags: constructive algorithms, strings Correct Solution: ``` t = int(input()) A = [] B = [] C = [] for i in range(t): n = int(input()) s = input() B = ["1" for j in range(n)] C = ["0" for j in range(n)] one = "".join(B) zero = "".join(C) if s.find(one) != -1: A.append(one) elif s...
output
1
48,087
0
96,175
Provide tags and a correct Python 3 solution for this coding contest problem. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integer i such that a_i = b_i). For example: * 10...
instruction
0
48,088
0
96,176
Tags: constructive algorithms, strings Correct Solution: ``` n = int(input()) for _ in range(n): k = int(input()) s = input() print(s[k - 1]*k) ```
output
1
48,088
0
96,177
Provide tags and a correct Python 3 solution for this coding contest problem. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integer i such that a_i = b_i). For example: * 10...
instruction
0
48,089
0
96,178
Tags: constructive algorithms, strings Correct Solution: ``` t = int(input()) while t: n = int(input()) s = input() l = [] j = 1 ans = "" for i in range(1, n + 1): l.append(s[i - 1 : n]) n += 1 ans += l[0][0] for i in l[1:]: ans += i[j] j += 1 pri...
output
1
48,089
0
96,179
Provide tags and a correct Python 3 solution for this coding contest problem. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integer i such that a_i = b_i). For example: * 10...
instruction
0
48,090
0
96,180
Tags: constructive algorithms, strings Correct Solution: ``` import sys input = sys.stdin.readline t = int(input().strip()) ## first read everything inputs = [] for i in range(0, t): n = int(input().strip()) s = input() inputs.append([n, s]) for i in range(0, t): # read both lines n = inputs[i][0...
output
1
48,090
0
96,181
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integ...
instruction
0
48,091
0
96,182
Yes
output
1
48,091
0
96,183
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integ...
instruction
0
48,092
0
96,184
Yes
output
1
48,092
0
96,185
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integ...
instruction
0
48,093
0
96,186
Yes
output
1
48,093
0
96,187
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integ...
instruction
0
48,094
0
96,188
Yes
output
1
48,094
0
96,189
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integ...
instruction
0
48,095
0
96,190
No
output
1
48,095
0
96,191
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integ...
instruction
0
48,096
0
96,192
No
output
1
48,096
0
96,193
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integ...
instruction
0
48,097
0
96,194
No
output
1
48,097
0
96,195
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A binary string is a string where each character is either 0 or 1. Two binary strings a and b of equal length are similar, if they have the same character in some position (there exists an integ...
instruction
0
48,098
0
96,196
No
output
1
48,098
0
96,197
Provide a correct Python 3 solution for this coding contest problem. Let N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`. Find the number of permutations (p_1, p_2, \ldots, p_N) of (1, 2, \ldots, N) that satisfy the following condition, modulo 10^9 + 7: * For each i (1 \l...
instruction
0
48,607
0
97,214
"Correct Solution: ``` N=int(input()) S=input() mod=10**9+7 #DP[i]#最後においた数の右にある残っている個数 rest=N-1 DP=[1]*(N) for s in S: NDP=[0]*(N) if s=="<": for i in range(rest+1): if i>=1: NDP[i-1]=(DP[i]+NDP[i-1])%mod DP=NDP for i in range(N-2,-1,-1): DP[i]=...
output
1
48,607
0
97,215
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. Co...
instruction
0
48,638
0
97,276
"Correct Solution: ``` def count_inversions(L): def helper(A,B): lA,lB = len(A),len(B) if lA == 0: return B,0 elif lB == 0: return A,0 A,c1 = helper(A[:lA//2],A[lA//2:]) B,c2 = helper(B[:lB//2],B[lB//2:]) cnt = c1+c2 i = 0 j = 0 C = [None]*(lA+lB) while i < lA...
output
1
48,638
0
97,277
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. Co...
instruction
0
48,639
0
97,278
"Correct Solution: ``` """ どれとペアになるかは最初から確定 位置を決めれば後は転倒数 """ import sys def bitadd(a,w,bit): #aにwを加える(1-origin) x = a while x <= (len(bit)-1): bit[x] += w x += x & (-1 * x) def bitsum(a,bit): #ind 1~aまでの和を求める ret = 0 x = a while x > 0: ret += bit[x] x -= x & (-...
output
1
48,639
0
97,279
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. Co...
instruction
0
48,640
0
97,280
"Correct Solution: ``` #!/usr/bin/env python3 class Bit: def __init__(self, n): self.size = n self.tree = [0] * n def sum(self, i): s = 0 i -= 1 while i >= 0: s += self.tree[i] i = (i & (i + 1)) - 1 return s def add(self, i, x): ...
output
1
48,640
0
97,281
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. Co...
instruction
0
48,641
0
97,282
"Correct Solution: ``` s = input() cnt = [0] * 26 n = len(s) for c in s: cnt[ord(c) - ord('a')] += 1 odd = -1 for i in range(26): if cnt[i] % 2 == 1: if odd != -1: print(-1) exit() odd = i cnt2 = [[] for i in range(26)] nums = [] left = 0 for i in range(len(s)): c ...
output
1
48,641
0
97,283
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. Co...
instruction
0
48,642
0
97,284
"Correct Solution: ``` """ まず、奇数個存在する文字種が複数ある場合は、回文にできない。 それ以外の場合は、回文にできる。 次に、操作の最小回数は、回文になった場合の各文字のインデックスを求めておき、BITを使って、入れ替えが必要な回数を求めて置く """ from collections import Counter S = input() N = len(S) #各文字の出現回数をカウント apperance = Counter(S) #回文を作成できるか判定 flag = False for k,v in apperance.items(): if v%2==1: if fl...
output
1
48,642
0
97,285
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. Co...
instruction
0
48,643
0
97,286
"Correct Solution: ``` from string import ascii_lowercase class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): whi...
output
1
48,643
0
97,287
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. Co...
instruction
0
48,644
0
97,288
"Correct Solution: ``` from collections import defaultdict, deque from heapq import heappop, heappush from string import ascii_lowercase as abc class BIT: def __init__(self, N): # Nは入れたい要素の個数 self.size = 2 ** (int.bit_length(N+1)) self.tree = [0]*(self.size + 1) def sum(self, i): ...
output
1
48,644
0
97,289
Provide a correct Python 3 solution for this coding contest problem. You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations. Co...
instruction
0
48,645
0
97,290
"Correct Solution: ``` import sys input = sys.stdin.readline S = list(input().rstrip()) L = len(S) # binary indexed tree bit = [0 for _ in range(L+1)] # 0からiまでの区間和 # 立っているビットを下から処理 def query_sum(i): s = 0 while i > 0: s += bit[i] i -= i & -i return s # i番目の要素にxを足す # 覆ってる区間すべてに足す def add(...
output
1
48,645
0
97,291
Provide tags and a correct Python 3 solution for this coding contest problem. Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG". Maxim was very boring to sit in class, so the teacher came up with a ta...
instruction
0
48,889
0
97,778
Tags: brute force, strings Correct Solution: ``` import os from math import fabs alphabet_A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' alphabet_C = 'CDEFGHIJKLMNOPQRSTUVWXYZAB' alphabet_T = 'TUVWXYZABCDEFGHIJKLMNOPQRS' alphabet_G = 'GHIJKLMNOPQRSTUVWXYZABCDEF' target = 'ACTG' A_count_map = {} C_count_map = {} T_count_map = {} G...
output
1
48,889
0
97,779
Provide tags and a correct Python 3 solution for this coding contest problem. Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG". Maxim was very boring to sit in class, so the teacher came up with a ta...
instruction
0
48,890
0
97,780
Tags: brute force, strings Correct Solution: ``` n=int(input()) x=input() c=0 y=[0]*(n-3) for i in range (n-3): c=0 d=ord(x[i]) c+=min(91-d,d-65) d=ord(x[i+3]) c+=min(abs(71-d),97-d) d=ord(x[i+2]) c+=min(abs(84-d),abs(58-d)) d=ord(x[i+1]) c+=min(abs(67-d),93-d) y[i]=c print(min(y...
output
1
48,890
0
97,781
Provide tags and a correct Python 3 solution for this coding contest problem. Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG". Maxim was very boring to sit in class, so the teacher came up with a ta...
instruction
0
48,891
0
97,782
Tags: brute force, strings Correct Solution: ``` n = int(input()) s = input() glob = float('inf') for i in range(len(s)-3): sub = s[i:i+4] curr = 0 A = ord('A') - 65 C = ord('C') - 65 T = ord('T') - 65 G = ord('G') - 65 s1 = ord(sub[0]) - 65 s2 = ord(sub[1]) - 65 s3 = ord(sub[2]) - 65 s4 = ord(sub[3]) - 65 g...
output
1
48,891
0
97,783
Provide tags and a correct Python 3 solution for this coding contest problem. Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG". Maxim was very boring to sit in class, so the teacher came up with a ta...
instruction
0
48,892
0
97,784
Tags: brute force, strings Correct Solution: ``` def f(l): # print(l) a=min(abs(l[0]-ord("A")),90-l[0]+1) c=min(abs(l[1]-ord("C")),90-l[1]+3) t=min(abs(l[2]-ord("T")),90-l[2]+20) g=min(abs(l[3]-ord("G")),90-l[3]+7) a=min(a,90-ord("A")+l[0]-64) c=min(c,90-ord("C")+l[1]-64) t=min(t,90-ord("T")+l[2]-64) g=min(g...
output
1
48,892
0
97,785
Provide tags and a correct Python 3 solution for this coding contest problem. Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG". Maxim was very boring to sit in class, so the teacher came up with a ta...
instruction
0
48,893
0
97,786
Tags: brute force, strings Correct Solution: ``` if __name__ == "__main__": N = int(input()) S = [ord(c) for c in input()] target = [ord(c) for c in "ACTG"] res = 1234567890 for i in range(N - 4 + 1): tmp = 0 for j in range(4): tmp += min((target[j] - S[i + j]) % 26, (S[...
output
1
48,893
0
97,787
Provide tags and a correct Python 3 solution for this coding contest problem. Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG". Maxim was very boring to sit in class, so the teacher came up with a ta...
instruction
0
48,894
0
97,788
Tags: brute force, strings Correct Solution: ``` # -*- coding: utf-8 -*- import sys import copy sys.setrecursionlimit(1000000) # input = sys.stdin.readline # ~~~~~~~~~~~~~~~~~~~~~_(^~^ 」 ∠)_~~~~~~~~~~~~~~~~~~~~~ N = int(input()) S = input().rstrip() ACTG = "ACTG" actg = [[None] * N for _ in range(4)] for i in ...
output
1
48,894
0
97,789
Provide tags and a correct Python 3 solution for this coding contest problem. Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG". Maxim was very boring to sit in class, so the teacher came up with a ta...
instruction
0
48,895
0
97,790
Tags: brute force, strings Correct Solution: ``` n=int(input()) s=input() t=[] for k in range(n-4+1): a=min( abs(ord(s[k])-ord('A')) ,abs((ord(s[k])-96)+122-ord('A')),abs((ord('A')-96)+122-ord(s[k]))) b=min( abs( ord(s[k+1])-ord('C')) ,abs((ord(s[k+1])-96)+122-ord('C')),abs((ord('C')-96)+122-ord(s[k+1]))) ...
output
1
48,895
0
97,791
Provide tags and a correct Python 3 solution for this coding contest problem. Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG". Maxim was very boring to sit in class, so the teacher came up with a ta...
instruction
0
48,896
0
97,792
Tags: brute force, strings Correct Solution: ``` def result(s): tmp = 0 s1 = 'ACTG' for i in range(4): a, b = ord(s[i]), ord(s1[i]) a, b = max(a, b), min(a, b) tmp += min(a-b, b-ord('A')+ord('Z')-a+1) return tmp n = int(input()) s = input() res = result(s[0:4]) for i in range(1,n...
output
1
48,896
0
97,793