message
stringlengths
2
23.4k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
129
108k
cluster
float64
6
6
__index_level_0__
int64
258
216k
Provide tags and a correct Python 3 solution for this coding contest problem. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1
instruction
0
88,103
6
176,206
Tags: constructive algorithms, implementation, strings Correct Solution: ``` #找出bug n = int(input()) src, tar = input(), input() ans = [] def shift(s, x): ans.append(x) return s[-x:][::-1] + s[:-x] flag = True for i in range(n): index = -1 for j in range(n-i): if src[j] == tar[i]: #print("found in %d" % j) index = j break if index == -1: flag = False break if index == n-1: continue src = shift(src, n - index - 1) src = shift(src, 1) src = shift(src, n) #print(src) if flag: ans = [str(x) for x in ans] print(len(ans)) print(' '.join(ans)) else: print(-1) ```
output
1
88,103
6
176,207
Provide tags and a correct Python 3 solution for this coding contest problem. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1
instruction
0
88,104
6
176,208
Tags: constructive algorithms, implementation, strings Correct Solution: ``` n, s, t = int(input()), input(), input() ans = [] for i in range(n): cur = 0 for j in range(n - i): if s[j] == t[i]: cur = j break else: print(-1) raise SystemExit ans.extend([n - 1 - cur, 1, n]) s = ''.join(reversed(s[0:cur])) + s[cur + 1:] #print('cur:', cur) #print('s:', s) print(len(ans)) print(*ans) ```
output
1
88,104
6
176,209
Provide tags and a correct Python 3 solution for this coding contest problem. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1
instruction
0
88,105
6
176,210
Tags: constructive algorithms, implementation, strings Correct Solution: ``` n = int(input()) s = input() t = input() s0 = sorted(list(s)) t0 = sorted(list(t)) if s0 != t0 : print(-1) else: ans = [] for i in range(n): j = 0 while (s[j] != t[i]): j = j + 1 ans += [n - j - 1, 1, n] s = ''.join(reversed(s[:j])) + s[j + 1:] + s[j] print(len(ans)) print(" ".join(str(i) for i in ans)) ```
output
1
88,105
6
176,211
Provide tags and a correct Python 3 solution for this coding contest problem. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1
instruction
0
88,106
6
176,212
Tags: constructive algorithms, implementation, strings Correct Solution: ``` n = int(input()) src, tar = input(), input() ans = [] def shift(s, x): ans.append(x) return s[-x:][::-1] + s[:-x] flag = True for i in range(n): index = -1 for j in range(n-i): if src[j] == tar[i]: index = j break if index == -1: flag = False break if index == n-1: continue src = shift(src, n - index - 1) src = shift(src, 1) src = shift(src, n) if flag: ans = [str(x) for x in ans] print(len(ans)) print(' '.join(ans)) else: print(-1) ```
output
1
88,106
6
176,213
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1 Submitted Solution: ``` n, s, t = int(input()), input(), input() ans = [] for i in range(n): cur = 0 for j in range(n - i): if s[j] == t[i]: cur = j break else: print(-1) raise SystemExit ans.extend([n - 1 - cur, 1, n]) #print('s[%d:0:-1]:' % (cur - 1), s[cur - 1:0:-1]) #print('s[%d:]:' % (cur + 1), s[cur + 1:]) #print('cur:', cur) s = s[max(cur - 1, 0):0:-1] + (s[0] if cur != 0 else '') + s[cur + 1:] #print('s:', s) #print('*'*20) print(len(ans)) print(*ans) ```
instruction
0
88,107
6
176,214
Yes
output
1
88,107
6
176,215
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1 Submitted Solution: ``` n = int(input()) t = input()[:n] s = input()[:n] ops =[] def shift(k, cur): if k == 0: return cur return cur[:-k-1:-1] + cur [:-k] def move_to_front(k, curst): if k == n-1: ops.append(1) curst = curst[-1] +curst [:-1] else: ops.append(n-1) ops.append(k) ops.append(1) curst = curst[k] + curst[:k] + curst[-1:k:-1] return curst def find_char(char, t): for m,cur_c in enumerate(t[::-1]): if cur_c == char: # print(t, 'found', char, ' at', n-m -1) return n- m -1 return 0 # t = 'abcdefg' # for j in range(len(t)): # print('before', j, t) # t = move_to_front(j, t ) # print(' after', j, t) # print() from collections import Counter scount = Counter(s) tcount = Counter(t) ori_t = t if scount != tcount: print(-1) exit() for char in s[::-1]: t = move_to_front(find_char(char, t), t) # print('got t', t) print(len(ops)) print(*ops) # for op in ops: # print(op, ori_t, shift(op, ori_t)) # ori_t = shift(op, ori_t) # # print(ori_t) ```
instruction
0
88,108
6
176,216
Yes
output
1
88,108
6
176,217
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1 Submitted Solution: ``` n = int(input()) s = input() t = input() if sorted(s) != sorted(t): print(-1) else: ans = [] for i in t: j = 0 for j in range(n): if i == s[j]: break ans.append(n-j-1) ans.append(1) ans.append(n) s =s[j-n-1:-n-1:-1] + s[j+1:] + s[j] print(len(ans)) for i in ans: print(i, end=' ') ```
instruction
0
88,109
6
176,218
Yes
output
1
88,109
6
176,219
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1 Submitted Solution: ``` n = int(input()) s = input() t = input() if sorted(s) != sorted(t): print(-1) else: ans = [] for i in t: j = 0 for j in range(n): if i == s[j]: break ans.append(n-j-1) ans.append(1) ans.append(n) s = "".join(reversed(s[:j])) + s[j+1:] + s[j] print(len(ans)) for i in ans: print(i, end=' ') ```
instruction
0
88,110
6
176,220
Yes
output
1
88,110
6
176,221
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1 Submitted Solution: ``` n = int(input()) s = input() t = input() s0 = sorted(list(s)) t0 = sorted(list(t)) if s0 != t0 : print(-1) else: ans = [] for i in range(n): j = 0 while (s[j] != t[i]): j = j + 1 ans += [n - j - 1, 1, n] s = ''.join(reversed(s[:j])) + s[j + 1:] + s[j] print(len(ans)) print(",".join(str(i) for i in ans)) ```
instruction
0
88,111
6
176,222
No
output
1
88,111
6
176,223
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1 Submitted Solution: ``` n = int(input()) s = input() t = input() if sorted(s) != sorted(t): print(-1) else: res = [] for i in range(n): k = 0 while(s[k] != t[i]): k += 1 res += [k + 1, n - 1, 0] s = ''.join(reversed(s[:k])) + s[k + 1:] + s[k] # print(s) print(len(res)) print(*res) ```
instruction
0
88,112
6
176,224
No
output
1
88,112
6
176,225
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1 Submitted Solution: ``` n = int(input()) t = input()[:n] s = input()[:n] ops =[] def shift(k, cur): if k == 0: return cur return cur[:-k-1:-1] + cur [:-k] def move_to_front(k, curst): if k == n-1: ops.append(1) curst = curst[-1] +curst [:-1] else: ops.append(n-1) ops.append(k) ops.append(1) curst = curst[k] + curst[:k] + curst[-1:k:-1] return curst def find_char(char, t): for m,cur_c in enumerate(t[::-1]): if cur_c == char: # print(t, 'found', char, ' at', n-m -1) return n- m -1 return 0 # t = 'abcdefg' # for j in range(len(t)): # print('before', j, t) # t = move_to_front(j, t ) # print(' after', j, t) # print() from collections import Counter scount = Counter(s) tcount = Counter(t) ori_t = t if scount != tcount: print(-1) exit() for char in s[::-1]: t = move_to_front(find_char(char, t), t) # print('got t', t) print(len(ops)) print(*ops) for op in ops: print(op, ori_t, shift(op, ori_t)) ori_t = shift(op, ori_t) print(ori_t) ```
instruction
0
88,113
6
176,226
No
output
1
88,113
6
176,227
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm! Of course, there is a code lock is installed on the safe. The lock has a screen that displays a string of n lowercase Latin letters. Initially, the screen displays string s. Whitfield and Martin found out that the safe will open when string t will be displayed on the screen. The string on the screen can be changed using the operation «shift x». In order to apply this operation, explorers choose an integer x from 0 to n inclusive. After that, the current string p = αβ changes to βRα, where the length of β is x, and the length of α is n - x. In other words, the suffix of the length x of string p is reversed and moved to the beginning of the string. For example, after the operation «shift 4» the string «abcacb» will be changed with string «bcacab », since α = ab, β = cacb, βR = bcac. Explorers are afraid that if they apply too many operations «shift», the lock will be locked forever. They ask you to find a way to get the string t on the screen, using no more than 6100 operations. Input The first line contains an integer n, the length of the strings s and t (1 ≤ n ≤ 2 000). After that, there are two strings s and t, consisting of n lowercase Latin letters each. Output If it is impossible to get string t from string s using no more than 6100 operations «shift», print a single number - 1. Otherwise, in the first line output the number of operations k (0 ≤ k ≤ 6100). In the next line output k numbers xi corresponding to the operations «shift xi» (0 ≤ xi ≤ n) in the order in which they should be applied. Examples Input 6 abacbb babcba Output 4 6 3 2 3 Input 3 aba bba Output -1 Submitted Solution: ``` n = int(input()) s = input() t = input() if sorted(s) != sorted(t): print(-1) else: res = [] for i in range(n): k = 0; while(s[k] != t[i]): k += 1 res += [n-k-1, 1, n] s = "".join(reversed(s[:k])) + s[k+1:] + s[k] print(s) #print(len(res)) print(*res) ```
instruction
0
88,114
6
176,228
No
output
1
88,114
6
176,229
Provide tags and a correct Python 3 solution for this coding contest problem. We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It's super simple, 100% accurate, and doesn't involve advanced machine learning algorithms. Let us tell you how it works. * If a sentence ends with "po" the language is Filipino. * If a sentence ends with "desu" or "masu" the language is Japanese. * If a sentence ends with "mnida" the language is Korean. Given this, we need you to implement a suffix three that can differentiate Filipino, Japanese, and Korean. Oh, did I say three suffixes? I meant four. Input The first line of input contains a single integer t (1 ≤ t ≤ 30) denoting the number of test cases. The next lines contain descriptions of the test cases. Each test case consists of a single line containing a single string denoting the sentence. Spaces are represented as underscores (the symbol "_") for ease of reading. The sentence has at least 1 and at most 1000 characters, and consists only of lowercase English letters and underscores. The sentence has no leading or trailing underscores and no two consecutive underscores. It is guaranteed that the sentence ends with one of the four suffixes mentioned above. Output For each test case, print a single line containing either "FILIPINO", "JAPANESE", or "KOREAN" (all in uppercase, without quotes), depending on the detected language. Example Input 8 kamusta_po genki_desu ohayou_gozaimasu annyeong_hashimnida hajime_no_ippo bensamu_no_sentou_houhou_ga_okama_kenpo ang_halaman_doon_ay_sarisari_singkamasu si_roy_mustang_ay_namamasu Output FILIPINO JAPANESE JAPANESE KOREAN FILIPINO FILIPINO JAPANESE JAPANESE Note The first sentence ends with "po", so it is written in Filipino. The second and third sentences end with "desu" and "masu", so they are written in Japanese. The fourth sentence ends with "mnida", so it is written in Korean.
instruction
0
88,495
6
176,990
Tags: implementation Correct Solution: ``` x=int(input()) for i in range(x): st=input() # print(st[-2:]) if "po" in st[-2:] : print("FILIPINO") elif "desu" in st[-5:] or "masu" in st[-5:] : print("JAPANESE") else: print("KOREAN") ```
output
1
88,495
6
176,991
Provide tags and a correct Python 3 solution for this coding contest problem. We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It's super simple, 100% accurate, and doesn't involve advanced machine learning algorithms. Let us tell you how it works. * If a sentence ends with "po" the language is Filipino. * If a sentence ends with "desu" or "masu" the language is Japanese. * If a sentence ends with "mnida" the language is Korean. Given this, we need you to implement a suffix three that can differentiate Filipino, Japanese, and Korean. Oh, did I say three suffixes? I meant four. Input The first line of input contains a single integer t (1 ≤ t ≤ 30) denoting the number of test cases. The next lines contain descriptions of the test cases. Each test case consists of a single line containing a single string denoting the sentence. Spaces are represented as underscores (the symbol "_") for ease of reading. The sentence has at least 1 and at most 1000 characters, and consists only of lowercase English letters and underscores. The sentence has no leading or trailing underscores and no two consecutive underscores. It is guaranteed that the sentence ends with one of the four suffixes mentioned above. Output For each test case, print a single line containing either "FILIPINO", "JAPANESE", or "KOREAN" (all in uppercase, without quotes), depending on the detected language. Example Input 8 kamusta_po genki_desu ohayou_gozaimasu annyeong_hashimnida hajime_no_ippo bensamu_no_sentou_houhou_ga_okama_kenpo ang_halaman_doon_ay_sarisari_singkamasu si_roy_mustang_ay_namamasu Output FILIPINO JAPANESE JAPANESE KOREAN FILIPINO FILIPINO JAPANESE JAPANESE Note The first sentence ends with "po", so it is written in Filipino. The second and third sentences end with "desu" and "masu", so they are written in Japanese. The fourth sentence ends with "mnida", so it is written in Korean.
instruction
0
88,496
6
176,992
Tags: implementation Correct Solution: ``` n = int(input()) i = 0 string1 = '' while i<n: string1= string1+ input() i= i+1 if n-i>=1: string1= string1+ ' ' list1= string1.split(' ') for n in range(len(list1)): if list1[n].endswith('po'): print('FILIPINO') elif list1[n].endswith('desu') or list1[n].endswith('masu'): print('JAPANESE') elif list1[n].endswith('mnida'): print('KOREAN') ```
output
1
88,496
6
176,993
Provide tags and a correct Python 3 solution for this coding contest problem. We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It's super simple, 100% accurate, and doesn't involve advanced machine learning algorithms. Let us tell you how it works. * If a sentence ends with "po" the language is Filipino. * If a sentence ends with "desu" or "masu" the language is Japanese. * If a sentence ends with "mnida" the language is Korean. Given this, we need you to implement a suffix three that can differentiate Filipino, Japanese, and Korean. Oh, did I say three suffixes? I meant four. Input The first line of input contains a single integer t (1 ≤ t ≤ 30) denoting the number of test cases. The next lines contain descriptions of the test cases. Each test case consists of a single line containing a single string denoting the sentence. Spaces are represented as underscores (the symbol "_") for ease of reading. The sentence has at least 1 and at most 1000 characters, and consists only of lowercase English letters and underscores. The sentence has no leading or trailing underscores and no two consecutive underscores. It is guaranteed that the sentence ends with one of the four suffixes mentioned above. Output For each test case, print a single line containing either "FILIPINO", "JAPANESE", or "KOREAN" (all in uppercase, without quotes), depending on the detected language. Example Input 8 kamusta_po genki_desu ohayou_gozaimasu annyeong_hashimnida hajime_no_ippo bensamu_no_sentou_houhou_ga_okama_kenpo ang_halaman_doon_ay_sarisari_singkamasu si_roy_mustang_ay_namamasu Output FILIPINO JAPANESE JAPANESE KOREAN FILIPINO FILIPINO JAPANESE JAPANESE Note The first sentence ends with "po", so it is written in Filipino. The second and third sentences end with "desu" and "masu", so they are written in Japanese. The fourth sentence ends with "mnida", so it is written in Korean.
instruction
0
88,497
6
176,994
Tags: implementation Correct Solution: ``` t=int(input()) while t!=0: t-=1 s=input() if s[-2:]=="po": print("FILIPINO") elif s[-4:]=="desu" or s[-4:]=="masu": print("JAPANESE") else: print("KOREAN") ```
output
1
88,497
6
176,995
Provide tags and a correct Python 3 solution for this coding contest problem. We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It's super simple, 100% accurate, and doesn't involve advanced machine learning algorithms. Let us tell you how it works. * If a sentence ends with "po" the language is Filipino. * If a sentence ends with "desu" or "masu" the language is Japanese. * If a sentence ends with "mnida" the language is Korean. Given this, we need you to implement a suffix three that can differentiate Filipino, Japanese, and Korean. Oh, did I say three suffixes? I meant four. Input The first line of input contains a single integer t (1 ≤ t ≤ 30) denoting the number of test cases. The next lines contain descriptions of the test cases. Each test case consists of a single line containing a single string denoting the sentence. Spaces are represented as underscores (the symbol "_") for ease of reading. The sentence has at least 1 and at most 1000 characters, and consists only of lowercase English letters and underscores. The sentence has no leading or trailing underscores and no two consecutive underscores. It is guaranteed that the sentence ends with one of the four suffixes mentioned above. Output For each test case, print a single line containing either "FILIPINO", "JAPANESE", or "KOREAN" (all in uppercase, without quotes), depending on the detected language. Example Input 8 kamusta_po genki_desu ohayou_gozaimasu annyeong_hashimnida hajime_no_ippo bensamu_no_sentou_houhou_ga_okama_kenpo ang_halaman_doon_ay_sarisari_singkamasu si_roy_mustang_ay_namamasu Output FILIPINO JAPANESE JAPANESE KOREAN FILIPINO FILIPINO JAPANESE JAPANESE Note The first sentence ends with "po", so it is written in Filipino. The second and third sentences end with "desu" and "masu", so they are written in Japanese. The fourth sentence ends with "mnida", so it is written in Korean.
instruction
0
88,498
6
176,996
Tags: implementation Correct Solution: ``` def main(): N = int(input()) for _ in range(N): S = str(input()) if S.endswith("po"): print("FILIPINO") elif S.endswith("desu") or S.endswith("masu"): print("JAPANESE") else: print("KOREAN") if __name__ == "__main__": main() ```
output
1
88,498
6
176,997
Provide tags and a correct Python 3 solution for this coding contest problem. We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It's super simple, 100% accurate, and doesn't involve advanced machine learning algorithms. Let us tell you how it works. * If a sentence ends with "po" the language is Filipino. * If a sentence ends with "desu" or "masu" the language is Japanese. * If a sentence ends with "mnida" the language is Korean. Given this, we need you to implement a suffix three that can differentiate Filipino, Japanese, and Korean. Oh, did I say three suffixes? I meant four. Input The first line of input contains a single integer t (1 ≤ t ≤ 30) denoting the number of test cases. The next lines contain descriptions of the test cases. Each test case consists of a single line containing a single string denoting the sentence. Spaces are represented as underscores (the symbol "_") for ease of reading. The sentence has at least 1 and at most 1000 characters, and consists only of lowercase English letters and underscores. The sentence has no leading or trailing underscores and no two consecutive underscores. It is guaranteed that the sentence ends with one of the four suffixes mentioned above. Output For each test case, print a single line containing either "FILIPINO", "JAPANESE", or "KOREAN" (all in uppercase, without quotes), depending on the detected language. Example Input 8 kamusta_po genki_desu ohayou_gozaimasu annyeong_hashimnida hajime_no_ippo bensamu_no_sentou_houhou_ga_okama_kenpo ang_halaman_doon_ay_sarisari_singkamasu si_roy_mustang_ay_namamasu Output FILIPINO JAPANESE JAPANESE KOREAN FILIPINO FILIPINO JAPANESE JAPANESE Note The first sentence ends with "po", so it is written in Filipino. The second and third sentences end with "desu" and "masu", so they are written in Japanese. The fourth sentence ends with "mnida", so it is written in Korean.
instruction
0
88,499
6
176,998
Tags: implementation Correct Solution: ``` for i in range(int(input())): n = input() if "po" == n[-2:]: print("FILIPINO") elif "desu" == n[-4:] or "masu" == n[-4:]: print("JAPANESE") #elif "mnid" == n[-4:]: else: print("KOREAN") ```
output
1
88,499
6
176,999
Provide tags and a correct Python 3 solution for this coding contest problem. We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It's super simple, 100% accurate, and doesn't involve advanced machine learning algorithms. Let us tell you how it works. * If a sentence ends with "po" the language is Filipino. * If a sentence ends with "desu" or "masu" the language is Japanese. * If a sentence ends with "mnida" the language is Korean. Given this, we need you to implement a suffix three that can differentiate Filipino, Japanese, and Korean. Oh, did I say three suffixes? I meant four. Input The first line of input contains a single integer t (1 ≤ t ≤ 30) denoting the number of test cases. The next lines contain descriptions of the test cases. Each test case consists of a single line containing a single string denoting the sentence. Spaces are represented as underscores (the symbol "_") for ease of reading. The sentence has at least 1 and at most 1000 characters, and consists only of lowercase English letters and underscores. The sentence has no leading or trailing underscores and no two consecutive underscores. It is guaranteed that the sentence ends with one of the four suffixes mentioned above. Output For each test case, print a single line containing either "FILIPINO", "JAPANESE", or "KOREAN" (all in uppercase, without quotes), depending on the detected language. Example Input 8 kamusta_po genki_desu ohayou_gozaimasu annyeong_hashimnida hajime_no_ippo bensamu_no_sentou_houhou_ga_okama_kenpo ang_halaman_doon_ay_sarisari_singkamasu si_roy_mustang_ay_namamasu Output FILIPINO JAPANESE JAPANESE KOREAN FILIPINO FILIPINO JAPANESE JAPANESE Note The first sentence ends with "po", so it is written in Filipino. The second and third sentences end with "desu" and "masu", so they are written in Japanese. The fourth sentence ends with "mnida", so it is written in Korean.
instruction
0
88,500
6
177,000
Tags: implementation Correct Solution: ``` n=int(input()) for i in range(1,n+1): str=input() if str[-5:]=="mnida": print("KOREAN") elif str[-4:]=="desu" or str[-4:]=="masu": print("JAPANESE") else: print("FILIPINO") ```
output
1
88,500
6
177,001
Provide tags and a correct Python 3 solution for this coding contest problem. We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It's super simple, 100% accurate, and doesn't involve advanced machine learning algorithms. Let us tell you how it works. * If a sentence ends with "po" the language is Filipino. * If a sentence ends with "desu" or "masu" the language is Japanese. * If a sentence ends with "mnida" the language is Korean. Given this, we need you to implement a suffix three that can differentiate Filipino, Japanese, and Korean. Oh, did I say three suffixes? I meant four. Input The first line of input contains a single integer t (1 ≤ t ≤ 30) denoting the number of test cases. The next lines contain descriptions of the test cases. Each test case consists of a single line containing a single string denoting the sentence. Spaces are represented as underscores (the symbol "_") for ease of reading. The sentence has at least 1 and at most 1000 characters, and consists only of lowercase English letters and underscores. The sentence has no leading or trailing underscores and no two consecutive underscores. It is guaranteed that the sentence ends with one of the four suffixes mentioned above. Output For each test case, print a single line containing either "FILIPINO", "JAPANESE", or "KOREAN" (all in uppercase, without quotes), depending on the detected language. Example Input 8 kamusta_po genki_desu ohayou_gozaimasu annyeong_hashimnida hajime_no_ippo bensamu_no_sentou_houhou_ga_okama_kenpo ang_halaman_doon_ay_sarisari_singkamasu si_roy_mustang_ay_namamasu Output FILIPINO JAPANESE JAPANESE KOREAN FILIPINO FILIPINO JAPANESE JAPANESE Note The first sentence ends with "po", so it is written in Filipino. The second and third sentences end with "desu" and "masu", so they are written in Japanese. The fourth sentence ends with "mnida", so it is written in Korean.
instruction
0
88,501
6
177,002
Tags: implementation Correct Solution: ``` t=int(input()) for q in range(t): a=list(input()) if(a[len(a)-1]=='o'): print("FILIPINO") if(a[len(a)-1]=='u'): print("JAPANESE") if(a[len(a)-1]=='a'): print("KOREAN") ```
output
1
88,501
6
177,003
Provide tags and a correct Python 3 solution for this coding contest problem. We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It's super simple, 100% accurate, and doesn't involve advanced machine learning algorithms. Let us tell you how it works. * If a sentence ends with "po" the language is Filipino. * If a sentence ends with "desu" or "masu" the language is Japanese. * If a sentence ends with "mnida" the language is Korean. Given this, we need you to implement a suffix three that can differentiate Filipino, Japanese, and Korean. Oh, did I say three suffixes? I meant four. Input The first line of input contains a single integer t (1 ≤ t ≤ 30) denoting the number of test cases. The next lines contain descriptions of the test cases. Each test case consists of a single line containing a single string denoting the sentence. Spaces are represented as underscores (the symbol "_") for ease of reading. The sentence has at least 1 and at most 1000 characters, and consists only of lowercase English letters and underscores. The sentence has no leading or trailing underscores and no two consecutive underscores. It is guaranteed that the sentence ends with one of the four suffixes mentioned above. Output For each test case, print a single line containing either "FILIPINO", "JAPANESE", or "KOREAN" (all in uppercase, without quotes), depending on the detected language. Example Input 8 kamusta_po genki_desu ohayou_gozaimasu annyeong_hashimnida hajime_no_ippo bensamu_no_sentou_houhou_ga_okama_kenpo ang_halaman_doon_ay_sarisari_singkamasu si_roy_mustang_ay_namamasu Output FILIPINO JAPANESE JAPANESE KOREAN FILIPINO FILIPINO JAPANESE JAPANESE Note The first sentence ends with "po", so it is written in Filipino. The second and third sentences end with "desu" and "masu", so they are written in Japanese. The fourth sentence ends with "mnida", so it is written in Korean.
instruction
0
88,502
6
177,004
Tags: implementation Correct Solution: ``` for _ in range(int(input())): s=input() if s[-2:]=='po': print("FILIPINO") elif s[-4:]=='masu' or s[-4:]=='desu': print("JAPANESE") else: print("KOREAN") ```
output
1
88,502
6
177,005
Provide tags and a correct Python 3 solution for this coding contest problem. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name. It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita". Names are case sensitive. Input The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem. Output Print "YES", if problem is from this contest, and "NO" otherwise. Examples Input Alex_and_broken_contest Output NO Input NikitaAndString Output YES Input Danil_and_Olya Output NO
instruction
0
90,626
6
181,252
Tags: implementation, strings Correct Solution: ``` s = input() # print(s) l = ["Danil", "Olya", "Slava", "Ann", "Nikita"] cnt = 0 for n in l: cnt = cnt + s.count(n) if cnt == 1: print("YES") else: print("NO") ```
output
1
90,626
6
181,253
Provide tags and a correct Python 3 solution for this coding contest problem. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name. It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita". Names are case sensitive. Input The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem. Output Print "YES", if problem is from this contest, and "NO" otherwise. Examples Input Alex_and_broken_contest Output NO Input NikitaAndString Output YES Input Danil_and_Olya Output NO
instruction
0
90,627
6
181,254
Tags: implementation, strings Correct Solution: ``` inp = input() names = ["Danil", "Olya", "Slava", "Ann", "Nikita"] rs = 0 for name in names: rs += inp.count(name) print("YES" if rs == 1 else "NO") ```
output
1
90,627
6
181,255
Provide tags and a correct Python 3 solution for this coding contest problem. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name. It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita". Names are case sensitive. Input The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem. Output Print "YES", if problem is from this contest, and "NO" otherwise. Examples Input Alex_and_broken_contest Output NO Input NikitaAndString Output YES Input Danil_and_Olya Output NO
instruction
0
90,628
6
181,256
Tags: implementation, strings Correct Solution: ``` str = input() FRIENDS = ["Danil", "Olya", "Slava", "Ann", "Nikita"] sum = 0 for name in FRIENDS: sum += str.count(name) if sum == 1: print('YES') else: print('NO') ```
output
1
90,628
6
181,257
Provide tags and a correct Python 3 solution for this coding contest problem. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name. It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita". Names are case sensitive. Input The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem. Output Print "YES", if problem is from this contest, and "NO" otherwise. Examples Input Alex_and_broken_contest Output NO Input NikitaAndString Output YES Input Danil_and_Olya Output NO
instruction
0
90,629
6
181,258
Tags: implementation, strings Correct Solution: ``` ls=["Danil","Olya","Slava","Ann","Nikita"] s=input() ctr=0 for a in ls: ctr+=s.count(a) if ctr==1: print("YES") else: print("NO") ```
output
1
90,629
6
181,259
Provide tags and a correct Python 3 solution for this coding contest problem. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name. It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita". Names are case sensitive. Input The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem. Output Print "YES", if problem is from this contest, and "NO" otherwise. Examples Input Alex_and_broken_contest Output NO Input NikitaAndString Output YES Input Danil_and_Olya Output NO
instruction
0
90,630
6
181,260
Tags: implementation, strings Correct Solution: ``` from sys import stdin, stdout s = stdin.readline().strip() challengers = ['Danil', 'Olya', 'Slava', 'Ann', 'Nikita'] n = len(s) cnt = 0 s += '#' * 50 for i in range(n): for f in challengers: if s[i: i + len(f)] == f: cnt += 1 if cnt == 1: stdout.write('YES') else: stdout.write('NO') ```
output
1
90,630
6
181,261
Provide tags and a correct Python 3 solution for this coding contest problem. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name. It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita". Names are case sensitive. Input The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem. Output Print "YES", if problem is from this contest, and "NO" otherwise. Examples Input Alex_and_broken_contest Output NO Input NikitaAndString Output YES Input Danil_and_Olya Output NO
instruction
0
90,631
6
181,262
Tags: implementation, strings Correct Solution: ``` s = input() print('YES' if sum(s.count(n) for n in ["Danil", "Olya", "Slava", "Ann", "Nikita"]) == 1 else 'NO') ```
output
1
90,631
6
181,263
Provide tags and a correct Python 3 solution for this coding contest problem. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name. It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita". Names are case sensitive. Input The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem. Output Print "YES", if problem is from this contest, and "NO" otherwise. Examples Input Alex_and_broken_contest Output NO Input NikitaAndString Output YES Input Danil_and_Olya Output NO
instruction
0
90,632
6
181,264
Tags: implementation, strings Correct Solution: ``` s = input() lis = ["Danil", "Olya", "Slava", "Ann" , "Nikita"] r = sum([s.count(i) for i in lis]) print('NO YES'.split()[r==1]) ```
output
1
90,632
6
181,265
Provide tags and a correct Python 3 solution for this coding contest problem. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name. It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita". Names are case sensitive. Input The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem. Output Print "YES", if problem is from this contest, and "NO" otherwise. Examples Input Alex_and_broken_contest Output NO Input NikitaAndString Output YES Input Danil_and_Olya Output NO
instruction
0
90,633
6
181,266
Tags: implementation, strings Correct Solution: ``` def get_ans(s, t): return s.count(t) s = input() a = get_ans(s, "Ann") + get_ans(s, "Danil") + get_ans(s, "Olya") + get_ans(s, "Slava") + get_ans(s, "Nikita") if a == 1: print("YES") else: print("NO") ```
output
1
90,633
6
181,267
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".
instruction
0
91,218
6
182,436
Tags: implementation, strings Correct Solution: ``` z = input() res = '' if z.startswith('http'): res += 'http://' z = z[4:] elif z.startswith('ftp'): res += 'ftp://' z = z[3:] pi = z.rfind('ru') res += z[:pi] res += '.ru' if not z.endswith('ru'): res += '/'+z[pi+2:] print(res) ```
output
1
91,218
6
182,437
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".
instruction
0
91,219
6
182,438
Tags: implementation, strings Correct Solution: ``` X = input() Result = "http://" if X[0] == "h" else "ftp://" Result += X[X.index("p") + 1:X.rfind("ru")] + ".ru/" Result += X[X.rfind("ru") + 2:] print(Result if Result[-1] != "/" else Result[:-1]) # UB_CodeForces # Advice: Falling down is an accident, staying down is a choice # Location: Here in Bojnurd # Caption: So Close man!! Take it easy!!!! # CodeNumber: 652 ```
output
1
91,219
6
182,439
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".
instruction
0
91,220
6
182,440
Tags: implementation, strings Correct Solution: ``` string = input() if string.startswith('http'): protocol = string[:4] string = string[4:] else: protocol = string[:3] string = string[3:] domain_end = string.find('ru', 1) domain_name = string[:domain_end] context = string[domain_end + 2:] result = protocol + '://' + domain_name + '.ru' if len(context) > 0: result += '/' + context print(result) ```
output
1
91,220
6
182,441
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".
instruction
0
91,221
6
182,442
Tags: implementation, strings Correct Solution: ``` t = input() if t[0] == 'h': ans, t = 'http://', t[4:] else: ans, t = 'ftp://', t[3:] k = t.find('ru', 1) ans += t[:k] + '.ru' if len(t) > k + 2: ans += '/' + t[k + 2:] print(ans) ```
output
1
91,221
6
182,443
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".
instruction
0
91,222
6
182,444
Tags: implementation, strings Correct Solution: ``` S = input() ans = "" ind = 0 if S[0] == 'f': ans += "ftp://" + S[3] ind = 4 else: ans += "http://" + S[4] ind = 5 while True: if S[ind:ind+2] == 'ru': ans += '.ru/' + S[ind + 2:] break ans += S[ind] ind += 1 if ans[-1] == '/': print(ans[:-1]) else: print(ans) ```
output
1
91,222
6
182,445
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".
instruction
0
91,223
6
182,446
Tags: implementation, strings Correct Solution: ``` s=input() ans="" if s[0]=='f': ans+='ftp://'+s[3] t=-1 for i in range(4,len(s)-1): if s[i]=='r' and s[i+1]=='u': t=i break ans+=s[4:t]+".ru" if len(s[t+2:])>0: ans+="/"+s[t+2:] print(ans) else: ans+='http://'+s[4] t=-1 for i in range(5,len(s)-1): if s[i]=='r' and s[i+1]=='u': t=i break ans+=s[5:t]+".ru" if len(s[t+2:])>0: ans+="/"+s[t+2:] print(ans) ```
output
1
91,223
6
182,447
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".
instruction
0
91,224
6
182,448
Tags: implementation, strings Correct Solution: ``` a = input() r = '' flag = 0 flag2 = 0 for i in range(len(a)): r+=a[i] if r=='ftp': r+='://' elif r=='http': r+='://' elif a[i+1:i+3]=='ru' and flag==0: r+='.' flag = 1 if i==len(a)-3: flag2 = 1 elif flag==1 and flag2==0: flag+=1 elif flag==2 and flag2==0: r+='/' flag = 3 # if a[i:i+2]=='ru': print(r) ```
output
1
91,224
6
182,449
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".
instruction
0
91,225
6
182,450
Tags: implementation, strings Correct Solution: ``` import re address = input() address = re.sub('(http|ftp)(\w+?)(ru)', r'\1://\2.\3', address) if re.match('.+?\.ru(\w+)', address): address = re.sub('\.ru(\w+)', r'.ru/\1', address) print(address) ```
output
1
91,225
6
182,451
Provide tags and a correct Python 3 solution for this coding contest problem. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets.
instruction
0
91,292
6
182,584
Tags: brute force, math, strings Correct Solution: ``` s = input() pos = len(s) + 1 print(26*(pos) - len(s)) ```
output
1
91,292
6
182,585
Provide tags and a correct Python 3 solution for this coding contest problem. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets.
instruction
0
91,293
6
182,586
Tags: brute force, math, strings Correct Solution: ``` s = input() l = [] li = ["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"] for c in li: for i in range(0, len(s)+2): str = s[0:i] + c + s[i:len(s)] if str in l: continue else: l.append(str) print(len(l)) ```
output
1
91,293
6
182,587
Provide tags and a correct Python 3 solution for this coding contest problem. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets.
instruction
0
91,294
6
182,588
Tags: brute force, math, 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'] string = input() result = set() first = '' second = '' for i in range(len(string)): first = string[:i] second = string[i:] for j in range(len(letters)): value = letters[j] + first + second result.add(value) value = first + letters[j] + second result.add(value) value = first + second + letters[j] result.add(value) print(len(result)) ```
output
1
91,294
6
182,589
Provide tags and a correct Python 3 solution for this coding contest problem. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets.
instruction
0
91,295
6
182,590
Tags: brute force, math, strings Correct Solution: ``` s=input() tedad = 26*(1+len(s))-len(s) print(tedad) ```
output
1
91,295
6
182,591
Provide tags and a correct Python 3 solution for this coding contest problem. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets.
instruction
0
91,296
6
182,592
Tags: brute force, math, strings Correct Solution: ``` s = input() d = set() for i in range(len(s)): for a in range(26): c = chr(ord('a') + a) d.add(s[:i] + c + s[i:]) for a in range(26): c = chr(ord('a') + a) d.add(s + c) print(len(d)) ```
output
1
91,296
6
182,593
Provide tags and a correct Python 3 solution for this coding contest problem. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets.
instruction
0
91,297
6
182,594
Tags: brute force, math, strings Correct Solution: ``` a=input() b=[0]*26 for i in range(len(a)): b[ord(a[i])-97]+=1 c=0 r=0 for i in range(26): if b[i]==0: c+=1 else: r+=(len(a)+1-b[i]) #print(r) r+=(c*(len(a)+1)) print(r) ```
output
1
91,297
6
182,595
Provide tags and a correct Python 3 solution for this coding contest problem. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets.
instruction
0
91,298
6
182,596
Tags: brute force, math, strings Correct Solution: ``` l = list(map(str, input())) aux = list(l) s = set() for i in range(len(l)+1): for j in range(97, 123): aux.insert(i, chr(j)) s.add(str(aux)) aux = list(l) print(len(s)) ```
output
1
91,298
6
182,597
Provide tags and a correct Python 3 solution for this coding contest problem. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets.
instruction
0
91,299
6
182,598
Tags: brute force, math, strings Correct Solution: ``` n=input() print(25*len(n)+26) ```
output
1
91,299
6
182,599
Provide tags and a correct Python 3 solution for this coding contest problem. Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block. For example: * the following words have typos: "hellno", "hackcerrs" and "backtothefutttture"; * the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo". When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos. Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem. Input The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters. Output Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them. Examples Input hellno Output hell no Input abacaba Output abacaba Input asdfasdf Output asd fasd f
instruction
0
92,303
6
184,606
Tags: dp, greedy, implementation Correct Solution: ``` import math mas = ['a', 'e', 'i', 'o', 'u'] def check(ch): if ch in mas: return False else: return True s = input() i = 0 ans = '' j = 0 while i < len(s) - 2: if check(s[i]) and check(s[i+1]) and check(s[i+2]) and not (s[i] == s[i+1] and s[i+1] == s[i+2]): ans += s[i] + s[i+1] + ' ' i += 2 j = i else: ans += s[i] i+=1 more = '' #print(j) if j == len(s): j +1 elif j == len(s) - 1: more += s[len(s)-1] else: more += s[len(s)-2] + s[len(s)-1] print(ans + more) ```
output
1
92,303
6
184,607
Provide tags and a correct Python 3 solution for this coding contest problem. Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block. For example: * the following words have typos: "hellno", "hackcerrs" and "backtothefutttture"; * the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo". When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos. Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem. Input The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters. Output Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them. Examples Input hellno Output hell no Input abacaba Output abacaba Input asdfasdf Output asd fasd f
instruction
0
92,304
6
184,608
Tags: dp, greedy, implementation Correct Solution: ``` s=input() t="" n=len(s) ans=[] arr=['a','e','i','o','u'] if(n<3): print(s) else: i=0 while(i<n-2): p=[s[i],s[i+1],s[i+2]] # print(p) if(len(set(p))==1): ans.append(s[i]) i+=1 else: if(s[i] not in arr and s[i+1] not in arr and s[i+2] not in arr): ans.append(s[i]) ans.append(s[i+1]) r=" " ans.append(r) i+=2 # print(t) else: ans.append(s[i]) i+=1 for j in range(i,n): ans.append(s[j]) for i in ans: t+=i print(t) ```
output
1
92,304
6
184,609
Provide tags and a correct Python 3 solution for this coding contest problem. Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block. For example: * the following words have typos: "hellno", "hackcerrs" and "backtothefutttture"; * the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo". When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos. Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem. Input The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters. Output Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them. Examples Input hellno Output hell no Input abacaba Output abacaba Input asdfasdf Output asd fasd f
instruction
0
92,305
6
184,610
Tags: dp, greedy, implementation Correct Solution: ``` s=input() if len(s)<=2 or len(set(s))==1: print(s) exit() d={} for i in range(97,123): x=chr(i) if x in ['a','e','i','o','u']: d.update({x:False}) else: d.update({x:True}) l,i=[],0 while True: if i>=len(s)-2: break if d[s[i]]==True and d[s[i+1]]==True and d[s[i+2]]==True: y=s[i]+s[i+1]+s[i+2] if len(set(y))>1: x=s[:i+2] l.append(x) l.append(' ') s=s[i+2:] i=0 else: i=i+1 else: i+=1 if len(s)>0: l.append(s) for i in l: print(i,end='') print() ```
output
1
92,305
6
184,611
Provide tags and a correct Python 3 solution for this coding contest problem. Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block. For example: * the following words have typos: "hellno", "hackcerrs" and "backtothefutttture"; * the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo". When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos. Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem. Input The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters. Output Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them. Examples Input hellno Output hell no Input abacaba Output abacaba Input asdfasdf Output asd fasd f
instruction
0
92,306
6
184,612
Tags: dp, greedy, implementation Correct Solution: ``` symbol = ["a", "e", "i", "o", "u"] a = input() i = 2 while i < len(a): if not (a[i] in symbol) and not(a[i - 1] in symbol) and not (a[i - 2] in symbol) and a[i - 2:i + 1] != a[i - 2] * 3: a = a[:i] + " " + a[i:] i = i + 3 else: i = i + 1 print(a) ```
output
1
92,306
6
184,613
Provide tags and a correct Python 3 solution for this coding contest problem. Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block. For example: * the following words have typos: "hellno", "hackcerrs" and "backtothefutttture"; * the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo". When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos. Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem. Input The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters. Output Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them. Examples Input hellno Output hell no Input abacaba Output abacaba Input asdfasdf Output asd fasd f
instruction
0
92,307
6
184,614
Tags: dp, greedy, implementation Correct Solution: ``` s=input() glas='aeiou' i=1 while i < len(s)-1: if s[i-1] not in glas and s[i] not in glas and s[i+1] not in glas: if s[i-1]!=s[i] or s[i]!=s[i+1] or s[i-1]!=s[i+1]: s=s[:i+1]+' '+s[i+1:] i+=3 continue i+=1 print(s) ```
output
1
92,307
6
184,615
Provide tags and a correct Python 3 solution for this coding contest problem. Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block. For example: * the following words have typos: "hellno", "hackcerrs" and "backtothefutttture"; * the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo". When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos. Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem. Input The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters. Output Print the given word without any changes if there are no typos. If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them. Examples Input hellno Output hell no Input abacaba Output abacaba Input asdfasdf Output asd fasd f
instruction
0
92,308
6
184,616
Tags: dp, greedy, implementation Correct Solution: ``` u = list(input()) n = len(u) a = set(['a', 'o', 'u', 'e', 'i']) p = 0 i = 2 while i < n: if u[i - 2] not in a and u[i - 1] not in a and u[i] not in a: if u[i - 2] != u[i - 1] or u[i - 1] != u[i] or u[i] != u[i - 2]: print(''.join(map(str, u[p:i])), end = ' ') p = i i += 2 else: i += 1 else: i += 1 print(''.join(map(str, u[p:i])), end = '') ```
output
1
92,308
6
184,617