message
stringlengths
2
43.5k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
853
107k
cluster
float64
24
24
__index_level_0__
int64
1.71k
214k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct. Each turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the leftmost or the rightmost stone). When Polycarp destroys the stone it does not exist any more. Now, Polycarp wants two achievements. He gets them if he destroys the stone with the least power and the stone with the greatest power. Help Polycarp find out what is the minimum number of moves he should make in order to achieve his goal. For example, if n = 5 and a = [1, 5, 4, 3, 2], then Polycarp could make the following moves: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the rightmost stone. After this move a = [5, 4, 3]; * Destroy the leftmost stone. After this move a = [4, 3]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Please note that in the example above, you can complete the game in two steps. For example: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the leftmost stone. After this move a = [4, 3, 2]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Input The first line contains an integer t (1 ≀ t ≀ 100). Then t test cases follow. The first line of each test case contains one integer n (2 ≀ n ≀ 100) β€” the number of stones. The second line contains n distinct integers a_1, a_2, …, a_n (1 ≀ a_i ≀ n) β€” the power of the stones. Output For each test case, output the minimum number of moves required to destroy the stones with the greatest and the lowest power. Example Input 5 5 1 5 4 3 2 8 2 1 3 4 5 6 8 7 8 4 2 3 1 8 6 7 5 4 3 4 2 1 4 2 3 1 4 Output 2 4 5 3 2 Submitted Solution: ``` t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) mi = min(a) ma = max(a) if a.index(mi)+a.index(ma)>a[::-1].index(mi)+a[::-1].index(ma): a = a[::-1] if abs(a.index(mi)-a.index(ma)) == 1: print(max(a.index(mi), a.index(ma))+1) else: print(min(max(a.index(mi), a.index(ma))+1, min(a.index(mi),a.index(ma))+ 1 + n - max(a.index(mi), a.index(ma)))) ```
instruction
0
80,189
24
160,378
Yes
output
1
80,189
24
160,379
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct. Each turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the leftmost or the rightmost stone). When Polycarp destroys the stone it does not exist any more. Now, Polycarp wants two achievements. He gets them if he destroys the stone with the least power and the stone with the greatest power. Help Polycarp find out what is the minimum number of moves he should make in order to achieve his goal. For example, if n = 5 and a = [1, 5, 4, 3, 2], then Polycarp could make the following moves: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the rightmost stone. After this move a = [5, 4, 3]; * Destroy the leftmost stone. After this move a = [4, 3]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Please note that in the example above, you can complete the game in two steps. For example: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the leftmost stone. After this move a = [4, 3, 2]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Input The first line contains an integer t (1 ≀ t ≀ 100). Then t test cases follow. The first line of each test case contains one integer n (2 ≀ n ≀ 100) β€” the number of stones. The second line contains n distinct integers a_1, a_2, …, a_n (1 ≀ a_i ≀ n) β€” the power of the stones. Output For each test case, output the minimum number of moves required to destroy the stones with the greatest and the lowest power. Example Input 5 5 1 5 4 3 2 8 2 1 3 4 5 6 8 7 8 4 2 3 1 8 6 7 5 4 3 4 2 1 4 2 3 1 4 Output 2 4 5 3 2 Submitted Solution: ``` for _ in range(int(input())): n = int(input()) l = list(map(int,input().split())) mi,mx = min(l),max(l) l2 =sorted(l) #ll = max(l.index(mi),l.index(mx)) #lr = max(n - l.index(mi),n - l.index(mx)) p1,p2 = l.index(mi)+1, l.index(mx)+1 p3,p4 = n-p1+1,n-p2+1 ll = max(p1,p2) lr = max(p3,p4) lm = min(p1,p3)+min(p2,p4) print(min(lm,ll,lr)) ```
instruction
0
80,190
24
160,380
Yes
output
1
80,190
24
160,381
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct. Each turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the leftmost or the rightmost stone). When Polycarp destroys the stone it does not exist any more. Now, Polycarp wants two achievements. He gets them if he destroys the stone with the least power and the stone with the greatest power. Help Polycarp find out what is the minimum number of moves he should make in order to achieve his goal. For example, if n = 5 and a = [1, 5, 4, 3, 2], then Polycarp could make the following moves: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the rightmost stone. After this move a = [5, 4, 3]; * Destroy the leftmost stone. After this move a = [4, 3]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Please note that in the example above, you can complete the game in two steps. For example: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the leftmost stone. After this move a = [4, 3, 2]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Input The first line contains an integer t (1 ≀ t ≀ 100). Then t test cases follow. The first line of each test case contains one integer n (2 ≀ n ≀ 100) β€” the number of stones. The second line contains n distinct integers a_1, a_2, …, a_n (1 ≀ a_i ≀ n) β€” the power of the stones. Output For each test case, output the minimum number of moves required to destroy the stones with the greatest and the lowest power. Example Input 5 5 1 5 4 3 2 8 2 1 3 4 5 6 8 7 8 4 2 3 1 8 6 7 5 4 3 4 2 1 4 2 3 1 4 Output 2 4 5 3 2 Submitted Solution: ``` t = int(input()) while(t): n = int(input()) a = list(map(int, input().split())) a1 = a[::-1] mx = max(a) mn = min(a) l = len(a) # both from the left for i in range(l): if(a[i] == mn): mn_lb = i+1 if(a[i] == mx): mx_lb = i+1 # both from the right for i in range(l): if(a1[i] == mn): mn_rb = i+1 if(a1[i] == mx): mx_rb = i+1 # min from left max from right for i in range(l): if(a[i] == mn): mn_l1 = i+1 for i in range(l): if(a1[i] == mx): mx_l1 = i+1 # min from right min from left for i in range(l): if(a1[i] == mn): mn_l2 = i+1 for i in range(l): if(a[i] == mx): mx_l2 = i+1 #......................................................................# ans = min(max(mn_lb, mx_lb), max(mn_rb, mx_rb), (mn_l1+mx_l1), (mn_l2+mx_l2)) print(ans) t -= 1 ```
instruction
0
80,191
24
160,382
Yes
output
1
80,191
24
160,383
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct. Each turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the leftmost or the rightmost stone). When Polycarp destroys the stone it does not exist any more. Now, Polycarp wants two achievements. He gets them if he destroys the stone with the least power and the stone with the greatest power. Help Polycarp find out what is the minimum number of moves he should make in order to achieve his goal. For example, if n = 5 and a = [1, 5, 4, 3, 2], then Polycarp could make the following moves: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the rightmost stone. After this move a = [5, 4, 3]; * Destroy the leftmost stone. After this move a = [4, 3]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Please note that in the example above, you can complete the game in two steps. For example: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the leftmost stone. After this move a = [4, 3, 2]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Input The first line contains an integer t (1 ≀ t ≀ 100). Then t test cases follow. The first line of each test case contains one integer n (2 ≀ n ≀ 100) β€” the number of stones. The second line contains n distinct integers a_1, a_2, …, a_n (1 ≀ a_i ≀ n) β€” the power of the stones. Output For each test case, output the minimum number of moves required to destroy the stones with the greatest and the lowest power. Example Input 5 5 1 5 4 3 2 8 2 1 3 4 5 6 8 7 8 4 2 3 1 8 6 7 5 4 3 4 2 1 4 2 3 1 4 Output 2 4 5 3 2 Submitted Solution: ``` import sys inputlines=sys.stdin.readlines() number_of_testcase=int(inputlines[0]) def find_index_of_min_and_max_element(input_array,length): # all the elements are distinct min_index=0 max_index=0 max=input_array[0] min=input_array[0] for i in range(1,length): if input_array[i]>max: max_index=i max=input_array[max_index] if input_array[i]<min: min_index=i min=input_array[min_index] #print(max_index,min_index) return max_index,min_index for i in range(number_of_testcase): number_of_elements=int(inputlines[2*i+1]) elements=list(map(int,inputlines[2*i+2].split(' '))) max_index,min_index=find_index_of_min_and_max_element(elements,number_of_elements) positons_list=[] positons_list.extend([max_index+1,number_of_elements-max_index,min_index+1,number_of_elements-min_index]) #print(positons_list) position_maxindex,position_minindex=find_index_of_min_and_max_element(positons_list,4) similar_index_to_positon_minindex=(position_minindex+2)%4 positons_list[similar_index_to_positon_minindex]-=positons_list[position_minindex] first_deletion=positons_list.pop(position_minindex) second_deletion=min(positons_list) print(first_deletion+second_deletion) ```
instruction
0
80,192
24
160,384
Yes
output
1
80,192
24
160,385
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct. Each turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the leftmost or the rightmost stone). When Polycarp destroys the stone it does not exist any more. Now, Polycarp wants two achievements. He gets them if he destroys the stone with the least power and the stone with the greatest power. Help Polycarp find out what is the minimum number of moves he should make in order to achieve his goal. For example, if n = 5 and a = [1, 5, 4, 3, 2], then Polycarp could make the following moves: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the rightmost stone. After this move a = [5, 4, 3]; * Destroy the leftmost stone. After this move a = [4, 3]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Please note that in the example above, you can complete the game in two steps. For example: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the leftmost stone. After this move a = [4, 3, 2]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Input The first line contains an integer t (1 ≀ t ≀ 100). Then t test cases follow. The first line of each test case contains one integer n (2 ≀ n ≀ 100) β€” the number of stones. The second line contains n distinct integers a_1, a_2, …, a_n (1 ≀ a_i ≀ n) β€” the power of the stones. Output For each test case, output the minimum number of moves required to destroy the stones with the greatest and the lowest power. Example Input 5 5 1 5 4 3 2 8 2 1 3 4 5 6 8 7 8 4 2 3 1 8 6 7 5 4 3 4 2 1 4 2 3 1 4 Output 2 4 5 3 2 Submitted Solution: ``` import sys import bisect import math #import itertools def get_line(): return list(map(int, sys.stdin.readline().strip().split())) def in1(): return int(input()) for _ in range(in1()): n=in1() a=get_line() t1=a.index(n) t2=a.index(1) if n%2==0: t3 = n // 2 if t1<=t3 and t2<=t3: print(max(t1,t2)+1) elif t1>=t3 and t2>=t3: print((n-1)-min(t1,t2)+1) elif t1<=t3 and t2>=t3: print(t1+1+(n)-t2) else: print((n)-t1+1+t2) else: t3=n//2 if t1<=t3 and t2<=t3: print(max(t1,t2)+1) elif t1>=t3 and t2>=t3: print((n-1)-min(t1,t2)+1) elif t1<t3 and t2>t3: print(t1+1+(n)-t2) else: print((n)-t1+1+t2) ```
instruction
0
80,193
24
160,386
No
output
1
80,193
24
160,387
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct. Each turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the leftmost or the rightmost stone). When Polycarp destroys the stone it does not exist any more. Now, Polycarp wants two achievements. He gets them if he destroys the stone with the least power and the stone with the greatest power. Help Polycarp find out what is the minimum number of moves he should make in order to achieve his goal. For example, if n = 5 and a = [1, 5, 4, 3, 2], then Polycarp could make the following moves: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the rightmost stone. After this move a = [5, 4, 3]; * Destroy the leftmost stone. After this move a = [4, 3]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Please note that in the example above, you can complete the game in two steps. For example: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the leftmost stone. After this move a = [4, 3, 2]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Input The first line contains an integer t (1 ≀ t ≀ 100). Then t test cases follow. The first line of each test case contains one integer n (2 ≀ n ≀ 100) β€” the number of stones. The second line contains n distinct integers a_1, a_2, …, a_n (1 ≀ a_i ≀ n) β€” the power of the stones. Output For each test case, output the minimum number of moves required to destroy the stones with the greatest and the lowest power. Example Input 5 5 1 5 4 3 2 8 2 1 3 4 5 6 8 7 8 4 2 3 1 8 6 7 5 4 3 4 2 1 4 2 3 1 4 Output 2 4 5 3 2 Submitted Solution: ``` def stone(arr): minIndex = arr.index(min(arr)) maxIndex = arr.index(max(arr)) length = len(arr) maxofboth = max(minIndex, maxIndex) minofboth = min(minIndex, maxIndex) if maxofboth <= length // 2: return maxofboth + 1 if minofboth >= length // 2: return length - minofboth return minofboth + length - maxofboth + 1 for _ in range(int(input())): input() print(stone([int(x) for x in input().split()])) ```
instruction
0
80,194
24
160,388
No
output
1
80,194
24
160,389
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct. Each turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the leftmost or the rightmost stone). When Polycarp destroys the stone it does not exist any more. Now, Polycarp wants two achievements. He gets them if he destroys the stone with the least power and the stone with the greatest power. Help Polycarp find out what is the minimum number of moves he should make in order to achieve his goal. For example, if n = 5 and a = [1, 5, 4, 3, 2], then Polycarp could make the following moves: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the rightmost stone. After this move a = [5, 4, 3]; * Destroy the leftmost stone. After this move a = [4, 3]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Please note that in the example above, you can complete the game in two steps. For example: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the leftmost stone. After this move a = [4, 3, 2]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Input The first line contains an integer t (1 ≀ t ≀ 100). Then t test cases follow. The first line of each test case contains one integer n (2 ≀ n ≀ 100) β€” the number of stones. The second line contains n distinct integers a_1, a_2, …, a_n (1 ≀ a_i ≀ n) β€” the power of the stones. Output For each test case, output the minimum number of moves required to destroy the stones with the greatest and the lowest power. Example Input 5 5 1 5 4 3 2 8 2 1 3 4 5 6 8 7 8 4 2 3 1 8 6 7 5 4 3 4 2 1 4 2 3 1 4 Output 2 4 5 3 2 Submitted Solution: ``` from math import sqrt data_samples = int(input()) for i in range(0, data_samples): amount = int(input()) a = list(map(int, input().split())) min_num_ind = "" ind = -1 ans = 0 for char in a: ind += 1 if min_num_ind == "": min_num_ind = ind max_num_ind = ind minimum = char maximum = char elif char > maximum: maximum = char max_num_ind = ind elif char < minimum: minimum = char min_num_ind = ind #print(minimum, maximum, max_num_ind, min_num_ind) range_to_lowest = min_num_ind - (amount / 2) if range_to_lowest < 0: ans += min_num_ind + 1 a = a[min_num_ind + 1:] elif range_to_lowest >= 0: ans += amount - min_num_ind a = a[:len(a)-ans] here = 0 ind = -1 for char in a: ind += 1 if char == maximum: here = 1 max_num_ind = ind break if here == 1: range_to_highest = max_num_ind - (len(a) / 2) if range_to_highest < 0: ans += max_num_ind + 1 elif range_to_highest >= 0: ans += len(a) - max_num_ind print(ans) ```
instruction
0
80,195
24
160,390
No
output
1
80,195
24
160,391
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct. Each turn Polycarp can destroy either stone on the first position or stone on the last position (in other words, either the leftmost or the rightmost stone). When Polycarp destroys the stone it does not exist any more. Now, Polycarp wants two achievements. He gets them if he destroys the stone with the least power and the stone with the greatest power. Help Polycarp find out what is the minimum number of moves he should make in order to achieve his goal. For example, if n = 5 and a = [1, 5, 4, 3, 2], then Polycarp could make the following moves: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the rightmost stone. After this move a = [5, 4, 3]; * Destroy the leftmost stone. After this move a = [4, 3]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Please note that in the example above, you can complete the game in two steps. For example: * Destroy the leftmost stone. After this move a = [5, 4, 3, 2]; * Destroy the leftmost stone. After this move a = [4, 3, 2]. Polycarp destroyed the stones with the greatest and least power, so he can end the game. Input The first line contains an integer t (1 ≀ t ≀ 100). Then t test cases follow. The first line of each test case contains one integer n (2 ≀ n ≀ 100) β€” the number of stones. The second line contains n distinct integers a_1, a_2, …, a_n (1 ≀ a_i ≀ n) β€” the power of the stones. Output For each test case, output the minimum number of moves required to destroy the stones with the greatest and the lowest power. Example Input 5 5 1 5 4 3 2 8 2 1 3 4 5 6 8 7 8 4 2 3 1 8 6 7 5 4 3 4 2 1 4 2 3 1 4 Output 2 4 5 3 2 Submitted Solution: ``` t = int(input()) for _ in range(t): n = int(input()) arr = list(map(int,input().split())) mi = min(arr) + 1 ma = max(arr) + 1 a = max(mi,ma) b = max(n - mi,n-ma) + 1 c = min(mi,ma) + n-max(mi,ma) + 1 print(min(a,min(b,c))) ```
instruction
0
80,196
24
160,392
No
output
1
80,196
24
160,393
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO
instruction
0
80,370
24
160,740
Tags: brute force, math, number theory, strings Correct Solution: ``` import sys input = sys.stdin.readline I = lambda : list(map(int,input().split())) n=input()[:-1] a,b=I() l=[];d=[-1]*len(n) a1=b1=0;po=0;x=str(n) le=len(x) for i in x: i=int(i);mu=pow(10,po,b) a1=(a1*10+i)%a;b1=(b1+int(x[le-po-1])*mu)%b l.append(a1);d[le-po-1]=b1 po+=1 for i in range(le-1): if x[i+1]!='0' and l[i]==0 and d[i+1]==0: print("YES") print(x[:i+1]) print(x[i+1:]);break else: print("NO") ```
output
1
80,370
24
160,741
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO
instruction
0
80,371
24
160,742
Tags: brute force, math, number theory, strings Correct Solution: ``` from math import pow s=list(input()) a,b=map(int,input().split()) l=len(s) s1=[0]*(l+1) s2=[0]*(l+1) for i in range(l): s[i]=ord(s[i])-ord('0') p=1 for i in range(l-1,-1,-1): s1[i]=(s1[i+1]+s[i]*p)%b p=(p*10)%b p=0 for i in range(l-1): p=(p*10+s[i])%a if p==0 and s1[i+1]==0 and s[i+1]: print("YES") print(''.join(map(str,s[:i+1]))) print(''.join(map(str,s[i+1:]))) exit() print("NO") ```
output
1
80,371
24
160,743
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO
instruction
0
80,372
24
160,744
Tags: brute force, math, number theory, strings Correct Solution: ``` def main(): s, x, pfx = input(), 0, [] a, b = map(int, input().split()) try: for i, c in enumerate(s, 1): x = (x * 10 + int(c)) % a if not x and s[i] != '0': pfx.append(i) #print(c,ord(c) - 48) except IndexError: pass x, p, i = 0, 1, len(s) for j in reversed(pfx): for i in range(i - 1, j - 1, -1): x = (x + (int(s[i])) * p) % b p = p * 10 % b if not x: print("YES") print(s[:i]) print(s[i:]) return print("NO") if __name__ == '__main__': main() ```
output
1
80,372
24
160,745
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO
instruction
0
80,373
24
160,746
Tags: brute force, math, number theory, strings Correct Solution: ``` l = input() a,b = input().split() a = int(a) b= int(b) n = len(l) ra = [] rb = [0]*n nn = "" f = 0 p = 1 ra.append(int(l[0])%a) rb[n-1] = (int(l[n-1])%b) for i in range(1,n-1): ra.append((ra[i-1]*10+int(l[i]))%a) for i in range(n-2,-1,-1): rb[i] = (rb[i+1] + (int(l[i])*p*10)%b)%b p = (p*10)%b st = "" for i in range(n-1): if(ra[i] ==0 and rb[i+1] == 0 and l[i+1] != "0"): print("YES") st += str(''.join(l[:i+1]))+"\n" st += str(''.join(l[i+1:n])) break if(len(st)== 0): print("NO") else: print(st) ```
output
1
80,373
24
160,747
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO
instruction
0
80,374
24
160,748
Tags: brute force, math, number theory, strings Correct Solution: ``` def main(): string = input() a,b = list(map(int,input().split())) forward = [-1]*len(string) backward = [-1]*len(string) x=1 for i in range(len(string)): cur = int(string[i]) j = len(string) - i - 1 curBack = int(string[j]) if i==0: forward[i] = cur%a backward[j] = curBack%b else: forward[i] = ((forward[i-1]*10)%a + cur%a)%a backward[j] = (backward[j+1] + (curBack*x)%b)%b x=(x*10)%b done = 0 for i in range(len(string)-1): leftMod = forward[i] rightMod = backward[i+1] if leftMod==0 and rightMod ==0 and int(string[i+1])!=0: print("YES") print(string[:i+1]) print(string[i+1:]) done = 1 break if done==0: print("NO") # print(forward) # print(backward) main() ```
output
1
80,374
24
160,749
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO
instruction
0
80,375
24
160,750
Tags: brute force, math, number theory, strings Correct Solution: ``` l = input() a,b = input().split() a = int(a) b= int(b) n = len(l) ra = [] rb = [0]*n nn = "" f = 0 p = 1 ra.append(int(l[0])%a) rb[n-1] = (int(l[n-1])%b) for i in range(1,n-1): ra.append((ra[i-1]*10+int(l[i]))%a) for i in range(n-2,-1,-1): rb[i] = (rb[i+1] + (int(l[i])*p*10)%b)%b p = (p*10)%b for i in range(n-1): if(ra[i] ==0 and rb[i+1] == 0 and l[i+1] != "0"): print("YES") print(l[:i+1]) print(l[i+1:n]) f = 1 break if(f== 0): print("NO") ```
output
1
80,375
24
160,751
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO
instruction
0
80,376
24
160,752
Tags: brute force, math, number theory, strings Correct Solution: ``` import sys from math import log2,floor,ceil,sqrt # import bisect # from collections import deque # from types import GeneratorType # def bootstrap(func, stack=[]): # def wrapped_function(*args, **kwargs): # if stack: # return func(*args, **kwargs) # else: # call = func(*args, **kwargs) # while True: # if type(call) is GeneratorType: # stack.append(call) # call = next(call) # else: # stack.pop() # if not stack: # break # call = stack[-1].send(call) # return call # return wrapped_function Ri = lambda : [int(x) for x in sys.stdin.readline().split()] ri = lambda : sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') INF = 10 ** 18 MOD = 10**9+7 s = ri() n = len(s) dp1 = [0]*(n+1) dp2 = [0]*(n+1) a,b = Ri() for i in range(n): dp1[i+1] = ((dp1[i]*10)%a + int(s[i]))%a p = 1 for i in range(n-1,-1,-1): dp2[i] = (dp2[i+1] + (p * int(s[i]) ) %b ) %b p = (p * 10)%b flag = -1 for i in range(0,n-1): if s[i+1] != '0' and dp1[i+1] == 0 and dp2[i+1] == 0: flag = i break if flag != -1: YES() print(s[:flag+1]) print(s[flag+1: ]) else: NO() ```
output
1
80,376
24
160,753
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO
instruction
0
80,377
24
160,754
Tags: brute force, math, number theory, strings Correct Solution: ``` # import sys # sys.stdin = open("F:\\Scripts\\input","r") # sys.stdout = open("F:\\Scripts\\output","w") MOD = 10**9 + 7 I = lambda:list(map(int,input().split())) s = input() a , b = I() n = len(s) x = [0]*n y = [0]*n x[0] = int(s[0])%a y[n - 1] = int(s[n - 1])%b p = 10%b for i in range(1,n): x[i] = (x[i-1]*10 + int(s[i]))%a y[n - i - 1] = (int(s[n - i - 1])*p + y[n - i])%b p *=10 p %= b for i in range(n-1): if not x[i] and not y[i+1] and (s[i+1] != '0'): print("YES",s[:i+1],s[i+1:],sep = '\n') break else: print("NO") ```
output
1
80,377
24
160,755
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO Submitted Solution: ``` #Run code in language PyPy2 #change input() in Python 3 become raw_input() like python2 then submit #Add this code prefix of your code import atexit import io import sys buff = io.BytesIO() sys.stdout = buff @atexit.register def write(): sys.__stdout__.write(buff.getvalue()) # code R = raw_input n = str(R()) a,b = map(int,R().split()) def rig(): ar = [] ar.append(0) q = 1 for i in n[::-1]: ar.append((ar[-1]%b+q*(ord(i)&15)%b)%b) q = q*10%b return ar def lef(): ar = [] ar.append(0) for i in range(0,len(n)): ar.append(((ar[-1]*10)%a+(ord(n[i])&15)%a)%a) return ar def res(): x = lef() y = rig() for i in range(1,len(n)): if(x[i]+y[~(i)]<1 and i < len(n) and n[i]>'0'): return "YES\n%s\n%s"%(n[:(i)],n[(i):]) return "NO" print(res()) ```
instruction
0
80,378
24
160,756
Yes
output
1
80,378
24
160,757
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO Submitted Solution: ``` import os import sys from io import BytesIO, IOBase import math def main(): pass # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") def exponentiation(bas, exp,N): t = 1 while (exp > 0): if (exp % 2 != 0): t = (t * bas) % N bas = (bas * bas) % N exp = int(exp / 2) return t % N s=input() a,b=map(int,input().split()) pre=[0] suf=[0] n=len(s) for i in range(0,n): v=int(s[i]) pre.append((v+pre[i]*10)%a) tp=1 for i in range(n-1,-1,-1): v = int(s[i]) suf.append((v*tp+suf[n-i-1])%b) tp=(tp*10)%b #print(pre,suf) pre.pop() pre.pop(0) suf.pop() suf.pop(0) suf.reverse() #print(pre,suf) ci=-1 for i in range(0,n-1): if pre[i]==0 and suf[i]==0: if s[i+1]!='0': ci=i+1 break if ci==-1: print("NO") else: print("YES") print(s[:ci]+"\n"+s[ci:]) ```
instruction
0
80,379
24
160,758
Yes
output
1
80,379
24
160,759
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO Submitted Solution: ``` import sys #sys.stdin, sys.stdout = open("input.txt", "r"), open("output.txt", "w") s = input() n = len(s) a, b = map(int, input().split()) pref, suff = [0] * n, [0] * n curr = 0 for i in range(n): pref[i] = ((curr * 10) % a + int(s[i])) % a curr = pref[i] curr = 0 for i in reversed(range(n)): suff[i] = ((int(s[i]) * pow(10, n - i - 1, b)) % b + curr) % b curr = suff[i] for i in range(n-1): if pref[i] == suff[i+1] == 0 and s[i+1] != '0': print("YES") print(s[:i+1]) print(s[i+1:]) exit(0) print("NO") ```
instruction
0
80,380
24
160,760
Yes
output
1
80,380
24
160,761
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO Submitted Solution: ``` s = input() a, b = map(int, input().split()) n = len(s) flag = 0 p = 0 pfx = [] for i,c in enumerate(s, 1): p = (p * 10 + int(c))%a if(i < n and p == 0 and s[i] != '0'): pfx.append(i) q = 0 p = 1 i = len(s) for j in reversed(pfx): for i in range(i-1, j -1, -1): q = (q + int(s[i]) * p) % b p = p * 10 % b if not q: print("YES") print(s[:i]) print(s[i:]) exit() print("NO") ```
instruction
0
80,381
24
160,762
Yes
output
1
80,381
24
160,763
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO Submitted Solution: ``` #zdelano dobrim chelovekom vnizy :D s, x, pfx = input(), 0, [] a, b = map(int, input().split()) try: for i, c in enumerate(s, 1): x = (x * 10 + ord(c)-48 ) % a if not x and s[i] != '0': pfx.append(i) except IndexError: pass x, p, i = 0, 1, len(s) for stop in reversed(pfx): for i in range(i - 1, stop - 1, -1): x = (x + (ord(s[i])-48) * p) % b p = p * 10 % b if not x: print("YES") print(s[:i]) print(s[i:]) exit() print("NO") ```
instruction
0
80,382
24
160,764
Yes
output
1
80,382
24
160,765
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO Submitted Solution: ``` n=input() a,b=input().split() a=int(a) b=int(b) pos_k=0 output_k=0 output_l=0 k=0 number=0 while k<len(n): number=(number*10)+int(n[k]) if number%a==0: pos_k=k output_k=number k=k+1 k=pos_k+1 number=0 while k<len(n): number=(number*10)+int(n[k]) if number%b==0: output_l=number k=k+1 if number==0: print('No') else: print("YES") print(output_k) print(output_l) ```
instruction
0
80,383
24
160,766
No
output
1
80,383
24
160,767
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO Submitted Solution: ``` n=list(map(int,list(input()))) a,b=map(int,input().split()) x=n[0] res=[-1]*len(n) for i in range(1,len(n)): if(x%a==0): res[i-1]=0 x=x*10+n[i] # print(res) flag=-1 x=n[-1] for i in range(len(n)-2,-1,-1): if(int(x)!=0 and int(x)%b==0): if(i>0 and res[i-1]==0): # print(i) flag=i break x=str(n[i])+str(x) if(flag==-1): print("NO") else: r1,r2=0,0 print("YES") for i in range(0,flag): r1=r1*10+n[i] for i in range(flag,len(n)): r2=r2*10+n[i] print(r1) print(r2) ```
instruction
0
80,384
24
160,768
No
output
1
80,384
24
160,769
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO Submitted Solution: ``` s = input() n,m = map(int, input().split()) l = len(s) a,p1,p2 = 0,0,0 f = 1 for i in range(l): a = a*10%n + int(s[i])%n a = a%n if a==0: p1=i f=0 #print(a) elif f==0 and a!=0: break a = 0 for i in range(p1+1,l): a = a*10%m + int(s[i])%m a = a%m if a==0: p2=i if p2+1<l: print("NO") exit() if p2==0: print("NO") exit() print(s[:p1+1]) print(s[p1+1:]) ```
instruction
0
80,385
24
160,770
No
output
1
80,385
24
160,771
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long integer which may consist of even a million digits! Polycarpus needs to find such a way to cut the public key into two nonempty parts, that the first (left) part is divisible by a as a separate number, and the second (right) part is divisible by b as a separate number. Both parts should be positive integers that have no leading zeros. Polycarpus knows values a and b. Help Polycarpus and find any suitable method to cut the public key. Input The first line of the input contains the public key of the messenger β€” an integer without leading zeroes, its length is in range from 1 to 106 digits. The second line contains a pair of space-separated positive integers a, b (1 ≀ a, b ≀ 108). Output In the first line print "YES" (without the quotes), if the method satisfying conditions above exists. In this case, next print two lines β€” the left and right parts after the cut. These two parts, being concatenated, must be exactly identical to the public key. The left part must be divisible by a, and the right part must be divisible by b. The two parts must be positive integers having no leading zeros. If there are several answers, print any of them. If there is no answer, print in a single line "NO" (without the quotes). Examples Input 116401024 97 1024 Output YES 11640 1024 Input 284254589153928171911281811000 1009 1000 Output YES 2842545891539 28171911281811000 Input 120 12 1 Output NO Submitted Solution: ``` ''' 116401024 97 1024 ''' s=input().rstrip() x=list(s) o=input().rstrip().split(' ') AA=int(o[0]) BB=int(o[1]) G=0; for i in range(1,len(x)-1): A=''.join(x[0:i]) B=''.join(x[i:]) if int(A)%AA==0 and int(B)%BB==0 and int(A[0])!=0 and int(B[0])!=0: G=1; break; if G==0: print("NO") else: print("YES") print(A) print(B) ```
instruction
0
80,386
24
160,772
No
output
1
80,386
24
160,773
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02
instruction
0
80,853
24
161,706
Tags: implementation Correct Solution: ``` h1,m1=map(int , input().split(":")) h2,m2=map(int , input().split(":")) if(m1>m2): m_diff=(h2-h1-1)*60+60-m1+m2 else: m_diff=(h2-h1)*60+abs(m2-m1) #print(m_diff) m_diff=m_diff//2 hr=m_diff//60 miin=m_diff%60 h=h1+hr m=m1+miin if(m>=60): if(m==60): h=h+1 m11="00" if(m>60): h=h+1 m=m-60 m11=str(m) else: m11=str(m) if(m==0 or m==1 or m==2 or m==3 or m==4 or m==5 or m==6 or m==7 or m==8 or m==9 ): if(m==1): m11="01" if(m==2): m11="02" if(m==3): m11="03" if(m==4): m11="04" if(m==5): m11="05" if(m==6): m11="06" if(m==7): m11="07" if(m==8): m11="08" if(m==9): m11="09" if(m==0): m11="00" if(h==0 or h==1 or h==2 or h==3 or h==4 or h==5 or h==6 or h==7 or h==8 or h==9 ): if(h==1): h11="01" if(h==2): h11="02" if(h==3): h11="03" if(h==4): h11="04" if(h==5): h11="05" if(h==6): h11="06" if(h==7): h11="07" if(h==8): h11="08" if(h==9): h11="09" if(h==0): h11="00" else: h11=str(h) print(h11,end="") print(":",end="") print(m11,end="") ```
output
1
80,853
24
161,707
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02
instruction
0
80,854
24
161,708
Tags: implementation Correct Solution: ``` h1,m1=map(int,input().split(':')) h2,m2=map(int,input().split(':')) tmin=((h2*60+m2)-(h1*60+m1)) h3=h1+(m1+tmin//2)//60 m3=(m1+tmin//2)%60 h3='0'+str(h3) if len(str(h3))==1 else str(h3) m3='0'+str(m3) if len(str(m3))==1 else str(m3) print(h3+':'+m3) ```
output
1
80,854
24
161,709
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02
instruction
0
80,855
24
161,710
Tags: implementation Correct Solution: ``` a = input() b = input() arr = [0] * 5 brr = [0] * 5 i = -1 for char in a: i += 1 arr[i] = char i = -1 for char in b: i += 1 brr[i] = char c = (int(arr[0] + arr[1]) + int(brr[0] + brr[1]))//2 g = (int(arr[3] + arr[4]) + int(brr[3] + brr[4]))/2 if (int(arr[0] + arr[1]) + int(brr[0] + brr[1]))%2 > 0: g += 30 if g >= 60: c += 1 g -= 60 g = int(g) if c < 10: c = str(0) + str(c) if g < 10: g = str(0) + str(g) print(c,":",g,sep ='') ```
output
1
80,855
24
161,711
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02
instruction
0
80,856
24
161,712
Tags: implementation Correct Solution: ``` while(True): try: a,b=map(int,input().split(":")) c,d=map(int,input().split(":")) except EOFError: break x=a*60+b y=c*60+d br=(y-x)//2 # print(x,y,br) h=a+br//60 m=b+br%60 if(m>=60): m=m%60 h+=1 if(len(str(h))==2 and len(str(m))==2): print("{}:{}".format(h,m)) else: if(len(str(h))==1 and len(str(m))==2): print("0{}:{}".format(h,m)) elif(len(str(m))==1 and len(str(h))==2): print("{}:0{}".format(h,m)) else: print("0{}:0{}".format(h,m)) ```
output
1
80,856
24
161,713
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02
instruction
0
80,857
24
161,714
Tags: implementation Correct Solution: ``` h1,m1 = map(int,input().split(':')) h2,m2 = map(int,input().split(':')) time = 0 if m2 - m1 < 0: time = 60 + (m2 - m1) if h2>h1: x = (h2-h1)-1 else: x=0 time+=x*60 else: time = m2 - m1 time+=(h2-h1)*60 time//=2 diff = time//60 remain = time%60 if m1+remain >=60: m1+=remain m1-=60 h1+=diff+1 else: m1+=remain h1+=diff if h1<10: h1='0'+str(h1) else: h1=str(h1) if m1<10: m1='0'+str(m1) else: m1=str(m1) z = h1+":"+m1 print(z) ```
output
1
80,857
24
161,715
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02
instruction
0
80,858
24
161,716
Tags: implementation Correct Solution: ``` hour1, minu1 = map(str,input().split(':')) hour2, minu2 = map(str,input().split(':')) rez = ((int(hour2)-int(hour1))*60+int(minu2)-int(minu1))//2 newh = int(hour1)+rez//60+(int(minu1)+rez%60)//60 if newh<10: newh = '0'+str(newh) newm = (int(minu1)+rez%60)%60 if newm<10: newm = '0'+str(newm) print(newh,':',newm,sep='') ```
output
1
80,858
24
161,717
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02
instruction
0
80,859
24
161,718
Tags: implementation Correct Solution: ``` h1,m1=input().split(':') h2,m2=input().split(':') ih1=int(h1) ih2=int(h2) im1=int(m1) im2=int(m2) min1=60*ih1+im1 min2=60*ih2+im2 minT=(min1+min2)/2 if(minT/60<10): if(minT%60<10): print("0{}:0{}".format(int(minT/60),int(minT%60))) else: print("0{}:{}".format(int(minT/60),int(minT%60))) else: if(minT%60<10): print("{}:0{}".format(int(minT/60),int(minT%60))) else: print("{}:{}".format(int(minT/60),int(minT%60))) ```
output
1
80,859
24
161,719
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02
instruction
0
80,860
24
161,720
Tags: implementation Correct Solution: ``` a=input().split(':') b=input().split(':') min1=int(a[0])*60+int(a[1]) min2=int(b[0])*60+int(b[1]) middle=(min1+min2)//2 hr=middle//60 mini=middle%60 if hr<10: print('0'+str(hr)+':',end='') else: print(str(hr)+':',end='') if mini<10: print('0'+str(mini)) else: print(mini) ```
output
1
80,860
24
161,721
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02 Submitted Solution: ``` import sys import math #to read string get_string = lambda: sys.stdin.readline().strip() #to read list of integers get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) ) #to read non spaced string and elements are integers to list of int get_intList_from_str = lambda: list(map(int,list(sys.stdin.readline().strip()))) #to read non spaced string and elements are character to list of character get_charList_from_str = lambda: list(sys.stdin.readline().strip()) #get word sepetared list of character get_char_list = lambda: sys.stdin.readline().strip().split() #to read integers get_int = lambda: int(sys.stdin.readline()) #to print faster pt = lambda x: sys.stdout.write(str(x)) #--------------------------------WhiteHat010--------------------------------# a = list(map(int,input().split(':'))) b = list(map(int,input().split(':'))) s = (a[0]*60 + b[0]*60 + a[1] + b[1])//2 hour = str(s//60) if len(hour) == 1: hour = '0'+hour minu = str(s%60) if len(minu) == 1: minu = '0'+minu print( hour + ':' + minu) ```
instruction
0
80,861
24
161,722
Yes
output
1
80,861
24
161,723
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02 Submitted Solution: ``` import sys read = lambda: list(map(int, sys.stdin.readline().strip().split())) import bisect s1 = input() s2 = input() h1 = int(s1[0:2]) m1 = int(s1[3:]) h2 = int(s2[0:2]) m2 = int(s2[3:]) h = (h2+h1)//2 m = (m2+m1)//2 if (h2-h1)%2 == 1: m += 30 #print(h, m) if m >= 60: h += 1 m -= 60 if h <10: print("0{}".format(h), end='') else: print(h, end='') print(":",end='') if m < 10: print("0{}".format(m)) else: print(m) ```
instruction
0
80,862
24
161,724
Yes
output
1
80,862
24
161,725
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02 Submitted Solution: ``` while True: try: ha = input() hb = input() h1, m1 = list(map(int, ha.split(":"))) h2, m2 = list(map(int, hb.split(":"))) h1m = h1 * 60 + m1 h2m = h2 * 60 + m2 hmm = int(h1m + ((h2m - h1m) / 2)) hm = int(hmm / 60) mm = int(hmm % 60) hm = "0" + str(hm) if hm < 10 else str(hm) mm = "0" + str(mm) if mm < 10 else str(mm) print(hm + ":" + mm) except EOFError: break ```
instruction
0
80,863
24
161,726
Yes
output
1
80,863
24
161,727
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02 Submitted Solution: ``` h1,m1=map(int,input().split(':')) h2,m2=map(int,input().split(':')) l1=h1*60+m1 l2=h2*60+m2 n=(l1+l2)/2 h=int(int(n)/60) m=int(int(n)%60) print(format(h, '02')+':'+format(m, '02')) ```
instruction
0
80,864
24
161,728
Yes
output
1
80,864
24
161,729
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02 Submitted Solution: ``` #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 13 11:07:20 2019 @author: lanliu """ a = [] for i in range(2): str_in = input() for j in range(len(str_in)): if str_in[j].isdigit(): a.append(int(str_in[j])) starttime_h = a[0]*10+a[1] starttime_m = a[2]*10+a[3] endtime_h = a[4]*10+a[5] endtime_m = a[6]*10+a[7] interval = (endtime_h*60+endtime_m-starttime_h*60-starttime_m)/2 mins = int(starttime_m+interval%60) if mins == 0: mins = '00' else: mins = str(mins) print(str(int(starttime_h+interval/60))+":"+mins) """ Time_0 = (a[0][0]*10 + a[0][1])*60 + a[0][2]*10 + a[0][3] Time_1 = (a[1][0]*10 + a[1][1])*60 + a[1][2]*10 + a[1][3] Interval = (int(Time_1) - int(Time_0))/2 """ ```
instruction
0
80,865
24
161,730
No
output
1
80,865
24
161,731
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02 Submitted Solution: ``` h1,m1=map(int,input().split(':')) h2,m2=map(int,input().split(':')) d=h1+h2 h3='0'+str(d//2) if len(str(d//2))==1 else str(d//2) m3='' if m1==m2: if d&1: m3=str((m1+m2+60)//2) else: m3=str(m1) if len(str(m1))!=1 else '0'+str(m1) else: m3=str((m1+m2)//2) print(h3+':'+m3) ```
instruction
0
80,866
24
161,732
No
output
1
80,866
24
161,733
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02 Submitted Solution: ``` h1,m1=map(int,input().split(":")) h2,m2=map(int,input().split(":")) m=((h2-h1)*60+m2-m1)//2 h3=m//60+h1 m3=m%60+m1 if h3<10: print(0,end="") print(h3,end=":") else: print(h3,end=":") if m3<10: print(0,end="") print(m3) else: print(m3) ```
instruction
0
80,867
24
161,734
No
output
1
80,867
24
161,735
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp is going to participate in the contest. It starts at h_1:m_1 and ends at h_2:m_2. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Polycarp wants to know the time of the midpoint of the contest. For example, if the contest lasts from 10:00 to 11:00 then the answer is 10:30, if the contest lasts from 11:10 to 11:12 then the answer is 11:11. Input The first line of the input contains two integers h_1 and m_1 in the format hh:mm. The second line of the input contains two integers h_2 and m_2 in the same format (hh:mm). It is guaranteed that 0 ≀ h_1, h_2 ≀ 23 and 0 ≀ m_1, m_2 ≀ 59. It is guaranteed that the contest lasts an even number of minutes (i.e. m_1 \% 2 = m_2 \% 2, where x \% y is x modulo y). It is also guaranteed that the entire contest is held during a single day. And finally it is guaranteed that the contest lasts at least two minutes. Output Print two integers h_3 and m_3 (0 ≀ h_3 ≀ 23, 0 ≀ m_3 ≀ 59) corresponding to the midpoint of the contest in the format hh:mm. Print each number as exactly two digits (prepend a number with leading zero if needed), separate them with ':'. Examples Input 10:00 11:00 Output 10:30 Input 11:10 11:12 Output 11:11 Input 01:02 03:02 Output 02:02 Submitted Solution: ``` first_line = input() second_line = input() h1 = int(first_line.split(':')[0]) m1 = int(first_line.split(':')[1]) h2 = int(second_line.split(':')[0]) m2 = int(second_line.split(':')[1]) h3 = h2 - h1 m3 = m2 - m1 time_to_add_h = round(h3 / 2) time_to_add_m = round(m3 / 2) if h3 == 1: time_to_add_h = 0 time_to_add_m += 30 result_h = h1 + time_to_add_h result_m = m1 + time_to_add_m if result_h < 10: result_h = "0" + str(result_h) if result_m < 10: result_m = "0" + str(result_m) print(str(result_h) + ":" + str(result_m)) ```
instruction
0
80,868
24
161,736
No
output
1
80,868
24
161,737
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j (1 ≀ j ≀ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+2}="two". For example: * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"), * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time. For example, if the string looks like s="onetwone", then if Polycarp selects two indices 3 and 6, then "onetwone" will be selected and the result is "ontwne". What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be? Input The first line of the input contains an integer t (1 ≀ t ≀ 10^4) β€” the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string s. Its length does not exceed 1.5β‹…10^5. The string s consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5β‹…10^6. Output Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain r (0 ≀ r ≀ |s|) β€” the required minimum number of positions to be removed, where |s| is the length of the given line. The second line of each answer should contain r different integers β€” the indices themselves for removal in any order. Indices are numbered from left to right from 1 to the length of the string. If r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them. Examples Input 4 onetwone testme oneoneone twotwo Output 2 6 3 0 3 4 1 7 2 1 4 Input 10 onetwonetwooneooonetwooo two one twooooo ttttwo ttwwoo ooone onnne oneeeee oneeeeeeetwooooo Output 6 18 11 12 1 6 21 1 1 1 3 1 2 1 6 0 1 4 0 1 1 2 1 11 Note In the first example, answers are: * "onetwone", * "testme" β€” Polycarp likes it, there is nothing to remove, * "oneoneone", * "twotwo". In the second example, answers are: * "onetwonetwooneooonetwooo", * "two", * "one", * "twooooo", * "ttttwo", * "ttwwoo" β€” Polycarp likes it, there is nothing to remove, * "ooone", * "onnne" β€” Polycarp likes it, there is nothing to remove, * "oneeeee", * "oneeeeeeetwooooo".
instruction
0
80,927
24
161,854
Tags: dp, greedy Correct Solution: ``` def make_liked(s): i = 0 remove = [] while i < len(s)-2: if i < len(s) - 4 and s[i] == "t" and s[i+1] == "w" and s[i+2] == "o" and s[i+3] == "n" and s[i+4] == "e": remove.append(i+3) i+=4 continue if s[i] == "o" and s[i+1] == "n" and s[i+2] == "e": #print(i,i+1,i+2) remove.append(i+2) elif s[i] == "t" and s[i+1] == "w" and s[i+2] == "o": #print(i,i+1,i+2) remove.append(i+2) i+=1 print(len(remove)) print(*remove) if __name__ == "__main__": t = int(input()) for i in range(t): s = input() make_liked(s) ```
output
1
80,927
24
161,855
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j (1 ≀ j ≀ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+2}="two". For example: * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"), * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time. For example, if the string looks like s="onetwone", then if Polycarp selects two indices 3 and 6, then "onetwone" will be selected and the result is "ontwne". What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be? Input The first line of the input contains an integer t (1 ≀ t ≀ 10^4) β€” the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string s. Its length does not exceed 1.5β‹…10^5. The string s consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5β‹…10^6. Output Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain r (0 ≀ r ≀ |s|) β€” the required minimum number of positions to be removed, where |s| is the length of the given line. The second line of each answer should contain r different integers β€” the indices themselves for removal in any order. Indices are numbered from left to right from 1 to the length of the string. If r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them. Examples Input 4 onetwone testme oneoneone twotwo Output 2 6 3 0 3 4 1 7 2 1 4 Input 10 onetwonetwooneooonetwooo two one twooooo ttttwo ttwwoo ooone onnne oneeeee oneeeeeeetwooooo Output 6 18 11 12 1 6 21 1 1 1 3 1 2 1 6 0 1 4 0 1 1 2 1 11 Note In the first example, answers are: * "onetwone", * "testme" β€” Polycarp likes it, there is nothing to remove, * "oneoneone", * "twotwo". In the second example, answers are: * "onetwonetwooneooonetwooo", * "two", * "one", * "twooooo", * "ttttwo", * "ttwwoo" β€” Polycarp likes it, there is nothing to remove, * "ooone", * "onnne" β€” Polycarp likes it, there is nothing to remove, * "oneeeee", * "oneeeeeeetwooooo".
instruction
0
80,928
24
161,856
Tags: dp, greedy Correct Solution: ``` a = int(input()) for x in range(a): b = input() c = len(b) d = list(b) k = 0 h = [] if c == 1 or c == 2: print(0) print() elif c == 3: if d[0] == "o": if d[1] == "n": if d[2] == "e": k += 1 d[0] = "@" h.append(1) elif d[2] == "o": if d[1] == "w": if d[0] == "t": k += 1 d[2] = "@" h.append(3) print(k) print(*h) else: for y in range(c): if d[y] == "o": if y == 0 or y == 1: if d[y+1] == "n": if d[y+2] == "e": k += 1 d[y+1] = "@" h.append(y+2) elif y == c-2 or y == c-1: if d[y-1] =="w": if d[y-2] == "t": k += 1 d[y-1] = "@" h.append(y) else: if (d[y+1] == "n" and d[y+2] == "e" ) and (d[y-1] == "w" and d[y-2] == "t"): k += 1 d[y] = "@" h.append(y+1) elif (d[y+1] == "n" and d[y+2] == "e" ): k += 1 d[y+1] == "@" h.append(y+2) elif (d[y-1] == "w" and d[y-2] == "t"): k += 1 d[y-1] == "@" h.append(y) print(k) print(*h) ```
output
1
80,928
24
161,857
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j (1 ≀ j ≀ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+2}="two". For example: * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"), * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time. For example, if the string looks like s="onetwone", then if Polycarp selects two indices 3 and 6, then "onetwone" will be selected and the result is "ontwne". What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be? Input The first line of the input contains an integer t (1 ≀ t ≀ 10^4) β€” the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string s. Its length does not exceed 1.5β‹…10^5. The string s consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5β‹…10^6. Output Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain r (0 ≀ r ≀ |s|) β€” the required minimum number of positions to be removed, where |s| is the length of the given line. The second line of each answer should contain r different integers β€” the indices themselves for removal in any order. Indices are numbered from left to right from 1 to the length of the string. If r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them. Examples Input 4 onetwone testme oneoneone twotwo Output 2 6 3 0 3 4 1 7 2 1 4 Input 10 onetwonetwooneooonetwooo two one twooooo ttttwo ttwwoo ooone onnne oneeeee oneeeeeeetwooooo Output 6 18 11 12 1 6 21 1 1 1 3 1 2 1 6 0 1 4 0 1 1 2 1 11 Note In the first example, answers are: * "onetwone", * "testme" β€” Polycarp likes it, there is nothing to remove, * "oneoneone", * "twotwo". In the second example, answers are: * "onetwonetwooneooonetwooo", * "two", * "one", * "twooooo", * "ttttwo", * "ttwwoo" β€” Polycarp likes it, there is nothing to remove, * "ooone", * "onnne" β€” Polycarp likes it, there is nothing to remove, * "oneeeee", * "oneeeeeeetwooooo".
instruction
0
80,929
24
161,858
Tags: dp, greedy Correct Solution: ``` for _ in range(int(input())): s=input();i=0;r=[] while i<len(s): if'twone'==s[i:i+5]:i+=3;r+=i, if s[i:i+3] in('one','two'): r+=i+2, i+=1 print(len(r),*r) ```
output
1
80,929
24
161,859
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j (1 ≀ j ≀ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+2}="two". For example: * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"), * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time. For example, if the string looks like s="onetwone", then if Polycarp selects two indices 3 and 6, then "onetwone" will be selected and the result is "ontwne". What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be? Input The first line of the input contains an integer t (1 ≀ t ≀ 10^4) β€” the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string s. Its length does not exceed 1.5β‹…10^5. The string s consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5β‹…10^6. Output Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain r (0 ≀ r ≀ |s|) β€” the required minimum number of positions to be removed, where |s| is the length of the given line. The second line of each answer should contain r different integers β€” the indices themselves for removal in any order. Indices are numbered from left to right from 1 to the length of the string. If r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them. Examples Input 4 onetwone testme oneoneone twotwo Output 2 6 3 0 3 4 1 7 2 1 4 Input 10 onetwonetwooneooonetwooo two one twooooo ttttwo ttwwoo ooone onnne oneeeee oneeeeeeetwooooo Output 6 18 11 12 1 6 21 1 1 1 3 1 2 1 6 0 1 4 0 1 1 2 1 11 Note In the first example, answers are: * "onetwone", * "testme" β€” Polycarp likes it, there is nothing to remove, * "oneoneone", * "twotwo". In the second example, answers are: * "onetwonetwooneooonetwooo", * "two", * "one", * "twooooo", * "ttttwo", * "ttwwoo" β€” Polycarp likes it, there is nothing to remove, * "ooone", * "onnne" β€” Polycarp likes it, there is nothing to remove, * "oneeeee", * "oneeeeeeetwooooo".
instruction
0
80,930
24
161,860
Tags: dp, greedy Correct Solution: ``` import sys, os, io def rs(): return sys.stdin.readline().rstrip() def ri(): return int(sys.stdin.readline()) def ria(): return list(map(int, sys.stdin.readline().split())) def ws(s): sys.stdout.write(s + '\n') def wi(n): sys.stdout.write(str(n) + '\n') def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n') import math,datetime,functools,itertools,operator,bisect from collections import deque,defaultdict,OrderedDict import collections def main(): starttime=datetime.datetime.now() if(os.path.exists('input.txt')): sys.stdin = open("input.txt","r") sys.stdout = open("output.txt","w") #Solving Area Starts--> for _ in range(ri()): s=rs() s="zz"+s+"zz" ans=[] r=0 for i in range(2,len(s)-2): if s[i]=='o': if s[i-2]+s[i-1]=="tw" and s[i+1]+s[i+2]=="ne": ans.append(i+1-2) if s[i-2]+s[i-1]=="tw" and s[i+1]+s[i+2]!="ne": ans.append(i-2) if s[i-2]+s[i-1]!="tw" and s[i+1]+s[i+2]=="ne": ans.append(i+2-2) print(len(ans)) print(*ans) #<--Solving Area Ends endtime=datetime.datetime.now() time=(endtime-starttime).total_seconds()*1000 if(os.path.exists('input.txt')): print("Time:",time,"ms") class FastReader(io.IOBase): newlines = 0 def __init__(self, fd, chunk_size=1024 * 8): self._fd = fd self._chunk_size = chunk_size self.buffer = io.BytesIO() def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self, size=-1): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() class FastWriter(io.IOBase): def __init__(self, fd): self._fd = fd self.buffer = io.BytesIO() self.write = self.buffer.write def flush(self): os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class FastStdin(io.IOBase): def __init__(self, fd=0): self.buffer = FastReader(fd) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") class FastStdout(io.IOBase): def __init__(self, fd=1): self.buffer = FastWriter(fd) self.write = lambda s: self.buffer.write(s.encode("ascii")) self.flush = self.buffer.flush if __name__ == '__main__': sys.stdin = FastStdin() sys.stdout = FastStdout() main() ```
output
1
80,930
24
161,861
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j (1 ≀ j ≀ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+2}="two". For example: * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"), * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time. For example, if the string looks like s="onetwone", then if Polycarp selects two indices 3 and 6, then "onetwone" will be selected and the result is "ontwne". What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be? Input The first line of the input contains an integer t (1 ≀ t ≀ 10^4) β€” the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string s. Its length does not exceed 1.5β‹…10^5. The string s consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5β‹…10^6. Output Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain r (0 ≀ r ≀ |s|) β€” the required minimum number of positions to be removed, where |s| is the length of the given line. The second line of each answer should contain r different integers β€” the indices themselves for removal in any order. Indices are numbered from left to right from 1 to the length of the string. If r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them. Examples Input 4 onetwone testme oneoneone twotwo Output 2 6 3 0 3 4 1 7 2 1 4 Input 10 onetwonetwooneooonetwooo two one twooooo ttttwo ttwwoo ooone onnne oneeeee oneeeeeeetwooooo Output 6 18 11 12 1 6 21 1 1 1 3 1 2 1 6 0 1 4 0 1 1 2 1 11 Note In the first example, answers are: * "onetwone", * "testme" β€” Polycarp likes it, there is nothing to remove, * "oneoneone", * "twotwo". In the second example, answers are: * "onetwonetwooneooonetwooo", * "two", * "one", * "twooooo", * "ttttwo", * "ttwwoo" β€” Polycarp likes it, there is nothing to remove, * "ooone", * "onnne" β€” Polycarp likes it, there is nothing to remove, * "oneeeee", * "oneeeeeeetwooooo".
instruction
0
80,931
24
161,862
Tags: dp, greedy Correct Solution: ``` from sys import stdin as inp from math import gcd,sqrt,floor,ceil,log2 from bisect import bisect_left as bi for _ in range(int(inp.readline())): s = list(inp.readline().strip()) n = len(s) ind = [] c = 0 for i in range(n-4): if s[i:i+5] == list('twone'): ind.append(i+2) s[i+2] = '' c = 0 i = 0 while i<n-2: x = '' j = i while len(x)<3 and j<n: x += s[j] j += 1 if x=='one' or x=='two': ind.append(i+1) s[i+1] = '' i += 2 else: i += 1 # print(''.join(s)) print(len(ind)) for i in range(len(ind)): ind[i] += 1 print(*ind) ```
output
1
80,931
24
161,863
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j (1 ≀ j ≀ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+2}="two". For example: * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"), * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time. For example, if the string looks like s="onetwone", then if Polycarp selects two indices 3 and 6, then "onetwone" will be selected and the result is "ontwne". What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be? Input The first line of the input contains an integer t (1 ≀ t ≀ 10^4) β€” the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string s. Its length does not exceed 1.5β‹…10^5. The string s consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5β‹…10^6. Output Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain r (0 ≀ r ≀ |s|) β€” the required minimum number of positions to be removed, where |s| is the length of the given line. The second line of each answer should contain r different integers β€” the indices themselves for removal in any order. Indices are numbered from left to right from 1 to the length of the string. If r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them. Examples Input 4 onetwone testme oneoneone twotwo Output 2 6 3 0 3 4 1 7 2 1 4 Input 10 onetwonetwooneooonetwooo two one twooooo ttttwo ttwwoo ooone onnne oneeeee oneeeeeeetwooooo Output 6 18 11 12 1 6 21 1 1 1 3 1 2 1 6 0 1 4 0 1 1 2 1 11 Note In the first example, answers are: * "onetwone", * "testme" β€” Polycarp likes it, there is nothing to remove, * "oneoneone", * "twotwo". In the second example, answers are: * "onetwonetwooneooonetwooo", * "two", * "one", * "twooooo", * "ttttwo", * "ttwwoo" β€” Polycarp likes it, there is nothing to remove, * "ooone", * "onnne" β€” Polycarp likes it, there is nothing to remove, * "oneeeee", * "oneeeeeeetwooooo".
instruction
0
80,932
24
161,864
Tags: dp, greedy Correct Solution: ``` #!/usr/bin/env python3 import sys #lines = stdin.readlines() def rint(): return map(int, sys.stdin.readline().split()) def input(): return sys.stdin.readline().rstrip('\n') def oint(): return int(input()) t = oint() one = list("one") two = list("two") twone = list("twone") for _ in range(t): s = list(input()) #print(s) l = len(s) cnt = 0 p = [] for i in range(l-2): if s[i:i+3] == one: cnt += 1 p.append(i+2) elif s[i:i+3] == two: if i + 4 < l: if s[i:i+5] == twone: s[i+2] = 'x' p.append(i+1+2) else: p.append(i+2) cnt += 1 else: cnt += 1 p.append(i+2) print(cnt) print(*p) ```
output
1
80,932
24
161,865
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j (1 ≀ j ≀ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+2}="two". For example: * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"), * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time. For example, if the string looks like s="onetwone", then if Polycarp selects two indices 3 and 6, then "onetwone" will be selected and the result is "ontwne". What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be? Input The first line of the input contains an integer t (1 ≀ t ≀ 10^4) β€” the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string s. Its length does not exceed 1.5β‹…10^5. The string s consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5β‹…10^6. Output Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain r (0 ≀ r ≀ |s|) β€” the required minimum number of positions to be removed, where |s| is the length of the given line. The second line of each answer should contain r different integers β€” the indices themselves for removal in any order. Indices are numbered from left to right from 1 to the length of the string. If r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them. Examples Input 4 onetwone testme oneoneone twotwo Output 2 6 3 0 3 4 1 7 2 1 4 Input 10 onetwonetwooneooonetwooo two one twooooo ttttwo ttwwoo ooone onnne oneeeee oneeeeeeetwooooo Output 6 18 11 12 1 6 21 1 1 1 3 1 2 1 6 0 1 4 0 1 1 2 1 11 Note In the first example, answers are: * "onetwone", * "testme" β€” Polycarp likes it, there is nothing to remove, * "oneoneone", * "twotwo". In the second example, answers are: * "onetwonetwooneooonetwooo", * "two", * "one", * "twooooo", * "ttttwo", * "ttwwoo" β€” Polycarp likes it, there is nothing to remove, * "ooone", * "onnne" β€” Polycarp likes it, there is nothing to remove, * "oneeeee", * "oneeeeeeetwooooo".
instruction
0
80,933
24
161,866
Tags: dp, greedy Correct Solution: ``` for tests in range(int(input())): A=input() num=0 x=[] for s in range(len(A)-2): if A[s:s+3]=='one': if num==0 or x[-1]!=s+1: x.append(s+2) num+=1 elif A[s:s+3]=='two': if A[s:s+5]=="twone": x.append(s+3) else: x.append(s+2) num+=1 print(num) if num==0: print("") else: print(" ".join(str(k) for k in x)) ```
output
1
80,933
24
161,867
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j (1 ≀ j ≀ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+2}="two". For example: * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"), * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time. For example, if the string looks like s="onetwone", then if Polycarp selects two indices 3 and 6, then "onetwone" will be selected and the result is "ontwne". What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be? Input The first line of the input contains an integer t (1 ≀ t ≀ 10^4) β€” the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string s. Its length does not exceed 1.5β‹…10^5. The string s consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5β‹…10^6. Output Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain r (0 ≀ r ≀ |s|) β€” the required minimum number of positions to be removed, where |s| is the length of the given line. The second line of each answer should contain r different integers β€” the indices themselves for removal in any order. Indices are numbered from left to right from 1 to the length of the string. If r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them. Examples Input 4 onetwone testme oneoneone twotwo Output 2 6 3 0 3 4 1 7 2 1 4 Input 10 onetwonetwooneooonetwooo two one twooooo ttttwo ttwwoo ooone onnne oneeeee oneeeeeeetwooooo Output 6 18 11 12 1 6 21 1 1 1 3 1 2 1 6 0 1 4 0 1 1 2 1 11 Note In the first example, answers are: * "onetwone", * "testme" β€” Polycarp likes it, there is nothing to remove, * "oneoneone", * "twotwo". In the second example, answers are: * "onetwonetwooneooonetwooo", * "two", * "one", * "twooooo", * "ttttwo", * "ttwwoo" β€” Polycarp likes it, there is nothing to remove, * "ooone", * "onnne" β€” Polycarp likes it, there is nothing to remove, * "oneeeee", * "oneeeeeeetwooooo".
instruction
0
80,934
24
161,868
Tags: dp, greedy Correct Solution: ``` for _ in range(int(input())): s=list(input()) ans=[] for i in range(len(s)-2): a,b,c=s[i],s[i+1],s[i+2] if a+b+c=='one':ans.append(i+2);s[i+1]='#' elif a+b+c=='two': if i<len(s)-4: d,e=s[i+3],s[i+4] if d+e=='ne':ans.append(i+3);s[i+2]='#' else: ans.append(i + 2);s[i + 1] = '#' else:ans.append(i+2);s[i+1]='#' print(len(ans)) print(*ans) ```
output
1
80,934
24
161,869
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j (1 ≀ j ≀ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+2}="two". For example: * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"), * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two"). Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time. For example, if the string looks like s="onetwone", then if Polycarp selects two indices 3 and 6, then "onetwone" will be selected and the result is "ontwne". What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be? Input The first line of the input contains an integer t (1 ≀ t ≀ 10^4) β€” the number of test cases in the input. Next, the test cases are given. Each test case consists of one non-empty string s. Its length does not exceed 1.5β‹…10^5. The string s consists only of lowercase Latin letters. It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5β‹…10^6. Output Print an answer for each test case in the input in order of their appearance. The first line of each answer should contain r (0 ≀ r ≀ |s|) β€” the required minimum number of positions to be removed, where |s| is the length of the given line. The second line of each answer should contain r different integers β€” the indices themselves for removal in any order. Indices are numbered from left to right from 1 to the length of the string. If r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them. Examples Input 4 onetwone testme oneoneone twotwo Output 2 6 3 0 3 4 1 7 2 1 4 Input 10 onetwonetwooneooonetwooo two one twooooo ttttwo ttwwoo ooone onnne oneeeee oneeeeeeetwooooo Output 6 18 11 12 1 6 21 1 1 1 3 1 2 1 6 0 1 4 0 1 1 2 1 11 Note In the first example, answers are: * "onetwone", * "testme" β€” Polycarp likes it, there is nothing to remove, * "oneoneone", * "twotwo". In the second example, answers are: * "onetwonetwooneooonetwooo", * "two", * "one", * "twooooo", * "ttttwo", * "ttwwoo" β€” Polycarp likes it, there is nothing to remove, * "ooone", * "onnne" β€” Polycarp likes it, there is nothing to remove, * "oneeeee", * "oneeeeeeetwooooo". Submitted Solution: ``` import os import sys from io import BytesIO, IOBase import re def solution(s): res = [m.start() + 3 for m in re.finditer('twone', s)] ss = s.replace('twone', '-----') ones = [m.start() + 2 for m in re.finditer('one', ss)] res.extend(ones) two = [m.start() + 2 for m in re.finditer('two', ss)] res.extend(two) write(len(res)) write(*res) def main(): for _ in range(r_int()): s = input() solution(s) BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) def input(): return sys.stdin.readline().rstrip("\r\n") def write(*args, end='\n'): for x in args: sys.stdout.write(str(x) + ' ') sys.stdout.write(end) def r_array(): return [int(x) for x in input().split()] def r_int(): return int(input()) if __name__ == "__main__": main() ```
instruction
0
80,935
24
161,870
Yes
output
1
80,935
24
161,871