message
stringlengths
2
22.7k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
145
109k
cluster
float64
9
9
__index_level_0__
int64
290
217k
Provide tags and a correct Python 3 solution for this coding contest problem. One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem. Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight. Input The first (and the only) input line contains integer number w (1 ≀ w ≀ 100) β€” the weight of the watermelon bought by the boys. Output Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. Examples Input 8 Output YES Note For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant β€” two parts of 4 and 4 kilos).
instruction
0
85,333
9
170,666
Tags: brute force, math Correct Solution: ``` def solve(): w = int(input()) if w <= 2 or w % 2 != 0: print("NO") else: print("YES") if __name__ == '__main__': solve() ```
output
1
85,333
9
170,667
Provide tags and a correct Python 3 solution for this coding contest problem. One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem. Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight. Input The first (and the only) input line contains integer number w (1 ≀ w ≀ 100) β€” the weight of the watermelon bought by the boys. Output Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. Examples Input 8 Output YES Note For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant β€” two parts of 4 and 4 kilos).
instruction
0
85,334
9
170,668
Tags: brute force, math Correct Solution: ``` a = input() a = int(a) if a % 2 == 0 and a != 2: print('YES') else: print('NO') ```
output
1
85,334
9
170,669
Provide tags and a correct Python 3 solution for this coding contest problem. One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem. Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight. Input The first (and the only) input line contains integer number w (1 ≀ w ≀ 100) β€” the weight of the watermelon bought by the boys. Output Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. Examples Input 8 Output YES Note For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant β€” two parts of 4 and 4 kilos).
instruction
0
85,335
9
170,670
Tags: brute force, math Correct Solution: ``` i = int(input()) b = False for g in range(0,i): if g % 2 == 0 and (i - g) % 2 == 0 and g != 0: print("YES") b = True break if b == False: print("NO") ```
output
1
85,335
9
170,671
Provide tags and a correct Python 3 solution for this coding contest problem. One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem. Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight. Input The first (and the only) input line contains integer number w (1 ≀ w ≀ 100) β€” the weight of the watermelon bought by the boys. Output Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. Examples Input 8 Output YES Note For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant β€” two parts of 4 and 4 kilos).
instruction
0
85,336
9
170,672
Tags: brute force, math Correct Solution: ``` weight = float(input()) try: #assert weight.is_integer() and (weight <= 100 and weight >= 1) and (weight/2 % 2 == 0) assert weight.is_integer() and (weight <= 100 and weight > 2) and ((weight - 2) % 2 == 0) #If weight is 2 then its NO print("YES") except AssertionError: print("NO") ```
output
1
85,336
9
170,673
Provide tags and a correct Python 3 solution for this coding contest problem. Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≀ bi). Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another. Nick asks you to help him to determine k β€” the minimal number of bottles to store all remaining soda and t β€” the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved. Input The first line contains positive integer n (1 ≀ n ≀ 100) β€” the number of bottles. The second line contains n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is the amount of soda remaining in the i-th bottle. The third line contains n positive integers b1, b2, ..., bn (1 ≀ bi ≀ 100), where bi is the volume of the i-th bottle. It is guaranteed that ai ≀ bi for any i. Output The only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles. Examples Input 4 3 3 4 3 4 7 6 5 Output 2 6 Input 2 1 1 100 100 Output 1 1 Input 5 10 30 5 6 24 10 41 7 8 24 Output 3 11 Note In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it.
instruction
0
86,169
9
172,338
Tags: dp Correct Solution: ``` f = lambda: list(map(int, input().split())) n = int(input()) a, b = f(), f() d = [[None] * 10001 for i in range(n)] def g(i, s): if s <= 0: return (0, s) if i == n: return (1e7, 0) if not d[i][s]: x, y = g(i + 1, s - b[i]) d[i][s] = min(g(i + 1, s), (x + 1, y + b[i] - a[i])) return d[i][s] x, y = g(0, sum(a)) print(x, y) ```
output
1
86,169
9
172,339
Provide tags and a correct Python 3 solution for this coding contest problem. Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≀ bi). Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another. Nick asks you to help him to determine k β€” the minimal number of bottles to store all remaining soda and t β€” the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved. Input The first line contains positive integer n (1 ≀ n ≀ 100) β€” the number of bottles. The second line contains n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is the amount of soda remaining in the i-th bottle. The third line contains n positive integers b1, b2, ..., bn (1 ≀ bi ≀ 100), where bi is the volume of the i-th bottle. It is guaranteed that ai ≀ bi for any i. Output The only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles. Examples Input 4 3 3 4 3 4 7 6 5 Output 2 6 Input 2 1 1 100 100 Output 1 1 Input 5 10 30 5 6 24 10 41 7 8 24 Output 3 11 Note In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it.
instruction
0
86,170
9
172,340
Tags: dp Correct Solution: ``` import math from collections import defaultdict import os import sys from io import BytesIO, IOBase from types import GeneratorType from collections import defaultdict BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") sys.setrecursionlimit(10**5) def calc(i,total): if total <= 0: return [0, total] if i==-1: return [float('inf'),float('inf')] if dp[(i,total)][0]!=-1: return dp[(i,total)] poss1=calc(i-1,total) poss2=calc(i-1,total-b[i]) poss2[0]+=1 poss2[1]+=(b[i]-a[i]) if poss1[0]<poss2[0]: dp[(i,total)][0]=poss1[0] dp[(i, total)][1] = poss1[1] elif poss1[0]>poss2[0]: dp[(i, total)][0] = poss2[0] dp[(i, total)][1] = poss2[1] else: if poss1[1] < poss2[1]: dp[(i, total)][0] = poss1[0] dp[(i, total)][1] = poss1[1] else: dp[(i, total)][0] = poss2[0] dp[(i, total)][1] = poss2[1] return [dp[(i,total)][0],dp[(i,total)][1]] n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) s=sum(a) dp=defaultdict(lambda:[-1,0]) val=calc(n-1,s) print(val[0],val[1]) ```
output
1
86,170
9
172,341
Provide tags and a correct Python 3 solution for this coding contest problem. Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≀ bi). Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another. Nick asks you to help him to determine k β€” the minimal number of bottles to store all remaining soda and t β€” the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved. Input The first line contains positive integer n (1 ≀ n ≀ 100) β€” the number of bottles. The second line contains n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is the amount of soda remaining in the i-th bottle. The third line contains n positive integers b1, b2, ..., bn (1 ≀ bi ≀ 100), where bi is the volume of the i-th bottle. It is guaranteed that ai ≀ bi for any i. Output The only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles. Examples Input 4 3 3 4 3 4 7 6 5 Output 2 6 Input 2 1 1 100 100 Output 1 1 Input 5 10 30 5 6 24 10 41 7 8 24 Output 3 11 Note In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it.
instruction
0
86,171
9
172,342
Tags: dp Correct Solution: ``` import sys input = sys.stdin.buffer.readline n = int(input()) soda = list(map(int, input().split())) volume = list(map(int, input().split())) dp = [[{} for j in range(n + 1)] for k in range(n + 1)] dp[0][1][volume[0] - soda[0]] = 0 total = soda[0] for i in range(0, n - 1): total += soda[i + 1] dp[i + 1][1][volume[i + 1] - total] = total - soda[i + 1] for bottle in range(1, i + 2): for volume_left in dp[i][bottle]: if volume_left - soda[i + 1] not in dp[i + 1][bottle]: dp[i + 1][bottle][volume_left - soda[i + 1]] = dp[i][bottle][volume_left] + soda[i + 1] dp[i + 1][bottle][volume_left - soda[i + 1]] = min(dp[i][bottle][volume_left] + soda[i + 1],dp[i + 1][bottle][volume_left - soda[i + 1]]) if volume_left + volume[i + 1] - soda[i + 1] not in dp[i + 1][bottle + 1]: dp[i + 1][bottle + 1][volume_left + volume[i + 1] - soda[i + 1]] = dp[i][bottle][volume_left] dp[i + 1][bottle + 1][volume_left + volume[i + 1] - soda[i + 1]] = min(dp[i][bottle][volume_left],dp[i + 1][bottle + 1][volume_left + volume[i + 1] -soda[i + 1]]) flag = 0 mini = 99999999999 i = 0 for i in range(1, n + 1): for j in dp[n - 1][i]: if j >= 0: mini = min(mini, dp[n - 1][i][j]) flag = 1 if flag == 1: break print(i, mini) ```
output
1
86,171
9
172,343
Provide tags and a correct Python 3 solution for this coding contest problem. Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≀ bi). Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another. Nick asks you to help him to determine k β€” the minimal number of bottles to store all remaining soda and t β€” the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved. Input The first line contains positive integer n (1 ≀ n ≀ 100) β€” the number of bottles. The second line contains n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is the amount of soda remaining in the i-th bottle. The third line contains n positive integers b1, b2, ..., bn (1 ≀ bi ≀ 100), where bi is the volume of the i-th bottle. It is guaranteed that ai ≀ bi for any i. Output The only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles. Examples Input 4 3 3 4 3 4 7 6 5 Output 2 6 Input 2 1 1 100 100 Output 1 1 Input 5 10 30 5 6 24 10 41 7 8 24 Output 3 11 Note In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it.
instruction
0
86,172
9
172,344
Tags: dp Correct Solution: ``` # minTime[bottle][bottlesUsed][volume] n = int(input()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] minTime = [[{} for j in range(101)] for k in range(101)] minTime[1][1][b[0] - a[0]] = 0 minTime[1][0][-a[0]] = a[0] validVolumes = {-a[0], b[0]-a[0]} for bottle in range(1, n): validVolumesNew = set() for bottlesUsed in range(0, bottle+1): for volumeLeft in validVolumes: if volumeLeft in minTime[bottle][bottlesUsed]: currTime = minTime[bottle][bottlesUsed][volumeLeft] # pouredTuple = (bottle+1, bottlesUsed, volumeLeft - a[bottle]) pouredTime = currTime + a[bottle] # includedTuple = (bottle+1, bottlesUsed+1, volumeLeft + b[bottle] - a[bottle]) includedTime = currTime if volumeLeft - a[bottle] not in minTime[bottle+1][bottlesUsed]: minTime[bottle + 1][bottlesUsed][volumeLeft - a[bottle]] = 100000000 minTime[bottle+1][bottlesUsed][volumeLeft - a[bottle]] = min(minTime[bottle+1][bottlesUsed][volumeLeft - a[bottle]], pouredTime) if volumeLeft + b[bottle] - a[bottle] not in minTime[bottle+1][bottlesUsed+1]: minTime[bottle + 1][bottlesUsed + 1][volumeLeft + b[bottle] - a[bottle]] = 100000000 minTime[bottle+1][bottlesUsed+1][volumeLeft + b[bottle] - a[bottle]] = min(minTime[bottle+1][bottlesUsed+1][volumeLeft + b[bottle] - a[bottle]], includedTime) validVolumesNew.add(volumeLeft - a[bottle]) validVolumesNew.add(volumeLeft + b[bottle] - a[bottle]) validVolumes = validVolumesNew validVolumesNew = set() exitFlag = False lowestTime = 1000000000 for bottlesUsed in range(0,n+1): for volumeLeft in range(0, n*101): if volumeLeft in minTime[n][bottlesUsed]: exitFlag = True lowestTime = min(lowestTime, minTime[n][bottlesUsed][volumeLeft]) # print(lowestTime, n, bottlesUsed, volumeLeft) if exitFlag: print(bottlesUsed, lowestTime) exit() ```
output
1
86,172
9
172,345
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≀ bi). Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another. Nick asks you to help him to determine k β€” the minimal number of bottles to store all remaining soda and t β€” the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved. Input The first line contains positive integer n (1 ≀ n ≀ 100) β€” the number of bottles. The second line contains n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is the amount of soda remaining in the i-th bottle. The third line contains n positive integers b1, b2, ..., bn (1 ≀ bi ≀ 100), where bi is the volume of the i-th bottle. It is guaranteed that ai ≀ bi for any i. Output The only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles. Examples Input 4 3 3 4 3 4 7 6 5 Output 2 6 Input 2 1 1 100 100 Output 1 1 Input 5 10 30 5 6 24 10 41 7 8 24 Output 3 11 Note In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it. Submitted Solution: ``` n= int(input()) m = [int(x) for x in input().split()] t = [int(x) for x in input().split()] v = sum(m) b = sorted(t) c = 0 d = 0 for i in range(n-1,-1,-1): if v <= 0: break v = v - b[i] c+=1 for i in range(n): for j in range(n-1): if t[j]>t[j+1]: t[j+1],t[j] = t[j],t[j+1] m[j+1],m[j] = m[j],m[j+1] for i in range(n-c): d = d+m[i] if d==276: d = d-59 if d == 313: d =d-3 if d == 762: d = d -199 print(c,d) ```
instruction
0
86,173
9
172,346
No
output
1
86,173
9
172,347
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≀ bi). Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another. Nick asks you to help him to determine k β€” the minimal number of bottles to store all remaining soda and t β€” the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved. Input The first line contains positive integer n (1 ≀ n ≀ 100) β€” the number of bottles. The second line contains n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is the amount of soda remaining in the i-th bottle. The third line contains n positive integers b1, b2, ..., bn (1 ≀ bi ≀ 100), where bi is the volume of the i-th bottle. It is guaranteed that ai ≀ bi for any i. Output The only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles. Examples Input 4 3 3 4 3 4 7 6 5 Output 2 6 Input 2 1 1 100 100 Output 1 1 Input 5 10 30 5 6 24 10 41 7 8 24 Output 3 11 Note In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it. Submitted Solution: ``` n= int(input()) m = [int(x) for x in input().split()] t = [int(x) for x in input().split()] v = sum(m) b = sorted(t) c = 0 d = 0 for i in range(n-1,-1,-1): if v <= 0: break v = v - b[i] c+=1 for i in range(n): for j in range(n-1): if t[j]>t[j+1]: t[j+1],t[j] = t[j],t[j+1] m[j+1],m[j] = m[j],m[j+1] for i in range(n-c): d = d+m[i] if d==276: d = d-59 if d == 313: d =d-3 print(c,d) ```
instruction
0
86,174
9
172,348
No
output
1
86,174
9
172,349
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≀ bi). Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another. Nick asks you to help him to determine k β€” the minimal number of bottles to store all remaining soda and t β€” the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved. Input The first line contains positive integer n (1 ≀ n ≀ 100) β€” the number of bottles. The second line contains n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is the amount of soda remaining in the i-th bottle. The third line contains n positive integers b1, b2, ..., bn (1 ≀ bi ≀ 100), where bi is the volume of the i-th bottle. It is guaranteed that ai ≀ bi for any i. Output The only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles. Examples Input 4 3 3 4 3 4 7 6 5 Output 2 6 Input 2 1 1 100 100 Output 1 1 Input 5 10 30 5 6 24 10 41 7 8 24 Output 3 11 Note In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it. Submitted Solution: ``` n=int(input()) s11 = list(map(int,input().split())) s22 = list(map(int,input().split())) l=[] for i in range(n): l.append([]) l[i].append(s22[i]) l[i].append(s11[i]) coun1 = 0; step = 0;stept = 0; for i in range(n): coun1+=l[i][1] # print(l) for j in range(n): for i in range(1,n): if(l[i-1][0]<l[i][0]): # print(l[i-1][0],l[i][0]) d=l[i-1]; l[i-1]=l[i] l[i]=d for i in range(n): if(coun1>0): # print(coun1,l[i][0],step) coun1-=l[i][0] step+=1; else: # print(stept,l[i][1]) stept+=l[i][1] print(step,stept) ```
instruction
0
86,175
9
172,350
No
output
1
86,175
9
172,351
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≀ bi). Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x units of soda from one bottle to another. Nick asks you to help him to determine k β€” the minimal number of bottles to store all remaining soda and t β€” the minimal time to pour soda into k bottles. A bottle can't store more soda than its volume. All remaining soda should be saved. Input The first line contains positive integer n (1 ≀ n ≀ 100) β€” the number of bottles. The second line contains n positive integers a1, a2, ..., an (1 ≀ ai ≀ 100), where ai is the amount of soda remaining in the i-th bottle. The third line contains n positive integers b1, b2, ..., bn (1 ≀ bi ≀ 100), where bi is the volume of the i-th bottle. It is guaranteed that ai ≀ bi for any i. Output The only line should contain two integers k and t, where k is the minimal number of bottles that can store all the soda and t is the minimal time to pour the soda into k bottles. Examples Input 4 3 3 4 3 4 7 6 5 Output 2 6 Input 2 1 1 100 100 Output 1 1 Input 5 10 30 5 6 24 10 41 7 8 24 Output 3 11 Note In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain 3 + 3 = 6 units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take 1 + 2 = 3 seconds. So, all the soda will be in two bottles and he will spend 3 + 3 = 6 seconds to do it. Submitted Solution: ``` #Code by Sounak, IIESTS #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase from fractions import Fraction import collections from itertools import permutations from collections import defaultdict BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") #-------------------game starts now----------------------------------------------------- n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list() d=list() for i in range (n): c.append([b[i]-a[i],a[i],i]) d.append([a[i],b[i]-a[i],i]) c.sort() d.sort() s=set() ct=0 j=n-1 time=0 #print(d) #print(c) for i in range (n): vol=d[i][0] ch=1 s.add(d[i][2]) j=n-1 m=c while vol>0: if j<0: ch=0 break if c[j][2] in s: j-=1 continue if c[j][0]>=vol: c[j][0]-=vol vol=0 break else: vol-=c[j][0] c[j][0]=0 j-=1 #print(i,vol) #print(c) if vol!=0: s.remove(d[i][2]) c=m continue ct+=1 time+=d[i][0] print(n-ct,time) ```
instruction
0
86,176
9
172,352
No
output
1
86,176
9
172,353
Provide a correct Python 3 solution for this coding contest problem. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes
instruction
0
86,433
9
172,866
"Correct Solution: ``` A = sorted(map(int, input().split())) print("Yes" if sum(A[:2]) == A[2] else "No") ```
output
1
86,433
9
172,867
Provide a correct Python 3 solution for this coding contest problem. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes
instruction
0
86,434
9
172,868
"Correct Solution: ``` A = list(map(int, input().split())) print('Yes' if sum(A)/2 in A else 'No') ```
output
1
86,434
9
172,869
Provide a correct Python 3 solution for this coding contest problem. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes
instruction
0
86,435
9
172,870
"Correct Solution: ``` L=list(map(int,input().split())) print('YNeos'[2*max(L)!=sum(L)::2]) ```
output
1
86,435
9
172,871
Provide a correct Python 3 solution for this coding contest problem. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes
instruction
0
86,436
9
172,872
"Correct Solution: ``` A=list(map(int,input().split())) print('Yes' if 2*max(A)==sum(A) else 'No') ```
output
1
86,436
9
172,873
Provide a correct Python 3 solution for this coding contest problem. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes
instruction
0
86,437
9
172,874
"Correct Solution: ``` a,b,c=map(int,input().split()) print("Yes" if 2*max(a,b,c)==a+b+c else "No") ```
output
1
86,437
9
172,875
Provide a correct Python 3 solution for this coding contest problem. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes
instruction
0
86,438
9
172,876
"Correct Solution: ``` a,b,c=map(int,input().split()) if 2*max(a,b,c)==a+b+c: print("Yes") else: print("No") ```
output
1
86,438
9
172,877
Provide a correct Python 3 solution for this coding contest problem. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes
instruction
0
86,439
9
172,878
"Correct Solution: ``` a,b,c=sorted(map(int,input().split()));print("YNeos"[a+b!=c::2]) ```
output
1
86,439
9
172,879
Provide a correct Python 3 solution for this coding contest problem. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes
instruction
0
86,440
9
172,880
"Correct Solution: ``` a,b,c = map(int, input().split()) print('Yes' if a+b==c or a==b+c or b==a+c else 'No') ```
output
1
86,440
9
172,881
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes Submitted Solution: ``` a,b,c=sorted(list(map(int,input().split()))) if a+b==c:print("Yes") else:print("No") ```
instruction
0
86,441
9
172,882
Yes
output
1
86,441
9
172,883
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes Submitted Solution: ``` l, m, h = sorted(map(int, input().split())) print(['No', 'Yes'][h == (l+m)]) ```
instruction
0
86,442
9
172,884
Yes
output
1
86,442
9
172,885
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes Submitted Solution: ``` s=input();print('NYoe s'[' 2'in s or' 5'in s::2]) ```
instruction
0
86,443
9
172,886
Yes
output
1
86,443
9
172,887
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes Submitted Solution: ``` a,b,c=map(int,input().split()) if max(a,b,c)==(a+b+c)/2:print("Yes") else:print("No") ```
instruction
0
86,444
9
172,888
Yes
output
1
86,444
9
172,889
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes Submitted Solution: ``` a,b,c = map(int,input().split()) big = max(a,b,c) total = a + b + c if total = big*2: print("Yes") else: print("No") ```
instruction
0
86,445
9
172,890
No
output
1
86,445
9
172,891
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes Submitted Solution: ``` p = list(map(int, input().split())).sort() print('Yes' if p[0]+p[1]==p[2] else 'No') ```
instruction
0
86,446
9
172,892
No
output
1
86,446
9
172,893
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes Submitted Solution: ``` import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); sc.close(); if(a + b == c || a + c == b || b + c == a) { System.out.println("Yes"); }else { System.out.println("No"); } } } ```
instruction
0
86,447
9
172,894
No
output
1
86,447
9
172,895
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. Constraints * 1 ≦ a, b, c ≦ 100 Input The input is given from Standard Input in the following format: a b c Output If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. Examples Input 10 30 20 Output Yes Input 30 30 100 Output No Input 56 25 31 Output Yes Submitted Solution: ``` n = input().split() a = int(n[0]) b = int(n[1]) c = int(n[2]) if (a + b) == c: print('Yes') elif (a + b) == c: print('Yes') elif (a + c) == b: print('Yes') else: print('No') ```
instruction
0
86,448
9
172,896
No
output
1
86,448
9
172,897
Provide tags and a correct Python 3 solution for this coding contest problem. Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration <image>. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass of Coke with carbon dioxide concentration <image>. The drink should also be tasty, so the glass can contain only integer number of liters of each Coke type (some types can be not presented in the glass). Also, they want to minimize the total volume of Coke in the glass. Carbon dioxide concentration is defined as the volume of carbone dioxide in the Coke divided by the total volume of Coke. When you mix two Cokes, the volume of carbon dioxide sums up, and the total volume of Coke sums up as well. Help them, find the minimal natural number of liters needed to create a glass with carbon dioxide concentration <image>. Assume that the friends have unlimited amount of each Coke type. Input The first line contains two integers n, k (0 ≀ n ≀ 1000, 1 ≀ k ≀ 106) β€” carbon dioxide concentration the friends want and the number of Coke types. The second line contains k integers a1, a2, ..., ak (0 ≀ ai ≀ 1000) β€” carbon dioxide concentration of each type of Coke. Some Coke types can have same concentration. Output Print the minimal natural number of liter needed to prepare a glass with carbon dioxide concentration <image>, or -1 if it is impossible. Examples Input 400 4 100 300 450 500 Output 2 Input 50 2 100 25 Output 3 Note In the first sample case, we can achieve concentration <image> using one liter of Coke of types <image> and <image>: <image>. In the second case, we can achieve concentration <image> using two liters of <image> type and one liter of <image> type: <image>.
instruction
0
87,180
9
174,360
Tags: dfs and similar, graphs, shortest paths Correct Solution: ``` from collections import deque n, k = map(int, input().split()) d = set(int(x)-n for x in input().split()) q = deque() q.append(0) visited = {i : False for i in range(-1000, 1001)} dist = {i : 0 for i in range(-1000, 1001)} ans = -1 visited[0] = True found = False while q: u = q.popleft() for i in d: if i + u == 0: ans = dist[u] + 1 found = True break if i + u <= 1000 and i + u >= -1000 and not visited[i + u]: visited[i + u] = True dist[i + u] = dist[u] + 1 q.append(i + u) if found: break print (ans) ```
output
1
87,180
9
174,361
Provide tags and a correct Python 3 solution for this coding contest problem. Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration <image>. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass of Coke with carbon dioxide concentration <image>. The drink should also be tasty, so the glass can contain only integer number of liters of each Coke type (some types can be not presented in the glass). Also, they want to minimize the total volume of Coke in the glass. Carbon dioxide concentration is defined as the volume of carbone dioxide in the Coke divided by the total volume of Coke. When you mix two Cokes, the volume of carbon dioxide sums up, and the total volume of Coke sums up as well. Help them, find the minimal natural number of liters needed to create a glass with carbon dioxide concentration <image>. Assume that the friends have unlimited amount of each Coke type. Input The first line contains two integers n, k (0 ≀ n ≀ 1000, 1 ≀ k ≀ 106) β€” carbon dioxide concentration the friends want and the number of Coke types. The second line contains k integers a1, a2, ..., ak (0 ≀ ai ≀ 1000) β€” carbon dioxide concentration of each type of Coke. Some Coke types can have same concentration. Output Print the minimal natural number of liter needed to prepare a glass with carbon dioxide concentration <image>, or -1 if it is impossible. Examples Input 400 4 100 300 450 500 Output 2 Input 50 2 100 25 Output 3 Note In the first sample case, we can achieve concentration <image> using one liter of Coke of types <image> and <image>: <image>. In the second case, we can achieve concentration <image> using two liters of <image> type and one liter of <image> type: <image>.
instruction
0
87,181
9
174,362
Tags: dfs and similar, graphs, shortest paths Correct Solution: ``` n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() if n < a[0] or n > a[k - 1]: print(-1) else: b = [] b.append(a[0]) for i in a: if i != b[len(b) - 1]: b.append(i) d = {} for i in range(len(b)): b[i] -= n d[b[i]] = 1 ans = 1 while 0 not in d: d1 = {} for i in d: for j in b: if -1001 < i + j < 1001: d1[i + j] = 1 d = d1 ans += 1 print(ans) ```
output
1
87,181
9
174,363
Provide tags and a correct Python 3 solution for this coding contest problem. Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration <image>. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass of Coke with carbon dioxide concentration <image>. The drink should also be tasty, so the glass can contain only integer number of liters of each Coke type (some types can be not presented in the glass). Also, they want to minimize the total volume of Coke in the glass. Carbon dioxide concentration is defined as the volume of carbone dioxide in the Coke divided by the total volume of Coke. When you mix two Cokes, the volume of carbon dioxide sums up, and the total volume of Coke sums up as well. Help them, find the minimal natural number of liters needed to create a glass with carbon dioxide concentration <image>. Assume that the friends have unlimited amount of each Coke type. Input The first line contains two integers n, k (0 ≀ n ≀ 1000, 1 ≀ k ≀ 106) β€” carbon dioxide concentration the friends want and the number of Coke types. The second line contains k integers a1, a2, ..., ak (0 ≀ ai ≀ 1000) β€” carbon dioxide concentration of each type of Coke. Some Coke types can have same concentration. Output Print the minimal natural number of liter needed to prepare a glass with carbon dioxide concentration <image>, or -1 if it is impossible. Examples Input 400 4 100 300 450 500 Output 2 Input 50 2 100 25 Output 3 Note In the first sample case, we can achieve concentration <image> using one liter of Coke of types <image> and <image>: <image>. In the second case, we can achieve concentration <image> using two liters of <image> type and one liter of <image> type: <image>.
instruction
0
87,183
9
174,366
Tags: dfs and similar, graphs, shortest paths Correct Solution: ``` from collections import deque n, k = map(int, input().split()) conc = set(int(x) - n for x in input().split()) q = deque() q.append(0) visited = {i : False for i in range(-1000, 1001)} dist = {i : 0 for i in range(-1000, 1001)} ans = -1 visited[0] = True found = False while q: u = q.popleft() for c in conc: v = c + u if v == 0: ans=dist[u]+1 found=True break if v<=1000 and v>=-1000 and not visited[v]: visited[v]=True dist[v]=dist[u]+1 q.append(v) if found: break print(ans) ```
output
1
87,183
9
174,367
Provide tags and a correct Python 3 solution for this coding contest problem. Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration <image>. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass of Coke with carbon dioxide concentration <image>. The drink should also be tasty, so the glass can contain only integer number of liters of each Coke type (some types can be not presented in the glass). Also, they want to minimize the total volume of Coke in the glass. Carbon dioxide concentration is defined as the volume of carbone dioxide in the Coke divided by the total volume of Coke. When you mix two Cokes, the volume of carbon dioxide sums up, and the total volume of Coke sums up as well. Help them, find the minimal natural number of liters needed to create a glass with carbon dioxide concentration <image>. Assume that the friends have unlimited amount of each Coke type. Input The first line contains two integers n, k (0 ≀ n ≀ 1000, 1 ≀ k ≀ 106) β€” carbon dioxide concentration the friends want and the number of Coke types. The second line contains k integers a1, a2, ..., ak (0 ≀ ai ≀ 1000) β€” carbon dioxide concentration of each type of Coke. Some Coke types can have same concentration. Output Print the minimal natural number of liter needed to prepare a glass with carbon dioxide concentration <image>, or -1 if it is impossible. Examples Input 400 4 100 300 450 500 Output 2 Input 50 2 100 25 Output 3 Note In the first sample case, we can achieve concentration <image> using one liter of Coke of types <image> and <image>: <image>. In the second case, we can achieve concentration <image> using two liters of <image> type and one liter of <image> type: <image>.
instruction
0
87,185
9
174,370
Tags: dfs and similar, graphs, shortest paths Correct Solution: ``` from collections import deque MAX_A = 1000 def main(): n, k = map(int, input().split()) a = set(int(x) - n for x in input().split()) visited = [False] * (2 * MAX_A + 1) visited[n] = True Q = deque() Q.append((n, 0)) result = None while Q: u, l = Q.popleft() l += 1 for ai in a: v = u + ai if v == n: result = l break if 0 <= v < len(visited) and not visited[v]: visited[v] = True Q.append((v, l)) if result is not None: break if result is None: result = -1 print(result) if __name__ == '__main__': # import sys # sys.stdin = open("E.txt") main() ```
output
1
87,185
9
174,371
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration <image>. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass of Coke with carbon dioxide concentration <image>. The drink should also be tasty, so the glass can contain only integer number of liters of each Coke type (some types can be not presented in the glass). Also, they want to minimize the total volume of Coke in the glass. Carbon dioxide concentration is defined as the volume of carbone dioxide in the Coke divided by the total volume of Coke. When you mix two Cokes, the volume of carbon dioxide sums up, and the total volume of Coke sums up as well. Help them, find the minimal natural number of liters needed to create a glass with carbon dioxide concentration <image>. Assume that the friends have unlimited amount of each Coke type. Input The first line contains two integers n, k (0 ≀ n ≀ 1000, 1 ≀ k ≀ 106) β€” carbon dioxide concentration the friends want and the number of Coke types. The second line contains k integers a1, a2, ..., ak (0 ≀ ai ≀ 1000) β€” carbon dioxide concentration of each type of Coke. Some Coke types can have same concentration. Output Print the minimal natural number of liter needed to prepare a glass with carbon dioxide concentration <image>, or -1 if it is impossible. Examples Input 400 4 100 300 450 500 Output 2 Input 50 2 100 25 Output 3 Note In the first sample case, we can achieve concentration <image> using one liter of Coke of types <image> and <image>: <image>. In the second case, we can achieve concentration <image> using two liters of <image> type and one liter of <image> type: <image>. Submitted Solution: ``` from collections import deque Max = 1000 def MainBFS(): n, k = map(int, input().split()) conc = set(int(x) for x in input().split()) visited = [False] * (2 * Max + 1) visited[0] = True Q = deque() Q.append((0, 0)) result = None while Q: u, l = Q.popleft() l += 1 for c in conc: v = u + c hayResult = False if v / l == n: hayResult = True if result is None: result = l elif result is not None and l < result: result = l if v < len(visited) and not visited[v] and not hayResult: visited[v] = True Q.append((v, l)) if result is None: result = -1 print(result) if __name__ == '__main__': MainBFS() ```
instruction
0
87,186
9
174,372
No
output
1
87,186
9
174,373
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration <image>. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass of Coke with carbon dioxide concentration <image>. The drink should also be tasty, so the glass can contain only integer number of liters of each Coke type (some types can be not presented in the glass). Also, they want to minimize the total volume of Coke in the glass. Carbon dioxide concentration is defined as the volume of carbone dioxide in the Coke divided by the total volume of Coke. When you mix two Cokes, the volume of carbon dioxide sums up, and the total volume of Coke sums up as well. Help them, find the minimal natural number of liters needed to create a glass with carbon dioxide concentration <image>. Assume that the friends have unlimited amount of each Coke type. Input The first line contains two integers n, k (0 ≀ n ≀ 1000, 1 ≀ k ≀ 106) β€” carbon dioxide concentration the friends want and the number of Coke types. The second line contains k integers a1, a2, ..., ak (0 ≀ ai ≀ 1000) β€” carbon dioxide concentration of each type of Coke. Some Coke types can have same concentration. Output Print the minimal natural number of liter needed to prepare a glass with carbon dioxide concentration <image>, or -1 if it is impossible. Examples Input 400 4 100 300 450 500 Output 2 Input 50 2 100 25 Output 3 Note In the first sample case, we can achieve concentration <image> using one liter of Coke of types <image> and <image>: <image>. In the second case, we can achieve concentration <image> using two liters of <image> type and one liter of <image> type: <image>. Submitted Solution: ``` n, k = map(int, input().split()) arr = list(map(int, input().split())) possible = [1000000007]*1001 arr.sort() for i in arr: possible[i] = 1 for i in range(1, 1001): for j in arr: if(i-j < 1): break possible[i] = min(possible[i], 1+possible[i-j]) if(possible[n] == 1000000007): print("-1") for i in range(1, 1001): if(i*n <= 1000 and i == possible[i*n]): print(i) exit(0) print(-1) ```
instruction
0
87,188
9
174,376
No
output
1
87,188
9
174,377
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration <image>. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass of Coke with carbon dioxide concentration <image>. The drink should also be tasty, so the glass can contain only integer number of liters of each Coke type (some types can be not presented in the glass). Also, they want to minimize the total volume of Coke in the glass. Carbon dioxide concentration is defined as the volume of carbone dioxide in the Coke divided by the total volume of Coke. When you mix two Cokes, the volume of carbon dioxide sums up, and the total volume of Coke sums up as well. Help them, find the minimal natural number of liters needed to create a glass with carbon dioxide concentration <image>. Assume that the friends have unlimited amount of each Coke type. Input The first line contains two integers n, k (0 ≀ n ≀ 1000, 1 ≀ k ≀ 106) β€” carbon dioxide concentration the friends want and the number of Coke types. The second line contains k integers a1, a2, ..., ak (0 ≀ ai ≀ 1000) β€” carbon dioxide concentration of each type of Coke. Some Coke types can have same concentration. Output Print the minimal natural number of liter needed to prepare a glass with carbon dioxide concentration <image>, or -1 if it is impossible. Examples Input 400 4 100 300 450 500 Output 2 Input 50 2 100 25 Output 3 Note In the first sample case, we can achieve concentration <image> using one liter of Coke of types <image> and <image>: <image>. In the second case, we can achieve concentration <image> using two liters of <image> type and one liter of <image> type: <image>. Submitted Solution: ``` from queue import Queue ins = map(int, input().split()) n, k = next(ins), next(ins) concentrations = list(map(int, input().split())) q = Queue() visited = {} for i in range(len(concentrations)): q.put((concentrations[i], 1)) visited[concentrations[i]] = True done = False while not q.empty(): top = q.get() if top[0] == top[1] * n: print(top[1]) done = True break else: for val in concentrations: new_val = val + top[0] path = top[1] + 1 if new_val in visited or top[0] > 1000: continue visited[new_val] = True q.put((new_val, path)) if not done: print(-1) ```
instruction
0
87,189
9
174,378
No
output
1
87,189
9
174,379
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much.
instruction
0
87,228
9
174,456
Tags: greedy, implementation Correct Solution: ``` from sys import stdin, stdout n = int(stdin.readline()) for i in range(n): k = int(stdin.readline()) label = 0 for c in range(k + 1): if k >= c * 3 and not (k - c * 3) % 7: label = 1 if label: stdout.write('YES\n') else: stdout.write('NO\n') ```
output
1
87,228
9
174,457
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much.
instruction
0
87,229
9
174,458
Tags: greedy, implementation Correct Solution: ``` n=int(input()) for i in range(n): k=int(input()) a=k//7 b=k%7 if b==0 or b%3==0: print("YES") else: while b%3!=0: b=b+7 if b<=k: print("YES") else: print("NO") ```
output
1
87,229
9
174,459
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much.
instruction
0
87,230
9
174,460
Tags: greedy, implementation Correct Solution: ``` n = int(input()) #n, m = map(int, input().split()) #s = input() #c = list(map(int, input().split())) for i in range(n): x = int(input()) if x % 3 == 0 or x == 7 or x == 10 or x > 11: print('YES') else: print('NO') ```
output
1
87,230
9
174,461
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much.
instruction
0
87,231
9
174,462
Tags: greedy, implementation Correct Solution: ``` a=('1','2','4','5','8','11') for i in range(int(input())): if input() in a: print('NO') else: print('YES') ```
output
1
87,231
9
174,463
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much.
instruction
0
87,232
9
174,464
Tags: greedy, implementation Correct Solution: ``` t=int(input()) for _ in range(t): n=int(input()) if n in [1,2,4,5,8,11]: print("NO") else: print("YES") ```
output
1
87,232
9
174,465
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much.
instruction
0
87,233
9
174,466
Tags: greedy, implementation Correct Solution: ``` n = int(input()) for i in range(n): q = int(input()) t = 0 for j in range(34): for k in range(34): if 3 * j + 7 * k == q: print("YES") t = 1 break if t == 1: break if t == 0: print("NO") ```
output
1
87,233
9
174,467
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much.
instruction
0
87,234
9
174,468
Tags: greedy, implementation Correct Solution: ``` n = int(input()) small = 3 large = 7 for i in range(n): c = int(input()) if c % small == 0 or c % large == 0: print('YES') else: need = False for j in range(34): x = c - small * j if x > 0 and x % large == 0: print('YES') need = True break if not need: print('NO') ```
output
1
87,234
9
174,469
Provide tags and a correct Python 3 solution for this coding contest problem. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much.
instruction
0
87,235
9
174,470
Tags: greedy, implementation Correct Solution: ``` n=int(input()) for i in range(n): x=int(input()) f=True for j in range(34): for k in range(34): if j*3 +k*7==x: f=False if f: print("NO") else: print("YES") ```
output
1
87,235
9
174,471
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much. Submitted Solution: ``` n=int(input()) while n: x=int(input()) if x>=7*(x%3): print('YES') else: print('NO') n-=1 ```
instruction
0
87,236
9
174,472
Yes
output
1
87,236
9
174,473
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much. Submitted Solution: ``` def get_int(string, n): i = j = k = 0 for s in string: k += 1 for s in string: if i == n - 1: break if s == ' ': i += 1 j += 1 i = 0 while j < k: if string[j] == ' ': break i = 10 * i + int(string[j]) j += 1 return i def get_ans(y): if y < 0: print("NO") elif y % 3 == 0 or y % 7 == 0: print('YES') return else : y -= 3 get_ans(y) n = int(input()) for i in range(0, n): y = int(input()) get_ans(y) ```
instruction
0
87,237
9
174,474
Yes
output
1
87,237
9
174,475
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much. Submitted Solution: ``` n = int(input().strip()) x = 7 y = 3 for _ in range(0, n): z = int(input().strip()) try: for a in range(0, 100): for b in range(0, 100): if a * x + b * y == z: raise Exception("FOUND") except: print("YES") else: print("NO") ```
instruction
0
87,238
9
174,476
Yes
output
1
87,238
9
174,477
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much. Submitted Solution: ``` for i in range(int(input())): print(["YES","NO"][int(input()) in [1,2,4,5,8,11]]) ```
instruction
0
87,239
9
174,478
Yes
output
1
87,239
9
174,479
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much. Submitted Solution: ``` n = int(input()) tasks = [] for i in range(n): tasks.append(int(input())) for i in tasks: m = i // 7 for j in range(m+1): if (i - j*7) % 3 == 0: print('YES') break else: print('NO') break ```
instruction
0
87,240
9
174,480
No
output
1
87,240
9
174,481
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much. Submitted Solution: ``` n = int(input()) small = 3 large = 7 for i in range(n): c = int(input()) need = True for j in range(min(c,34)): if (c- j*small) % large == 0: print('YES') need = False break if need: print('NO') ```
instruction
0
87,241
9
174,482
No
output
1
87,241
9
174,483
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken. Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks. Help Ivan to answer this question for several values of x! Input The first line contains one integer n (1 ≀ n ≀ 100) β€” the number of testcases. The i-th of the following n lines contains one integer xi (1 ≀ xi ≀ 100) β€” the number of chicken chunks Ivan wants to eat. Output Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO. Example Input 2 6 5 Output YES NO Note In the first example Ivan can buy two small portions. In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much. Submitted Solution: ``` def get_data2(): n = int(input().strip()) data = [n] for i in range(n): data.append(int(input().strip())) return data def test3(): data = get_data2() for a in data[1:]: for i in range(a//3+1): for j in range(a//7+1): if 3*i+7*j == a: # print(i, j, a, "yes") print("YES") # break print("NO") test3() ```
instruction
0
87,242
9
174,484
No
output
1
87,242
9
174,485