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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation: <image> A swap operation is the following sequence of actions: * choose two indexes...
instruction
0
72,866
12
145,732
No
output
1
72,866
12
145,733
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation: <image> A swap operation is the following sequence of actions: * choose two indexes...
instruction
0
72,867
12
145,734
No
output
1
72,867
12
145,735
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation: <image> A swap operation is the following sequence of actions: * choose two indexes...
instruction
0
72,868
12
145,736
No
output
1
72,868
12
145,737
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation: <image> A swap operation is the following sequence of actions: * choose two indexes...
instruction
0
72,869
12
145,738
No
output
1
72,869
12
145,739
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n. This sequence had ...
instruction
0
72,895
12
145,790
No
output
1
72,895
12
145,791
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n. This sequence had ...
instruction
0
72,896
12
145,792
No
output
1
72,896
12
145,793
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n. This sequence had ...
instruction
0
72,897
12
145,794
No
output
1
72,897
12
145,795
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n. This sequence had ...
instruction
0
72,898
12
145,796
No
output
1
72,898
12
145,797
Provide tags and a correct Python 3 solution for this coding contest problem. You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You need to permute the array elements so that value <image> became minimal possible. In particular, it is allowed not to c...
instruction
0
72,904
12
145,808
Tags: dp, greedy, sortings Correct Solution: ``` def solve(n, k, As): As.sort() m, r = divmod(n, k) dp = [0] * (r + 1) for i in range(1, k): im = i * m new_dp = [0] * (r + 1) new_dp[0] = dp[0] + As[im] - As[im - 1] for h in range(1, min(i, r) + 1): new_dp[h] =...
output
1
72,904
12
145,809
Provide tags and a correct Python 3 solution for this coding contest problem. You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You need to permute the array elements so that value <image> became minimal possible. In particular, it is allowed not to c...
instruction
0
72,905
12
145,810
Tags: dp, greedy, sortings Correct Solution: ``` f = lambda: map(int, input().split()) n, k = f() p = sorted(f()) m, d = n // k, n % k u, v = d + 1, k - d + 1 g = [0] * u * v i = 0 for a in range(u): j = a * m + a - 1 for b in range(v): x = g[i - 1] + p[j] - p[j - m + 1] if b else 9e9 y = g[i ...
output
1
72,905
12
145,811
Provide tags and a correct Python 3 solution for this coding contest problem. You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You need to permute the array elements so that value <image> became minimal possible. In particular, it is allowed not to c...
instruction
0
72,906
12
145,812
Tags: dp, greedy, sortings Correct Solution: ``` inf = 10 ** 10 n, k = map(int, input().split()) a = sorted(map(int, input().split())) L, M = n // k, n % k dp = [[0] * (k - M + 1) for i in range(M + 1)] for i in range(M + 1): for j in range(k - M + 1): pos = i * (L + 1) + j * L dp[i][j] = min((dp[i ...
output
1
72,906
12
145,813
Provide tags and a correct Python 3 solution for this coding contest problem. You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You need to permute the array elements so that value <image> became minimal possible. In particular, it is allowed not to c...
instruction
0
72,907
12
145,814
Tags: dp, greedy, sortings Correct Solution: ``` INF = 10 ** 18 + 179 [n, k], a = [list(map(int, input().split())) for x in range(2)] a.sort() dp, l = [[0] * (k - n % k + 1) for x in range(n % k + 1)], n // k for i in range(n % k + 1): for j in range(k - n % k + 1): pos = i * (l + 1) + j * l dp[i][j...
output
1
72,907
12
145,815
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You need to permute the array elements so that value <image> became minimal ...
instruction
0
72,908
12
145,816
No
output
1
72,908
12
145,817
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You need to permute the array elements so that value <image> became minimal ...
instruction
0
72,909
12
145,818
No
output
1
72,909
12
145,819
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You need to permute the array elements so that value <image> became minimal ...
instruction
0
72,910
12
145,820
No
output
1
72,910
12
145,821
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You need to permute the array elements so that value <image> became minimal ...
instruction
0
72,911
12
145,822
No
output
1
72,911
12
145,823
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash is finally tired of computing the length of the longest Fibonacci-ish sequence. He now plays around with more complex things such as Fibonacci-ish potentials. Fibonacci-ish potential of a...
instruction
0
72,933
12
145,866
No
output
1
72,933
12
145,867
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Yash is finally tired of computing the length of the longest Fibonacci-ish sequence. He now plays around with more complex things such as Fibonacci-ish potentials. Fibonacci-ish potential of a...
instruction
0
72,934
12
145,868
No
output
1
72,934
12
145,869
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a table consisting of n rows and m columns. Each cell of the table contains either 0 or 1. In one move, you are allowed to pick any row or any column and invert all values, that is...
instruction
0
72,935
12
145,870
No
output
1
72,935
12
145,871
Provide a correct Python 3 solution for this coding contest problem. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i β‰  i for all 1≀i≀N. Find ...
instruction
0
73,167
12
146,334
"Correct Solution: ``` n=int(input()) p=[int(i) for i in input().split()] cnt=0 for i in range(n-1): if p[i]==i+1: p[i],p[i+1]=p[i+1],p[i] cnt+=1 if p[-1]==n:cnt+=1 print(cnt) ```
output
1
73,167
12
146,335
Provide a correct Python 3 solution for this coding contest problem. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i β‰  i for all 1≀i≀N. Find ...
instruction
0
73,168
12
146,336
"Correct Solution: ``` N=int(input()) k=0 s=0 m=0 L=list(map(int,input().split())) for i in range(N): if L[i]==i+1: m+=1 else: s+=m//2+m%2 m=0 s+=m//2+m%2 print(s) ```
output
1
73,168
12
146,337
Provide a correct Python 3 solution for this coding contest problem. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i β‰  i for all 1≀i≀N. Find ...
instruction
0
73,169
12
146,338
"Correct Solution: ``` n=int(input()) p=list(map(int,input().split())) c=0 def swap(i): global c t=p[i+1] p[i+1]=p[i] p[i]=t c+=1 for i in range(n-1): if p[i]==i+1:swap(i) print(c+(p[n-1]==n)) ```
output
1
73,169
12
146,339
Provide a correct Python 3 solution for this coding contest problem. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i β‰  i for all 1≀i≀N. Find ...
instruction
0
73,170
12
146,340
"Correct Solution: ``` N = int(input()) P = list(map(lambda p: int(p) - 1, input().split())) i, ans = 0, 0 while i < N: if P[i] == i: ans += 1 i += 1 i += 1 print(ans) ```
output
1
73,170
12
146,341
Provide a correct Python 3 solution for this coding contest problem. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i β‰  i for all 1≀i≀N. Find ...
instruction
0
73,171
12
146,342
"Correct Solution: ``` N = int(input()) P = list(map(int, input().split())) i, count = 0, 0 while i < N: #print(i, i + 1, P[i]) if i + 1 == P[i]: count += 1 i += 2 else: i += 1 print(count) ```
output
1
73,171
12
146,343
Provide a correct Python 3 solution for this coding contest problem. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i β‰  i for all 1≀i≀N. Find ...
instruction
0
73,172
12
146,344
"Correct Solution: ``` n = int(input()) p = list(map(int, input().split())) ans = 0 i = 0 while i<n: if p[i]==i+1: ans += 1 i += 1 i += 1 print(ans) ```
output
1
73,172
12
146,345
Provide a correct Python 3 solution for this coding contest problem. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i β‰  i for all 1≀i≀N. Find ...
instruction
0
73,173
12
146,346
"Correct Solution: ``` n=int(input()) p=list(map(int,input().split())) r=p[:] ans=0 for i in range(n): if p[i]==i+1: ans+=1 if i!=n-1: p[i]=r[i+1] p[i+1]=r[i] print(ans) ```
output
1
73,173
12
146,347
Provide a correct Python 3 solution for this coding contest problem. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i β‰  i for all 1≀i≀N. Find ...
instruction
0
73,174
12
146,348
"Correct Solution: ``` N=int(input()) P=[int(x)-1 for x in input().split()] T=[0]*N for i in range(N): if P[i]==i: T[i]=1 for i in range(1,N): if T[i]==T[i-1]==1: T[i]=0 print(sum(T)) ```
output
1
73,174
12
146,349
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the per...
instruction
0
73,175
12
146,350
Yes
output
1
73,175
12
146,351
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the per...
instruction
0
73,176
12
146,352
Yes
output
1
73,176
12
146,353
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the per...
instruction
0
73,177
12
146,354
Yes
output
1
73,177
12
146,355
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the per...
instruction
0
73,178
12
146,356
Yes
output
1
73,178
12
146,357
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the per...
instruction
0
73,179
12
146,358
No
output
1
73,179
12
146,359
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the per...
instruction
0
73,180
12
146,360
No
output
1
73,180
12
146,361
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the per...
instruction
0
73,181
12
146,362
No
output
1
73,181
12
146,363
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the per...
instruction
0
73,182
12
146,364
No
output
1
73,182
12
146,365
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length k is a sequence of k integers from 1 to k containing each integer exactly once. For example, the sequence [3, 1, 2] is a permutation of length 3. When Neko was five, he thought of an array a of n positive integers an...
instruction
0
73,383
12
146,766
Tags: constructive algorithms, dfs and similar, graphs Correct Solution: ``` class multiset: def __init__(self): self.contenido = dict() self.len = 0 def add(self, x): self.contenido[x] = self.contenido.get(x, 0)+1 self.len += 1 def remove(self, x): valor = self.contenido.get(x, 1)-1 if valor == 0: ...
output
1
73,383
12
146,767
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length k is a sequence of k integers from 1 to k containing each integer exactly once. For example, the sequence [3, 1, 2] is a permutation of length 3. When Neko was five, he thought of an array a of n positive integers an...
instruction
0
73,384
12
146,768
Tags: constructive algorithms, dfs and similar, graphs Correct Solution: ``` class multiset: def __init__(self): self.items = dict() self.len = 0 def add(self, it): self.items[it] = self.items.get(it,0) + 1 self.len += 1 def remove(self, it): it_value = self...
output
1
73,384
12
146,769
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length k is a sequence of k integers from 1 to k containing each integer exactly once. For example, the sequence [3, 1, 2] is a permutation of length 3. When Neko was five, he thought of an array a of n positive integers an...
instruction
0
73,385
12
146,770
Tags: constructive algorithms, dfs and similar, graphs Correct Solution: ``` from collections import defaultdict, Counter from sys import exit N = int(input()) B = list(map(int, input().split())) C = list(map(int, input().split())) Edge = defaultdict(list) Edc = defaultdict(int) for b, c in zip(B, C): if b > c: ...
output
1
73,385
12
146,771
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length k is a sequence of k integers from 1 to k containing each integer exactly once. For example, the sequence [3, 1, 2] is a permutation of length 3. When Neko was five, he ...
instruction
0
73,386
12
146,772
No
output
1
73,386
12
146,773
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length k is a sequence of k integers from 1 to k containing each integer exactly once. For example, the sequence [3, 1, 2] is a permutation of length 3. When Neko was five, he ...
instruction
0
73,387
12
146,774
No
output
1
73,387
12
146,775
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length k is a sequence of k integers from 1 to k containing each integer exactly once. For example, the sequence [3, 1, 2] is a permutation of length 3. When Neko was five, he ...
instruction
0
73,388
12
146,776
No
output
1
73,388
12
146,777
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length k is a sequence of k integers from 1 to k containing each integer exactly once. For example, the sequence [3, 1, 2] is a permutation of length 3. When Neko was five, he ...
instruction
0
73,389
12
146,778
No
output
1
73,389
12
146,779
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya likes to play very much. And most of all he likes to play the following game: He is given a sequence of N integer numbers. At each step it is allowed to increase the value of any number by 1 or to decrease it by 1. The goal of ...
instruction
0
73,522
12
147,044
Tags: dp, sortings Correct Solution: ``` import heapq input() ans=0 a=[] inf=10**9 for x in map(int,input().split()): x=inf-x heapq.heappush(a,x) ans+=a[0]-x heapq.heappop(a) heapq.heappush(a,x) print(-ans) ```
output
1
73,522
12
147,045
Provide tags and a correct Python 3 solution for this coding contest problem. Little Petya likes to play very much. And most of all he likes to play the following game: He is given a sequence of N integer numbers. At each step it is allowed to increase the value of any number by 1 or to decrease it by 1. The goal of ...
instruction
0
73,523
12
147,046
Tags: dp, sortings Correct Solution: ``` from bisect import insort def min_steps_N(arr): pri_q = [] ans = 0 for n in arr: if pri_q: if pri_q[-1] > n: ans += pri_q[-1] - n pri_q.pop() insort(pri_q, n) insort(pri_q, n) return ans...
output
1
73,523
12
147,047
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] β€” are permutations, and [1, 1], [4, 3, 1], [2, 3, 4] β€” no. Permutation a is lexicographically ...
instruction
0
73,528
12
147,056
Tags: brute force, math, two pointers Correct Solution: ``` import io,os;from math import *;input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline manual = 20;n,Q = map(int,input().split());after = min(manual, n);before = n -after;ind = 0 def unrankperm(i): unused = [i+1 for i in range(after)];r = [] for j in ra...
output
1
73,528
12
147,057
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] β€” are permutations, and [1, 1], [4, 3, 1], [2, 3, 4] β€” no. Permutation a is lexicographically ...
instruction
0
73,529
12
147,058
Tags: brute force, math, two pointers Correct Solution: ``` import sys input = sys.stdin.readline n,q=map(int,input().split()) X=list(range(1,n+1)) S=[0] for x in X: S.append(S[-1]+x) FACT=[1,1] for i in range(2,16): FACT.append(FACT[-1]*i) A=X[-15:] LEN=len(A) def calc(x): AA=[a for a in A] ANS...
output
1
73,529
12
147,059
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] β€” are permutations, and [1, 1], [4, 3, 1], [2, 3, 4] β€” no. Permutation a is lexicographically ...
instruction
0
73,530
12
147,060
Tags: brute force, math, two pointers Correct Solution: ``` import io,os input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline import bisect factor = [1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200] n,q = map(int,input().split()) def getpermute(x,n): m = b...
output
1
73,530
12
147,061
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] β€” are permutations, and [1, 1], [4, 3, 1], [2, 3, 4] β€” no. Permutation a is lexicographically ...
instruction
0
73,531
12
147,062
Tags: brute force, math, two pointers Correct Solution: ``` import io,os from math import * input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, q = list(map(int, input().split())) after = min(15, n) before = n - after def perm(i): unused = [i + 1 for i in range(after)] arr = [] for j in revers...
output
1
73,531
12
147,063
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] β€” are permutations, and [1, 1], [4, 3, 1], [2, 3, 4] β€” no. Permutation a is lexicographically ...
instruction
0
73,532
12
147,064
Tags: brute force, math, two pointers Correct Solution: ``` import sys input=sys.stdin.readline fact=[1] for i in range(1,15+1): fact.append(fact[-1]*i) def generate_perm(n,m): ret=[] if n<=15: cand=[i+1 for i in range(n)] else: cand=[i+1 for i in range(n-15,n)] for i in range(1,mi...
output
1
73,532
12
147,065
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] β€” are permutations, and [1, 1], [4, 3, 1], [2, 3, 4] β€” no. Permutation a is lexicographically ...
instruction
0
73,533
12
147,066
Tags: brute force, math, two pointers Correct Solution: ``` n, q = map(int, input().split()) A = [i for i in range(1, n + 1)] prefix = [0] * (n + 1) prefix[0] = A[0] for i in range(1, n): prefix[i] = prefix[i - 1] + A[i] used0 = A[max(0, n - 15)::] used0.sort() used_d = {} for i in used0: used_d[i] = 0 ...
output
1
73,533
12
147,067