message
stringlengths
2
20.2k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
757
108k
cluster
float64
4
4
__index_level_0__
int64
1.51k
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≤ a ≤ 1000; 2 ≤ b ≤ 1000). Output Print a single integer — the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` a, b = map(int, input().split()) count = a while count >= 0: count += a // b if a//b == 0: print(count) break a = a // b ```
instruction
0
86,050
4
172,100
No
output
1
86,050
4
172,101
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≤ a ≤ 1000; 2 ≤ b ≤ 1000). Output Print a single integer — the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` ab = input().split() a = int(ab[0]) b = int(ab[1]) tot = a while(a >= b): newCandle = int(a / b) a = newCandle tot = tot + newCandle print(tot) ```
instruction
0
86,051
4
172,102
No
output
1
86,051
4
172,103
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≤ a ≤ 1000; 2 ≤ b ≤ 1000). Output Print a single integer — the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` a,b = map(int,input().split()) hours = a trash = 0 while a !=0: hours += a//b trash +=a - (a//b)*b a = a//b print(hours + trash//b) ```
instruction
0
86,052
4
172,104
No
output
1
86,052
4
172,105
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≤ a ≤ 1000; 2 ≤ b ≤ 1000). Output Print a single integer — the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` numbers = list(map(int,input().split())) a=numbers[0] b=numbers[1] count = a while a / b >= 1: count += a / b a = a/b print (int(count)) ```
instruction
0
86,053
4
172,106
No
output
1
86,053
4
172,107
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden. Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length ai if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden. See the examples for better understanding. Input The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively. The second line of input contains n integer numbers ai (1 ≤ ai ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour. It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket. Output Print one integer number — the minimum number of hours required to water the garden. Examples Input 3 6 2 3 5 Output 2 Input 6 7 1 2 3 4 5 6 Output 7 Note In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden. In the second test we can choose only the bucket that allows us to water the segment of length 1. Submitted Solution: ``` a=list(map(int,input().split())) b=list(map(int,input().split())) s=[] temp=0 for i in range(a[0]): if(a[1]%b[i]==0): s.append(int(a[1]//b[i])) print(min(s)) ```
instruction
0
86,255
4
172,510
Yes
output
1
86,255
4
172,511
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden. Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length ai if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden. See the examples for better understanding. Input The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively. The second line of input contains n integer numbers ai (1 ≤ ai ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour. It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket. Output Print one integer number — the minimum number of hours required to water the garden. Examples Input 3 6 2 3 5 Output 2 Input 6 7 1 2 3 4 5 6 Output 7 Note In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden. In the second test we can choose only the bucket that allows us to water the segment of length 1. Submitted Solution: ``` # import sys # sys.stdin=open("input.in",'r') # sys.stdout=open("output4.out",'w') n,k=map(int,input().split()) a=list(map(int,input().split())) m=0 for i in a: if k%i==0: m=max(m,i) print(int(k/m)) ```
instruction
0
86,256
4
172,512
Yes
output
1
86,256
4
172,513
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden. Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length ai if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden. See the examples for better understanding. Input The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively. The second line of input contains n integer numbers ai (1 ≤ ai ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour. It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket. Output Print one integer number — the minimum number of hours required to water the garden. Examples Input 3 6 2 3 5 Output 2 Input 6 7 1 2 3 4 5 6 Output 7 Note In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden. In the second test we can choose only the bucket that allows us to water the segment of length 1. Submitted Solution: ``` import sys ipt = input().split() n = int(ipt.pop(0)) k = int(ipt.pop(0)) numbers = [int(i) for i in input().split()] times = [] for n in numbers: if k % n == 0: times.append(n) result = int(k / max(times)) print(result) ```
instruction
0
86,257
4
172,514
Yes
output
1
86,257
4
172,515
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden. Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length ai if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden. See the examples for better understanding. Input The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively. The second line of input contains n integer numbers ai (1 ≤ ai ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour. It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket. Output Print one integer number — the minimum number of hours required to water the garden. Examples Input 3 6 2 3 5 Output 2 Input 6 7 1 2 3 4 5 6 Output 7 Note In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden. In the second test we can choose only the bucket that allows us to water the segment of length 1. Submitted Solution: ``` n, k = [int(i) for i in input().split()] a = [int(i) for i in input().split()] ans = 10 ** 100 for i in a: if k % i == 0 and k // i < ans: ans = k // i print(ans) ```
instruction
0
86,258
4
172,516
Yes
output
1
86,258
4
172,517
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden. Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length ai if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden. See the examples for better understanding. Input The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively. The second line of input contains n integer numbers ai (1 ≤ ai ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour. It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket. Output Print one integer number — the minimum number of hours required to water the garden. Examples Input 3 6 2 3 5 Output 2 Input 6 7 1 2 3 4 5 6 Output 7 Note In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden. In the second test we can choose only the bucket that allows us to water the segment of length 1. Submitted Solution: ``` if __name__ == '__main__': n, l = [int(i) for i in input().strip().split()] arr = [int(i) for i in input().strip().split()] mi = 10000000 for i in arr: if l % i == 0: mi = l // min(mi, i) print(mi) ```
instruction
0
86,259
4
172,518
No
output
1
86,259
4
172,519
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden. Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length ai if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden. See the examples for better understanding. Input The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively. The second line of input contains n integer numbers ai (1 ≤ ai ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour. It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket. Output Print one integer number — the minimum number of hours required to water the garden. Examples Input 3 6 2 3 5 Output 2 Input 6 7 1 2 3 4 5 6 Output 7 Note In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden. In the second test we can choose only the bucket that allows us to water the segment of length 1. Submitted Solution: ``` n,k=list(map(int,input().split())) t=list(map(int,input().split())) s=0 for i in range(len(t)): if k%t[i]==0: p=k//t[i] if p>s: s=p print(p) ```
instruction
0
86,261
4
172,522
No
output
1
86,261
4
172,523
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden. Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length ai if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden. See the examples for better understanding. Input The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively. The second line of input contains n integer numbers ai (1 ≤ ai ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour. It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket. Output Print one integer number — the minimum number of hours required to water the garden. Examples Input 3 6 2 3 5 Output 2 Input 6 7 1 2 3 4 5 6 Output 7 Note In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden. In the second test we can choose only the bucket that allows us to water the segment of length 1. Submitted Solution: ``` line = input().split() num_buckets = int(line[0]) length = int(line[1]) ans = 0 line = input().split() for bucket in line: bucket_size = int(bucket) if length % bucket_size == 0: ans = max(ans, bucket_size) print(ans) ```
instruction
0
86,262
4
172,524
No
output
1
86,262
4
172,525
Provide a correct Python 3 solution for this coding contest problem. You are the God of Wind. By moving a big cloud around, you can decide the weather: it invariably rains under the cloud, and the sun shines everywhere else. But you are a benign God: your goal is to give enough rain to every field in the countryside, and sun to markets and festivals. Small humans, in their poor vocabulary, only describe this as “weather forecast”. You are in charge of a small country, called Paccimc. This country is constituted of 4 × 4 square areas, denoted by their numbers. <image> Your cloud is of size 2 × 2, and may not cross the borders of the country. You are given the schedule of markets and festivals in each area for a period of time. On the first day of the period, it is raining in the central areas (6-7-10-11), independently of the schedule. On each of the following days, you may move your cloud by 1 or 2 squares in one of the four cardinal directions (North, West, South, and East), or leave it in the same position. Diagonal moves are not allowed. All moves occur at the beginning of the day. You should not leave an area without rain for a full week (that is, you are allowed at most 6 consecutive days without rain). You don’t have to care about rain on days outside the period you were given: i.e. you can assume it rains on the whole country the day before the period, and the day after it finishes. Input The input is a sequence of data sets, followed by a terminating line containing only a zero. A data set gives the number N of days (no more than 365) in the period on a single line, followed by N lines giving the schedule for markets and festivals. The i-th line gives the schedule for the i-th day. It is composed of 16 numbers, either 0 or 1, 0 standing for a normal day, and 1 a market or festival day. The numbers are separated by one or more spaces. Output The answer is a 0 or 1 on a single line for each data set, 1 if you can satisfy everybody, 0 if there is no way to do it. Example Input 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 Output 0 1 0 1
instruction
0
86,489
4
172,978
"Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**13 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def pf(s): return print(s, flush=True) def main(): rr = [] mij = [] for i in range(3): mi = [] for j in range(3): mi.append([i*4+j,i*4+j+1,i*4+j+4,i*4+j+5]) mij.append(mi) def f(n): a = [LI() for _ in range(n)] fs = set() def _f(i,j,d,d1,d4,d13,d16): if d >= n: return True key = (i,j,d,d1,d4,d13,d16) if key in fs: return False if i == 0: if j == 0: d1 = d elif j == 2: d4 = d elif i == 2: if j == 0: d13 = d elif j == 2: d16 = d for mm in mij[i][j]: if a[d][mm] > 0: fs.add(key) return False if d - min([d1,d4,d13,d16]) >= 7: fs.add(key) return False if _f(i,j,d+1,d1,d4,d13,d16): return True for ni in range(3): if i == ni: continue if _f(ni,j,d+1,d1,d4,d13,d16): return True for nj in range(3): if j == nj: continue if _f(i,nj,d+1,d1,d4,d13,d16): return True fs.add(key) return False if _f(1,1,0,-1,-1,-1,-1): return 1 return 0 while True: n = I() if n == 0: break rr.append(f(n)) return '\n'.join(map(str,rr)) print(main()) ```
output
1
86,489
4
172,979
Provide a correct Python 3 solution for this coding contest problem. You are the God of Wind. By moving a big cloud around, you can decide the weather: it invariably rains under the cloud, and the sun shines everywhere else. But you are a benign God: your goal is to give enough rain to every field in the countryside, and sun to markets and festivals. Small humans, in their poor vocabulary, only describe this as “weather forecast”. You are in charge of a small country, called Paccimc. This country is constituted of 4 × 4 square areas, denoted by their numbers. <image> Your cloud is of size 2 × 2, and may not cross the borders of the country. You are given the schedule of markets and festivals in each area for a period of time. On the first day of the period, it is raining in the central areas (6-7-10-11), independently of the schedule. On each of the following days, you may move your cloud by 1 or 2 squares in one of the four cardinal directions (North, West, South, and East), or leave it in the same position. Diagonal moves are not allowed. All moves occur at the beginning of the day. You should not leave an area without rain for a full week (that is, you are allowed at most 6 consecutive days without rain). You don’t have to care about rain on days outside the period you were given: i.e. you can assume it rains on the whole country the day before the period, and the day after it finishes. Input The input is a sequence of data sets, followed by a terminating line containing only a zero. A data set gives the number N of days (no more than 365) in the period on a single line, followed by N lines giving the schedule for markets and festivals. The i-th line gives the schedule for the i-th day. It is composed of 16 numbers, either 0 or 1, 0 standing for a normal day, and 1 a market or festival day. The numbers are separated by one or more spaces. Output The answer is a 0 or 1 on a single line for each data set, 1 if you can satisfy everybody, 0 if there is no way to do it. Example Input 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 Output 0 1 0 1
instruction
0
86,490
4
172,980
"Correct Solution: ``` from collections import deque while True: n=int(input()) if n==0: exit() data = [] for i in range(n): tmp = list(map(int,input().split())) tmp = [tmp[:4],tmp[4:8],tmp[8:12],tmp[12:]] d = [ [0 for i in range(3)]for i in range(3)] for i in range(3): for j in range(3): for k in range(2): for l in range(2): d[i][j] += tmp[i+k][j+l] data.append(d) q = deque() memo = set() if data[0][1][1]: print(0) continue q.append((0,1,1,(0,0,0,0))) while len(q): z,y,x,h = q.popleft() if (y,x) == (0,0): h = (0,h[1]+1,h[2]+1,h[3]+1) elif (y,x) == (0,2): h = (h[0]+1,0,h[2]+1,h[3]+1) elif (y,x) == (2,0): h = (h[0]+1,h[1]+1,0,h[3]+1) elif (y,x) == (2,2): h = (h[0]+1,h[1]+1,h[2]+1,0) else: h = (h[0]+1,h[1]+1,h[2]+1,h[3]+1) if max(h)>6: continue if (z,y,x,h) in memo: continue memo.add((z,y,x,h)) if z==n-1: print(1) break for i in range(3): if not data[z+1][i][x]: q.append((z+1,i,x,h)) if not data[z+1][y][i]: q.append((z+1,y,i,h)) else: print(0) ```
output
1
86,490
4
172,981
Provide tags and a correct Python 3 solution for this coding contest problem. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good.
instruction
0
86,753
4
173,506
Tags: dp, implementation Correct Solution: ``` n, h, l, r = map(int, input().split()) a = list(map(int, input().split())) cursum = [0] * (n + 1) for i in range(n): cursum[i + 1] += cursum[i] + a[i] cursum[i + 1] %= h dp = [[0] * (n + 1) for i in range(n + 1)] for i in range(n): for j in range(i + 1): # ai t = (cursum[i + 1] - j) % h if l <= t <= r: dp[i + 1][j] = max(dp[i][j] + 1, dp[i + 1][j]) else: dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]) # ai - 1 t = (cursum[i + 1] - j - 1) % h if l <= t <= r: dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j + 1]) else: dp[i + 1][j + 1] = max(dp[i][j], dp[i + 1][j + 1]) print(max(dp[-1])) ```
output
1
86,753
4
173,507
Provide tags and a correct Python 3 solution for this coding contest problem. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good.
instruction
0
86,754
4
173,508
Tags: dp, implementation Correct Solution: ``` z=lambda:map(int,input().split());a,b,c,d=z();e=[-10000000000]*b;f=list(map(int,input().split()));e[0]=0 for i in range(a): k=[] for j in range(b): o=max(e[(j-f[i])%b],e[(j-f[i]+1)%b]) if c<=j<=d:o+=1 k+=[o] e=k print(max(e)) ```
output
1
86,754
4
173,509
Provide tags and a correct Python 3 solution for this coding contest problem. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good.
instruction
0
86,755
4
173,510
Tags: dp, implementation Correct Solution: ``` n, h, l, r = map(int, input().split()) a = list(map(int, input().split())) cur = [-3000] * h cur[0] = 0 for x in a: new = [] for i in range(h): f = max(cur[(i-x)%h], cur[(i-x+1)%h]) if l<=i<=r: f += 1 new += [f] cur = new print(max(cur)) ```
output
1
86,755
4
173,511
Provide tags and a correct Python 3 solution for this coding contest problem. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good.
instruction
0
86,756
4
173,512
Tags: dp, implementation Correct Solution: ``` # https://codeforces.com/problemset/problem/1324/E n, h,l,r = list(map(int,input().strip().split())) arr = list(map(int,input().strip().split())) dp_arr = [[0 for j in range(h)] for i in range(n+1)] pre_set = set([0]) for i in range(n): # print(arr[i],pre_set) temp_set = set() for j in pre_set: for k in [arr[i],arr[i]-1]: pre_val = dp_arr[i][j] new_time = (j+k)%h if l<=new_time and new_time<=r: pre_val+=1 dp_arr[i+1][new_time] = max(dp_arr[i+1][new_time],pre_val) temp_set.add(new_time) pre_set = temp_set # print(pre_set) # for i in dp_arr: # print(*i) print(max(dp_arr[-1])) ```
output
1
86,756
4
173,513
Provide tags and a correct Python 3 solution for this coding contest problem. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good.
instruction
0
86,757
4
173,514
Tags: dp, implementation Correct Solution: ``` n, h, l, r = map(int, input().split()) a = list(map(int, input().split())) MINN = -int(1e9) dp = [[MINN] * (n + 1) for i in range(n + 1)] dp[0][0] = 0 s = 0 for i in range(n): s += a[i] for j in range(n + 1): dp[i + 1][j] = max(dp[i + 1][j],dp[i][j] + int((l <= (s - j) % h <= r))) if j < n: dp[i + 1][j + 1] = max(dp[i + 1][j + 1],dp[i][j] + int((l <= (s - j - 1) % h <= r))) print(max(dp[n])) ```
output
1
86,757
4
173,515
Provide tags and a correct Python 3 solution for this coding contest problem. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good.
instruction
0
86,758
4
173,516
Tags: dp, implementation Correct Solution: ``` n, h, l, r = map(int, input().split()) dp = [[0] * h for _ in range(n + 1)] possible = [set() for i in range(n + 1)] possible[0].add(0) for i, length in zip(range(1, n + 1), map(int, input().split())): for time in possible[i - 1]: trans0 = (time + length) % h trans1 = (h + time + length - 1) % h dp[i][trans0] = max(dp[i][trans0], dp[i - 1][time]) dp[i][trans1] = max(dp[i][trans1], dp[i - 1][time]) possible[i].add(trans0) possible[i].add(trans1) for time in possible[i]: if l <= time <= r: dp[i][time] += 1 print(max(dp[n])) ```
output
1
86,758
4
173,517
Provide tags and a correct Python 3 solution for this coding contest problem. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good.
instruction
0
86,759
4
173,518
Tags: dp, implementation Correct Solution: ``` n,h,l,r=map(int,input().split()) a=list(map(int,input().split())) b=[a[0]] for i in a[1:]:b.append(b[-1]+i) dp=[(n+1)*[0]for _ in range(n)] if l<=a[0]<=r:dp[0][0]=1 if l<=a[0]-1<=r:dp[0][1]=1 for i in range(1,n): for j in range(i+2): if j==0: dp[i][j]=dp[i-1][j] if l<=b[i]%h<=r:dp[i][j]+=1 m=(b[i]-j)%h if l<=m<=r:f=1 else:f=0 dp[i][j]=max(dp[i-1][j-1],dp[i-1][j])+f print(max(dp[n-1])) ```
output
1
86,759
4
173,519
Provide tags and a correct Python 3 solution for this coding contest problem. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good.
instruction
0
86,760
4
173,520
Tags: dp, implementation Correct Solution: ``` from math import * n, h, l, r = map(int, input().split()) a = [int(i) for i in input().split()] dp = [] for i in range(n): dp.append([0] * (n+1)) s = sum(a) for i in range(n - 1, -1, -1): for j in range(i + 2): if r >= (s - j) % h >= l: dp[i][j] += 1 if i < n - 1: dp[i][j] += max(dp[i+1][j], dp[i+1][j+1]) s -= a[i] #for i in dp: # print(i) print(max(dp[0][0], dp[0][1])) ```
output
1
86,760
4
173,521
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good. Submitted Solution: ``` n, h, l, r = map(int, input().split()) a = list(map(int, input().split())) s = 0 d = [[-float('inf') for i in range(n + 1)] for j in range(n + 1)] d[0][0] = 0 for i in range(n): s += a[i] for j in range(n + 1): d[i + 1][j] = max(d[i + 1][j], d[i][j] + int(l <= (s - j) % h <= r)) if j < n: d[i + 1][j + 1] = max(d[i + 1][j + 1], d[i][j] + int(l <= (s - j - 1) % h <= r)) print(max(d[n])) ```
instruction
0
86,761
4
173,522
Yes
output
1
86,761
4
173,523
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good. Submitted Solution: ``` n, h, l, r = map(int, input().split()) a = [int(_) for _ in input().split()] d = [[-2024] * h for _ in range(n)] d[0][a[0]] = (1 if l <= a[0] and a[0] <= r else 0) d[0][a[0] - 1] = (1 if l <= a[0]-1 and a[0]-1 <= r else 0) for i in range(1, n): x = a[i] for v in range(h): d[i][v] = max(d[i-1][v-x], d[i-1][v-x+1]) + (1 if l <= v and v <= r else 0) print(max(d[-1])) ```
instruction
0
86,762
4
173,524
Yes
output
1
86,762
4
173,525
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good. Submitted Solution: ``` n, h, l, r = map(int, input().split()) a = list(map(int, input().split())) cur = [-1] * h cur[0] = 0 for i in range(n): next = [-1] * h for j in range(h): if cur[j] > -1: p = (j + a[i]) % h next[p] = max(cur[j] + (l <= p <= r), next[p]) p = (j + a[i] - 1) % h next[p] = max(cur[j] + (l <= p <= r), next[p]) cur = next.copy() print(max(cur)) ```
instruction
0
86,763
4
173,526
Yes
output
1
86,763
4
173,527
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good. Submitted Solution: ``` n, h, l, r = map(int, input().split()) a = list(map(int, input().split())) dp = [[None for i in range(h)] for i in range(n)] if l <= a[0] <= r: dp[0][a[0]] = 1 else: dp[0][a[0]] = 0 if l <= a[0] - 1 <= r: dp[0][a[0] - 1] = 1 else: dp[0][a[0] - 1] = 0 for i in range(1, n): for j in range(0, h): if dp[i-1][(j+h-a[i])%h] != None: if l <= j <= r: if dp[i][j] != None: dp[i][j] = max(dp[i-1][(j+h-a[i])%h] + 1, dp[i][j]) else: dp[i][j] = dp[i-1][(j+h-a[i])%h] + 1 else: if dp[i][j] != None: dp[i][j] = max(dp[i-1][(j+h-a[i])%h] + 1, dp[i][j]) else: dp[i][j] = dp[i-1][(j+h-a[i])%h] if dp[i-1][(j+h-a[i]+1)%h] != None: if l <= j <= r: if dp[i][j] != None: dp[i][j] = max(dp[i-1][(j+h-a[i]+1)%h] + 1, dp[i][j]) else: dp[i][j] = dp[i-1][(j+h-a[i]+1)%h] + 1 else: if dp[i][j] != None: dp[i][j] = max(dp[i-1][(j+h-a[i]+1)%h], dp[i][j]) else: dp[i][j] = dp[i-1][(j+h-a[i]+1)%h] ans = 0 for i in range(h): if dp[n-1][i] != None: ans = max(ans, dp[n-1][i]) print(ans) ```
instruction
0
86,764
4
173,528
Yes
output
1
86,764
4
173,529
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good. Submitted Solution: ``` def printit(matrix): for i in matrix: for j in i: print (j,end=" ") print () n,h,start,end=map(int,input().split()) l=list(map(int,input().split())) dp=[[0 for i in range(h)] for j in range(n)] dp[0][l[0]-1]=1 dp[0][l[0]-2]=1 #printit(dp) for i in range(1,n): for j in range(h): time1=j+h-l[i] time2=j+h-l[i]+1 if time1>=h: time1-=h if time2>=h: time2-=h #print (time1,time2) dp[i][j]=max(dp[i-1][time1],dp[i-1][time2]) #printit(dp) ans=0 for i in range(start,end+1): count=0 for j in range(n): if dp[j][i]==1: count+=1 if count>ans: ans=count print (ans) ```
instruction
0
86,765
4
173,530
No
output
1
86,765
4
173,531
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good. Submitted Solution: ``` n,h,l,r = map(int,input().split()) a = list(map(int,input().split())) t = 0 hson = 0 for x in range(n): if t > h: t -= h if t + a[x] >= l and t + a[x] <= r: hson += 1 t += a[x] elif t + a[x] - 1 and t + a[x] - 1 <= r: hson += 1 t += a[x] - 1 else: t += a[x] - 1 print(hson) ```
instruction
0
86,766
4
173,532
No
output
1
86,766
4
173,533
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good. Submitted Solution: ``` ###### ### ####### ####### ## # ##### ### ##### # # # # # # # # # # # # # ### # # # # # # # # # # # # # ### ###### ######### # # # # # # ######### # ###### ######### # # # # # # ######### # # # # # # # # # # # #### # # # # # # # # # # ## # # # # # ###### # # ####### ####### # # ##### # # # # # mandatory imports import os import sys from io import BytesIO, IOBase from math import log2, ceil, sqrt, gcd, log # optional imports # from itertools import permutations # from functools import cmp_to_key # for adding custom comparator # from fractions import Fraction from collections import * from bisect import * # from __future__ import print_function # for PyPy2 from heapq import * 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") g = lambda : input().strip() gl = lambda : g().split() gil = lambda : [int(var) for var in gl()] gfl = lambda : [float(var) for var in gl()] gcl = lambda : list(g()) gbs = lambda : [int(var) for var in g()] rr = lambda x : reversed(range(x)) mod = int(1e9)+7 inf = float("inf") n, h, l, r = gil() a = gil() for i in range(1, n): a[i] += a[i-1] a[i] %= h dp = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): dp[0][i] += (1 if l <= a[i] <= r else 0) + (dp[0][i-1] if i else 0) ans = dp[0][-1] for i in range(1, n): for j in range(i-1, n): at = a[j] - i if at < 0:at += h dp[i][j] += (1 if l <= at <= r else 0) + max((dp[i-1][j-1] if j else 0), (dp[i][j-1] if j else 0)) ans = max(ans, dp[i][-1]) # for r in dp: # print(*r) print(ans) ```
instruction
0
86,767
4
173,534
No
output
1
86,767
4
173,535
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vova had a pretty weird sleeping schedule. There are h hours in a day. Vova will sleep exactly n times. The i-th time he will sleep exactly after a_i hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 0). Each time Vova sleeps exactly one day (in other words, h hours). Vova thinks that the i-th sleeping time is good if he starts to sleep between hours l and r inclusive. Vova can control himself and before the i-th time can choose between two options: go to sleep after a_i hours or after a_i - 1 hours. Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally. Input The first line of the input contains four integers n, h, l and r (1 ≤ n ≤ 2000, 3 ≤ h ≤ 2000, 0 ≤ l ≤ r < h) — the number of times Vova goes to sleep, the number of hours in a day and the segment of the good sleeping time. The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i < h), where a_i is the number of hours after which Vova goes to sleep the i-th time. Output Print one integer — the maximum number of good sleeping times Vova can obtain if he acts optimally. Example Input 7 24 21 23 16 17 14 20 20 11 22 Output 3 Note The maximum number of good times in the example is 3. The story starts from t=0. Then Vova goes to sleep after a_1 - 1 hours, now the time is 15. This time is not good. Then Vova goes to sleep after a_2 - 1 hours, now the time is 15 + 16 = 7. This time is also not good. Then Vova goes to sleep after a_3 hours, now the time is 7 + 14 = 21. This time is good. Then Vova goes to sleep after a_4 - 1 hours, now the time is 21 + 19 = 16. This time is not good. Then Vova goes to sleep after a_5 hours, now the time is 16 + 20 = 12. This time is not good. Then Vova goes to sleep after a_6 hours, now the time is 12 + 11 = 23. This time is good. Then Vova goes to sleep after a_7 hours, now the time is 23 + 22 = 21. This time is also good. Submitted Solution: ``` import sys input=sys.stdin.readline from math import * n,h,l,r=map(int,input().split()) a=[int(x) for x in input().split()] s=[0 for i in range(n)] s[0]=a[0] for i in range(1,n): s[i]=s[i-1]+a[i] c=0 #print(s) for i in range(n): for j in range(i+2): if l<=(s[i]-j)%h<=r: c+=1 break print(c) ```
instruction
0
86,768
4
173,536
No
output
1
86,768
4
173,537
Provide a correct Python 3 solution for this coding contest problem. D: Sunburn-Suntan- story Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. Cute like an angel. Aizu Nyan is planning to participate in this summer festival, so I made a schedule for the band to go to listen to. I'm worried about sunburn here. All live performances are held outdoors, but Aizu Nyan has a constitution that makes it easy to get sunburned, so if you are exposed to too much ultraviolet rays outdoors for a long time, you will get sunburned immediately. I plan to avoid UV rays as much as possible by evacuating indoors while there is no live performance, but during the live performance, it will inevitably hit the sun. Therefore, Aizu Nyan thought about taking measures against ultraviolet rays by applying sunscreen. problem If you apply sunscreen, you can get the effect for T minutes from the time you apply it. Sunscreen can only be applied once, so I want to use it effectively. Aizu Nyan is outdoors from the start time to the end time of the live, and is indoors at other times. You'll be given a live schedule that Aizu Nyan will listen to, so find the maximum amount of time you can get the sunscreen effect while you're outdoors. Input format The input can be given in the following format. T N s_1 t_1 ... s_N t_N The first line is given an integer T that represents the time it takes to get the sunscreen effect. The second line is given an integer N that represents the number of live concerts Aizu Nyan listens to. The following N lines are given the integer s_i, which represents the start time of the live that Aizu Nyan listens to thi, and the integer t_i, which represents the end time, separated by spaces. Constraint * 1 ≤ T ≤ 10 ^ {15} * 1 ≤ N ≤ 10 ^ 5 * 0 ≤ s_i <t_i ≤ 10 ^ {15} (1 ≤ i ≤ N) * The start time of the (i + 1) th live is the same as or later than the end time of the i-th live. That is, t_i ≤ s_ {i + 1} (1 ≤ i <N) output Print one line for the maximum amount of time you can get the sunscreen effect while you're outdoors. Input example 1 20 1 0 10 Output example 1 Ten Input example 2 20 1 0 100 Output example 2 20 Input example 3 9 3 1 5 9 11 13 20 Output example 3 7 Input example 4 twenty five Five 9 12 15 20 21 25 28 40 45 60 Output example 4 twenty one Example Input 20 1 0 10 Output 10
instruction
0
87,478
4
174,956
"Correct Solution: ``` # AOJ 2801: Suntan # Python3 2018.7.11 bal4u from bisect import bisect_left T, N = int(input()), int(input()) a, s, t = [0], [0], [0] for i in range(N): _s, _t = map(int, input().split()) s.append(_s) t.append(_t) a.append(a[-1]+_t-_s) s.append(1<<62) t.append(1<<62) ans = 0 k = bisect_left(t, T, 0)-1 for i in range(1, N+1): x = s[i]+T k = bisect_left(t, x, k)-1 y = a[k]-a[i-1] if x > s[k+1]: y += x-s[k+1] if y > ans: ans = y; if ans == T: break print(ans) ```
output
1
87,478
4
174,957
Provide tags and a correct Python 3 solution for this coding contest problem. Pasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and each hamster either sat down or stood up. For another exercise, Pasha needs exactly <image> hamsters to stand up and the other hamsters to sit down. In one minute, Pasha can make some hamster ether sit down or stand up. How many minutes will he need to get what he wants if he acts optimally well? Input The first line contains integer n (2 ≤ n ≤ 200; n is even). The next line contains n characters without spaces. These characters describe the hamsters' position: the i-th character equals 'X', if the i-th hamster in the row is standing, and 'x', if he is sitting. Output In the first line, print a single integer — the minimum required number of minutes. In the second line, print a string that describes the hamsters' position after Pasha makes the required changes. If there are multiple optimal positions, print any of them. Examples Input 4 xxXx Output 1 XxXx Input 2 XX Output 1 xX Input 6 xXXxXx Output 0 xXXxXx
instruction
0
87,916
4
175,832
Tags: implementation Correct Solution: ``` import sys from functools import reduce from collections import Counter import time import datetime from math import sqrt,gcd # def time_t(): # print("Current date and time: " , datetime.datetime.now()) # print("Current year: ", datetime.date.today().strftime("%Y")) # print("Month of year: ", datetime.date.today().strftime("%B")) # print("Week number of the year: ", datetime.date.today().strftime("%W")) # print("Weekday of the week: ", datetime.date.today().strftime("%w")) # print("Day of year: ", datetime.date.today().strftime("%j")) # print("Day of the month : ", datetime.date.today().strftime("%d")) # print("Day of week: ", datetime.date.today().strftime("%A")) def ip(): return int(sys.stdin.readline()) def sip(): return sys.stdin.readline() def mip(): return map(int,sys.stdin.readline().split()) def mips(): return map(str,sys.stdin.readline().split()) def lip(): return list(map(int,sys.stdin.readline().split())) def matip(n,m): lst=[] for i in range(n): arr = lip() lst.insert(i,arr) return lst def factors(n): # find the factors of a number return list(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))) def minJumps(arr, n): #to reach from 0 to n-1 in the array in minimum steps jumps = [0 for i in range(n)] if (n == 0) or (arr[0] == 0): return float('inf') jumps[0] = 0 for i in range(1, n): jumps[i] = float('inf') for j in range(i): if (i <= j + arr[j]) and (jumps[j] != float('inf')): jumps[i] = min(jumps[i], jumps[j] + 1) break return jumps[n-1] def dic(arr): # converting list into dict of count return Counter(arr) def check_prime(n): if n<2: return False for i in range(2,int(n**(0.5))+1,2): if n%i==0: return False return True # --------------------------------------------------------- # # sys.stdin = open('input.txt','r') # sys.stdout = open('output.txt','w') # --------------------------------------------------------- # n = ip() s = sip() up,down = 0,0 lst= [] for i in range(n): lst.append(s[i]) if s[i]=='X': up+=1 else: down+=1 if up==down: print(0) print(s) elif up>down: recq = n//2-down print(recq) for i in range(n): if lst[i]=='X': lst[i]='x' recq-=1 if recq==0: break print(''.join(lst)) else: recq = n//2-up print(recq) for i in range(n): if lst[i]=='x': lst[i]='X' recq-=1 if recq==0: break print(''.join(lst)) ```
output
1
87,916
4
175,833
Provide tags and a correct Python 3 solution for this coding contest problem. Stepan has n pens. Every day he uses them, and on the i-th day he uses the pen number i. On the (n + 1)-th day again he uses the pen number 1, on the (n + 2)-th — he uses the pen number 2 and so on. On every working day (from Monday to Saturday, inclusive) Stepan spends exactly 1 milliliter of ink of the pen he uses that day. On Sunday Stepan has a day of rest, he does not stend the ink of the pen he uses that day. Stepan knows the current volume of ink in each of his pens. Now it's the Monday morning and Stepan is going to use the pen number 1 today. Your task is to determine which pen will run out of ink before all the rest (that is, there will be no ink left in it), if Stepan will use the pens according to the conditions described above. Input The first line contains the integer n (1 ≤ n ≤ 50 000) — the number of pens Stepan has. The second line contains the sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of milliliters of ink which the pen number i currently has. Output Print the index of the pen which will run out of ink before all (it means that there will be no ink left in it), if Stepan will use pens according to the conditions described above. Pens are numbered in the order they are given in input data. The numeration begins from one. Note that the answer is always unambiguous, since several pens can not end at the same time. Examples Input 3 3 3 3 Output 2 Input 5 5 4 5 4 4 Output 5 Note In the first test Stepan uses ink of pens as follows: 1. on the day number 1 (Monday) Stepan will use the pen number 1, after that there will be 2 milliliters of ink in it; 2. on the day number 2 (Tuesday) Stepan will use the pen number 2, after that there will be 2 milliliters of ink in it; 3. on the day number 3 (Wednesday) Stepan will use the pen number 3, after that there will be 2 milliliters of ink in it; 4. on the day number 4 (Thursday) Stepan will use the pen number 1, after that there will be 1 milliliters of ink in it; 5. on the day number 5 (Friday) Stepan will use the pen number 2, after that there will be 1 milliliters of ink in it; 6. on the day number 6 (Saturday) Stepan will use the pen number 3, after that there will be 1 milliliters of ink in it; 7. on the day number 7 (Sunday) Stepan will use the pen number 1, but it is a day of rest so he will not waste ink of this pen in it; 8. on the day number 8 (Monday) Stepan will use the pen number 2, after that this pen will run out of ink. So, the first pen which will not have ink is the pen number 2.
instruction
0
88,031
4
176,062
Tags: *special, binary search, number theory Correct Solution: ``` import sys def Min(x, y): if x > y: return y else: return x def Gcd(x, y): if x == 0: return y else: return Gcd(y % x, x) def Lcm(x, y): return x * y // Gcd(x, y) n = int(input()) a = [int(i) for i in input().split()] d = [int(0) for i in range(0, n)] ok = 0 cur = 0 len = Lcm(7, n) for i in range(0, 7 * n): if a[i % n] == 0 : print(i % n + 1) ok = 1 break if cur != 6: a[i % n] -= 1 d[i % n] += 1 cur = (cur + 1) % 7 if ok == 0: k = 10**20 for i in range(0, n): a[i] += d[i] if d[i] == 0: continue if a[i] % d[i] > 0: k = Min(k, a[i] // d[i]) else: k = Min(k, a[i] // d[i] - 1) if k == 10**20: k = 0 for i in range(0, n): a[i] -= k * d[i] iter = 0 cur = 0 while True: if a[iter] == 0: print(iter % n + 1) break else: if cur != 6: a[iter] -= 1 cur = (cur + 1) % 7 iter = (iter + 1) % n ```
output
1
88,031
4
176,063
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Stepan has n pens. Every day he uses them, and on the i-th day he uses the pen number i. On the (n + 1)-th day again he uses the pen number 1, on the (n + 2)-th — he uses the pen number 2 and so on. On every working day (from Monday to Saturday, inclusive) Stepan spends exactly 1 milliliter of ink of the pen he uses that day. On Sunday Stepan has a day of rest, he does not stend the ink of the pen he uses that day. Stepan knows the current volume of ink in each of his pens. Now it's the Monday morning and Stepan is going to use the pen number 1 today. Your task is to determine which pen will run out of ink before all the rest (that is, there will be no ink left in it), if Stepan will use the pens according to the conditions described above. Input The first line contains the integer n (1 ≤ n ≤ 50 000) — the number of pens Stepan has. The second line contains the sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of milliliters of ink which the pen number i currently has. Output Print the index of the pen which will run out of ink before all (it means that there will be no ink left in it), if Stepan will use pens according to the conditions described above. Pens are numbered in the order they are given in input data. The numeration begins from one. Note that the answer is always unambiguous, since several pens can not end at the same time. Examples Input 3 3 3 3 Output 2 Input 5 5 4 5 4 4 Output 5 Note In the first test Stepan uses ink of pens as follows: 1. on the day number 1 (Monday) Stepan will use the pen number 1, after that there will be 2 milliliters of ink in it; 2. on the day number 2 (Tuesday) Stepan will use the pen number 2, after that there will be 2 milliliters of ink in it; 3. on the day number 3 (Wednesday) Stepan will use the pen number 3, after that there will be 2 milliliters of ink in it; 4. on the day number 4 (Thursday) Stepan will use the pen number 1, after that there will be 1 milliliters of ink in it; 5. on the day number 5 (Friday) Stepan will use the pen number 2, after that there will be 1 milliliters of ink in it; 6. on the day number 6 (Saturday) Stepan will use the pen number 3, after that there will be 1 milliliters of ink in it; 7. on the day number 7 (Sunday) Stepan will use the pen number 1, but it is a day of rest so he will not waste ink of this pen in it; 8. on the day number 8 (Monday) Stepan will use the pen number 2, after that this pen will run out of ink. So, the first pen which will not have ink is the pen number 2. Submitted Solution: ``` n = int(input()) a = list(map(int, input().split())) ans = 100000 min = 10000000000 if ((n % 7) == 0): for i in range(6, n, 7): if a[i] < min: ans = i min = a[i] else: i = 7 % n while True: if a[i] < min: ans = i min = a[i] i = (i + 7) % n if i == (7 % n): break print(ans + 1) ```
instruction
0
88,032
4
176,064
No
output
1
88,032
4
176,065
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Stepan has n pens. Every day he uses them, and on the i-th day he uses the pen number i. On the (n + 1)-th day again he uses the pen number 1, on the (n + 2)-th — he uses the pen number 2 and so on. On every working day (from Monday to Saturday, inclusive) Stepan spends exactly 1 milliliter of ink of the pen he uses that day. On Sunday Stepan has a day of rest, he does not stend the ink of the pen he uses that day. Stepan knows the current volume of ink in each of his pens. Now it's the Monday morning and Stepan is going to use the pen number 1 today. Your task is to determine which pen will run out of ink before all the rest (that is, there will be no ink left in it), if Stepan will use the pens according to the conditions described above. Input The first line contains the integer n (1 ≤ n ≤ 50 000) — the number of pens Stepan has. The second line contains the sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of milliliters of ink which the pen number i currently has. Output Print the index of the pen which will run out of ink before all (it means that there will be no ink left in it), if Stepan will use pens according to the conditions described above. Pens are numbered in the order they are given in input data. The numeration begins from one. Note that the answer is always unambiguous, since several pens can not end at the same time. Examples Input 3 3 3 3 Output 2 Input 5 5 4 5 4 4 Output 5 Note In the first test Stepan uses ink of pens as follows: 1. on the day number 1 (Monday) Stepan will use the pen number 1, after that there will be 2 milliliters of ink in it; 2. on the day number 2 (Tuesday) Stepan will use the pen number 2, after that there will be 2 milliliters of ink in it; 3. on the day number 3 (Wednesday) Stepan will use the pen number 3, after that there will be 2 milliliters of ink in it; 4. on the day number 4 (Thursday) Stepan will use the pen number 1, after that there will be 1 milliliters of ink in it; 5. on the day number 5 (Friday) Stepan will use the pen number 2, after that there will be 1 milliliters of ink in it; 6. on the day number 6 (Saturday) Stepan will use the pen number 3, after that there will be 1 milliliters of ink in it; 7. on the day number 7 (Sunday) Stepan will use the pen number 1, but it is a day of rest so he will not waste ink of this pen in it; 8. on the day number 8 (Monday) Stepan will use the pen number 2, after that this pen will run out of ink. So, the first pen which will not have ink is the pen number 2. Submitted Solution: ``` import sys def Min(x, y): if x > y: return y else: return x n = int(input()) a = [int(i) for i in input().split()] d = [int(0) for i in range(0, n)] ok = 0 cur = 0 for i in range(0, 7 * n): if a[i % n] == 0 : print(i % n + 1) ok = 1 break if cur != 6: a[i % n] -= 1 d[i % n] += 1 cur = (cur + 1) % 7 if ok == 0: k = -1 for i in range(0, n): if d[i] == 0: continue if a[i] % d[i] > 0: k = Min(k, a[i] // d[i]) else: k = Min(k, a[i] // d[i] - 1) for i in range(0, n): a[i] -= k * d[i] iter = 0 cur = 0 while True: if a[iter] == 0: print(iter) break else: if cur != 6: a[iter] -= 1 cur = (cur + 1) % 7 iter = (iter + 1) % n ```
instruction
0
88,033
4
176,066
No
output
1
88,033
4
176,067
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Stepan has n pens. Every day he uses them, and on the i-th day he uses the pen number i. On the (n + 1)-th day again he uses the pen number 1, on the (n + 2)-th — he uses the pen number 2 and so on. On every working day (from Monday to Saturday, inclusive) Stepan spends exactly 1 milliliter of ink of the pen he uses that day. On Sunday Stepan has a day of rest, he does not stend the ink of the pen he uses that day. Stepan knows the current volume of ink in each of his pens. Now it's the Monday morning and Stepan is going to use the pen number 1 today. Your task is to determine which pen will run out of ink before all the rest (that is, there will be no ink left in it), if Stepan will use the pens according to the conditions described above. Input The first line contains the integer n (1 ≤ n ≤ 50 000) — the number of pens Stepan has. The second line contains the sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of milliliters of ink which the pen number i currently has. Output Print the index of the pen which will run out of ink before all (it means that there will be no ink left in it), if Stepan will use pens according to the conditions described above. Pens are numbered in the order they are given in input data. The numeration begins from one. Note that the answer is always unambiguous, since several pens can not end at the same time. Examples Input 3 3 3 3 Output 2 Input 5 5 4 5 4 4 Output 5 Note In the first test Stepan uses ink of pens as follows: 1. on the day number 1 (Monday) Stepan will use the pen number 1, after that there will be 2 milliliters of ink in it; 2. on the day number 2 (Tuesday) Stepan will use the pen number 2, after that there will be 2 milliliters of ink in it; 3. on the day number 3 (Wednesday) Stepan will use the pen number 3, after that there will be 2 milliliters of ink in it; 4. on the day number 4 (Thursday) Stepan will use the pen number 1, after that there will be 1 milliliters of ink in it; 5. on the day number 5 (Friday) Stepan will use the pen number 2, after that there will be 1 milliliters of ink in it; 6. on the day number 6 (Saturday) Stepan will use the pen number 3, after that there will be 1 milliliters of ink in it; 7. on the day number 7 (Sunday) Stepan will use the pen number 1, but it is a day of rest so he will not waste ink of this pen in it; 8. on the day number 8 (Monday) Stepan will use the pen number 2, after that this pen will run out of ink. So, the first pen which will not have ink is the pen number 2. Submitted Solution: ``` import sys def Min(x, y): if x > y: return y else: return x def Gcd(x, y): if x == 0: return y else: return Gcd(y % x, x) def Lcm(x, y): return x * y // Gcd(x, y) n = int(input()) a = [int(i) for i in input().split()] d = [int(0) for i in range(0, n)] ok = 0 cur = 0 len = Lcm(7, n) for i in range(0, 7 * n): if a[i % n] == 0 : print(i % n + 1) ok = 1 break if cur != 6: a[i % n] -= 1 d[i % n] += 1 cur = (cur + 1) % 7 if ok == 0: k = -1 for i in range(0, n): a[i] += d[i] if d[i] == 0: continue if a[i] % d[i] > 0: k = Min(k, a[i] // d[i]) else: k = Min(k, a[i] // d[i] - 1) for i in range(0, n): a[i] -= k * d[i] iter = 0 cur = 0 while True: if a[iter] == 0: print(iter) break else: if cur != 6: a[iter] -= 1 cur = (cur + 1) % 7 iter = (iter + 1) % n ```
instruction
0
88,034
4
176,068
No
output
1
88,034
4
176,069
Provide a correct Python 3 solution for this coding contest problem. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday
instruction
0
88,263
4
176,526
"Correct Solution: ``` # Aizu Problem 0027: What day is today? # import sys, math, os, datetime # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") DAY = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] while True: m, d = [int(_) for _ in input().split()] if m == d == 0: break print(DAY[datetime.date(2004, m, d).weekday()]) ```
output
1
88,263
4
176,527
Provide a correct Python 3 solution for this coding contest problem. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday
instruction
0
88,264
4
176,528
"Correct Solution: ``` from datetime import date week=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] while True: a,b=map(int,input().split()) if a==0: break print(week[date(2004,a,b).weekday()]) ```
output
1
88,264
4
176,529
Provide a correct Python 3 solution for this coding contest problem. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday
instruction
0
88,265
4
176,530
"Correct Solution: ``` # -*- coding:utf-8 -*- import datetime def main(a, b): dt = datetime.datetime(2004, a, b) week_num = dt.weekday() if week_num == 0: print('Monday') elif week_num == 1: print('Tuesday') elif week_num == 2: print('Wednesday') elif week_num == 3: print('Thursday') elif week_num == 4: print('Friday') elif week_num == 5: print('Saturday') elif week_num == 6: print('Sunday') while True: a, b = [int(e) for e in input().split()] if a == 0 and b == 0: break main(a, b) ```
output
1
88,265
4
176,531
Provide a correct Python 3 solution for this coding contest problem. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday
instruction
0
88,266
4
176,532
"Correct Solution: ``` import datetime for e in iter(input,'0 0'):print(['Mon','Tues','Wednes','Thurs','Fri','Satur','Sun'][datetime.date(2004,*map(int,e.split())).weekday()]+'day') ```
output
1
88,266
4
176,533
Provide a correct Python 3 solution for this coding contest problem. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday
instruction
0
88,267
4
176,534
"Correct Solution: ``` import sys readline = sys.stdin.readline write = sys.stdout.write def convert(y, m, d): if m <= 2: m += 12 y -= 1 mjd = int(365.25*y) + (y//400) - (y//100) + int(30.59*(m-2)) + d - 678912 return mjd youbi = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", ] def solve(): m, d = map(int, readline().split()) if m == 0: return False write("%s\n" % youbi[(convert(2004, m, d) - convert(2004, 1, 1) + 3) % 7]) return True while solve(): ... ```
output
1
88,267
4
176,535
Provide a correct Python 3 solution for this coding contest problem. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday
instruction
0
88,268
4
176,536
"Correct Solution: ``` ndays = [31,29,31,30,31,30,31,31,30,31,30,31] days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] offset = 3 while(1): m,d = [int(i) for i in input().split()] if m == 0 and d == 0: break tot_d = sum(ndays[:m-1]) + d print(days[(tot_d + offset - 1)%7]) ```
output
1
88,268
4
176,537
Provide a correct Python 3 solution for this coding contest problem. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday
instruction
0
88,269
4
176,538
"Correct Solution: ``` while(True): m,d = map(int,input().split()) if m==0 and d==0: break dn = sum([[31,29,31,30,31,30,31,31,30,31,30,31][a] for a in range(m-1)]) + d-1 print(["Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"][dn%7]) ```
output
1
88,269
4
176,539
Provide a correct Python 3 solution for this coding contest problem. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday
instruction
0
88,270
4
176,540
"Correct Solution: ``` # AOJ 0027 What day is today? # Python3 2018.6.11 bal4u def Zeller(y, m, d): if m == 1 or m == 2: y -= 1 m += 12 return (y + y//4 - y//100 + y//400 + (13*m + 8)//5 + d) % 7 import sys week = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] for line in sys.stdin: m, d = list(map(int, line.split())) if m >= 1: print(week[Zeller(2004, m, d)]) else: break ```
output
1
88,270
4
176,541
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday Submitted Solution: ``` days_in_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] while True: m, d = map(int, input().split()) if m == 0 or d == 0: break days = 0 for month in range(0, m-1): days += days_in_month[month] days += d + 2 days %= 7 print(day[days]) ```
instruction
0
88,271
4
176,542
Yes
output
1
88,271
4
176,543
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday Submitted Solution: ``` days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] nums = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] while True: try: m, d = map(int, input().split()) if not m: break except: break print(days[(sum(nums[:m - 1]) + d + 2) % 7]) ```
instruction
0
88,272
4
176,544
Yes
output
1
88,272
4
176,545
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday Submitted Solution: ``` import datetime weekdays = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ] while True: m,d = [int(i) for i in input().split()] if not(m or d): break print(weekdays[datetime.date(2004, m, d).weekday()]) ```
instruction
0
88,273
4
176,546
Yes
output
1
88,273
4
176,547
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday Submitted Solution: ``` day = ['Wednesday','Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday'] month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] m, d = [int(i) for i in input().split()] while m != 0: sum = 0 for i in range(0, m - 1): sum += month[i] sum += d print(day[sum % 7]) m, d = [int(i) for i in input().split()] ```
instruction
0
88,274
4
176,548
Yes
output
1
88,274
4
176,549
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday Submitted Solution: ``` days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] nums = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] while True: try: m, d = map(int, input().split()) if not m: break except: break print(days[(sum(nums[:m - 1]) + d) % 7 + 2]) ```
instruction
0
88,275
4
176,550
No
output
1
88,275
4
176,551
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday Submitted Solution: ``` from datetime import date week=["Monday","Trueday","Wednesday","Thursday","Friday","Saturday","Sunday"] while True: a,b=map(int,input().split()) if a==0: break print(week[date(2004,a,b).weekday()]) ```
instruction
0
88,276
4
176,552
No
output
1
88,276
4
176,553
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day. The number of datasets is less than or equal to 50. Output For each dataset, print the day (please see the following words) in a line. Monday Tuesday Wednesday Thursday Friday Saturday Sunday Example Input 1 1 2 29 0 0 Output Thursday Sunday Submitted Solution: ``` lis=[0 for i in range(7)] lis[0]="Wednesday" lis[1]="Thursday" lis[2]="Friday" lis[3]="Saturday" lis[4]="Sunday" lis[5]="Monday" lis[6]="Tuesday" while 1: date=0 x,y=map(int,input().split()) if x!=0 and y!=0: for i in range(1,x): if i==4 or i==6 or i==9 or i==11: date=date+30 elif i==2: date =date+29 else: date=date+31 print(date) k=(date+y)%7 print(date+y) print(lis[k]) else: break ```
instruction
0
88,277
4
176,554
No
output
1
88,277
4
176,555