message
stringlengths
2
67k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
463
109k
cluster
float64
19
19
__index_level_0__
int64
926
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n/2 nonempty piles). Given the starting configuration, determine who will win the game. Input The first line contains one integer n (2 ≀ n ≀ 50) β€” the number of piles. It is guaranteed that n is an even number. The second line contains n integers a_1, a_2, …, a_n (1 ≀ a_i ≀ 50) β€” the number of stones in the piles. Output Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes). Examples Input 2 8 8 Output Bob Input 4 3 1 4 1 Output Alice Note In the first example, each player can only remove stones from one pile (2/2=1). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first. In the second example, Alice can remove 2 stones from the first pile and 3 stones from the third pile on her first move to guarantee a win. Submitted Solution: ``` i=input n,s=int(i()),list(map(int,i().split())) print("Bob"if s.count(min(s))>n/2 else"Alice") ```
instruction
0
69,902
19
139,804
Yes
output
1
69,902
19
139,805
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n/2 nonempty piles). Given the starting configuration, determine who will win the game. Input The first line contains one integer n (2 ≀ n ≀ 50) β€” the number of piles. It is guaranteed that n is an even number. The second line contains n integers a_1, a_2, …, a_n (1 ≀ a_i ≀ 50) β€” the number of stones in the piles. Output Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes). Examples Input 2 8 8 Output Bob Input 4 3 1 4 1 Output Alice Note In the first example, each player can only remove stones from one pile (2/2=1). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first. In the second example, Alice can remove 2 stones from the first pile and 3 stones from the third pile on her first move to guarantee a win. Submitted Solution: ``` def nim(lst): count = 0 m1, m2 = min(lst), max(lst) for elem in lst: if elem == m1 and not m1 == m2: count += 1 if m1 == m2: return "Bob" elif len(lst) // 2 < count: return 'Bob' return 'Alice' n = int(input()) a = [int(i) for i in input().split()] print(nim(a)) ```
instruction
0
69,903
19
139,806
Yes
output
1
69,903
19
139,807
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n/2 nonempty piles). Given the starting configuration, determine who will win the game. Input The first line contains one integer n (2 ≀ n ≀ 50) β€” the number of piles. It is guaranteed that n is an even number. The second line contains n integers a_1, a_2, …, a_n (1 ≀ a_i ≀ 50) β€” the number of stones in the piles. Output Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes). Examples Input 2 8 8 Output Bob Input 4 3 1 4 1 Output Alice Note In the first example, each player can only remove stones from one pile (2/2=1). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first. In the second example, Alice can remove 2 stones from the first pile and 3 stones from the third pile on her first move to guarantee a win. Submitted Solution: ``` n = int(input()) a = list(map(int,input().split())) min1 = min(a) if(a.count(min1) > n//2 ): print('Bob') else: print('Alice') ```
instruction
0
69,904
19
139,808
Yes
output
1
69,904
19
139,809
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n/2 nonempty piles). Given the starting configuration, determine who will win the game. Input The first line contains one integer n (2 ≀ n ≀ 50) β€” the number of piles. It is guaranteed that n is an even number. The second line contains n integers a_1, a_2, …, a_n (1 ≀ a_i ≀ 50) β€” the number of stones in the piles. Output Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes). Examples Input 2 8 8 Output Bob Input 4 3 1 4 1 Output Alice Note In the first example, each player can only remove stones from one pile (2/2=1). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first. In the second example, Alice can remove 2 stones from the first pile and 3 stones from the third pile on her first move to guarantee a win. Submitted Solution: ``` n = int(input()) a = list(map(int,input().split())) if a.count(min(a)) > n//2: print('Bob') else: print('Alice') ```
instruction
0
69,905
19
139,810
Yes
output
1
69,905
19
139,811
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n/2 nonempty piles). Given the starting configuration, determine who will win the game. Input The first line contains one integer n (2 ≀ n ≀ 50) β€” the number of piles. It is guaranteed that n is an even number. The second line contains n integers a_1, a_2, …, a_n (1 ≀ a_i ≀ 50) β€” the number of stones in the piles. Output Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes). Examples Input 2 8 8 Output Bob Input 4 3 1 4 1 Output Alice Note In the first example, each player can only remove stones from one pile (2/2=1). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first. In the second example, Alice can remove 2 stones from the first pile and 3 stones from the third pile on her first move to guarantee a win. Submitted Solution: ``` n = int(input()) A = list(map(int, input().split())) cnt = 0 for a in A: if a == 1: cnt += 1 if 1 <= cnt <= n//2: print('Alice') else: print('Bob') ```
instruction
0
69,906
19
139,812
No
output
1
69,906
19
139,813
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n/2 nonempty piles). Given the starting configuration, determine who will win the game. Input The first line contains one integer n (2 ≀ n ≀ 50) β€” the number of piles. It is guaranteed that n is an even number. The second line contains n integers a_1, a_2, …, a_n (1 ≀ a_i ≀ 50) β€” the number of stones in the piles. Output Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes). Examples Input 2 8 8 Output Bob Input 4 3 1 4 1 Output Alice Note In the first example, each player can only remove stones from one pile (2/2=1). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first. In the second example, Alice can remove 2 stones from the first pile and 3 stones from the third pile on her first move to guarantee a win. Submitted Solution: ``` from collections import Counter as C n = int(input()) c = C(map(int, input().split())) m = c[min(c.keys())] print("Alice" if m < n else "Bob") ```
instruction
0
69,907
19
139,814
No
output
1
69,907
19
139,815
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n/2 nonempty piles). Given the starting configuration, determine who will win the game. Input The first line contains one integer n (2 ≀ n ≀ 50) β€” the number of piles. It is guaranteed that n is an even number. The second line contains n integers a_1, a_2, …, a_n (1 ≀ a_i ≀ 50) β€” the number of stones in the piles. Output Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes). Examples Input 2 8 8 Output Bob Input 4 3 1 4 1 Output Alice Note In the first example, each player can only remove stones from one pile (2/2=1). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first. In the second example, Alice can remove 2 stones from the first pile and 3 stones from the third pile on her first move to guarantee a win. Submitted Solution: ``` x=int(input()) a=input().split() s=[int(num)for num in a] q=0 for i in s: q+=i if q%2==0: print('Bob') else: print('Alice') ```
instruction
0
69,908
19
139,816
No
output
1
69,908
19
139,817
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n/2 nonempty piles). Given the starting configuration, determine who will win the game. Input The first line contains one integer n (2 ≀ n ≀ 50) β€” the number of piles. It is guaranteed that n is an even number. The second line contains n integers a_1, a_2, …, a_n (1 ≀ a_i ≀ 50) β€” the number of stones in the piles. Output Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes). Examples Input 2 8 8 Output Bob Input 4 3 1 4 1 Output Alice Note In the first example, each player can only remove stones from one pile (2/2=1). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first. In the second example, Alice can remove 2 stones from the first pile and 3 stones from the third pile on her first move to guarantee a win. Submitted Solution: ``` n = int(input()) a = list(map(int,input().split())) n2 = n//2 a.sort() from bisect import bisect_right Alice = True while True: #if a[n2] > 1: if bisect_right(a,1) < n2: a[n2:] = [x-1 for x in a[n2:]] a.sort() Alice=(Alice==False) else: break if Alice: print('Alice') else: print('Bob') ```
instruction
0
69,909
19
139,818
No
output
1
69,909
19
139,819
Provide tags and a correct Python 3 solution for this coding contest problem. There is a game called "Unique Bid Auction". You can read more about it here: https://en.wikipedia.org/wiki/Unique_bid_auction (though you don't have to do it to solve this problem). Let's simplify this game a bit. Formally, there are n participants, the i-th participant chose the number a_i. The winner of the game is such a participant that the number he chose is unique (i. e. nobody else chose this number except him) and is minimal (i. e. among all unique values of a the minimum one is the winning one). Your task is to find the index of the participant who won the game (or -1 if there is no winner). Indexing is 1-based, i. e. the participants are numbered from 1 to n. You have to answer t independent test cases. Input The first line of the input contains one integer t (1 ≀ t ≀ 2 β‹… 10^4) β€” the number of test cases. Then t test cases follow. The first line of the test case contains one integer n (1 ≀ n ≀ 2 β‹… 10^5) β€” the number of participants. The second line of the test case contains n integers a_1, a_2, …, a_n (1 ≀ a_i ≀ n), where a_i is the i-th participant chosen number. It is guaranteed that the sum of n does not exceed 2 β‹… 10^5 (βˆ‘ n ≀ 2 β‹… 10^5). Output For each test case, print the answer β€” the index of the participant who won the game (or -1 if there is no winner). Note that the answer is always unique. Example Input 6 2 1 1 3 2 1 3 4 2 2 2 3 1 1 5 2 3 2 4 2 6 1 1 5 5 4 4 Output -1 2 4 1 2 -1
instruction
0
70,059
19
140,118
Tags: implementation Correct Solution: ``` import sys #input=sys.stdin.readline from collections import defaultdict as dc from collections import Counter from bisect import bisect_right, bisect_left import math from operator import itemgetter from heapq import heapify, heappop, heappush for _ in range(int(input())): n=int(input()) l=list(map(int,input().split())) x=dc(int) m=sys.maxsize p=-1 for i in range(n): x[l[i]]+=1 for i in x: if x[i]==1: m=min(m,i) if m==sys.maxsize: print(-1) else: print(l.index(m)+1) ```
output
1
70,059
19
140,119
Provide tags and a correct Python 3 solution for this coding contest problem. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.
instruction
0
70,153
19
140,306
Tags: games, math, number theory Correct Solution: ``` def gcd(a, b): while b > 0: a, b = b, a % b return a n = int(input()) A = list(map(int, input().split())) GCD = A[0] for x in A[1:]: GCD = gcd(GCD, x) num = max(A) // GCD - n if num % 2 == 0: print("Bob") else: print("Alice") ```
output
1
70,153
19
140,307
Provide tags and a correct Python 3 solution for this coding contest problem. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.
instruction
0
70,154
19
140,308
Tags: games, math, number theory Correct Solution: ``` def gcd(a,b): return a if b==0 else gcd(b,a%b) n=int(input()) a=list(map(int,input().split())) com=a[0] for x in a: com=gcd(com,x) cnt=max(a)//com print((cnt-n)%2==1 and 'Alice' or 'Bob') ```
output
1
70,154
19
140,309
Provide tags and a correct Python 3 solution for this coding contest problem. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.
instruction
0
70,155
19
140,310
Tags: games, math, number theory Correct Solution: ``` from fractions import gcd n = int(input()) sez = [int(i) for i in input().split()] sez.sort() g = gcd(sez[0], sez[1]) for i in range(2, n): g = gcd(g, sez[i]) left = sez[n-1]/g - n if left%2 == 1: print("Alice") else: print("Bob") ```
output
1
70,155
19
140,311
Provide tags and a correct Python 3 solution for this coding contest problem. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.
instruction
0
70,156
19
140,312
Tags: games, math, number theory Correct Solution: ``` import fractions; n = int(input()); a = list(map(int, input().split())); gcd = a[0]; for i in range(1, n): gcd = fractions.gcd(gcd, a[i]); x = (max(a) / gcd - n) if (x % 2 == 1): print("Alice"); else: print("Bob"); ```
output
1
70,156
19
140,313
Provide tags and a correct Python 3 solution for this coding contest problem. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.
instruction
0
70,157
19
140,314
Tags: games, math, number theory Correct Solution: ``` import fractions n = int(input()) A = list(map(int, input().split())) x = A[0] for i in A: x = fractions.gcd(x, i) if (max(A) // x - len(A)) % 2 == 0: print('Bob') else: print('Alice') ```
output
1
70,157
19
140,315
Provide tags and a correct Python 3 solution for this coding contest problem. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.
instruction
0
70,158
19
140,316
Tags: games, math, number theory Correct Solution: ``` from fractions import gcd n = int(input()) x = list(map(int, input().split(' '))) gcdx = x[0] for i in x: gcdx = gcd(gcdx, i) nums = max(x) / gcdx if (int(nums) - n)%2 == 1: print("Alice") else: print("Bob") ```
output
1
70,158
19
140,317
Provide tags and a correct Python 3 solution for this coding contest problem. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.
instruction
0
70,159
19
140,318
Tags: games, math, number theory Correct Solution: ``` from fractions import gcd from functools import reduce n = int(input()) a = list(map(int, input().split())) g = reduce(gcd, a) s = max(a)//g - n if s%2: print('Alice') else: print('Bob') ```
output
1
70,159
19
140,319
Provide tags and a correct Python 3 solution for this coding contest problem. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.
instruction
0
70,160
19
140,320
Tags: games, math, number theory Correct Solution: ``` from math import * n=int(input()) a=list(map(int,input().split())) b=a[0] for i in a: b=gcd(i,b) print('Alice' if (max(*a)//b-n)%2==1 else 'Bob') ```
output
1
70,160
19
140,321
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. Submitted Solution: ``` n, listo2, c= int(input()), [], 0 import math listo = list(map(int,input().split())) listo.sort() obaa = listo[0] def gcd(x, y): while(y): x, y = y, x % y return x for i in range(1,n): GCD = gcd(listo[i], obaa) obaa = GCD bomba = int(listo[n-1]/GCD) - n if bomba % 2 == 0: print("Bob") else: print("Alice") ```
instruction
0
70,161
19
140,322
Yes
output
1
70,161
19
140,323
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. Submitted Solution: ``` ## necessary imports import sys input = sys.stdin.readline # from math import ceil, floor, factorial; def ceil(x): if x != int(x): x = int(x) + 1; return x; # swap_array function def swaparr(arr, a,b): temp = arr[a]; arr[a] = arr[b]; arr[b] = temp ## gcd function def gcd(a,b): if b == 0: return a return gcd(b, a % b); ## nCr function efficient using Binomial Cofficient def nCr(n, k): if(k > n - k): k = n - k res = 1 for i in range(k): res = res * (n - i) res = res / (i + 1) return int(res) ## upper bound function code -- such that e in a[:i] e < x; def upper_bound(a, x, lo=0, hi = None): if hi == None: hi = len(a); while lo < hi: mid = (lo+hi)//2 if a[mid] < x: lo = mid+1 else: hi = mid return lo ## prime factorization def primefs(n): ## if n == 1 ## calculating primes primes = {} while(n%2 == 0 and n > 0): primes[2] = primes.get(2, 0) + 1 n = n//2 for i in range(3, int(n**0.5)+2, 2): while(n%i == 0 and n > 0): primes[i] = primes.get(i, 0) + 1 n = n//i if n > 2: primes[n] = primes.get(n, 0) + 1 ## prime factoriazation of n is stored in dictionary ## primes and can be accesed. O(sqrt n) return primes ## MODULAR EXPONENTIATION FUNCTION def power(x, y, p): res = 1 x = x % p if (x == 0) : return 0 while (y > 0) : if ((y & 1) == 1) : res = (res * x) % p y = y >> 1 x = (x * x) % p return res ## DISJOINT SET UNINON FUNCTIONS def swap(a,b): temp = a a = b b = temp return a,b # find function with path compression included (recursive) # def find(x, link): # if link[x] == x: # return x # link[x] = find(link[x], link); # return link[x]; # find function with path compression (ITERATIVE) def find(x, link): p = x; while( p != link[p]): p = link[p]; while( x != p): nex = link[x]; link[x] = p; x = nex; return p; # the union function which makes union(x,y) # of two nodes x and y def union(x, y, link, size): x = find(x, link) y = find(y, link) if size[x] < size[y]: x,y = swap(x,y) if x != y: size[x] += size[y] link[y] = x ## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES def sieve(n): prime = [True for i in range(n+1)] p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p * p, n+1, p): prime[i] = False p += 1 return prime #### PRIME FACTORIZATION IN O(log n) using Sieve #### MAXN = int(1e5 + 5) def spf_sieve(): spf[1] = 1; for i in range(2, MAXN): spf[i] = i; for i in range(4, MAXN, 2): spf[i] = 2; for i in range(3, ceil(MAXN ** 0.5), 2): if spf[i] == i: for j in range(i*i, MAXN, i): if spf[j] == j: spf[j] = i; ## function for storing smallest prime factors (spf) in the array ################## un-comment below 2 lines when using factorization ################# # spf = [0 for i in range(MAXN)] # spf_sieve(); def factoriazation(x): ret = {}; while x != 1: ret[spf[x]] = ret.get(spf[x], 0) + 1; x = x//spf[x] return ret ## this function is useful for multiple queries only, o/w use ## primefs function above. complexity O(log n) ## taking integer array input def int_array(): return list(map(int, input().strip().split())) ## taking string array input def str_array(): return input().strip().split(); #defining a couple constants MOD = int(1e9)+7; CMOD = 998244353; INF = float('inf'); NINF = -float('inf'); ################### ---------------- TEMPLATE ENDS HERE ---------------- ################### # while(1): # a = int_array(); # mset = set(a); # while(1): # f = 0; # for i in mset: # if f: # break; # for j in mset: # if i == j: # continue; # x = abs(i - j); # if x not in mset: # num = x; # f = 1; break; # if not f: # break; # else: # mset.add(num); # print(sorted(list(mset))); n = int(input()); a = sorted(int_array()); mingw = INF; for i in range(n - 1): for j in range(i + 1, n): x = gcd(a[i], a[j]); if a[-1] % x == 0: mingw = min(x, mingw); x = a[-1] // mingw; x -= n; if x % 2: print('Alice'); else: print('Bob'); ```
instruction
0
70,162
19
140,324
Yes
output
1
70,162
19
140,325
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. Submitted Solution: ``` from math import gcd n = int(input()) l = list(map(int,input().split())) cnt = 0 g = 0 for i in range(n): g = gcd(g,l[i]) z = max(l)//g - n if z%2!=0: print('Alice') else: print('Bob') ```
instruction
0
70,163
19
140,326
Yes
output
1
70,163
19
140,327
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. Submitted Solution: ``` def gcd(a, b): a, b = max(a, b), min(a, b) while a % b != 0: a %= b a, b = b, a return b n = int(input()) sp = list(map(int, input().split())) g = sp[0] mx = 0 for i in sp: mx = max(mx, i) g = gcd(g, i) cnt = mx / g - n if cnt % 2 == 1: print("Alice") else: print("Bob") ```
instruction
0
70,164
19
140,328
Yes
output
1
70,164
19
140,329
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. Submitted Solution: ``` n = int(input()) arr = list(map(int, input().split())) arr.sort() def hcf(x,y): if y == 0: return x else: return hcf(y, x % y) gcd = hcf(arr[0], arr[1]) for i in arr: geeceedee = hcf(i, gcd) rounds = int(arr[n-1]/geeceedee) - n if rounds % 2 == 0: print("Bob") else: print("Alice") ```
instruction
0
70,165
19
140,330
No
output
1
70,165
19
140,331
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. Submitted Solution: ``` n= input() a= list() for x in input().split(' '): a.append( int(x) ) #print(a) a= sorted(a) if a[0] != 1: res= a[0]-1 else: res= 0 prev= a[0] for cur in a: if cur-prev > 1 : res+= cur-prev - 1 # print('cur-prev = {0}, res = {1} '.format(cur-prev,res)) prev= cur ''' for i in range(1,max(a)): if not i in a: print('{0} is not in a'.format(i)) res+=1 ''' if res%2 == 0 : print('Bob') else: print('Alice') ```
instruction
0
70,166
19
140,332
No
output
1
70,166
19
140,333
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. Submitted Solution: ``` n=int(input()) s=set(map(int,input().split())) if len(s) %2==0:print("Alice") else:print("Bob") ```
instruction
0
70,167
19
140,334
No
output
1
70,167
19
140,335
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one). If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first. Input The first line contains an integer n (2 ≀ n ≀ 100) β€” the initial number of elements in the set. The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the elements of the set. Output Print a single line with the winner's name. If Alice wins print "Alice", otherwise print "Bob" (without quotes). Examples Input 2 2 3 Output Alice Input 2 5 3 Output Alice Input 3 5 6 7 Output Bob Note Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice. Submitted Solution: ``` n = int(input()) a = list(map(int,input().split())) s = set(a[::]) ans = 1 for i in range(n): cnt = 0 for j in range(n): if i == j: continue if abs(a[i]-a[j]) not in s: cnt += 1 ans *= (cnt) if ans%2 == 0: print("Bob") else: print("Alice") ```
instruction
0
70,168
19
140,336
No
output
1
70,168
19
140,337
Provide tags and a correct Python 3 solution for this coding contest problem. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12
instruction
0
70,176
19
140,352
Tags: greedy, implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) sum = 0 for x in a: sum += x t = sum // n ans = 0 for i in range(n - 1): if a[i] < t: ans += (t - a[i]) a[i + 1] -= (t - a[i]) else: ans += (a[i] - t) a[i + 1] += (a[i] - t) print(ans) ```
output
1
70,176
19
140,353
Provide tags and a correct Python 3 solution for this coding contest problem. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12
instruction
0
70,177
19
140,354
Tags: greedy, implementation Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) + [0] s = sum(a) // n d = 0 for i in range(n): if a[i] > s: a[i + 1] += abs(a[i] - s) else: a[i + 1] -= abs(a[i] - s) d += abs(a[i] - s) print(d) ```
output
1
70,177
19
140,355
Provide tags and a correct Python 3 solution for this coding contest problem. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12
instruction
0
70,178
19
140,356
Tags: greedy, implementation Correct Solution: ``` n = int(input()) a = [int(x) for x in input().split()] s = sum(a) // n lft = 0 ans = 0 for i in range(n): ans += abs(lft) lft += a[i] - s print(ans) ```
output
1
70,178
19
140,357
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12 Submitted Solution: ``` n = int(input()) t = list(map(int, input().split())) s, k = 0, sum(t) // n t = [i - k for i in t] for i in range(n - 1): s += abs(t[i]) t[i + 1] += t[i] print(s) ```
instruction
0
70,183
19
140,366
Yes
output
1
70,183
19
140,367
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12 Submitted Solution: ``` n=int(input()) a=list(map(int,input().split())) need=sum(a)//n ans=0 from math import * for i in range(n-1): if(a[i]<=need): a[i+1]-=need-a[i] else: a[i+1]+=a[i]-need ans+=abs(a[i]-need) print(ans) ```
instruction
0
70,184
19
140,368
Yes
output
1
70,184
19
140,369
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12 Submitted Solution: ``` """ Codeforces Testing Round 10 Problem B Author : chaotic_iak Language: Python 3.3.4 """ def read(mode=2): # 0: String # 1: List of strings # 2: List of integers inputs = input().strip() if mode == 0: return inputs if mode == 1: return inputs.split() if mode == 2: return [int(x) for x in inputs.split()] def write(s="\n"): if isinstance(s, list): s = " ".join(s) s = str(s) print(s, end="") ################################################### SOLUTION n, = read() a = read() s = sum(a) // n r = 0 for i in range(n-1): if a[i] < s: r += s - a[i] a[i+1] -= s - a[i] else: r += a[i] - s a[i+1] += a[i] - s print(r) ```
instruction
0
70,185
19
140,370
Yes
output
1
70,185
19
140,371
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12 Submitted Solution: ``` a=[] def main(): n=int(input()) a.append(0) B=input() for x in B.split(): a.append(int(x)) a.append(0) S=sum(a) ave=int(S/n) ans=0 for i in range(1,n+1,1): if a[i] < ave: ans += ave-a[i] a[i+1] -= ave-a[i] else: ans += a[i]-ave a[i+1] += a[i]-ave print(ans) main() ```
instruction
0
70,186
19
140,372
Yes
output
1
70,186
19
140,373
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12 Submitted Solution: ``` n=int(input()) a=list(map(int,input().split()));cnt=0;b=sum(a)//n for i in a : cnt+=abs(b-i) print(cnt) ```
instruction
0
70,187
19
140,374
No
output
1
70,187
19
140,375
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12 Submitted Solution: ``` from sys import stdin as cin,stdout as cout from math import factorial as f from itertools import combinations as comb n = int(cin.readline()) a = list(map(int,cin.readline().split())) k = int(sum(a)/n) sum = 0 for x in a: sum+= abs(x-k) print(sum) ```
instruction
0
70,188
19
140,376
No
output
1
70,188
19
140,377
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12 Submitted Solution: ``` #!/usr/bin/python3 from array import array n = int(input()) t = [int(v) for v in input().split()] a = array("l") a.fromlist(t) s = 0 k = sum(a) m = int(k/n) for i in range(n-1): d = m - a[i] a[i] = m a[i+1] -= d s += d print(s) ```
instruction
0
70,189
19
140,378
No
output
1
70,189
19
140,379
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move. How many such moves does he need to achieve the desired configuration? Input The first line contains integer n (1 ≀ n ≀ 50000). The second line contains n non-negative numbers that do not exceed 109, the i-th written number is the number of matches in the i-th matchbox. It is guaranteed that the total number of matches is divisible by n. Output Print the total minimum number of moves. Examples Input 6 1 6 2 5 3 7 Output 12 Submitted Solution: ``` x = int(input()) y = sorted(list(map(int, input().split()))) z=sum(y) t=sum(y)//x c=0 for i in range(z): if(y[i]<t): c += t-y[i] y[i] = t if(y[i]>t): c += y[i] - t y[i] = t if(y[x-1] == t): break print(c) ```
instruction
0
70,190
19
140,380
No
output
1
70,190
19
140,381
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable.
instruction
0
70,312
19
140,624
Tags: greedy, implementation Correct Solution: ``` def main(): n = int(input()) // 2 a = [int(i) for i in input().split()] import copy cp = copy.copy(a) cp.sort() i, j = 0, len(cp) - 1 while n != 0: im = a.index(cp[i]) a[im] = None jm = a.index(cp[j]) a[jm] = None print('{} {}'.format(im+1,jm+1)) i += 1 j -= 1 n -= 1 if __name__ == '__main__': main() ```
output
1
70,312
19
140,625
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable.
instruction
0
70,313
19
140,626
Tags: greedy, implementation Correct Solution: ``` n=int(input()) a=[int(i) for i in input().split()] s=0 for i in a: s+=i s//=(n//2) for i in range(n): for j in range(n): if a[i]+a[j]==s and i!=j and a[i]!=-1 and a[j]!=-1: print(i+1, j+1) a[i], a[j]=-1, -1 ```
output
1
70,313
19
140,627
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable.
instruction
0
70,314
19
140,628
Tags: greedy, implementation Correct Solution: ``` def main(): n = int(input()) a = list(map(int,input().split())) each = sum(a)*2//n used = [False for _ in range(n)] for i in range(n): if used[i]: continue for j in range(i+1,n): if used[j]: continue if a[i]+a[j] == each: used[i] = True used[j] = True print(i+1,j+1) break if __name__ == '__main__': main() ```
output
1
70,314
19
140,629
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable.
instruction
0
70,315
19
140,630
Tags: greedy, implementation Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) t=n//2 b=[] u,s=0,0 e=sum(a)//t for i in range(n): for j in range(i+1,n): if a[i]+a[j]==e: if i+1 not in b: if j+1 not in b: print(i+1,j+1) b.append(i+1) b.append(j+1) u+=1 if u==t: s+=1 break if s==1: break ```
output
1
70,315
19
140,631
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable.
instruction
0
70,316
19
140,632
Tags: greedy, implementation Correct Solution: ``` a = int(input()) l=sorted(zip(map(int,input().split()),range(1,a+1))) for i in range(0,a//2): print(l[i][1],l[-1-i][1]) ```
output
1
70,316
19
140,633
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable.
instruction
0
70,317
19
140,634
Tags: greedy, implementation Correct Solution: ``` n = int(input()) sp = list(map(int, input().split())) mid = sum(sp) / (n / 2) for i in range(n): for j in range(n): if i != j: if sp[i] + sp[j] == mid: I, J = sp[i], sp[j] print(sp.index(I) + 1, end=' ') del sp[i] sp.insert(i, 0) print(sp.index(J) + 1) del sp[j] sp.insert(j, 0) ```
output
1
70,317
19
140,635
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable.
instruction
0
70,318
19
140,636
Tags: greedy, implementation Correct Solution: ``` def int_lst_input(): return [int(val) for val in input().split(' ')] def int_input(): return int(input()) def solve(): n = int_input() a = int_lst_input() target = sum(a) // (n // 2) idx_used = set() for i in range(0, n): for j in range(0, n): if ( i not in idx_used and j not in idx_used and a[i] + a[j] == target and i != j ): idx_used.add(i) idx_used.add(j) print(f'{i+1} {j+1}') if __name__ == '__main__': solve() ```
output
1
70,318
19
140,637
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable.
instruction
0
70,319
19
140,638
Tags: greedy, implementation Correct Solution: ``` import sys n = int(input()) arr = list(map(int,input().split())) arr2 = sorted(arr) s = -1 found = 0 indexx = [] for i in range(int(n/2)): for j in range(n): if j+1 not in indexx and arr[j] == arr2[i]: indexx.append(j+1) pos1 = j+1 break for j in range(n): if j+1 not in indexx and arr[j] == arr2[n-i-1]: indexx.append(j+1) pos2 = j+1 break print(pos1,pos2) ```
output
1
70,319
19
140,639
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable. Submitted Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return sys.stdin.readline().split() def S(): return input() def main(): n=I() l=LI() l2=[] for i,x in enumerate(l): l2.append([i,x]) l2=sorted(l2,key=lambda x:x[1]) for i in range(n//2): print(l2[i][0]+1,l2[n-i-1][0]+1) main() # print(main()) ```
instruction
0
70,320
19
140,640
Yes
output
1
70,320
19
140,641
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable. Submitted Solution: ``` n=int(input()) l=input().split() s=sorted([(int(l[i]),i+1) for i in range(n)]) for i in range(n//2): print(s[i][1],s[-1-i][1]) ```
instruction
0
70,321
19
140,642
Yes
output
1
70,321
19
140,643
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable. Submitted Solution: ``` n=int(input()) cards=list(map(int, input().split())) s=min(cards)+max(cards) for i in range(n): if cards[i]!=0: val=cards[i] cards[i]=0 pos=cards.index(s-val) cards[pos]=0 print(str(i+1)+" "+str(pos+1)) ```
instruction
0
70,322
19
140,644
Yes
output
1
70,322
19
140,645
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable. Submitted Solution: ``` n = int(input()) a = [int(s) for s in input().split(' ')] taken = [] for i in range(n): if i + 1 not in taken: for j in range(i + 1, n): if j + 1 not in taken and a[i] + a[j] == 2 * sum(a) // n: taken.append(i + 1) taken.append(j + 1) break for k in range(n // 2): print(taken[2 * k], taken[2*k + 1]) ```
instruction
0
70,323
19
140,646
Yes
output
1
70,323
19
140,647
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable. Submitted Solution: ``` x = [] n = int(input()) a = map(int, input().split()) a = list(a) z = (sum(a) // n) * 2 for i in a: if a.count(z // 2) == len(a): for j in range(n // 2): j = j * 2 print(j + 1, (j + 1) + 1) break elif a.index(i) not in x or a.index(z - i) not in x: if len(a) == 2: print(1, 2) break elif a.index(i) == a.index(z - i): print(a.index(i) + 1, a.index((z - i), a.index(z - i) + 1) + 1) x.append(a.index(i)) x.append(a.index(z - i)) else: print(a.index(i) + 1, a.index(z - i) + 1) x.append(a.index(i)) x.append(a.index(z - i)) ```
instruction
0
70,324
19
140,648
No
output
1
70,324
19
140,649
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible. Input The first line of the input contains integer n (2 ≀ n ≀ 100) β€” the number of cards in the deck. It is guaranteed that n is even. The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is equal to the number written on the i-th card. Output Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input. It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them. Examples Input 6 1 5 7 4 4 3 Output 1 3 6 2 4 5 Input 4 10 10 10 10 Output 1 2 3 4 Note In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8. In the second sample, all values ai are equal. Thus, any distribution is acceptable. Submitted Solution: ``` n = int(input()) t = list(map(int, input().split())) a = sorted([t[i], i+1] for i in range(n)) print(a) for i in range(n//2): print(a[i][1],a[-i-1][1]) ```
instruction
0
70,325
19
140,650
No
output
1
70,325
19
140,651