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 are given an array a consisting of n integers a_1, a_2, ..., a_n. You want to split it into exactly k non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that b...
instruction
0
84,311
12
168,622
Tags: constructive algorithms, math Correct Solution: ``` t = int(input()) for q in range(t): n, k = map(int, input().split()) A = list(map(int, input().split())) if k == 1: if sum(A) % 2 != 0: print("YES") print(n) else: print("NO") else: arr = [] total = 0 for i in range(len(A)): total +...
output
1
84,311
12
168,623
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integers a_1, a_2, ..., a_n. You want to split it into exactly k non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that b...
instruction
0
84,312
12
168,624
Tags: constructive algorithms, math Correct Solution: ``` import sys input = sys.stdin.readline for _ in range(int(input())): n,k=map(int,input().split()) a=[int(j)%2 for j in input().split()] sum1=sum(a) if(sum1<k or abs(sum1-k)%2==1): print("NO") else: print("YES") l=[] ...
output
1
84,312
12
168,625
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 consisting of n integers a_1, a_2, ..., a_n. You want to split it into exactly k non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for ...
instruction
0
84,313
12
168,626
Yes
output
1
84,313
12
168,627
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 consisting of n integers a_1, a_2, ..., a_n. You want to split it into exactly k non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for ...
instruction
0
84,314
12
168,628
Yes
output
1
84,314
12
168,629
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 consisting of n integers a_1, a_2, ..., a_n. You want to split it into exactly k non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for ...
instruction
0
84,315
12
168,630
Yes
output
1
84,315
12
168,631
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 consisting of n integers a_1, a_2, ..., a_n. You want to split it into exactly k non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for ...
instruction
0
84,316
12
168,632
Yes
output
1
84,316
12
168,633
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 consisting of n integers a_1, a_2, ..., a_n. You want to split it into exactly k non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for ...
instruction
0
84,317
12
168,634
No
output
1
84,317
12
168,635
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 consisting of n integers a_1, a_2, ..., a_n. You want to split it into exactly k non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for ...
instruction
0
84,318
12
168,636
No
output
1
84,318
12
168,637
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 consisting of n integers a_1, a_2, ..., a_n. You want to split it into exactly k non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for ...
instruction
0
84,319
12
168,638
No
output
1
84,319
12
168,639
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 consisting of n integers a_1, a_2, ..., a_n. You want to split it into exactly k non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for ...
instruction
0
84,320
12
168,640
No
output
1
84,320
12
168,641
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by 2 rounding down (in other words, in one move y...
instruction
0
84,321
12
168,642
Tags: brute force, implementation Correct Solution: ``` INF = int (2e9) n, k = list (map (int, input ().split ())) a = list (map (int, input ().split ())) a.sort() a = [(x, 0) for x in a] ans = INF ha = {} tail = n - 1 p = 0 def lowerbound (x): l, r = 0, tail - 1 while (l <= r) : mid = (l + r) >> 1 ...
output
1
84,321
12
168,643
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by 2 rounding down (in other words, in one move y...
instruction
0
84,322
12
168,644
Tags: brute force, implementation Correct Solution: ``` a,b=list(map(int,input().split())) array=list(map(int,input().split())) c=b-1 answer=[] array.sort() arr=list(range(1,array[-1]+1)) for it in arr: element=it current=0 count=0 for y in range(0,a): copare=array[y] if copare<element: ...
output
1
84,322
12
168,645
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by 2 rounding down (in other words, in one move y...
instruction
0
84,323
12
168,646
Tags: brute force, implementation Correct Solution: ``` N, K = [int(x) for x in input().split()] l = [int(x) for x in input().split()] lk = [0] * (1000000) for n in l: t = n while t != 0: lk[t] += 1 t //= 2 lk[0] = 99999999 g = 0 mn = 9999999 for i in range(len(lk) - 1, -1, -1): if(lk[i] >= K): g = i; ed = [...
output
1
84,323
12
168,647
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by 2 rounding down (in other words, in one move y...
instruction
0
84,324
12
168,648
Tags: brute force, implementation Correct Solution: ``` n, k = map(int,input().split()) l = list(map(int,input().split())) d = {} for liczba in l: ll = liczba while ll > 0: d[ll] = [] ll //= 2 for liczba in l: i = 0 ll = liczba while ll > 0: d[ll].append(i) ll //= 2 ...
output
1
84,324
12
168,649
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by 2 rounding down (in other words, in one move y...
instruction
0
84,325
12
168,650
Tags: brute force, implementation Correct Solution: ``` # import numpy as np # def get_num_operations(m, x): # if x < m: return big_number # if x == m: return 0 # return 1 + get_num_operations(m, int(x / 2)) # big_number = 10000000 # n, k=map(int, input().split()) # elements_array = np.array(map(int, in...
output
1
84,325
12
168,651
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by 2 rounding down (in other words, in one move y...
instruction
0
84,326
12
168,652
Tags: brute force, implementation Correct Solution: ``` # # n , com = map(int , input().split()) # # *a , = map(int , input().split()) # # test = [0 for i in range(n)] # # for i in range(n): # # test[i] = a[i]%2 # # print('mod2' , test) # # test1 = [0 for i in range(n)] # # m = min(a) # # for i in range(n): # # t...
output
1
84,326
12
168,653
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by 2 rounding down (in other words, in one move y...
instruction
0
84,327
12
168,654
Tags: brute force, implementation Correct Solution: ``` import math n,k=map(int,input().split()) l=[int(i) for i in input().split()] l.sort() moves=[0]*(200001) freq=[0]*(200001) ans=1e9 for i in l: freq[i]+=1 for i in range(len(l)): count=0 a=l[i] while a>1: a=a//2 count+=1 if f...
output
1
84,327
12
168,655
Provide tags and a correct Python 3 solution for this coding contest problem. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by 2 rounding down (in other words, in one move y...
instruction
0
84,328
12
168,656
Tags: brute force, implementation Correct Solution: ``` n, k = map(int, input().split()) from collections import defaultdict nums = list(map(int, input().split())) cc = defaultdict(int) aa = defaultdict(list) for num in nums: o = num i = 0 while o != 0: cc[o] += 1 aa[o].append(i) ...
output
1
84,328
12
168,657
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by...
instruction
0
84,329
12
168,658
Yes
output
1
84,329
12
168,659
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by...
instruction
0
84,330
12
168,660
Yes
output
1
84,330
12
168,661
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by...
instruction
0
84,331
12
168,662
Yes
output
1
84,331
12
168,663
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by...
instruction
0
84,332
12
168,664
Yes
output
1
84,332
12
168,665
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by...
instruction
0
84,333
12
168,666
No
output
1
84,333
12
168,667
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by...
instruction
0
84,334
12
168,668
No
output
1
84,334
12
168,669
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by...
instruction
0
84,335
12
168,670
No
output
1
84,335
12
168,671
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The only difference between easy and hard versions is the number of elements in the array. You are given an array a consisting of n integers. In one move you can choose any a_i and divide it by...
instruction
0
84,336
12
168,672
No
output
1
84,336
12
168,673
Provide tags and a correct Python 3 solution for this coding contest problem. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is empty, the result is the other array. That is, me...
instruction
0
84,406
12
168,812
Tags: dp Correct Solution: ``` t=int(input()) while(t>0): t-=1 n=int(input()) p=list(map(int, input().split())) l=[] j=0 for i in range(1, 2*n): if j==i or p[j] > p[i]: if i!=2*n-1: continue else: l.append(i-j) j=i if i=...
output
1
84,406
12
168,813
Provide tags and a correct Python 3 solution for this coding contest problem. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is empty, the result is the other array. That is, me...
instruction
0
84,407
12
168,814
Tags: dp Correct Solution: ``` def isSubsetSum(set, n, sum): # The value of subset[i][j] will be # true if there is a # subset of set[0..j-1] with sum equal to i subset =([[False for i in range(sum + 1)] for i in range(n + 1)]) # If sum is 0, then answer is true ...
output
1
84,407
12
168,815
Provide tags and a correct Python 3 solution for this coding contest problem. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is empty, the result is the other array. That is, me...
instruction
0
84,408
12
168,816
Tags: dp Correct Solution: ``` import time,math as mt,bisect,sys from sys import stdin,stdout from collections import deque from fractions import Fraction from collections import Counter from collections import OrderedDict pi=3.14159265358979323846264338327950 def II(): # to take integer input return int(stdin.read...
output
1
84,408
12
168,817
Provide tags and a correct Python 3 solution for this coding contest problem. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is empty, the result is the other array. That is, me...
instruction
0
84,409
12
168,818
Tags: dp Correct Solution: ``` import sys,os,io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline class SortedList: def __init__(self, iterable=[], _load=200): """Initialize sorted list instance.""" values = sorted(iterable) self._len = _len = len(values) self._load = _l...
output
1
84,409
12
168,819
Provide tags and a correct Python 3 solution for this coding contest problem. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is empty, the result is the other array. That is, me...
instruction
0
84,410
12
168,820
Tags: dp Correct Solution: ``` from collections import deque t=int(input()) while(t): n=int(input()) a=list(map(int,input().split())) u=[x+1 for x in range(2*n-1)] if(a==u): print("YES") t-=1 continue count,m=1,a[0] b=deque() for x in range(1,2*n): if(a[x]>m): m=a[x] b.append(c...
output
1
84,410
12
168,821
Provide tags and a correct Python 3 solution for this coding contest problem. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is empty, the result is the other array. That is, me...
instruction
0
84,411
12
168,822
Tags: dp Correct Solution: ``` tests = int(input()) for t in range(tests): n = int(input()) ls = list(map(int, input().split())) curr = ls[0] groups = [] group_len = 1 for item in ls[1:]: if curr > item: group_len += 1 else: groups.append(group_len) ...
output
1
84,411
12
168,823
Provide tags and a correct Python 3 solution for this coding contest problem. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is empty, the result is the other array. That is, me...
instruction
0
84,412
12
168,824
Tags: dp Correct Solution: ``` from math import inf, log2 class SegmentTree: def __init__(self, array, func=max): self.n = len(array) self.size = 2**(int(log2(self.n-1))+1) if self.n != 1 else 1 self.func = func self.default = 0 if self.func != min else inf self.data = [sel...
output
1
84,412
12
168,825
Provide tags and a correct Python 3 solution for this coding contest problem. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is empty, the result is the other array. That is, me...
instruction
0
84,413
12
168,826
Tags: dp Correct Solution: ``` from bisect import * from collections import * from math import gcd,ceil,sqrt,floor,inf from heapq import * from itertools import * from operator import add,mul,sub,xor,truediv,floordiv from functools import * #------------------------------------------------------------------------ impo...
output
1
84,413
12
168,827
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is em...
instruction
0
84,414
12
168,828
Yes
output
1
84,414
12
168,829
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is em...
instruction
0
84,415
12
168,830
Yes
output
1
84,415
12
168,831
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is em...
instruction
0
84,416
12
168,832
Yes
output
1
84,416
12
168,833
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is em...
instruction
0
84,417
12
168,834
Yes
output
1
84,417
12
168,835
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is em...
instruction
0
84,418
12
168,836
No
output
1
84,418
12
168,837
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is em...
instruction
0
84,419
12
168,838
No
output
1
84,419
12
168,839
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is em...
instruction
0
84,420
12
168,840
No
output
1
84,420
12
168,841
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array merge(a,b) of length n+m recursively as follows: * If one of the arrays is em...
instruction
0
84,421
12
168,842
No
output
1
84,421
12
168,843
Provide tags and a correct Python 3 solution for this coding contest problem. You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi. For the i-th query find any position pi (li ≤ pi ≤ ri) so that api ≠ xi. Input The first line contains two integers n, m (1 ≤ n, ...
instruction
0
84,627
12
169,254
Tags: data structures, implementation Correct Solution: ``` from sys import stdin _data = iter(stdin.read().split('\n')) def input(): while True: return next(_data) n ,m = map(int, input().split()) a = list(map(int, input().split())) ans=[] difPre=[-1 for i in range(n)] for i in range(1,n): if a[i]==a[...
output
1
84,627
12
169,255
Provide tags and a correct Python 3 solution for this coding contest problem. You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi. For the i-th query find any position pi (li ≤ pi ≤ ri) so that api ≠ xi. Input The first line contains two integers n, m (1 ≤ n, ...
instruction
0
84,628
12
169,256
Tags: data structures, implementation Correct Solution: ``` import sys input = sys.stdin.readline n, m = map(int, input().split()) a = list(map(int, input().split())) b, c = [0], [] now = 0 for j in range(n - 1): if a[j] ^ a[j + 1]: now += 1 c.append(j) b.append(now) c.append(n) for _ in range(...
output
1
84,628
12
169,257
Provide tags and a correct Python 3 solution for this coding contest problem. You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi. For the i-th query find any position pi (li ≤ pi ≤ ri) so that api ≠ xi. Input The first line contains two integers n, m (1 ≤ n, ...
instruction
0
84,629
12
169,258
Tags: data structures, implementation Correct Solution: ``` import collections import math n ,m = map(int, input().split()) A = list(map(int, input().split())) ans, f = [], [0] * n f[0] = -1 for i in range(1, n): if A[i] != A[i - 1]: f[i] = i - 1 else: f[i] = f[i - 1] for i in range(m): l, ...
output
1
84,629
12
169,259
Provide tags and a correct Python 3 solution for this coding contest problem. You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi. For the i-th query find any position pi (li ≤ pi ≤ ri) so that api ≠ xi. Input The first line contains two integers n, m (1 ≤ n, ...
instruction
0
84,630
12
169,260
Tags: data structures, implementation Correct Solution: ``` from itertools import combinations, accumulate, groupby, count from sys import stdout, stdin, setrecursionlimit from io import BytesIO, IOBase from collections import * from random import * from bisect import * from string import * from queue import * from hea...
output
1
84,630
12
169,261
Provide tags and a correct Python 3 solution for this coding contest problem. You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi. For the i-th query find any position pi (li ≤ pi ≤ ri) so that api ≠ xi. Input The first line contains two integers n, m (1 ≤ n, ...
instruction
0
84,631
12
169,262
Tags: data structures, implementation Correct Solution: ``` import sys def preprocess(arr): left_i = -1 prev = arr[0] preprocessed = [] for i, k in enumerate(arr): if prev != k: prev = k left_i = i preprocessed.append(left_i) return preprocessed def query(...
output
1
84,631
12
169,263
Provide tags and a correct Python 3 solution for this coding contest problem. You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi. For the i-th query find any position pi (li ≤ pi ≤ ri) so that api ≠ xi. Input The first line contains two integers n, m (1 ≤ n, ...
instruction
0
84,632
12
169,264
Tags: data structures, implementation Correct Solution: ``` from sys import * n, m = [int(t) for t in input().split()] vec = [0 for t in range(n)] pre = [0 for t in range(n)] for idx, val in enumerate([int(t) for t in stdin.readline().split()]): vec[idx] = val pre[idx] = -1 if idx == 0 else (idx-1 if vec[idx-...
output
1
84,632
12
169,265
Provide tags and a correct Python 3 solution for this coding contest problem. You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi. For the i-th query find any position pi (li ≤ pi ≤ ri) so that api ≠ xi. Input The first line contains two integers n, m (1 ≤ n, ...
instruction
0
84,633
12
169,266
Tags: data structures, implementation Correct Solution: ``` from collections import defaultdict import bisect from itertools import accumulate import os import sys import math from decimal import * from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): ...
output
1
84,633
12
169,267
Provide tags and a correct Python 3 solution for this coding contest problem. You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi. For the i-th query find any position pi (li ≤ pi ≤ ri) so that api ≠ xi. Input The first line contains two integers n, m (1 ≤ n, ...
instruction
0
84,634
12
169,268
Tags: data structures, implementation Correct Solution: ``` from sys import * n, m = [int(t) for t in input().split()] vec = [] pre = [] for idx, val in enumerate([int(t) for t in stdin.readline().split()]): vec.append(val) last = -1 if idx == 0 else (idx-1 if vec[idx-1] != val else pre[idx-1]) pre.appen...
output
1
84,634
12
169,269