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
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces.
instruction
0
42,403
24
84,806
Tags: implementation Correct Solution: ``` n,m=map(int,input().split()) if(n%m)==0: for i in range(m): print(n//m,end=" ") print() else: x=n%m y=n//m for i in range(x): print(y+1,end=" ") for i in range(m-x): print(y,end=" ") print() ```
output
1
42,403
24
84,807
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces.
instruction
0
42,404
24
84,808
Tags: implementation Correct Solution: ``` import time import collections class Time_test: def __enter__(self): self.enter_time = time.time() def __exit__(self, exc_type, exc_val, exc_tb): print("Command was executed in", time.time()-self.enter_time) n, m = [int(x) for x in input().split()] print((str(n//m)+" ")*(m-n%m)+(str(n//m+1)+" ")*(n%m)) ```
output
1
42,404
24
84,809
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces.
instruction
0
42,405
24
84,810
Tags: implementation Correct Solution: ``` n, m = map(int, input().split()) res = [] while m: res.append(n // m) n -= (n // m) m -= 1 print(*res) ```
output
1
42,405
24
84,811
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces.
instruction
0
42,406
24
84,812
Tags: implementation Correct Solution: ``` n, m = map(int, input().split()) if(n%m == 0): arr = [n//m]*m else: arr= [n//m + 1]*(n%m) sm = sum(arr) diff = n - sm last = m - len(arr) arr = arr + [diff//last]*last for i in sorted(arr): print(i,end=" ") ```
output
1
42,406
24
84,813
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces.
instruction
0
42,407
24
84,814
Tags: implementation Correct Solution: ``` def main(): n, m = map(int, input().split()) a = [(n//m)]*m if sum(a) < n: for i in range(n-sum(a)): a[i]+= 1 print(*a) main() ```
output
1
42,407
24
84,815
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces. Submitted Solution: ``` ##A from math import ceil,floor n,m=map(int,input().split()) L=[] if not n%m: for _ in range(m): L.append(n//m) else: MIN=floor(n/m) MAX=ceil(n/m) for _ in range(n%m): L.append(MAX) for _ in range(m-(n%m)): L.append(MIN) print (' '.join(map(str,L))) ```
instruction
0
42,408
24
84,816
Yes
output
1
42,408
24
84,817
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces. Submitted Solution: ``` n, m = input().split() n = int(n) m = int(m) resDiv = n // m temp = resDiv * m temp = n - temp temp = m - temp for i in range(m): if temp == 0: print(resDiv + 1, end=" ") else: print(resDiv, end=" ") temp = temp - 1 ```
instruction
0
42,409
24
84,818
Yes
output
1
42,409
24
84,819
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces. Submitted Solution: ``` param = list(map(int,input().split())) answer = "" for i in range(param[1]): if i <= (param[1]-(param[0] % param[1])-1): answer += str(param[0]//param[1]) + " " else: answer += str(param[0]//param[1] + 1) + " " print(answer) ```
instruction
0
42,410
24
84,820
Yes
output
1
42,410
24
84,821
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces. Submitted Solution: ``` def main(): n, m = [int(i) for i in input().split()] a = [n//m] * m l = n - (n//m)*m for i in range(l): a[i] += 1 print(' '.join(map(str, a))) main() ```
instruction
0
42,411
24
84,822
Yes
output
1
42,411
24
84,823
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces. Submitted Solution: ``` import math n,k=map(int,input().split()) x=[] if n%k==0: c=n//k for _ in range(k): x.append(c) else: c=math.ceil(n/k) l=k*c d=l-n for _ in range(d): x.append(c-1) for _ in range(k-d): x.append(c) print(x) ```
instruction
0
42,412
24
84,824
No
output
1
42,412
24
84,825
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces. Submitted Solution: ``` amount_candy, amount_friends = map(int, input().split()) my_string = "" list_candies = [0] * amount_friends avarage_candy = amount_candy // amount_friends vestiges_candy = amount_candy % amount_friends for i in range(amount_friends): list_candies[i] += avarage_candy while vestiges_candy > 0: list_candies[amount_friends-1] += 1 vestiges_candy -= 1 amount_friends -= 1 for i in range(len(list_candies)): my_string += str(list_candies[i]) + " " print(list_candies) print(my_string) ```
instruction
0
42,413
24
84,826
No
output
1
42,413
24
84,827
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces. Submitted Solution: ``` [num_candies, num_friends] = map(int, input().split()) candy_allocation = [] # All friends get same number of candies except the last who gets more # All but the last gets equal_candies equal_candies = num_candies//num_friends for i in range(num_friends-1): candy_allocation.append(equal_candies) # Last friend gets higher number of candies "last_candy" last_candy = num_candies - equal_candies * (num_friends-1) candy_allocation.append(last_candy) for i in range(num_friends): print(candy_allocation[i], end=' ') ```
instruction
0
42,414
24
84,828
No
output
1
42,414
24
84,829
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus has got n candies and m friends (n β‰₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible. For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one. Input The single line of the input contains a pair of space-separated positive integers n, m (1 ≀ n, m ≀ 100;n β‰₯ m) β€” the number of candies and the number of Polycarpus's friends. Output Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value. Examples Input 12 3 Output 4 4 4 Input 15 4 Output 3 4 4 4 Input 18 7 Output 2 2 2 3 3 3 3 Note Print ai in any order, separate the numbers by spaces. Submitted Solution: ``` candies,n=input().split(" ") candies=int(candies) n=int(n) answer=[] while(n>0): temp=int(candies/n) answer.append(temp) n-=1 candies=candies-temp for i in answer: print(answer[i], end=" ") ```
instruction
0
42,415
24
84,830
No
output
1
42,415
24
84,831
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp loves not only to take pictures, but also to show his photos to friends. On his personal website he has recently installed a widget that can display n photos with the scroll option. At each moment of time the widget displays exactly one photograph with the option showing the previous/next one. From the first photo, you can switch to the second one or to the n-th one, from the second photo you can switch to the third one or to the first one, etc. Thus, navigation is performed in a cycle. Polycarp's collection consists of m photo albums, the i-th album contains ai photos. Polycarp wants to choose n photos and put them on a new widget. To make watching the photos interesting to the visitors, he is going to post pictures so that no two photos from one album were neighboring (each photo will have exactly two neighbors, the first photo's neighbors are the second and the n-th one). Help Polycarp compile a photo gallery. Select n photos from his collection and put them in such order that no two photos from one album went one after the other. Input The first line contains two integers n and m (3 ≀ n ≀ 1000, 1 ≀ m ≀ 40), where n is the number of photos on the widget, and m is the number of albums. The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ 1000), where ai is the number of photos in the i-th album. Output Print the single number -1 if there is no solution. Otherwise, print n numbers t1, t2, ..., tn, where ti represents the number of the album of the i-th picture in the widget. The albums are numbered from 1 in the order of their appearance in the input. If there are several solutions, print any of them. Examples Input 4 3 1 3 5 Output 3 1 3 2 Input 10 2 5 5 Output 2 1 2 1 2 1 2 1 2 1 Input 10 3 1 10 3 Output -1 Submitted Solution: ``` n,m=list(map(int,input().split())) a=list(map(int,input().split())) if sum(a)-sorted(a)[-1]>=n//2: for i in range(m): a[i]=[a[i],i+1] c=[] d=0 while d<n: a.sort() a=a[::-1] b=[] for i in range(m-1): b.append([a[i][0]-a[i+1][0],i+2]) b.sort() b=b[::-1] e=b[0][0] if m==2: f=0 else: f=b[1][0] z=0 for i in range(e-f+1): j=0 while j<b[0][1]: if (d!=0 and (a[j][1]==c[d-1] or (d==n-1 and a[j][1]==c[0]))) or a[j][0]==0: j+=1 if j==b[0][1]: break if d==n: z=1 break c.append(a[j][1]) a[j][0]-=1 d+=1 j+=1 if z==1: break print(*c) else: print(-1) ```
instruction
0
42,572
24
85,144
No
output
1
42,572
24
85,145
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp loves not only to take pictures, but also to show his photos to friends. On his personal website he has recently installed a widget that can display n photos with the scroll option. At each moment of time the widget displays exactly one photograph with the option showing the previous/next one. From the first photo, you can switch to the second one or to the n-th one, from the second photo you can switch to the third one or to the first one, etc. Thus, navigation is performed in a cycle. Polycarp's collection consists of m photo albums, the i-th album contains ai photos. Polycarp wants to choose n photos and put them on a new widget. To make watching the photos interesting to the visitors, he is going to post pictures so that no two photos from one album were neighboring (each photo will have exactly two neighbors, the first photo's neighbors are the second and the n-th one). Help Polycarp compile a photo gallery. Select n photos from his collection and put them in such order that no two photos from one album went one after the other. Input The first line contains two integers n and m (3 ≀ n ≀ 1000, 1 ≀ m ≀ 40), where n is the number of photos on the widget, and m is the number of albums. The second line contains m integers a1, a2, ..., am (1 ≀ ai ≀ 1000), where ai is the number of photos in the i-th album. Output Print the single number -1 if there is no solution. Otherwise, print n numbers t1, t2, ..., tn, where ti represents the number of the album of the i-th picture in the widget. The albums are numbered from 1 in the order of their appearance in the input. If there are several solutions, print any of them. Examples Input 4 3 1 3 5 Output 3 1 3 2 Input 10 2 5 5 Output 2 1 2 1 2 1 2 1 2 1 Input 10 3 1 10 3 Output -1 Submitted Solution: ``` n,m=list(map(int,input().split())) a=list(map(int,input().split())) if sum(a)-sorted(a)[-1]>=n//2: for i in range(m): a[i]=[a[i],i+1] c=[] d=0 while d<n: a.sort() a=a[::-1] b=[] for i in range(m-1): b.append([a[i][0]-a[i+1][0],i+2]) b.sort() b=b[::-1] e=b[0][0] if m==2: f=0 else: f=b[1][0] z=0 for i in range(e-f+1): j=0 while j<b[0][1]: if d!=0 and (a[j][1]==c[d-1] or (d==n-1 and a[j][1]==c[0])): j+=1 if j==b[0][1]: break if d==n: z=1 break c.append(a[j][1]) a[j][0]-=1 d+=1 j+=1 if z==1: break print(*c) else: print(-1) ```
instruction
0
42,573
24
85,146
No
output
1
42,573
24
85,147
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO
instruction
0
42,977
24
85,954
Tags: constructive algorithms, greedy, math Correct Solution: ``` rint = lambda: int(input()) rmint = lambda: map(int, input().split()) rlist = lambda: list(rmint()) n, k = rmint() t = k a = [0] * k def no(): print("NO"); exit(0) d = [-1] * (k+1); d[0] = 1 mx = 10 ** 9 for i in range(1, k+1): if d[i-1] * 2 > mx: break d[i] = d[i-1] * 2 for i in range(k): if n < 0: break if d[t] < 0: p = 1 if i: p = a[i-1] + 1 else: f = d[t] - 1 p = max(1, (n + f - 1) // f) if i: p = max(p, a[i-1] + 1) p = min(p, a[i-1] * 2) a[i] = p t -= 1 n -= p if n: no() print("YES") for i in range(k): print(a[i],end=' ') ```
output
1
42,977
24
85,955
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO
instruction
0
42,978
24
85,956
Tags: constructive algorithms, greedy, math Correct Solution: ``` import sys n,k=map(int,input().split()) a=[0]*(k+2) if k*(k+1)>n*2: print("NO") sys.exit() for i in range(1,k+1): a[i]=i n-=k*(k+1)//2 rest=n//k n-=rest*k a[1]+=rest for i in range(2,k+1): a[i]=a[i-1]+1 rest=n//(k-i+1) tmp=min(rest,a[i-1]*2-a[i]) a[i]+=tmp n-=(k-i+1)*tmp if n>0: print("NO") sys.exit() print("YES") for i in range(1,k+1): print(a[i],end=" ") ```
output
1
42,978
24
85,957
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO
instruction
0
42,979
24
85,958
Tags: constructive algorithms, greedy, math Correct Solution: ``` from math import * def f(n,k,a): if k == 0: return 0 L = max(ceil(n/(2**k - 1)), a+1) R = floor(n/k - (k-1)/2) if not (a == 0): R = min(R,2*a) if ( R >= L ): return L else: return 0 nk = input().split() n = int(nk[0]) k = int(nk[1]) sol = [0]* k subst = 0 lasta = 0 for i in range(k): sol[i] = f((n-subst), k-i, lasta) lasta = sol[i] subst += lasta if 0 in sol: print("NO") exit(0) print("YES") print(' '.join(str(x) for x in sol)) ```
output
1
42,979
24
85,959
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO
instruction
0
42,980
24
85,960
Tags: constructive algorithms, greedy, math Correct Solution: ``` def solve(): N, K = map(int, input().split()) result = list(range(1, K+1)) Sum = (K*(K+1))//2 if N < Sum: print ("NO") return add = (N - Sum)//K for i in range(K): result[i] += add add = (N - Sum) % K i = K-1 while i > 0 and add: x = min(2*result[i-1] - result[i], add) result[i] += x add -= x i -= 1 if sum(result) != N: print ("NO") return print ("YES") print (' '.join(map(str, result))) if __name__ == "__main__": solve() ```
output
1
42,980
24
85,961
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO
instruction
0
42,981
24
85,962
Tags: constructive algorithms, greedy, math Correct Solution: ``` #!/usr/bin/evn python # -*- coding: utf-8 -*- import math """ 26 6 2 5 """ def solution(): n, k = map(int, input().strip().split()) # n, k = 200, 30 a = [] for i in range(k): mi = math.floor((2 * n / (k - i) + i + 1 - k) / 2) if mi < 0: break mi = 2 * a[-1] if len(a) > 0 and mi > 2 * a[-1] else mi a.append(mi) n -= mi if n != 0: print('NO') # print(a) else: print('YES') print(' '.join(map(str, a))) # print(sum(a)) while True: try: solution() except: break # solution() ```
output
1
42,981
24
85,963
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO
instruction
0
42,982
24
85,964
Tags: constructive algorithms, greedy, math Correct Solution: ``` def mp(): return map(int, input().split()) n, k = mp() a = [i for i in range(1, k + 1)] s = (1 + k) * k // 2 p = [0] * k pp = 0 i = 0 while i < k and s < n: #print((n - s), (k - i), (n - s) // (k - i)) q = (n - s) // (k - i) if i == 0 or a[i] + q <= 2 * a[i - 1] + pp: p[i] = q pp += q s += q * (k - i) i += 1 if s == n: print('YES') q = 0 for i in range(k): q += p[i] print(a[i] + q, end = ' ') else: print('NO') ```
output
1
42,982
24
85,965
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO
instruction
0
42,983
24
85,966
Tags: constructive algorithms, greedy, math Correct Solution: ``` def main(): n, k = map(int, input().split()) if n < k*(k+1)//2: print('NO') else: add = (n-k*(k+1)//2) // k res = [x+add for x in range(1, k+1)] left = n-sum(res) added = True while left > 0 and added: added = False pos = k-1 while pos > 0: while left > 0 and res[pos]+1 <= 2*res[pos-1]: res[pos] += 1 left -= 1 added = True pos -= 1 ok = True for i in range(k-1): if res[i+1]<=res[i] or res[i+1] > 2*res[i]: ok = False break if ok and left == 0: print('YES') print(*res) else: print('NO') if __name__ == '__main__': main() ```
output
1
42,983
24
85,967
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO
instruction
0
42,984
24
85,968
Tags: constructive algorithms, greedy, math Correct Solution: ``` def check(n, k, fl, fr): if n < k * (2 * fl + k - 1) // 2: return 1 if k <= 32 and n > fr * (2**k - 1): return -1 return 0 def main(): n, k = map(int, input().split(' ')) l, r = 1, n ans = [] while k > 0: ll, rr = l, r cnt = -1 while rr >= ll: mid = (ll + rr) // 2 ck = check(n - mid, k - 1, mid + 1, mid * 2) if ck == 0: cnt = mid break elif ck < 0: ll = mid + 1 else: rr = mid - 1 if cnt == -1: print('NO') return ans.append(cnt) k -= 1 n -= cnt l = cnt + 1 r = min(n, cnt * 2) print('YES') print(*ans) if __name__ == '__main__': main() ```
output
1
42,984
24
85,969
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO Submitted Solution: ``` n, k = map(int, input().split()) max_x = (n - k * (k - 1) // 2) / k if max_x < 1: print('NO') exit(0) x = int(max_x) r = n - (k * x + k * (k - 1) // 2) A = [x + i for i in range(k)] p = r + 1 while r > 0 and r != p: p = r for i in range(k - 1, 0, -1): q = min(r, 2 * A[i - 1] - A[i]) r -= q A[i] += q if r == 0: break if r == 0: print('YES') print(*A, sep=' ') else: print('NO') ```
instruction
0
42,985
24
85,970
Yes
output
1
42,985
24
85,971
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO Submitted Solution: ``` n, k = list(map(int, input().split())) mi = (k * (k+1))//2 mx = 2**(k-1) if n<mi: print('NO') else: ans = [] for i in range(1, k+1): ans.append(i) remain = n-mi add = remain//k if add: for i in range(k): ans[i]+=add remain-=(k*add) while remain: i = k-1 while remain and ans[i] < (add + ans[0] * 2**(i)): ans[i]+=1 i-=1 remain-=1 if ans[-1] == (add + ans[0] * 2**(k-1)): break if remain: print('NO') else: print('YES') for a in ans[:-1]: print(a, end=" ") print(ans[-1]) ```
instruction
0
42,986
24
85,972
Yes
output
1
42,986
24
85,973
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO Submitted Solution: ``` n, k = map(int, input().split()) d = [0]*k if k == 1: print ('YES') print (n) else: for i in range(k): d[i] = i + 1 if sum(d) > n: print ('NO') else: t = n - sum(d) if t >= k: a = t // k t = t % k for i in range(k): d[i] += a if t > 0: if d[0] > 1: for i in range(k-1, k-1-t, -1): d[i] += 1 elif d[0] == 1: for i in range(k-1, 1, -1): d[i] += 1 t -= 1 if t == 0: break if t > 0: for i in range(k-1, 2, -1): d[i] += 1 t -= 1 if t == 0: break # print (d) chk = True for i in range(k - 1): if d[i + 1] > 2 * d[i]: chk = False break if sum(d) != n: chk = False if chk: print ('YES') s = "" for i in d: s += str(i) + " " print (s[:-1]) else: print ('NO') ```
instruction
0
42,987
24
85,974
Yes
output
1
42,987
24
85,975
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO Submitted Solution: ``` n, k = [int(i) for i in input().split()] def ok(a): print("YES") print(*a) if k * (k + 1) // 2 > n: print("NO") else: v = (n - k * (k + 1) // 2) // k a = [v + i for i in range(1, k + 1)] if v == 0: if k == 2: if sum(a) != n: print("NO") else: ok(a) elif k == 3: if n == 6: print(ok(a)) elif n == 7: print("YES") print("1 2 4") else: print("NO") else: if sum(a) < n: a[-2] += 1 a[-1] += n - sum(a) ok(a) else: a[-1] += n - sum(a) ok(a) ```
instruction
0
42,988
24
85,976
Yes
output
1
42,988
24
85,977
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO Submitted Solution: ``` n, k = [int(s) for s in input().split()] if n < k * (k + 1) / 2: print("NO") exit() if ((k == 3 and n == 8) or (k == 2 and n < 3)): print("NO") exit() print("YES") if k == 1: print(n) elif (k == 2): print((n + 2) // 3, n - (n + 2) // 3) else: i = 1 while i * k + k * (k - 1) // 2 <= n: i += 1 i -= 1 last = i + k - 1 last_ = last - 1 sum = i * (k - 1) + (k - 2) * (k - 1) // 2 last = n - sum if last_ * 2 >= last: for q in range(i, last_ + 1): print(q, end = " ") print(last) exit() last_ += 1 last -= 1 for q in range(i, i + k - 2): print(q, end=" ") print(last_, end=' ') print(last) ```
instruction
0
42,989
24
85,978
No
output
1
42,989
24
85,979
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO Submitted Solution: ``` def solve(): N, K = map(int, input().split()) result = list(range(1, K+1)) Sum = (K*(K+1))//2 if N < Sum: print ("NO") return add = (N - Sum)//K for i in range(K): result[i] += add add = (N - Sum) % K i = K-1 while i > 0 and add: x = min(2*result[i-1] - result[i], add) result[i] += x add -= x i -= 1 print ("YES") print (' '.join(map(str, result))) if __name__ == "__main__": solve() ```
instruction
0
42,990
24
85,980
No
output
1
42,990
24
85,981
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO Submitted Solution: ``` def find(n,k): lst = list(range(1,k+1)) sm = k * (k+1) / 2 r = k-1 while sm < n: # double # print(r,sm) # print(lst) if sm + -lst[r] + lst[r-1] * 2 <= n: sm += -lst[r] + lst[r-1] * 2 lst[r] = lst[r-1] * 2 else: lst[r] += int(n - sm) sm = n r -= 1 print(" ".join(list(map(str, lst)))) return lst n, k = list(map(int, input().split())) if k > 44725: print("NO") else: lb = k * (k+1) // 2 if k < 31: ub = 2 ** (k) - 1 if n >= lb and n <= ub: print("YES") find(n,k) else: print("NO") else: if n >= lb: print("YES") find(n,k) else: print("NO") ```
instruction
0
42,991
24
85,982
No
output
1
42,991
24
85,983
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarp has to solve exactly n problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in k days. It means that Polycarp has exactly k days for training! Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of k days. He also doesn't want to overwork, so if he solves x problems during some day, he should solve no more than 2x problems during the next day. And, at last, he wants to improve his skill, so if he solves x problems during some day, he should solve at least x+1 problem during the next day. More formally: let [a_1, a_2, ..., a_k] be the array of numbers of problems solved by Polycarp. The i-th element of this array is the number of problems Polycarp solves during the i-th day of his training. Then the following conditions must be satisfied: * sum of all a_i for i from 1 to k should be n; * a_i should be greater than zero for each i from 1 to k; * the condition a_i < a_{i + 1} ≀ 2 a_i should be satisfied for each i from 1 to k-1. Your problem is to find any array a of length k satisfying the conditions above or say that it is impossible to do it. Input The first line of the input contains two integers n and k (1 ≀ n ≀ 10^9, 1 ≀ k ≀ 10^5) β€” the number of problems Polycarp wants to solve and the number of days Polycarp wants to train. Output If it is impossible to find any array a of length k satisfying Polycarp's rules of training, print "NO" in the first line. Otherwise print "YES" in the first line, then print k integers a_1, a_2, ..., a_k in the second line, where a_i should be the number of problems Polycarp should solve during the i-th day. If there are multiple answers, you can print any. Examples Input 26 6 Output YES 1 2 4 5 6 8 Input 8 3 Output NO Input 1 1 Output YES 1 Input 9 4 Output NO Submitted Solution: ``` import math def sigma(num): ret=0 for i in range(num+1): ret+=i return ret def checkans(arr): for i in range(len(arr)-1): if arr[i+1]<arr[i] or arr[i]*2<arr[i+1]: return False else: return True n,k=map(int,input().split()) s=sigma(k) if n<s: print('NO') elif k==2: print('YES') print(n//k, math.ceil(n/k)) else: prod=int(n/s) diff=n-prod*s arr=[prod*(i+1) for i in range(k)] if diff==0: print('YES') print(' '.join(map(str,arr))) else: prod2=int(diff/k) diff2=diff-prod2*k width=math.ceil(k/2) for i in range(k): arr[i]+=prod2 for i in range(2): for j in range(width): if diff2==0: break arr[-(j+1)]+=1 diff2-=1 if checkans(arr)==True: print('YES') print(' '.join(map(str,arr))) else: print('NO') ```
instruction
0
42,992
24
85,984
No
output
1
42,992
24
85,985
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3
instruction
0
43,268
24
86,536
Tags: greedy, implementation Correct Solution: ``` s=input() ans=a1=a2=0 for i in s: if i=='+': ans+=1 else: ans-=1 a1=max(a1,ans) a2=min(a2,ans) print(a1+abs(a2)) ```
output
1
43,268
24
86,537
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3
instruction
0
43,269
24
86,538
Tags: greedy, implementation Correct Solution: ``` a = [1 if x == '+' else -1 for x in input()] b = list(map(lambda i : sum(a[0:i]), range(len(a) + 1))) print(max(b) - min(b)) ```
output
1
43,269
24
86,539
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3
instruction
0
43,270
24
86,540
Tags: greedy, implementation Correct Solution: ``` s=input() s=list(s) s1=[0]*len(s) for i in range(len(s)): if s[i]=='-': s[i]=1 s1[i]=-1 else: s[i]=-1 s1[i]=1 def kadane(s): maxi=-1 curr=0 for i in s: curr=max(curr+i,i) maxi=max(maxi,curr) return maxi print(max(kadane(s),kadane(s1))) ```
output
1
43,270
24
86,541
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3
instruction
0
43,271
24
86,542
Tags: greedy, implementation Correct Solution: ``` s = input() low = 0 high = 0 sum = 0 for i in s: if i == '+': sum += 1 else: sum -= 1 if sum < low: low = sum if sum > high: high = sum print(high - low) ```
output
1
43,271
24
86,543
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3
instruction
0
43,272
24
86,544
Tags: greedy, implementation Correct Solution: ``` c, v1, v2 = 0, 0, 0 for ch in input(): c += 1 if ch == '+' else -1 v1, v2 = min(v1, c), max(v2, c) print(v2 - v1) ```
output
1
43,272
24
86,545
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3
instruction
0
43,273
24
86,546
Tags: greedy, implementation Correct Solution: ``` # collaborated with no one suspects = input() minSus = 0 maxSus = 0 counter = 0 for x in suspects: if x == '+': counter += 1 minSus = min(minSus, counter) maxSus = max(maxSus, counter) else: counter -= 1 minSus = min(minSus, counter) maxSus = max(maxSus, counter) print(maxSus - minSus) ```
output
1
43,273
24
86,547
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3
instruction
0
43,274
24
86,548
Tags: greedy, implementation Correct Solution: ``` #COLLABORATED WITH PRASOON SHAKYA input_var=input() counter1=0 counter2=0 for temp in input_var: if temp=="+": counter1+=1 if counter2>0: counter2-=1 else: counter2+=1 if counter1>0: counter1-=1 print(counter1+counter2) ```
output
1
43,274
24
86,549
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3
instruction
0
43,275
24
86,550
Tags: greedy, implementation Correct Solution: ``` #Created By Minsol Jeong def N5(): seq = input() inside = outside = 0 for i in seq: if (i == '+'): inside +=1 if (outside): outside -=1 else: outside +=1 if (inside): inside -=1 suspects = abs(inside + outside) print(suspects) if __name__=="__main__": N5() ```
output
1
43,275
24
86,551
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3 Submitted Solution: ``` def solve(s): n = len(s) if(n == 1): return 1 else: start = 0 prev = s[0] ans = 0 f = 1 for i in range(1,n): f = 1 if(s[i] == prev): continue else: f = 0 ans = max(ans,i-start) start = i prev = s[i] # print(ans) if(f): ans = max(ans,n-start) start = i prev = s[i] return ans def solve1(s): st = [] ans = 0 maxx = 0 for i in s: if(st): ans = 0 if(i == '+'): st.append('+') else: if(st): st.pop() else: ans += 1 maxx = max(maxx,ans) maxx = max(maxx,len(st)) # print(st) maxx = max(maxx,len(st)) return maxx def solve2(s): st = [] ans = 0 maxx = 0 for i in s: if(st): ans = 0 if(i == '-'): st.append('-') else: if(st): st.pop() else: ans += 1 maxx = max(maxx,ans) maxx = max(maxx,len(st)) # print(st) maxx = max(maxx,len(st)) return maxx l = input() ans = solve(l) ans1 = solve1(l) ans2 = solve2(l) print(max(ans,ans1,ans2)) ```
instruction
0
43,276
24
86,552
Yes
output
1
43,276
24
86,553
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3 Submitted Solution: ``` s = input() p = 0 m = 0 for i in s: if i == "+": p += 1 m = max(m-1, 0) elif i == "-": m += 1 p = max(p-1, 0) print(p+m) ```
instruction
0
43,277
24
86,554
Yes
output
1
43,277
24
86,555
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3 Submitted Solution: ``` s = input() d, f, r = 0, 0, 0 for c in s: if c == "-": f += 1 if d >= 1: d -= 1 else: r += 1 elif c == "+": d += 1 if f >= 1: f -= 1 else: r += 1 print(r) ```
instruction
0
43,278
24
86,556
Yes
output
1
43,278
24
86,557
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3 Submitted Solution: ``` s=input() n=len(s) x,a,b=0,0,0 for i in range(n): if s[i]=='-': x-=1 else: x+=1 a = min(a,x) b = max(b,x) print(b-a) ```
instruction
0
43,279
24
86,558
Yes
output
1
43,279
24
86,559
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3 Submitted Solution: ``` visitors = input() unique = 0 inClubNow = 0 while '+-' in visitors: unique += 1 visitors = ''.join(visitors.split('+-')) if unique: unique = 1 unique += len(visitors) if '+' in visitors: unique -= 1 print(unique) ```
instruction
0
43,280
24
86,560
No
output
1
43,280
24
86,561
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3 Submitted Solution: ``` n = input() inside_count = 0 outside_count = 0 for element in n: if element == '+': inside_count += 1 outside_count -= 1 if outside_count < 0 and inside_count > 100: outside_count = 0 else: inside_count -= 1 outside_count += 1 if inside_count < 0 or outside_count > 100: inside_count = 0 print(inside_count + outside_count) ```
instruction
0
43,281
24
86,562
No
output
1
43,281
24
86,563
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3 Submitted Solution: ``` S = input() ans = 0 f = 0 for i in range( len( S ) ): if S[ i ] == '+': f += 1 else: f -= 1 ans = max( ans, abs( f ) ) print( ans ) ```
instruction
0
43,282
24
86,564
No
output
1
43,282
24
86,565
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen. On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, each time a visitor left the club, Polycarpus put character "-" in his notes. We know that all cases of going in and out happened consecutively, that is, no two events happened at the same time. Polycarpus doesn't remember whether there was somebody in the club at the moment when his shift begun and at the moment when it ended. Right now the police wonders what minimum number of distinct people Polycarpus could have seen. Assume that he sees anybody coming in or out of the club. Each person could have come in or out an arbitrary number of times. Input The only line of the input contains a sequence of characters "+" and "-", the characters are written one after another without any separators. The characters are written in the order, in which the corresponding events occurred. The given sequence has length from 1 to 300 characters, inclusive. Output Print the sought minimum number of people Examples Input +-+-+ Output 1 Input --- Output 3 Submitted Solution: ``` s=input() a,ans=10000,0 for i in range(len(s)): if(s[i]=='+'): a=a+1 else: a=a-1 if(ans < abs(a-10000)): ans=abs(a-10000) print(ans) ```
instruction
0
43,283
24
86,566
No
output
1
43,283
24
86,567
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp took n videos, the duration of the i-th video is a_i seconds. The videos are listed in the chronological order, i.e. the 1-st video is the earliest, the 2-nd video is the next, ..., the n-th video is the last. Now Polycarp wants to publish exactly k (1 ≀ k ≀ n) posts in Instabram. Each video should be a part of a single post. The posts should preserve the chronological order, it means that the first post should contain one or more of the earliest videos, the second post should contain a block (one or more videos) going next and so on. In other words, if the number of videos in the j-th post is s_j then: * s_1+s_2+...+s_k=n (s_i>0), * the first post contains the videos: 1, 2, ..., s_1; * the second post contains the videos: s_1+1, s_1+2, ..., s_1+s_2; * the third post contains the videos: s_1+s_2+1, s_1+s_2+2, ..., s_1+s_2+s_3; * ... * the k-th post contains videos: n-s_k+1,n-s_k+2,...,n. Polycarp is a perfectionist, he wants the total duration of videos in each post to be the same. Help Polycarp to find such positive integer values s_1, s_2, ..., s_k that satisfy all the conditions above. Input The first line contains two integers n and k (1 ≀ k ≀ n ≀ 10^5). The next line contains n positive integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 10^4), where a_i is the duration of the i-th video. Output If solution exists, print "Yes" in the first line. Print k positive integers s_1, s_2, ..., s_k (s_1+s_2+...+s_k=n) in the second line. The total duration of videos in each post should be the same. It can be easily proven that the answer is unique (if it exists). If there is no solution, print a single line "No". Examples Input 6 3 3 3 1 4 1 6 Output Yes 2 3 1 Input 3 3 1 1 1 Output Yes 1 1 1 Input 3 3 1 1 2 Output No Input 3 1 1 10 100 Output Yes 3
instruction
0
43,829
24
87,658
Tags: implementation Correct Solution: ``` def run(): n, k = map(int, input().split()) a = list(map(int, input().split())) s = 0 for x in a: s += x if s%k: print("No") return dur = s//k cs = 0 ans = [] for i in range(n): cs += a[i] if cs == dur: ans.append(i+1) cs = 0 elif cs > dur: print("No") return print("Yes") for i in range(len(ans)-1, 0, -1): ans[i] = ans[i]-ans[i-1] print(' '.join(map(str, ans))) if __name__ == '__main__': run() ```
output
1
43,829
24
87,659
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp took n videos, the duration of the i-th video is a_i seconds. The videos are listed in the chronological order, i.e. the 1-st video is the earliest, the 2-nd video is the next, ..., the n-th video is the last. Now Polycarp wants to publish exactly k (1 ≀ k ≀ n) posts in Instabram. Each video should be a part of a single post. The posts should preserve the chronological order, it means that the first post should contain one or more of the earliest videos, the second post should contain a block (one or more videos) going next and so on. In other words, if the number of videos in the j-th post is s_j then: * s_1+s_2+...+s_k=n (s_i>0), * the first post contains the videos: 1, 2, ..., s_1; * the second post contains the videos: s_1+1, s_1+2, ..., s_1+s_2; * the third post contains the videos: s_1+s_2+1, s_1+s_2+2, ..., s_1+s_2+s_3; * ... * the k-th post contains videos: n-s_k+1,n-s_k+2,...,n. Polycarp is a perfectionist, he wants the total duration of videos in each post to be the same. Help Polycarp to find such positive integer values s_1, s_2, ..., s_k that satisfy all the conditions above. Input The first line contains two integers n and k (1 ≀ k ≀ n ≀ 10^5). The next line contains n positive integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 10^4), where a_i is the duration of the i-th video. Output If solution exists, print "Yes" in the first line. Print k positive integers s_1, s_2, ..., s_k (s_1+s_2+...+s_k=n) in the second line. The total duration of videos in each post should be the same. It can be easily proven that the answer is unique (if it exists). If there is no solution, print a single line "No". Examples Input 6 3 3 3 1 4 1 6 Output Yes 2 3 1 Input 3 3 1 1 1 Output Yes 1 1 1 Input 3 3 1 1 2 Output No Input 3 1 1 10 100 Output Yes 3
instruction
0
43,830
24
87,660
Tags: implementation Correct Solution: ``` n,k=[int(x) for x in input().split()] arr=[int(x) for x in input().split()] s=sum(arr) if s%k!=0: print('No') else: d=s//k ans=[] curr=0 t=0 flag=True for i in arr: curr+=i t+=1 if curr==d: ans.append(t) t=0 curr=0 elif curr>d: flag=False break if flag: print('Yes') for i in ans: print(i,end=' ') else: print('No') ```
output
1
43,830
24
87,661
Provide tags and a correct Python 3 solution for this coding contest problem. Polycarp took n videos, the duration of the i-th video is a_i seconds. The videos are listed in the chronological order, i.e. the 1-st video is the earliest, the 2-nd video is the next, ..., the n-th video is the last. Now Polycarp wants to publish exactly k (1 ≀ k ≀ n) posts in Instabram. Each video should be a part of a single post. The posts should preserve the chronological order, it means that the first post should contain one or more of the earliest videos, the second post should contain a block (one or more videos) going next and so on. In other words, if the number of videos in the j-th post is s_j then: * s_1+s_2+...+s_k=n (s_i>0), * the first post contains the videos: 1, 2, ..., s_1; * the second post contains the videos: s_1+1, s_1+2, ..., s_1+s_2; * the third post contains the videos: s_1+s_2+1, s_1+s_2+2, ..., s_1+s_2+s_3; * ... * the k-th post contains videos: n-s_k+1,n-s_k+2,...,n. Polycarp is a perfectionist, he wants the total duration of videos in each post to be the same. Help Polycarp to find such positive integer values s_1, s_2, ..., s_k that satisfy all the conditions above. Input The first line contains two integers n and k (1 ≀ k ≀ n ≀ 10^5). The next line contains n positive integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 10^4), where a_i is the duration of the i-th video. Output If solution exists, print "Yes" in the first line. Print k positive integers s_1, s_2, ..., s_k (s_1+s_2+...+s_k=n) in the second line. The total duration of videos in each post should be the same. It can be easily proven that the answer is unique (if it exists). If there is no solution, print a single line "No". Examples Input 6 3 3 3 1 4 1 6 Output Yes 2 3 1 Input 3 3 1 1 1 Output Yes 1 1 1 Input 3 3 1 1 2 Output No Input 3 1 1 10 100 Output Yes 3
instruction
0
43,831
24
87,662
Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) vids = [int(bruh) for bruh in input().split()] len = 0 cnt = 0 res = [] summy = sum(vids)/k for x in range(n): len += vids[x] cnt += 1 if len == summy: res.append(cnt) cnt = 0 len = 0 elif len > summy: print("No") exit() print("Yes") res1 = [str(bruhh) for bruhh in res] print(' '.join(res1)) ```
output
1
43,831
24
87,663