message
stringlengths
2
65.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
0
108k
cluster
float64
14
14
__index_level_0__
int64
0
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time.
instruction
0
19,923
14
39,846
Tags: implementation Correct Solution: ``` nb_pair = int(input()) drawn = [int(x) for x in input().split()] maxs = 1 table = set() for i in drawn: table ^= {i} maxs = max(maxs, len(table)) print(maxs) ```
output
1
19,923
14
39,847
Provide tags and a correct Python 3 solution for this coding contest problem. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time.
instruction
0
19,924
14
39,848
Tags: implementation Correct Solution: ``` N=input() L=input().split() S=set() m=0 for i in L: S^={i} if len(S)>m: m=len(S) print(m) ```
output
1
19,924
14
39,849
Provide tags and a correct Python 3 solution for this coding contest problem. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time.
instruction
0
19,925
14
39,850
Tags: implementation Correct Solution: ``` n = int(input()) a = [int(x) for x in input().split()] maxn = maxans = 0 used = [True] * n for i in range(n * 2): if used[a[i] - 1]: used[a[i] - 1] = False maxn += 1 elif not used[a[i] - 1]: maxn -= 1 if maxn > maxans: maxans = maxn print(maxans) ```
output
1
19,925
14
39,851
Provide tags and a correct Python 3 solution for this coding contest problem. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time.
instruction
0
19,926
14
39,852
Tags: implementation Correct Solution: ``` n = int(input()) a = [False] * n x = list(map(int, input().split())) cnt = 0 ans = 0 for y in x: y -= 1 if a[y]: cnt -= 1 else: cnt += 1 a[y] = True ans = max(ans, cnt) print(ans) ```
output
1
19,926
14
39,853
Provide tags and a correct Python 3 solution for this coding contest problem. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time.
instruction
0
19,927
14
39,854
Tags: implementation Correct Solution: ``` # https://codeforces.com/problemset/problem/780/A n = input() s = set() ans = 0 for i in input().split(): if i not in s: s.add(i) ans = max(ans, len(s)) else: s.discard(i) print(ans) ```
output
1
19,927
14
39,855
Provide tags and a correct Python 3 solution for this coding contest problem. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time.
instruction
0
19,928
14
39,856
Tags: implementation Correct Solution: ``` input() sp=input().split() count=1 sont=set() for x in sp: sont^={x} l = len(sont) if l>count: count=l print(count) ```
output
1
19,928
14
39,857
Provide tags and a correct Python 3 solution for this coding contest problem. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time.
instruction
0
19,929
14
39,858
Tags: implementation Correct Solution: ``` # import sys # sys.stdin=open('input.in','r') # sys.stdout=open('output.out','w') n=int(input()) m=list(map(int,input().strip().split()[:2*n])) t=set() k=[] count=0 for x in m: if x not in t: t.add(x) count=max(count,len(t)) else: t.remove(x) print(count) ```
output
1
19,929
14
39,859
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time. Submitted Solution: ``` n = int(input()) l = input() l = l.split() for i in range(2 * n): l[i] = int(l[i]) stk = set() m = None for x in l: if x in stk: stk.remove(x) else: stk.add(x) if m is None or len(stk) > m: m = len(stk) print(m) ```
instruction
0
19,930
14
39,860
Yes
output
1
19,930
14
39,861
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time. Submitted Solution: ``` # print("Input n") n = int(input()) # print("Input the 2n integers") a = [int(x) for x in input().split()] pairtracker = [0 for x in range(n)] largestsofar = 0 countnow = 0 for x in a: x = x - 1 # Making it zero-based if pairtracker[x] == 0: # First one of the pair pairtracker[x] = 1 countnow += 1 if countnow > largestsofar: largestsofar = countnow else: # Second one of the pair countnow -= 1 print(largestsofar) ```
instruction
0
19,931
14
39,862
Yes
output
1
19,931
14
39,863
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time. Submitted Solution: ``` n = int(input()) m = 0 now = 0 table = [False]*(100100) arr = list(map(int,input().split())) for i in arr: if table[i]: now-=1 else: table[i] = True now+=1 m = max(now,m) print(m) ```
instruction
0
19,932
14
39,864
Yes
output
1
19,932
14
39,865
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time. Submitted Solution: ``` input() res = 0 s = set() for el in input().split(): if el in s: s.remove(el) else: s.add(el) res = max(res, len(s)) print(res) ```
instruction
0
19,933
14
39,866
Yes
output
1
19,933
14
39,867
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time. Submitted Solution: ``` n = int(input()) l = list(map(int, input().split())) l_table = [] maxlen = 0 i = 0 while n - i > maxlen: if l[i] not in l_table: l_table.append(l[i]) else: l_table.remove(l[i]) i += 1 if len(l_table) > maxlen: maxlen = len(l_table) print(maxlen) ```
instruction
0
19,934
14
39,868
No
output
1
19,934
14
39,869
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time. Submitted Solution: ``` n = int(input()) string = input() numbers = [int(x) for x in string.split()] socks = [] s = 0 table = [0 for x in range(n)] for x in numbers: if table[x - 1] == 0: table[x - 1] = 1 s += 1 else: table[x - 1] = 0 s -= 2 socks.append(s) print(max(socks)) ```
instruction
0
19,935
14
39,870
No
output
1
19,935
14
39,871
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time. Submitted Solution: ``` n = int(input()) l = list(map(int,input().split())) max1 = 1 ans = [] rep=0 for i in l: if i in ans: break else: ans.append(i) if len(ans)-rep > max1: max1 = len(ans) print(max1) ```
instruction
0
19,936
14
39,872
No
output
1
19,936
14
39,873
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Andryusha is an orderly boy and likes to keep things in their place. Today he faced a problem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe. Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time? Input The first line contains the single integer n (1 ≀ n ≀ 105) β€” the number of sock pairs. The second line contains 2n integers x1, x2, ..., x2n (1 ≀ xi ≀ n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi. It is guaranteed that Andryusha took exactly two socks of each pair. Output Print single integer β€” the maximum number of socks that were on the table at the same time. Examples Input 1 1 1 Output 1 Input 3 2 1 1 3 2 3 Output 2 Note In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time. In the second example Andryusha behaved as follows: * Initially the table was empty, he took out a sock from pair 2 and put it on the table. * Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table. * Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe. * Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table. * Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe. * Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe. Thus, at most two socks were on the table at the same time. Submitted Solution: ``` n=input() m=input().split(' ') print(len(set(m[:int(n)]))) ```
instruction
0
19,937
14
39,874
No
output
1
19,937
14
39,875
Provide tags and a correct Python 3 solution for this coding contest problem. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his office exactly ai times. We will assume that an examination takes much more time than making tests and other extra procedures, and therefore we will assume that once an animal leaves the room, it immediately gets to the end of the queue to the doctor. Of course, if the animal has visited the doctor as many times as necessary, then it doesn't have to stand at the end of the queue and it immediately goes home. Doctor plans to go home after receiving k animals, and therefore what the queue will look like at that moment is important for him. Since the doctor works long hours and she can't get distracted like that after all, she asked you to figure it out. Input The first line of input data contains two space-separated integers n and k (1 ≀ n ≀ 105, 0 ≀ k ≀ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator). Output If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers β€” number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or print one "End of line"-character. Both will be accepted. Examples Input 3 3 1 2 1 Output 2 Input 4 10 3 3 2 1 Output -1 Input 7 10 1 3 3 1 2 3 1 Output 6 2 3 Note In the first sample test: * Before examination: {1, 2, 3} * After the first examination: {2, 3} * After the second examination: {3, 2} * After the third examination: {2} In the second sample test: * Before examination: {1, 2, 3, 4, 5, 6, 7} * After the first examination: {2, 3, 4, 5, 6, 7} * After the second examination: {3, 4, 5, 6, 7, 2} * After the third examination: {4, 5, 6, 7, 2, 3} * After the fourth examination: {5, 6, 7, 2, 3} * After the fifth examination: {6, 7, 2, 3, 5} * After the sixth examination: {7, 2, 3, 5, 6} * After the seventh examination: {2, 3, 5, 6} * After the eighth examination: {3, 5, 6, 2} * After the ninth examination: {5, 6, 2, 3} * After the tenth examination: {6, 2, 3}
instruction
0
19,957
14
39,914
Tags: binary search, math, sortings Correct Solution: ``` import sys from array import array # noqa: F401 from collections import deque def input(): return sys.stdin.buffer.readline().decode('utf-8') n, k = map(int, input().split()) a = list(map(int, input().split())) if sum(a) < k: print(-1) exit() ok, ng = 0, 10**9 + 10 while abs(ok - ng) > 1: mid = (ok + ng) >> 1 if sum(mid if mid < x else x for x in a) <= k: ok = mid else: ng = mid index = deque([i + 1 for i in range(n) if a[i] > ok]) dq = deque([x - ok for x in a if x > ok]) k -= sum(ok if ok < x else x for x in a) for _ in range(k): dq[0] -= 1 if dq[0]: dq.rotate(-1) index.rotate(-1) else: dq.popleft() index.popleft() print(*index) ```
output
1
19,957
14
39,915
Provide tags and a correct Python 3 solution for this coding contest problem. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his office exactly ai times. We will assume that an examination takes much more time than making tests and other extra procedures, and therefore we will assume that once an animal leaves the room, it immediately gets to the end of the queue to the doctor. Of course, if the animal has visited the doctor as many times as necessary, then it doesn't have to stand at the end of the queue and it immediately goes home. Doctor plans to go home after receiving k animals, and therefore what the queue will look like at that moment is important for him. Since the doctor works long hours and she can't get distracted like that after all, she asked you to figure it out. Input The first line of input data contains two space-separated integers n and k (1 ≀ n ≀ 105, 0 ≀ k ≀ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator). Output If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers β€” number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or print one "End of line"-character. Both will be accepted. Examples Input 3 3 1 2 1 Output 2 Input 4 10 3 3 2 1 Output -1 Input 7 10 1 3 3 1 2 3 1 Output 6 2 3 Note In the first sample test: * Before examination: {1, 2, 3} * After the first examination: {2, 3} * After the second examination: {3, 2} * After the third examination: {2} In the second sample test: * Before examination: {1, 2, 3, 4, 5, 6, 7} * After the first examination: {2, 3, 4, 5, 6, 7} * After the second examination: {3, 4, 5, 6, 7, 2} * After the third examination: {4, 5, 6, 7, 2, 3} * After the fourth examination: {5, 6, 7, 2, 3} * After the fifth examination: {6, 7, 2, 3, 5} * After the sixth examination: {7, 2, 3, 5, 6} * After the seventh examination: {2, 3, 5, 6} * After the eighth examination: {3, 5, 6, 2} * After the ninth examination: {5, 6, 2, 3} * After the tenth examination: {6, 2, 3}
instruction
0
19,958
14
39,916
Tags: binary search, math, sortings Correct Solution: ``` from sys import stdin, stdout n, k = map(int, stdin.readline().split()) values = list(map(int, stdin.readline().split())) if sum(values) < k: stdout.write('-1') elif sum(values) > k: l = 0 r = k + 1 while (r - l > 1): m = (r + l) // 2 cnt = 0 for i in range(n): cnt += min(values[i], m) if cnt > k: r = m else: l = m for i in range(n): k -= min(values[i], l) values[i] -= min(values[i], l) i = 0 while k: if values[i]: values[i] -= 1 k -= 1 i = (i + 1) % n for j in range(i, i + n): if values[j % n]: stdout.write(str(j % n + 1) + ' ') ```
output
1
19,958
14
39,917
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his office exactly ai times. We will assume that an examination takes much more time than making tests and other extra procedures, and therefore we will assume that once an animal leaves the room, it immediately gets to the end of the queue to the doctor. Of course, if the animal has visited the doctor as many times as necessary, then it doesn't have to stand at the end of the queue and it immediately goes home. Doctor plans to go home after receiving k animals, and therefore what the queue will look like at that moment is important for him. Since the doctor works long hours and she can't get distracted like that after all, she asked you to figure it out. Input The first line of input data contains two space-separated integers n and k (1 ≀ n ≀ 105, 0 ≀ k ≀ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator). Output If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers β€” number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or print one "End of line"-character. Both will be accepted. Examples Input 3 3 1 2 1 Output 2 Input 4 10 3 3 2 1 Output -1 Input 7 10 1 3 3 1 2 3 1 Output 6 2 3 Note In the first sample test: * Before examination: {1, 2, 3} * After the first examination: {2, 3} * After the second examination: {3, 2} * After the third examination: {2} In the second sample test: * Before examination: {1, 2, 3, 4, 5, 6, 7} * After the first examination: {2, 3, 4, 5, 6, 7} * After the second examination: {3, 4, 5, 6, 7, 2} * After the third examination: {4, 5, 6, 7, 2, 3} * After the fourth examination: {5, 6, 7, 2, 3} * After the fifth examination: {6, 7, 2, 3, 5} * After the sixth examination: {7, 2, 3, 5, 6} * After the seventh examination: {2, 3, 5, 6} * After the eighth examination: {3, 5, 6, 2} * After the ninth examination: {5, 6, 2, 3} * After the tenth examination: {6, 2, 3} Submitted Solution: ``` from sys import stdin, stdout n, k = map(int, stdin.readline().split()) values = list(map(int, stdin.readline().split())) l = 0 r = k + 10 while (r - l > 1): m = (r + l) // 2 cnt = 0 for i in range(n): cnt += min(values[i], m) if cnt > k: r = m else: l = m if l == k + 9: stdout.write('-1') else: for i in range(n): k -= min(values[i], l) values[i] -= min(values[i], l) i = 0 while k: if values[i]: values[i] -= 1 k -= 1 i = (i + 1) % n if not k: break for j in range(i, i + n): if values[j % n]: stdout.write(str(j % n + 1) + ' ') ```
instruction
0
19,959
14
39,918
No
output
1
19,959
14
39,919
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his office exactly ai times. We will assume that an examination takes much more time than making tests and other extra procedures, and therefore we will assume that once an animal leaves the room, it immediately gets to the end of the queue to the doctor. Of course, if the animal has visited the doctor as many times as necessary, then it doesn't have to stand at the end of the queue and it immediately goes home. Doctor plans to go home after receiving k animals, and therefore what the queue will look like at that moment is important for him. Since the doctor works long hours and she can't get distracted like that after all, she asked you to figure it out. Input The first line of input data contains two space-separated integers n and k (1 ≀ n ≀ 105, 0 ≀ k ≀ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109). Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator). Output If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers β€” number of animals in the order in which they stand in the queue. Note that this sequence may be empty. This case is present in pretests. You can just print nothing or print one "End of line"-character. Both will be accepted. Examples Input 3 3 1 2 1 Output 2 Input 4 10 3 3 2 1 Output -1 Input 7 10 1 3 3 1 2 3 1 Output 6 2 3 Note In the first sample test: * Before examination: {1, 2, 3} * After the first examination: {2, 3} * After the second examination: {3, 2} * After the third examination: {2} In the second sample test: * Before examination: {1, 2, 3, 4, 5, 6, 7} * After the first examination: {2, 3, 4, 5, 6, 7} * After the second examination: {3, 4, 5, 6, 7, 2} * After the third examination: {4, 5, 6, 7, 2, 3} * After the fourth examination: {5, 6, 7, 2, 3} * After the fifth examination: {6, 7, 2, 3, 5} * After the sixth examination: {7, 2, 3, 5, 6} * After the seventh examination: {2, 3, 5, 6} * After the eighth examination: {3, 5, 6, 2} * After the ninth examination: {5, 6, 2, 3} * After the tenth examination: {6, 2, 3} Submitted Solution: ``` from sys import stdin, stdout n, k = map(int, stdin.readline().split()) values = list(map(int, stdin.readline().split())) l = 0 r = k + 1 while (r - l > 1): m = (r + l) // 2 cnt = 0 for i in range(n): cnt += min(values[i], m) if cnt > k: r = m else: l = m if l == k: stdout.write('-1') else: for i in range(n): k -= min(values[i], l) values[i] -= min(values[i], l) i = 0 while k: if values[i]: values[i] -= 1 k -= 1 i = (i + 1) % n if not k: break for j in range(i, i + n): if values[j % n]: stdout.write(str(j % n + 1) + ' ') ```
instruction
0
19,960
14
39,920
No
output
1
19,960
14
39,921
Provide tags and a correct Python 3 solution for this coding contest problem. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302.
instruction
0
19,961
14
39,922
Tags: implementation Correct Solution: ``` n, k, x = map(int, input().split()) times = list(map(int, input().split())) for i in range(n - 1, n - k - 1, -1): times[i] = x print(sum(times)) ```
output
1
19,961
14
39,923
Provide tags and a correct Python 3 solution for this coding contest problem. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302.
instruction
0
19,962
14
39,924
Tags: implementation Correct Solution: ``` n,k,x = map(int,input().split()) l = list(map(int,input().split())) print(sum([l[i] for i in range(n-k)])+k*x) ```
output
1
19,962
14
39,925
Provide tags and a correct Python 3 solution for this coding contest problem. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302.
instruction
0
19,963
14
39,926
Tags: implementation Correct Solution: ``` n,k,x = map(int,input().split()) a = list(map(int,input().split())) print(sum(a[:len(a)-k])+k*x) ```
output
1
19,963
14
39,927
Provide tags and a correct Python 3 solution for this coding contest problem. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302.
instruction
0
19,964
14
39,928
Tags: implementation Correct Solution: ``` # A. Chores n, k, x = map(int, input().split()) a = list(map(int, input().split())) ans = sum(a[:n-k]) ans += k * x print(ans) ```
output
1
19,964
14
39,929
Provide tags and a correct Python 3 solution for this coding contest problem. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302.
instruction
0
19,965
14
39,930
Tags: implementation Correct Solution: ``` n, k, x = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(k): if a[n - 1 - i] > x: a[n - 1 - i] = x else: break print(sum(a)) ```
output
1
19,965
14
39,931
Provide tags and a correct Python 3 solution for this coding contest problem. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302.
instruction
0
19,966
14
39,932
Tags: implementation Correct Solution: ``` n, k, x = map(int, input().split()) a = list(map(int, input().split())) for i in range(k): a[-1-i] = x print(sum(a)) ```
output
1
19,966
14
39,933
Provide tags and a correct Python 3 solution for this coding contest problem. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302.
instruction
0
19,967
14
39,934
Tags: implementation Correct Solution: ``` n,k,x = map(int,input().split()) lis = list(map(int,input().split())) aa=sum(lis[:n-k])+(x*k) print(aa) ```
output
1
19,967
14
39,935
Provide tags and a correct Python 3 solution for this coding contest problem. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302.
instruction
0
19,968
14
39,936
Tags: implementation Correct Solution: ``` read = lambda: tuple(map(int, input().split())) n, k, x = read() l = list(read()) for i in range(k): l[-i-1] = x print(sum(l)) ```
output
1
19,968
14
39,937
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302. Submitted Solution: ``` ##a = list(map(int, input().split())) ##print(' '.join(map(str, res))) [n, k, x] = list(map(int, input().split())) a = list(map(int, input().split())) a.sort(reverse=True) res = 0 for i in range(n): if i < k: res += x else: res += a[i] print(res) ```
instruction
0
19,969
14
39,938
Yes
output
1
19,969
14
39,939
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302. Submitted Solution: ``` n, k, x = map(int, input().split()) a = list(map(int, input().split())) d = sum(a[:-k]) print(d + (k * x)) # CodeForcesian # β™₯ # Ψ§Ϊ―Ω‡ Ω…ΫŒΨͺΩˆΩ†ΫŒ Ψͺءور Ϊ©Ω†ΫŒ ΩΎΨ³ Ψ­ΨͺΩ…Ψ§ Ω…ΫŒΨͺΩˆΩ†ΫŒ Ψ§Ω†Ψ¬Ψ§Ω…Ψ΄ بدی ```
instruction
0
19,970
14
39,940
Yes
output
1
19,970
14
39,941
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302. Submitted Solution: ``` n, k, x = map(int, input().split()) a = list(map(int, input().split())) print(sum(a) + k * x - sum(a[i] for i in range(n - 1, n - k - 1, -1))) ```
instruction
0
19,971
14
39,942
Yes
output
1
19,971
14
39,943
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302. Submitted Solution: ``` n,k,x = [int(i) for i in input().split()] a = [int(i) for i in input().split()] ans = 0 for i in range(n-k): ans += a[i] ans += x*k print(ans) ```
instruction
0
19,972
14
39,944
Yes
output
1
19,972
14
39,945
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302. Submitted Solution: ``` n,k,x=map(int,input().split()) a=list(map(int,input().split())) if(len(a))<=2: print(k*x) else: a.remove(max(a)) a.remove(max(a)) print(sum(a)+k*x) ```
instruction
0
19,973
14
39,946
No
output
1
19,973
14
39,947
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302. Submitted Solution: ``` n, k, x = map(int, input().split()) l = sorted([int(i) for i in input().split()])[::-1] lst = l[2:] print(sum(lst) + k*x) ```
instruction
0
19,974
14
39,948
No
output
1
19,974
14
39,949
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302. Submitted Solution: ``` n, k, x = map(int, input().split()) a = list(map(int, input().split())) for i in range(n - 1 - k, n): a[i] = x print(sum(a)) ```
instruction
0
19,975
14
39,950
No
output
1
19,975
14
39,951
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai β‰₯ ai - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>). Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously. Input The first line contains three integers n, k, x (1 ≀ k ≀ n ≀ 100, 1 ≀ x ≀ 99) β€” the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself. The second line contains n integer numbers ai (2 ≀ ai ≀ 100) β€” the time Luba has to spend to do i-th chore. It is guaranteed that <image>, and for each <image> ai β‰₯ ai - 1. Output Print one number β€” minimum time Luba needs to do all n chores. Examples Input 4 2 2 3 6 7 10 Output 13 Input 5 2 1 100 100 100 100 100 Output 302 Note In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13. In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100Β·3 + 2Β·1 = 302. Submitted Solution: ``` line1 = input().split() n,k,x = int(line1[0]),int(line1[1]),int(line1[2]) suma = [int(i) for i in input().split()] print(sum(suma[:k+1])+x*k) ```
instruction
0
19,976
14
39,952
No
output
1
19,976
14
39,953
Provide a correct Python 3 solution for this coding contest problem. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2
instruction
0
20,251
14
40,502
"Correct Solution: ``` n,q=[int(i) for i in input().split(" ")] Q=[[] for i in range(n)] for _ in range(q): query=[int(j) for j in input().split(" ")] if query[0]==0: Q[query[1]].append(query[2]) elif query[0]==1: if len(Q[query[1]])>0: print(Q[query[1]][0]) else: if len(Q[query[1]])>0: Q[query[1]].pop(0) ```
output
1
20,251
14
40,503
Provide a correct Python 3 solution for this coding contest problem. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2
instruction
0
20,252
14
40,504
"Correct Solution: ``` from collections import deque n, q = list(map(int, input().split())) Q = deque() [Q.append(deque([])) for _ in range(n)] for i in range(q): query = list(map(int, input().split())) t = query[1] # enqueue if query[0] == 0: Q[t].append(query[2]) # front elif query[0] == 1: if Q[t]: print(Q[t][0]) # dequeue else: if Q[t]: Q[t].popleft() ```
output
1
20,252
14
40,505
Provide a correct Python 3 solution for this coding contest problem. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2
instruction
0
20,253
14
40,506
"Correct Solution: ``` n,q = map(int,input().split()) li = [] for i in range(n): li.append([]) for i in range(q): x = list(map(int,input().split())) if len(x) == 3: li[x[1]].append(x[2]) else: if x[0] == 1: if li[x[1]] != []: print(li[x[1]][0]) else: if li[x[1]] != []: li[x[1]].remove(li[x[1]][0]) ```
output
1
20,253
14
40,507
Provide a correct Python 3 solution for this coding contest problem. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2
instruction
0
20,254
14
40,508
"Correct Solution: ``` n,q = map(int,input().split()) Q = [] for i in range(n): Q.append([]) for i in range(q): nq = list(map(int,input().split())) if nq[0] == 0: Q[nq[1]].append(nq[2]) elif nq[0] == 1 and len(Q[nq[1]]) > 0: print (Q[nq[1]][0]) elif len(Q[nq[1]]) > 0: del Q[nq[1]][0] ```
output
1
20,254
14
40,509
Provide a correct Python 3 solution for this coding contest problem. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2
instruction
0
20,255
14
40,510
"Correct Solution: ``` import collections n, q = map(int, input().split()) Q = [collections.deque() for i in range(n)] queries = list() for i in range(q): queries.append(list(map(int, input().split()))) for query in queries: if query[0] == 0: Q[query[1]].append(query[2]) elif query[0] == 1: try: print(Q[query[1]][0]) except: pass elif query[0] == 2: try: Q[query[1]].popleft() except: pass ```
output
1
20,255
14
40,511
Provide a correct Python 3 solution for this coding contest problem. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2
instruction
0
20,256
14
40,512
"Correct Solution: ``` from collections import deque n, q = map(int, input().split()) S = [deque([]) for _ in range(n)] for _ in range(q): command, *list_num = input().split() t = int(list_num[0]) if command == "0": # enqueue(t, x) x = int(list_num[1]) S[t].append(x) elif command == "1": # front(t) if S[t]: print(S[t][0]) elif command == "2": # dequeue(t) if S[t]: S[t].popleft() else: raise ```
output
1
20,256
14
40,513
Provide a correct Python 3 solution for this coding contest problem. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2
instruction
0
20,257
14
40,514
"Correct Solution: ``` from collections import deque n, q = map(int, input().split()) Q = [deque() for _ in range(n)] for _ in range(q): query = list(map(int, input().split())) if query[0] == 0: Q[query[1]].append(query[2]) elif len(Q[query[1]]) > 0: if query[0] == 1: print(Q[query[1]][0]) elif query[0] == 2: Q[query[1]].popleft() ```
output
1
20,257
14
40,515
Provide a correct Python 3 solution for this coding contest problem. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2
instruction
0
20,258
14
40,516
"Correct Solution: ``` # -*- coding: utf-8 -*- """ Created on Sun Jun 24 14:53:50 2018 ITP22B @author: maezawa """ from collections import deque n, q = list(map(int, input().split())) d = [deque() for _ in range(n)] for i in range(q): c = list(map(int, input().split())) if c[0] == 0: d[c[1]].append(c[2]) elif c[0] == 1: if d[c[1]]: print(d[c[1]][0]) else: if d[c[1]]: d[c[1]].popleft() ```
output
1
20,258
14
40,517
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2 Submitted Solution: ``` from collections import deque def main(): num_queues, num_queries = [int(x) for x in input().split(" ")] qs = [deque() for i in range(num_queues)] for i in range(num_queries): query = input() if (query[0] == '0'): cmd, q_idx, elem = [int(x) for x in query.split(" ")] qs[q_idx].appendleft(elem) elif (query[0] == '1'): cmd, q_idx = [int(x) for x in query.split(" ")] if qs[q_idx]: print(qs[q_idx][-1]) elif (query[0] == '2'): cmd, q_idx = [int(x) for x in query.split(" ")] if qs[q_idx]: qs[q_idx].pop() if __name__ == '__main__': main() ```
instruction
0
20,259
14
40,518
Yes
output
1
20,259
14
40,519
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2 Submitted Solution: ``` class Node: def __init__(self,key): self.key = key self.prev = None self.next = None class Queue: def __init__(self): self.head = Node(0) self.tail = self.head def enqueue(self,key): node = Node(key) self.tail.next = node node.prev = self.tail self.tail = node def front(self): if self.head != self.tail: return self.head.next.key def dequeue(self): if self.head != self.tail: if self.head.next == self.tail: self.tail = self.head self.head.next = self.head.next.next n,q = map(int,input().split()) Q = [Queue() for i in range(n)] for i in range(q): com, index, *n = map(int,input().split()) if com == 0: Q[index].enqueue(*n) elif com == 1: key = Q[index].front() if key != None: print(key) elif com == 2: Q[index].dequeue() ```
instruction
0
20,260
14
40,520
Yes
output
1
20,260
14
40,521
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2 Submitted Solution: ``` from sys import stdin,stdout from collections import defaultdict,deque n, q = map(int,stdin.readline().split()) queries = stdin.readlines() A = defaultdict(deque) ans = [] #count = 0 for query in queries: #print(count) #count += 1 query = query.split() if query[0] == '0': A[int(query[1])].append(query[2]) elif query[0] == '1': index = int(query[1]) if A[index]: ans.append(A[index][0]+'\n') else: index = int(query[1]) if A[index]: A[index].popleft() stdout.writelines(ans) ```
instruction
0
20,261
14
40,522
Yes
output
1
20,261
14
40,523
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2 Submitted Solution: ``` def resolve(): from collections import deque n, Q = [int(i) for i in input().split()] ans = [deque() for _ in range(n)] for _ in range(Q): q = [int(i) for i in input().split()] if q[0] == 0: ans[q[1]].append(q[2]) elif q[0] == 1: if len(ans[q[1]]) > 0: print(ans[q[1]][0]) else: if len(ans[q[1]]) > 0: ans[q[1]].popleft() resolve() ```
instruction
0
20,262
14
40,524
Yes
output
1
20,262
14
40,525
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out). For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * enqueue($t$, $x$): Insert an integer $x$ to $Q_t$. * front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing. * dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing. In the initial state, all queues are empty. Constraints * $1 \leq n \leq 1,000$ * $1 \leq q \leq 200,000$ * $-1,000,000,000 \leq x \leq 1,000,000,000$ Input The input is given in the following format. $n \; q$ $query_1$ $query_2$ : $query_q$ Each query $query_i$ is given by 0 $t$ $x$ or 1 $t$ or 2 $t$ where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively. Output For each front operation, print an integer in a line. Example Input 3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0 Output 1 4 2 Submitted Solution: ``` from collections import deque a = [int(i) for i in input().split()] q = deque([]) for i in range(a[0]): q.append(deque([])) for i in range(a[1]): cmd = [int(i) for i in input().split()] if cmd[0] == 0: q[cmd[1]].append(cmd[2]) elif cmd[0] == 1: if q[cmd[1]] != []: print(q[cmd[1]][0]) elif cmd[0] == 2: if q[cmd[1]] != []: q[cmd[1]].popleft() ```
instruction
0
20,263
14
40,526
No
output
1
20,263
14
40,527
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cats in a line, labeled from 1 to n, with the i-th cat at position i. They are bored of gyrating in the same spot all day, so they want to reorder themselves such that no cat is in the same place as before. They are also lazy, so they want to minimize the total distance they move. Help them decide what cat should be at each location after the reordering. For example, if there are 3 cats, this is a valid reordering: [3, 1, 2]. No cat is in its original position. The total distance the cats move is 1 + 1 + 2 = 4 as cat 1 moves one place to the right, cat 2 moves one place to the right, and cat 3 moves two places to the left. Input The first line contains a single integer t (1 ≀ t ≀ 100) β€” the number of test cases. Then t test cases follow. The first and only line of each test case contains one integer n (2 ≀ n ≀ 100) β€” the number of cats. It can be proven that under the constraints of the problem, an answer always exist. Output Output t answers, one for each test case. Each answer consists of n integers β€” a permutation with the minimum total distance. If there are multiple answers, print any. Example Input 2 2 3 Output 2 1 3 1 2 Note For the first test case, there is only one possible permutation that satisfies the conditions: [2, 1]. The second test case was described in the statement. Another possible answer is [2, 3, 1].
instruction
0
20,532
14
41,064
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` t=int(input()) for i in range(t): n=int(input()) if n%2==0: for j in range(n//2): print(j*2+2,end=' ') print(j*2+1,end=' ') else: for j in range(n//2-1): print(j*2+2,end=' ') print(j*2+1,end=' ') print(n,end=' ') print(n-2,end=' ') print(n-1,end=' ') print() ```
output
1
20,532
14
41,065
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cats in a line, labeled from 1 to n, with the i-th cat at position i. They are bored of gyrating in the same spot all day, so they want to reorder themselves such that no cat is in the same place as before. They are also lazy, so they want to minimize the total distance they move. Help them decide what cat should be at each location after the reordering. For example, if there are 3 cats, this is a valid reordering: [3, 1, 2]. No cat is in its original position. The total distance the cats move is 1 + 1 + 2 = 4 as cat 1 moves one place to the right, cat 2 moves one place to the right, and cat 3 moves two places to the left. Input The first line contains a single integer t (1 ≀ t ≀ 100) β€” the number of test cases. Then t test cases follow. The first and only line of each test case contains one integer n (2 ≀ n ≀ 100) β€” the number of cats. It can be proven that under the constraints of the problem, an answer always exist. Output Output t answers, one for each test case. Each answer consists of n integers β€” a permutation with the minimum total distance. If there are multiple answers, print any. Example Input 2 2 3 Output 2 1 3 1 2 Note For the first test case, there is only one possible permutation that satisfies the conditions: [2, 1]. The second test case was described in the statement. Another possible answer is [2, 3, 1].
instruction
0
20,533
14
41,066
Tags: constructive algorithms, greedy, implementation Correct Solution: ``` t = int(input()) for _ in range(0,t): n = int(input()) if n%2 == 0: pairs = int(n/2) for i in range(1,pairs+1): print(2*i,end = " ") print(2*i - 1, end = " ") else: pairs = int(n//2) - 1 for i in range(1,pairs+1): print(2*i,end = " ") print(2*i - 1, end = " ") print(n,n-2,n-1, end = " ") print() ```
output
1
20,533
14
41,067