message
stringlengths
2
433k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
113
108k
cluster
float64
12
12
__index_level_0__
int64
226
217k
Provide tags and a correct Python 3 solution for this coding contest problem. You have been blessed as a child of Omkar. To express your gratitude, please solve this problem for Omkar! An array a of length n is called complete if all elements are positive and don't exceed 1000, and for all indices x,y,z (1 ≀ x,y,z ≀ ...
instruction
0
31,907
12
63,814
Tags: constructive algorithms, implementation Correct Solution: ``` t=int(input()) for i in range(t): n=int(input()) arr=[1]*n print(*arr) ```
output
1
31,907
12
63,815
Provide tags and a correct Python 3 solution for this coding contest problem. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. V...
instruction
0
32,080
12
64,160
Tags: implementation Correct Solution: ``` def main(): n = int(input()) a = [int(x) for x in input().split()] temp = [1] * n for i in range(1, n): if a[i] != a[i-1]: temp[i] = temp[i-1]+1 else: temp[i] = 1 print((max(temp) - 1)//2) temp2 = [-1] * n...
output
1
32,080
12
64,161
Provide tags and a correct Python 3 solution for this coding contest problem. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. V...
instruction
0
32,081
12
64,162
Tags: implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) cnt = 0 cur = a[0] ind = [] i = 0 ind.append((0, 0)) while i < len(a): left = i right = i while i + 1 < len(a) and cur != a[i + 1]: cur = a[i + 1] i += 1 right += 1 ind.append((left, r...
output
1
32,081
12
64,163
Provide tags and a correct Python 3 solution for this coding contest problem. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. V...
instruction
0
32,082
12
64,164
Tags: implementation Correct Solution: ``` def main(): n, l = int(input()), input().split() x, a = [False] * n, l[0] for i, b in enumerate(l): if a == b: x[i] = x[i - 1] = True a = b b = 0 for i, a in enumerate(x): if a: if b: if b & 1:...
output
1
32,082
12
64,165
Provide tags and a correct Python 3 solution for this coding contest problem. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. V...
instruction
0
32,083
12
64,166
Tags: implementation Correct Solution: ``` import math as mt import sys,string,bisect input=sys.stdin.readline import random from collections import deque,defaultdict L=lambda : list(map(int,input().split())) Ls=lambda : list(input().split()) M=lambda : map(int,input().split()) I=lambda :int(input()) d=defaultdict(lis...
output
1
32,083
12
64,167
Provide tags and a correct Python 3 solution for this coding contest problem. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. V...
instruction
0
32,084
12
64,168
Tags: implementation Correct Solution: ``` #------------------------template--------------------------# import os import sys from math import * from collections import * from fractions import * from bisect import * from heapq import* from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') ...
output
1
32,084
12
64,169
Provide tags and a correct Python 3 solution for this coding contest problem. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. V...
instruction
0
32,085
12
64,170
Tags: implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) r, b, c = 0, [a[0]], 0 for x, y, z in zip(a, a[1:], a[2:]): if x != y != z: c += 1 else: if c & 1: b.extend([y]*(c+1)) else: b.extend([1-y]*(c//2) + [y]*(c//2+1)) ...
output
1
32,085
12
64,171
Provide tags and a correct Python 3 solution for this coding contest problem. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. V...
instruction
0
32,086
12
64,172
Tags: implementation Correct Solution: ``` N = int(input()) seq = [ i for i in input().split() ] def end_lst(i): while i < N - 1 and seq[i] != seq[i + 1]: i = i + 1 return i def reorder(lst, start, end): if start == end - 1: return 0 if lst[start] == lst[end]: for i in range(s...
output
1
32,086
12
64,173
Provide tags and a correct Python 3 solution for this coding contest problem. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. V...
instruction
0
32,087
12
64,174
Tags: implementation Correct Solution: ``` def main(): n = int(input()) a = [int(i) for i in input().split()] flag = 0 now_begin = 0 kek = 0 ans = [[-1] * 2 for i in range(n)] for i in range(1, n - 1): if a[i] != a[i - 1] and a[i] != a[i + 1]: kek += 1 else: ...
output
1
32,087
12
64,175
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its ...
instruction
0
32,088
12
64,176
Yes
output
1
32,088
12
64,177
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its ...
instruction
0
32,089
12
64,178
Yes
output
1
32,089
12
64,179
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its ...
instruction
0
32,090
12
64,180
Yes
output
1
32,090
12
64,181
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its ...
instruction
0
32,091
12
64,182
Yes
output
1
32,091
12
64,183
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its ...
instruction
0
32,092
12
64,184
No
output
1
32,092
12
64,185
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its ...
instruction
0
32,093
12
64,186
No
output
1
32,093
12
64,187
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its ...
instruction
0
32,094
12
64,188
No
output
1
32,094
12
64,189
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its ...
instruction
0
32,095
12
64,190
No
output
1
32,095
12
64,191
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Blake is the boss of Kris, however, this doesn't spoil their friendship. They often gather at the bar to talk about intriguing problems about maximising some values. This time the problem is rea...
instruction
0
32,096
12
64,192
No
output
1
32,096
12
64,193
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Blake is the boss of Kris, however, this doesn't spoil their friendship. They often gather at the bar to talk about intriguing problems about maximising some values. This time the problem is rea...
instruction
0
32,097
12
64,194
No
output
1
32,097
12
64,195
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Blake is the boss of Kris, however, this doesn't spoil their friendship. They often gather at the bar to talk about intriguing problems about maximising some values. This time the problem is rea...
instruction
0
32,098
12
64,196
No
output
1
32,098
12
64,197
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Blake is the boss of Kris, however, this doesn't spoil their friendship. They often gather at the bar to talk about intriguing problems about maximising some values. This time the problem is rea...
instruction
0
32,099
12
64,198
No
output
1
32,099
12
64,199
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to o...
instruction
0
32,100
12
64,200
Tags: binary search, dp, two pointers Correct Solution: ``` L=list(map(int,input().split())) n=L[0] k=L[1] a=list(map(int,input().split())) nbr0=0 posi=0 taillemax=0 p=0 for i in range(len(a)): nbr0+=(a[i]==0) if nbr0>k: if (i-posi)>taillemax: p=posi taillemax=i-pos...
output
1
32,100
12
64,201
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to o...
instruction
0
32,101
12
64,202
Tags: binary search, dp, two pointers Correct Solution: ``` n, k = map(int, input().split()) a = list(map(int, input().split())) l, r = 0, 0 ans_idx, ans_len = 0, 0 zeros = 0 while r < n: # slide window if r < n: zeros += a[r] == 0 r += 1 if zeros > k: zeros -= a[l] == 0 l +=...
output
1
32,101
12
64,203
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to o...
instruction
0
32,102
12
64,204
Tags: binary search, dp, two pointers Correct Solution: ``` ch=input() ch1=input() ch=ch.split(' ') n=int(ch[0]) k=int(ch[1]) l=ch1.split(' ') l=[int(i) for i in l] nb=l.count(0) if k>=nb: print(n) l=['1']*n ch2=' '.join(l) print(ch2) else: c=0 t=[] while (len(t)<nb): if (l[c]==0): ...
output
1
32,102
12
64,205
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to o...
instruction
0
32,103
12
64,206
Tags: binary search, dp, two pointers Correct Solution: ``` n,k=map(int,input().split()) l=list(map(int,input().split())) m=0 z=0 p=0 r=0 for i in range(n): if l[i]==0: z+=1 if z<=k: m+=1 r=i else: if l[p]==0 : z-= 1 p+=1 print(m) l[r-m+1:r+1]=[1]*m print(...
output
1
32,103
12
64,207
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to o...
instruction
0
32,104
12
64,208
Tags: binary search, dp, two pointers Correct Solution: ``` import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in ...
output
1
32,104
12
64,209
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to o...
instruction
0
32,105
12
64,210
Tags: binary search, dp, two pointers Correct Solution: ``` s=list(map(int,input().split())) s1=list(map(int,input().split())) start=0 end=0 c=0 s2=0 x=0 y=0 while(end<s[0]): if(s1[end]==0): c+=1 while(c>s[1]): c+=s1[start]-1 start+=1 if(end-start+1>s2): s2=end-start+1 ...
output
1
32,105
12
64,211
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to o...
instruction
0
32,106
12
64,212
Tags: binary search, dp, two pointers Correct Solution: ``` n, k = map(int, input().split()) s = list(map(int, input().split())) ans = 0 def get(x) : return 1 - x l = 0 cnt = 0 L = n R = 0 for i in range(n) : cnt += get(s[i]) while cnt > k : cnt -= get(s[l]) l += 1 if l <= i : ...
output
1
32,106
12
64,213
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to o...
instruction
0
32,107
12
64,214
Tags: binary search, dp, two pointers Correct Solution: ``` n,k=map(int,input().split()) a=[int(x) for x in input().split()] i=0 j=0 c=0 an=0 p=[0,n-1] while (j<n and c<k): if a[j]==0 : c+=1 j+=1 an=j-i p=[i,j] while (j<n): if a[j]==0: while (a[i]!=0): i+=1 i+=1 j+=...
output
1
32,107
12
64,215
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as ...
instruction
0
32,108
12
64,216
Yes
output
1
32,108
12
64,217
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as ...
instruction
0
32,109
12
64,218
Yes
output
1
32,109
12
64,219
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as ...
instruction
0
32,110
12
64,220
Yes
output
1
32,110
12
64,221
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as ...
instruction
0
32,111
12
64,222
Yes
output
1
32,111
12
64,223
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as ...
instruction
0
32,112
12
64,224
No
output
1
32,112
12
64,225
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as ...
instruction
0
32,113
12
64,226
No
output
1
32,113
12
64,227
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as ...
instruction
0
32,114
12
64,228
No
output
1
32,114
12
64,229
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as ...
instruction
0
32,115
12
64,230
No
output
1
32,115
12
64,231
Provide tags and a correct Python 3 solution for this coding contest problem. It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k β‰₯ 0, 0 < r ≀ 2k. Let's call that representation prairie partition of x. For example, the prairie part...
instruction
0
32,132
12
64,264
Tags: binary search, constructive algorithms, greedy, math Correct Solution: ``` n = int(input()) a = sorted(list(map(int, input().split()))) maxe = max(a) cnt = [] cur, k, i = 1, 0, 0 while i < n: cnt.append(0) while i < n and a[i] < cur: cnt[2 * k] += 1 i += 1 cnt.append(0) ...
output
1
32,132
12
64,265
Provide tags and a correct Python 3 solution for this coding contest problem. It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k β‰₯ 0, 0 < r ≀ 2k. Let's call that representation prairie partition of x. For example, the prairie part...
instruction
0
32,133
12
64,266
Tags: binary search, constructive algorithms, greedy, math Correct Solution: ``` from collections import Counter from math import log2 def can(): seqs_cp = Counter(seqs) for num in set(nums): cnt = nums[num] while cnt != 0 and num < 2 ** 63: dif = min(cnt, seqs_cp[num]) ...
output
1
32,133
12
64,267
Provide tags and a correct Python 3 solution for this coding contest problem. It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k β‰₯ 0, 0 < r ≀ 2k. Let's call that representation prairie partition of x. For example, the prairie part...
instruction
0
32,136
12
64,272
Tags: binary search, constructive algorithms, greedy, math Correct Solution: ``` n = int(input()) a = sorted(list(map(int, input().split()))) maxe = max(a) cnt = [] cur = 1 k = 0 i = 0 while i < n: cnt.append(0) while i < n and a[i] < cur: cnt[2 * k] += 1 i += 1 cnt.append(0) while i < ...
output
1
32,136
12
64,273
Provide tags and a correct Python 3 solution for this coding contest problem. It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k β‰₯ 0, 0 < r ≀ 2k. Let's call that representation prairie partition of x. For example, the prairie part...
instruction
0
32,137
12
64,274
Tags: binary search, constructive algorithms, greedy, math Correct Solution: ``` from collections import Counter from math import log2 MAX = 10 ** 12 + 1 def can(): seqs_cp = Counter(seqs) for num in set(nums): cnt = nums[num] while cnt != 0 and num < MAX: dif = min(cnt, seqs_cp[n...
output
1
32,137
12
64,275
Provide tags and a correct Python 3 solution for this coding contest problem. It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k β‰₯ 0, 0 < r ≀ 2k. Let's call that representation prairie partition of x. For example, the prairie part...
instruction
0
32,138
12
64,276
Tags: binary search, constructive algorithms, greedy, math Correct Solution: ``` from collections import Counter n = int(input()) a = list(map(int, input().split())) def get(cnt): c = Counter(a) last = [] while c[1] and (cnt is None or len(last) < cnt): x = 1 while c[x]: c[x] -=...
output
1
32,138
12
64,277
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print 0....
instruction
0
32,530
12
65,060
Tags: implementation, sortings Correct Solution: ``` # cook your dish here n,k=map(int,input().split()) l=list(map(int,input().split())) l=list(set(l)) l.sort() val=0 for i in range(k): if i>=len(l): print(0) else: print(l[i]-val) val=l[i] ```
output
1
32,530
12
65,061
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print 0....
instruction
0
32,531
12
65,062
Tags: implementation, sortings Correct Solution: ``` R = lambda: map(int, input().split()) n, k = R() a = iter(sorted(set(R()))) p = 0 while k: x = next(a, p) print(x - p) p = x k -= 1 ```
output
1
32,531
12
65,063
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print 0....
instruction
0
32,532
12
65,064
Tags: implementation, sortings Correct Solution: ``` n,k = tuple(map(int,input().split())) arr = list(map(int,input().split())) arr.sort() sm = 0 for a in arr: if a-sm!=0: print(a-sm) sm += (a-sm) k-=1 if k==0: break while k >0: print(0) k-=1 ```
output
1
32,532
12
65,065
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print 0....
instruction
0
32,533
12
65,066
Tags: implementation, sortings Correct Solution: ``` N, K = map(int,input().split()) A = sorted(list(set(map(int, input().split())))) j = 0 M = 0 for i in range(K): if j >= len(A): print("0") continue if A[j] - M > 0: print(A[j]-M) M+=A[j]-M j+=1 else: pr...
output
1
32,533
12
65,067
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print 0....
instruction
0
32,534
12
65,068
Tags: implementation, sortings Correct Solution: ``` n,k = map(int,input().split()) st = [0] + list(sorted(set(map(int,input().split())))) print('\n'.join(['0' if i >= len(st) else str(st[i]-st[i-1]) for i in range(1,k+1)])) ```
output
1
32,534
12
65,069
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print 0....
instruction
0
32,535
12
65,070
Tags: implementation, sortings Correct Solution: ``` n , k = map(int,input().split()) l = list(map(int,input().split())) l = list(set(l)) l.sort() #print(l) ans = [] ans.append(l[0]) for i in range(1 , len(l) , 1): ans.append(l[i] - l[i - 1]) if(k < len(ans)): for i in range(k): print(ans[i]) else: ...
output
1
32,535
12
65,071
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print 0....
instruction
0
32,536
12
65,072
Tags: implementation, sortings Correct Solution: ``` n, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] sa = set(a) if 0 in sa: sa.remove(0) lsa = list(sa) lsa.sort() ds = 0 for i in range(k): if i >= len(lsa): print(0) else: print(lsa[i]-ds) ds = lsa[i] ...
output
1
32,536
12
65,073
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print 0....
instruction
0
32,537
12
65,074
Tags: implementation, sortings Correct Solution: ``` from collections import deque n, k = [int(p) for p in input().split()] arr = sorted([int(p) for p in input().split()]) arr = deque(arr) curr = 0 while arr and k > 0: p = arr.popleft() if p == curr: continue print(p-curr) curr = p k -= 1 while k: print(0) k -...
output
1
32,537
12
65,075