message
stringlengths
2
30.5k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
237
109k
cluster
float64
10
10
__index_level_0__
int64
474
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier. Constraints * 1 ≦ N < 10000 * 1 ≦ K < 10 * 0 ≦ D_1 < D_2 < … < D_K≦9 * \\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\} Input The input is given from Standard Input in the following format: N K D_1 D_2 … D_K Output Print the amount of money that Iroha will hand to the cashier. Examples Input 1000 8 1 3 4 5 6 7 8 9 Output 2000 Input 9999 1 0 Output 9999 Submitted Solution: ``` N, K = map(int, input().split()) D = set(input().split()) while any(s in D for s in str(N)): N += 1 print(N) ```
instruction
0
9,780
10
19,560
Yes
output
1
9,780
10
19,561
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier. Constraints * 1 ≦ N < 10000 * 1 ≦ K < 10 * 0 ≦ D_1 < D_2 < … < D_K≦9 * \\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\} Input The input is given from Standard Input in the following format: N K D_1 D_2 … D_K Output Print the amount of money that Iroha will hand to the cashier. Examples Input 1000 8 1 3 4 5 6 7 8 9 Output 2000 Input 9999 1 0 Output 9999 Submitted Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) n,k = list(map(int, input().split())) d = list(map(int, input().split())) d.sort() e = 0 for i in range(10): if i not in d: e = i break a = list(map(int, str(n))) s = a[:] l = len(s) for i in range(l+1): if i == l: break if s[i] in d: break if i == l: print(n) else: while i >= 0: while s[i] in d: s[i] += 1 for j in range(i+1,l): s[j] = e if s[i] > 9: if i != 0: s[i-1] += 1 s[i] = e i -= 1 if s[0] == 10: for i in range(1,10): if i not in d: s[0] = i*10+e if 0 not in d and i == e: s[0] -+ e print("".join(list(map(str, s)))) ```
instruction
0
9,781
10
19,562
No
output
1
9,781
10
19,563
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier. Constraints * 1 ≦ N < 10000 * 1 ≦ K < 10 * 0 ≦ D_1 < D_2 < … < D_K≦9 * \\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\} Input The input is given from Standard Input in the following format: N K D_1 D_2 … D_K Output Print the amount of money that Iroha will hand to the cashier. Examples Input 1000 8 1 3 4 5 6 7 8 9 Output 2000 Input 9999 1 0 Output 9999 Submitted Solution: ``` #!usr/bin/env python3 def LI(): return list(map(int, input().split())) def II(): return int(input()) def LS(): return input().split() def S(): return input() def LIR(n): return [LI() for i in range(n)] #A """ s = S() if s[0] != "A": print("WA") else: count = [] for i in range(2,len(s)-1): if s[i] == "C": count.append(i) if len(count) != 1: print("WA") else: for i in range(1,len(s)): if i not in count: if s[i] == s[i].upper(): print("WA") quit() print("AC") """ #B """ n,m,k = LI() for i in range((n+1)//2): if (k - m*i) % (n - 2*i) == 0 and (k-m*i)//(n-2*i) >= 0 and (k-m*i)//(n-2*i) <= m: print("Yes") quit() print("No") """ #C """ from collections import defaultdict n,k = LI() d = defaultdict(int) for i in range(n): a,b = LI() d[a] += b s = list(d.items()) s.sort(key = lambda x:x[0]) su = 0 for i in range(len(s)): su += s[i][1] if su >= k: print(s[i][0]) break """ #D n,k = LI() d = LI() lis = [0,1,2,3,4,5,6,7,8,9] for i in d: if i in lis: lis.remove(i) n = list(str(n)) i = 0 while i < len(n): while int(n[i]) not in lis and n[i] != "10": n[i] = str(int(n[i])+1) if n[i] == "10": if i == 0: n[i] = "0" n.insert(i,"1") else: n[i-1] = str(int(n[i-1])+1) n[i] = "0" i -= 1 i -= 1 i += 1 for i in n: print(i,end = "") print() #E #F #G #H #I #J #K #L #M #N #O #P #Q #R #S #T ```
instruction
0
9,782
10
19,564
No
output
1
9,782
10
19,565
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier. Constraints * 1 ≦ N < 10000 * 1 ≦ K < 10 * 0 ≦ D_1 < D_2 < … < D_K≦9 * \\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\} Input The input is given from Standard Input in the following format: N K D_1 D_2 … D_K Output Print the amount of money that Iroha will hand to the cashier. Examples Input 1000 8 1 3 4 5 6 7 8 9 Output 2000 Input 9999 1 0 Output 9999 Submitted Solution: ``` N, K = (int(i) for i in input().split()) D = [int(i) for i in input().split()] for i in range(N, 100000): for d in D: if d not in str(i): break print(i) ```
instruction
0
9,783
10
19,566
No
output
1
9,783
10
19,567
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier. Constraints * 1 ≦ N < 10000 * 1 ≦ K < 10 * 0 ≦ D_1 < D_2 < … < D_K≦9 * \\{D_1,D_2,...,D_K\\} ≠ \\{1,2,3,4,5,6,7,8,9\\} Input The input is given from Standard Input in the following format: N K D_1 D_2 … D_K Output Print the amount of money that Iroha will hand to the cashier. Examples Input 1000 8 1 3 4 5 6 7 8 9 Output 2000 Input 9999 1 0 Output 9999 Submitted Solution: ``` import bisect n, k = list(map(int, input().split())) d = list(map(int, input().split())) can_use = list(set([i for i in range(10)]) - set(d)) can_use.sort() s = str(n) ans = "" up = 0 for ind, i in enumerate(s[::-1]): num = int(i) + up if num in can_use: ans += str(num) up = 0 else: if can_use[-1] > num: ans += str(can_use[bisect.bisect_left(can_use, num)]) up = 0 else: ans += str(can_use[0]) up = 1 if up: ans += str(max(1, int(can_use[0]))) print(int(ans[::-1])) ```
instruction
0
9,784
10
19,568
No
output
1
9,784
10
19,569
Provide tags and a correct Python 3 solution for this coding contest problem. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0
instruction
0
11,124
10
22,248
Tags: binary search, greedy, implementation, math Correct Solution: ``` def Mashmokh(arr,a,b): arr1=[] for i in arr: if i % (a*b)==0: arr1.append(0) else: resultado=i-(b/a)*(i*a//b) arr1.append(int(resultado)) arr_aux = " ".join(map(str, arr1)) return arr_aux a1,a2,a3=input().split() n=int(a1) a=int(a2) b=int(a3) arr = list(map(int, input().strip().split())) print(Mashmokh(arr,a,b)) ```
output
1
11,124
10
22,249
Provide tags and a correct Python 3 solution for this coding contest problem. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0
instruction
0
11,125
10
22,250
Tags: binary search, greedy, implementation, math Correct Solution: ``` import math x=input("").split(' ') x=[int(y) for y in x] a= x[0] b=x[1] c=x[2] l=input("").split(' ') str2="" l=[int(y) for y in l] for g in range (0, a): t=l[g] if ((t*b)/c==math.floor((t*2)/c)): str2=str2+"0 " else: ttt= t*b equate=math.floor(ttt/c) if ((equate*c)%b==0): unawesome= equate*c/b str2=str2+str(int(t-unawesome)) str2=str2+" " else: unawesome= math.floor(equate*c/b)+1 str2=str2+str(int(t-unawesome)) str2=str2+" " print(str2) ```
output
1
11,125
10
22,251
Provide tags and a correct Python 3 solution for this coding contest problem. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0
instruction
0
11,126
10
22,252
Tags: binary search, greedy, implementation, math Correct Solution: ``` R = lambda:map(int, input().split()) n, a, b = R() for w in R(): print(w * a % b // a, end=" ") ```
output
1
11,126
10
22,253
Provide tags and a correct Python 3 solution for this coding contest problem. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0
instruction
0
11,127
10
22,254
Tags: binary search, greedy, implementation, math Correct Solution: ``` def mymod(x,a,b): import math return x - math.ceil(int(x*a/b))*b/a n,a,b = map(int,input().strip().split()) x= list(map(int,input().split())) for q in x: print(int(mymod(q,a,b)),end= ' ') ```
output
1
11,127
10
22,255
Provide tags and a correct Python 3 solution for this coding contest problem. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0
instruction
0
11,128
10
22,256
Tags: binary search, greedy, implementation, math Correct Solution: ``` f=lambda: map(int, input().split()) n,a,b=f() print(' '.join([str(int(x*a%b/a)) for x in f()])) ```
output
1
11,128
10
22,257
Provide tags and a correct Python 3 solution for this coding contest problem. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0
instruction
0
11,129
10
22,258
Tags: binary search, greedy, implementation, math Correct Solution: ``` n,a,b=map(int,input().strip().split(' ')) L=list(map(int,input().split(' '))) for i in range(n): s=L[i] res=s*a//b j=int((s-b*res/a)) print(j) ```
output
1
11,129
10
22,259
Provide tags and a correct Python 3 solution for this coding contest problem. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0
instruction
0
11,130
10
22,260
Tags: binary search, greedy, implementation, math Correct Solution: ``` from math import * n,a,b = list(map(int,input().split())) l = list(map(int,input().split())) for i in l: x = i-ceil(((i*a//b)*b)/a) print(x,end = " ") print() ```
output
1
11,130
10
22,261
Provide tags and a correct Python 3 solution for this coding contest problem. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0
instruction
0
11,131
10
22,262
Tags: binary search, greedy, implementation, math Correct Solution: ``` import math x=input("").split(' ') x=[int(y) for y in x] a= x[0] b=x[1] c=x[2] l=input("").split(' ') str2="" l=[int(y) for y in l] for g in range (0, a): t=l[g] if ((t*b)/c==math.floor((t*b)/c)): str2=str2+"0 " else: ttt= t*b equate=math.floor(ttt/c) if ((equate*c)%b==0): unawesome= equate*c/b str2=str2+str(int(t-unawesome)) str2=str2+" " else: unawesome= math.floor(equate*c/b)+1 str2=str2+str(int(t-unawesome)) str2=str2+" " print(str2) ```
output
1
11,131
10
22,263
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0 Submitted Solution: ``` n, a, b = map(int, input().split()) x = [int(i) for i in input().split()] def find_index(n): l = 0; r = n while l < r: mid = (l+r)//2 if (mid*a)//b == (r*a)//b: r = mid else: l = mid+1 return r for i in range(n): print(x[i]-find_index(x[i]), end = " ") print() ```
instruction
0
11,132
10
22,264
Yes
output
1
11,132
10
22,265
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0 Submitted Solution: ``` import functools import math import sys def In(): return map(int, sys.stdin.readline().split()) input = sys.stdin.readline def mashtok(): n, a, b = In() ans = [] for i in input().split(): ans.append(str((int(i) * a) % b // a)) print(' '.join(ans)) mashtok() ```
instruction
0
11,133
10
22,266
Yes
output
1
11,133
10
22,267
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0 Submitted Solution: ``` n, a, b = map(int, input().split()) coins = map(int, input().split()) result = map(lambda x: str((x * a % b) // a), coins) print(" ".join(list(result))) ```
instruction
0
11,134
10
22,268
Yes
output
1
11,134
10
22,269
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0 Submitted Solution: ``` from math import * n,a,b=map(int,input().split()) x=list(map(int,input().split())) ans=[0]*n for i in range(n): ans[i]=x[i]-ceil(int(x[i]*a/b)*b/a) print(*ans) ```
instruction
0
11,135
10
22,270
Yes
output
1
11,135
10
22,271
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0 Submitted Solution: ``` n,a,b=map(int,input().split()) x=list(map(int,input().split())) ans=[0]*n for i in range(n): ans[i]=x[i]-int(int(x[i]*a/b)*b/a) print(*ans) ```
instruction
0
11,136
10
22,272
No
output
1
11,136
10
22,273
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0 Submitted Solution: ``` import math ip = input('') ip = ip.split(' ') n,a,b = ip n,a,b = int(n),int(a),int(b) l = map(int,input().split()) g = math.gcd(a,b) a,b = a/g ,b/g for i in l : tok = (i*a)//b print(int(i-(tok*b)//a),end=" ") print() ```
instruction
0
11,137
10
22,274
No
output
1
11,137
10
22,275
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0 Submitted Solution: ``` import math n,a,b=map(int,input().split()) xlist=[int(x) for x in input().split()] savestring='' for i in range(n): saves=math.floor(math.modf(xlist[i]*a/b)[0]*b/a) savestring+=str(saves)+' ' print(savestring) ```
instruction
0
11,138
10
22,276
No
output
1
11,138
10
22,277
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save. Input The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109). Output Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day. Examples Input 5 1 4 12 6 11 9 1 Output 0 2 3 1 1 Input 3 1 2 1 2 3 Output 1 0 1 Input 1 1 1 1 Output 0 Submitted Solution: ``` n,a,b = map(int,input().split()) tokens = [i for i in map(int,input().split())] for i in tokens: print(i%b,end = ' ') ```
instruction
0
11,139
10
22,278
No
output
1
11,139
10
22,279
Provide tags and a correct Python 3 solution for this coding contest problem. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1
instruction
0
11,175
10
22,350
Tags: implementation, sortings Correct Solution: ``` n=int(input()) l=list(map(int,input().split())) print('-1' if 1 in l else '1') ```
output
1
11,175
10
22,351
Provide tags and a correct Python 3 solution for this coding contest problem. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1
instruction
0
11,176
10
22,352
Tags: implementation, sortings Correct Solution: ``` x = input() s = list(map(int, input().split())) if 1 in s: print(-1) else: print(1) ```
output
1
11,176
10
22,353
Provide tags and a correct Python 3 solution for this coding contest problem. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1
instruction
0
11,177
10
22,354
Tags: implementation, sortings Correct Solution: ``` n = int(input()) a = list(map(int, input().split())) b = min(a) if b == 1: print(-1) else: print(1) ```
output
1
11,177
10
22,355
Provide tags and a correct Python 3 solution for this coding contest problem. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1
instruction
0
11,178
10
22,356
Tags: implementation, sortings Correct Solution: ``` N = int(input()) A = list(map(int, input().split())) mina = min(A) if mina == 1: print(-1) else: print(1) ```
output
1
11,178
10
22,357
Provide tags and a correct Python 3 solution for this coding contest problem. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1
instruction
0
11,179
10
22,358
Tags: implementation, sortings Correct Solution: ``` n = int(input()) arr = list(map(int, input().split())) arr.sort() if (arr[0] == 1): print(-1) else: print(1) ```
output
1
11,179
10
22,359
Provide tags and a correct Python 3 solution for this coding contest problem. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1
instruction
0
11,180
10
22,360
Tags: implementation, sortings Correct Solution: ``` import math int(input()) a = [int(x) for x in input().split()] if(1 in a): print(-1) else: print(1) ```
output
1
11,180
10
22,361
Provide tags and a correct Python 3 solution for this coding contest problem. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1
instruction
0
11,181
10
22,362
Tags: implementation, sortings Correct Solution: ``` n = int(input()) banknotes = [ int(banknote) for banknote in input().split() ] if 1 in banknotes: print(-1) else: print(1) ```
output
1
11,181
10
22,363
Provide tags and a correct Python 3 solution for this coding contest problem. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1
instruction
0
11,182
10
22,364
Tags: implementation, sortings Correct Solution: ``` n = int(input()) notes = list(map(int, input().split(' '))) notes.sort() if notes[0] != 1: print(1) else: print(-1) ```
output
1
11,182
10
22,365
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1 Submitted Solution: ``` n = int(input()) notes = sorted(list(map(int, input().split()))) if notes[0] == 1: print(-1) else: print(1) ```
instruction
0
11,183
10
22,366
Yes
output
1
11,183
10
22,367
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1 Submitted Solution: ``` input() a = input().split() print(-1 if '1' in a else 1) ```
instruction
0
11,184
10
22,368
Yes
output
1
11,184
10
22,369
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1 Submitted Solution: ``` n=int(input()) l=input().split() for i in range(n): l[i]=int(l[i]) if(l.count(1)==0): print(1) else: print(-1) ```
instruction
0
11,185
10
22,370
Yes
output
1
11,185
10
22,371
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1 Submitted Solution: ``` #!/usr/bin/env python3 n=int(input()) a=[int(i) for i in input().split()] ans=1 for x in a: if x==1: ans=-1 print(ans) ```
instruction
0
11,186
10
22,372
Yes
output
1
11,186
10
22,373
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1 Submitted Solution: ``` x = input() s = list(map(int, input().split())) if 1 in s: print(-11) else: print(1) ```
instruction
0
11,187
10
22,374
No
output
1
11,187
10
22,375
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1 Submitted Solution: ``` a=int(input()) num=sorted(list(map(int,input().split()))) ans=num[0] for b in range(a-1): ans=min(ans,num[b+1]-num[b]) if ans == 1: print(-1) else: print(ans-1) ```
instruction
0
11,188
10
22,376
No
output
1
11,188
10
22,377
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1 Submitted Solution: ``` input() a=list(map(int,input().split())) if("1" in a): print("-1") else: print("1") ```
instruction
0
11,189
10
22,378
No
output
1
11,189
10
22,379
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum? Input The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion. The second line contains n distinct space-separated numbers a1, a2, ..., an (1 ≤ ai ≤ 106) — the values of the banknotes. Output Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print - 1. Examples Input 5 1 2 3 4 5 Output -1 Submitted Solution: ``` BnkNotesNum = int(input()) BankNotes = [int(x) for x in input().split()] print(BankNotes) if (1 in BankNotes) or (2 in BankNotes and 3 in BankNotes): print(-1) else: print(1) ```
instruction
0
11,190
10
22,380
No
output
1
11,190
10
22,381
Provide a correct Python 3 solution for this coding contest problem. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000
instruction
0
11,440
10
22,880
"Correct Solution: ``` N, M = map(int, input().split()) cost = 0 for A, B in sorted((tuple(map(int, input().split())) for i in range(N)), key=lambda p: p[0]): bought = min(M, B) cost += A * bought M -= bought print(cost) ```
output
1
11,440
10
22,881
Provide a correct Python 3 solution for this coding contest problem. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000
instruction
0
11,441
10
22,882
"Correct Solution: ``` n, m = map(int, input().split()) d = [tuple(map(int, input().split())) for _ in range(n)] d.sort() ans = 0 for ai, bi in d: if m <= bi: ans += ai * m break ans += ai * bi m -= bi print(ans) ```
output
1
11,441
10
22,883
Provide a correct Python 3 solution for this coding contest problem. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000
instruction
0
11,442
10
22,884
"Correct Solution: ``` n, m = map(int, input().split()) st = [] for _ in range(n): st.append(tuple(map(int, input().split()))) st.sort() i = 0 c = 0 while m > 0: b = min(m, st[i][1]) c += b * st[i][0] m -= b i += 1 print(c) ```
output
1
11,442
10
22,885
Provide a correct Python 3 solution for this coding contest problem. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000
instruction
0
11,443
10
22,886
"Correct Solution: ``` n,m=map(int,input().split()) drinks = sorted([list(map(int,input().split())) for _ in range(n)]) rest, res = m, 0 for i in range(n): buy = min(rest, drinks[i][1]) res += buy * drinks[i][0] rest -= buy print(res) ```
output
1
11,443
10
22,887
Provide a correct Python 3 solution for this coding contest problem. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000
instruction
0
11,444
10
22,888
"Correct Solution: ``` N, M = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in range(N)] AB.sort(key=lambda x: x[0]) ans = 0 bought = 0 for a, b in AB: m = min(M - bought, b) bought += m ans += a * m print(ans) ```
output
1
11,444
10
22,889
Provide a correct Python 3 solution for this coding contest problem. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000
instruction
0
11,445
10
22,890
"Correct Solution: ``` n,m=map(int,input().split()) ab=[list(map(int,input().split())) for _ in range(n)] ab.sort() x = 0 c = 0 for a,b in ab: if x+b <= m: x += b c += a*b else: c += a*(m-x) break print(c) ```
output
1
11,445
10
22,891
Provide a correct Python 3 solution for this coding contest problem. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000
instruction
0
11,446
10
22,892
"Correct Solution: ``` n,m = map(int,input().split()) A = [list(map(int,input().split())) for _ in range(n)] A.sort() ans = 0 cnt = 0 for a in A: tmp = min(m-cnt,a[1]) ans += tmp*a[0] cnt+=tmp if cnt >= m: break print(ans) ```
output
1
11,446
10
22,893
Provide a correct Python 3 solution for this coding contest problem. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000
instruction
0
11,447
10
22,894
"Correct Solution: ``` N,M = map(int,input().split()) D = sorted([list(map(int,input().split())) for n in range(N)]) ans = 0 num = 0 for a,b in D: num+=b ans+=a*b if M<=num: ans-=a*(num-M) break print(ans) ```
output
1
11,447
10
22,895
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000 Submitted Solution: ``` N, M = map(int, input().split()) X = sorted([list(map(int,input().split())) for _ in range(N)]) m = 0 c = 0 for x in X: c += x[0]*min(M-m, x[1]) m += min(M-m, x[1]) if m == M: break print(c) ```
instruction
0
11,448
10
22,896
Yes
output
1
11,448
10
22,897
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000 Submitted Solution: ``` from collections import deque n,m = map(int,input().split()) l =deque(sorted([list(map(int,input().split())) for i in range(n)])) money = 0 while m!=0: a,b = l.popleft() t = min(b,m) m -= t money += a*t print(money) ```
instruction
0
11,449
10
22,898
Yes
output
1
11,449
10
22,899
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000 Submitted Solution: ``` n,m,*l=map(int,open(0).read().split());c=0 for a,b in sorted(zip(*[iter(l)]*2)):t=min(b,m);c+=a*t;m-=t print(c) ```
instruction
0
11,450
10
22,900
Yes
output
1
11,450
10
22,901
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000 Submitted Solution: ``` I = lambda: map(int, input().split()) n, m = I() A = sorted([list(I()) for _ in range(n)]) c = p = 0 for a, b in A: if c >= m: break p += a*min(b, m-c) c += b print(p) ```
instruction
0
11,451
10
22,902
Yes
output
1
11,451
10
22,903
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can buy M cans of energy drinks? It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks. Constraints * All values in input are integers. * 1 \leq N, M \leq 10^5 * 1 \leq A_i \leq 10^9 * 1 \leq B_i \leq 10^5 * B_1 + ... + B_N \geq M Input Input is given from Standard Input in the following format: N M A_1 B_1 A_2 B_2 \vdots A_N B_N Output Print the minimum amount of money with which Takahashi can buy M cans of energy drinks. Examples Input 2 5 4 9 2 4 Output 12 Input 4 30 6 18 2 5 3 10 7 9 Output 130 Input 1 100000 1000000000 100000 Output 100000000000000 Submitted Solution: ``` n,m = map(int,input().split()) ab = [list(map(int,input().split())) for _ in range(n)] ab.sort() ans = 0 cnt = 0 i = 0 while cnt < m: ans += ab[i][0]*ab[i][1] cnt += ab[i][1] i += 1 print(ans - (cnt - m)*ab[i][0]) ```
instruction
0
11,452
10
22,904
No
output
1
11,452
10
22,905