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. In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month. Constraints * Both 2019-M_1-D_1 and 2019-M_2-D_2 are valid dates in the Gregorian calendar. * The date 2019-M_2-D_2 follows 2019-M_1-D_1. Input Input is given from Standard Input in the following format: M_1 D_1 M_2 D_2 Output If the date 2019-M_1-D_1 is the last day of a month, print `1`; otherwise, print `0`. Examples Input 11 16 11 17 Output 0 Input 11 30 12 1 Output 1 Submitted Solution: ``` m1=int(input()) d1=int(input()) m2=int(input()) d2=int(input()) if m1+1==m2: print(1) else: print(0) ```
instruction
0
103,474
4
206,948
No
output
1
103,474
4
206,949
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
instruction
0
104,016
4
208,032
Tags: brute force, implementation, math Correct Solution: ``` row = input() n = int(row.split()[0]) m = int(row.split()[1]) rem = int(n/m) + int(n%m) x = int(n/m) while rem >= m: x = x + int(rem/m) rem = int(rem/m) + int(rem%m) print(n + x) ```
output
1
104,016
4
208,033
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
instruction
0
104,017
4
208,034
Tags: brute force, implementation, math Correct Solution: ``` n, m = map(int, input().split()) d = 0 i = 1 while n != 0: n -= 1 d += 1 if d == i * m: n += 1 i += 1 print(d) ```
output
1
104,017
4
208,035
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
instruction
0
104,018
4
208,036
Tags: brute force, implementation, math Correct Solution: ``` n, m = map(int, input().split()) count = 0 i = 1 while i*m <= n: i += 1 n += 1 while n > 0: count += 1 n -= 1 print(count) ```
output
1
104,018
4
208,037
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
instruction
0
104,019
4
208,038
Tags: brute force, implementation, math Correct Solution: ``` n,m = map(int,input().split(" ")) days=0 if n>=m: while n>=m: days+=(n-n%m) n=int(n/m)+int(n%m) days+=n else: days=n print(days) ```
output
1
104,019
4
208,039
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
instruction
0
104,020
4
208,040
Tags: brute force, implementation, math Correct Solution: ``` (n,m)=map(int,input().strip().split()) days=1 while n!=0: n-=1 if days%m==0: n+=1 days+=1 print(days-1) ```
output
1
104,020
4
208,041
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
instruction
0
104,021
4
208,042
Tags: brute force, implementation, math Correct Solution: ``` __author__ = 'Gamoool' import sys n,m = map(int,sys.stdin.readline().split()) u = n+ ((n-1)//(m-1)) print(u) ```
output
1
104,021
4
208,043
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
instruction
0
104,022
4
208,044
Tags: brute force, implementation, math Correct Solution: ``` n,m = map(int,input().split()) s,q = 0,0 i = 1 for i in range(1,n+1): s+=1 if i % m == 0: q+=1 while q!=0: i+=1 s+=1 q-=1 if s % m == 0: q+=1 print(s) ```
output
1
104,022
4
208,045
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
instruction
0
104,023
4
208,046
Tags: brute force, implementation, math Correct Solution: ``` n, m = map(int, input().split()) print(n + ~- n // ~- m) ```
output
1
104,023
4
208,047
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day. Submitted Solution: ``` a=list(map(int,input().split())) n=a[0] m=a[1] i=0 dias=0 j=1 while True: i+=1 if n>0: dias+=1 n-=1 if i==j*m: j+=1 n+=1 if n==0: break print(dias) ```
instruction
0
104,024
4
208,048
Yes
output
1
104,024
4
208,049
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day. Submitted Solution: ``` a,b = map(int, input().split()) c = a while a >= b: c = c + a//b a = a//b +a%b print(c) ```
instruction
0
104,025
4
208,050
Yes
output
1
104,025
4
208,051
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day. Submitted Solution: ``` n,m = map(int, input().split()) k = 0 while n > 0: k += 1 n -= 1 if k%m == 0: n += 1 print(k) ```
instruction
0
104,026
4
208,052
Yes
output
1
104,026
4
208,053
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day. Submitted Solution: ``` n, m = input().split() n = eval(n) m = eval(m) k = 0 for i in range(1, 100000): #print(n) if (not n): break n -= 1 k += 1 if (i % m == 0): n += 1 print(k) ```
instruction
0
104,027
4
208,054
Yes
output
1
104,027
4
208,055
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day. Submitted Solution: ``` n,m = map(int, input().split()) ans = n k = 0 while(n >= m): n = n // m k = k + n ans = ans + k print(ans) ```
instruction
0
104,028
4
208,056
No
output
1
104,028
4
208,057
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day. Submitted Solution: ``` n, m = map(int, input().split()) col = 0 while n > 0: col += 1 n -= 1 if n == 0: break if col % m == 0: n += 1 print(col + 1) ```
instruction
0
104,029
4
208,058
No
output
1
104,029
4
208,059
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day. Submitted Solution: ``` ln = input().split(" ") n = int(ln[0]) m = int(ln[1]) res = n k = int(n/m) while k > 0: res += k k = int(k/m) print(res) ```
instruction
0
104,030
4
208,060
No
output
1
104,030
4
208,061
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks? Input The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space. Output Print a single integer — the answer to the problem. Examples Input 2 2 Output 3 Input 9 3 Output 13 Note In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two. In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day. Submitted Solution: ``` def vasya(): c = list(map(int, input().split())) if c==[10,3]: print(19) return d = c[0] f = c[1] while c[0]>=c[1]: e=c[0]/c[1] f=c[0]%c[1] c[0]=e+f d+=e print(int(d)) print(vasya()) ```
instruction
0
104,031
4
208,062
No
output
1
104,031
4
208,063
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches. You are given a length equal to n centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The result should be an integer rounded to the closest value containing an integral number of inches. Note that when you round up, 1 cm rounds up to 0 inches and 2 cm round up to 1 inch. Input The only line contains an integer n (1 ≤ n ≤ 10000). Output Print two non-negative space-separated integers a and b, where a is the numbers of feet and b is the number of inches. Examples Input 42 Output 1 2 Input 5 Output 0 2 Submitted Solution: ``` #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase from fractions import Fraction BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") #-------------------game starts now---------------------------------------------------- n=int(input()) i=n//3 if n%3==2: i+=1 print(i//12,i%12) ```
instruction
0
104,531
4
209,062
Yes
output
1
104,531
4
209,063
Provide a correct Python 3 solution for this coding contest problem. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0
instruction
0
105,116
4
210,232
"Correct Solution: ``` N=int(input()) from collections import defaultdict data=defaultdict(int) data[0]+=1 for d in map(int,input().split()): data[d]+=1 check=[[]] ans=1 for d in data.keys(): if data[d]>2: ans=0 break checkc=check.copy() if data[d]==2: if d==0 or d==12: ans=0 break for c in check: c+=[d,-1*d] elif data[d]==1: if d==0: for c in check: c.append(d) continue check=[] for c in checkc: check.append(c+[d]) check.append(c+[-1*d]) if ans!=0: ans=0 for c in check: c.sort() now=24 for i in range(len(c)): now=min(now,(c[i]-c[i-1])%24) ans=max(now,ans) print(ans) ```
output
1
105,116
4
210,233
Provide a correct Python 3 solution for this coding contest problem. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0
instruction
0
105,117
4
210,234
"Correct Solution: ``` #設定 import sys input = sys.stdin.buffer.readline from collections import defaultdict def getlist(): return list(map(int, input().split())) #処理内容 def main(): N = int(input()) D = getlist() if N >= 24: print(0) elif N >= 12: d = defaultdict(int) judge = "Yes" for i in D: d[i] += 1 if d[0] >= 1: judge = "No" if d[12] >= 2: judge = "No" for i in range(1, 12): if d[i] >= 3: judge = "No" if judge == "No": print(0) else: print(1) else: ans = 0 for i in range(1 << N): L = [0, 24] for j in range(N): if ((i >> j) & 1) == 1: L.append(D[j]) else: L.append(24 - D[j]) L = sorted(L) val = 24 for i in range(N + 1): val = min(val, L[i + 1] - L[i]) ans = max(ans, val) print(ans) if __name__ == '__main__': main() ```
output
1
105,117
4
210,235
Provide a correct Python 3 solution for this coding contest problem. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0
instruction
0
105,118
4
210,236
"Correct Solution: ``` import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) import itertools N = int(input()) D = [int(x) for x in input().split()] counter = [1] + [0] * 12 for x in D: counter[x] += 1 bl = counter[0] > 1 or counter[12] > 1 or any(x >= 3 for x in counter) if bl: print(0) exit() itrs = [[[0]]] for x in range(1,12): if counter[x] == 0: itr = [[]] elif counter[x] == 1: itr = [[x],[-x]] else: itr = [[x,-x]] itrs.append(itr) itrs.append([[]] if counter[12] == 0 else [[12]]) def F(arr): f = lambda x,y: min((x-y)%24, (y-x)%24) return min(f(x,y) for x,y in itertools.combinations(arr,2)) answer = 0 for p in itertools.product(*itrs): arr = [] for x in p: arr += x answer = max(answer, F(arr)) print(answer) ```
output
1
105,118
4
210,237
Provide a correct Python 3 solution for this coding contest problem. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0
instruction
0
105,119
4
210,238
"Correct Solution: ``` import itertools def calc(s): ret = 24 for i in range(1, len(s)): ret = min(ret, s[i] - s[i-1]) return ret def main(): N = int(input()) D = list(map(int, input().split())) if D.count(0) >= 1 or D.count(12) >= 2: print(0) return cnt = [0] * 13 for d in D: cnt[d] += 1 fixed = [0, 24] variable = [] for i in range(1, 12): if cnt[i] >= 3: print(0) return elif cnt[i] == 2: fixed.append(i) fixed.append(24-i) elif cnt[i] == 1: variable.append(i) if cnt[12] == 1: fixed.append(12) ans = 0 for p in itertools.product((False, True), repeat=len(variable)): s = list(fixed) for i in range(len(variable)): if p[i]: s.append(variable[i]) else: s.append(24-variable[i]) s.sort() ans = max(ans, calc(s)) print(ans) if __name__ == "__main__": main() ```
output
1
105,119
4
210,239
Provide a correct Python 3 solution for this coding contest problem. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0
instruction
0
105,120
4
210,240
"Correct Solution: ``` import sys input = sys.stdin.readline n = int(input()) D = list(map(int,input().split())) # from random import randint # n = randint(1, 50) # D = [randint(0, 12) for i in range(n)] C = [0] * 13 C[0] = 1 for i in range(n): C[D[i]] += 1 if C[0] >= 2 or C[12] >=2: print(0) sys.exit() for i in range(13): if C[i] >= 3: print(0) sys.exit() # D = [] # for i in range(13): # for j in range(C[i]): # D.append(i) # n = len(D) # A = [0] * n # print(C) ans0 = 0 for i in range(2**13): zero = 0 ib = format(i, "b").zfill(13) A = [] for j in range(13): if C[j] == 1: A.append(j * (-1) ** int(ib[j])) if C[j] == 2: if int(ib[j]) == 0: A.append(j) A.append(-j) else: zero = 1 if zero == 1: continue # print("not cont") ans = 30 # if len(A)>1: # print(A) # print(ib, A) for j in range(len(A)): for k in range(j+1, len(A)): di = abs(A[k] - A[j]) # print(ans) ans = min(ans, min(di, 24-di)) if ans <= ans0: break if ans <= ans0: break # print(ib, ans0,ans) ans0 = max(ans0, ans) print(ans0) ```
output
1
105,120
4
210,241
Provide a correct Python 3 solution for this coding contest problem. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0
instruction
0
105,121
4
210,242
"Correct Solution: ``` def solve(N, D): fill = [0] * 24 fill[0] = 1 left = False for i in range(N): if D[i] == 0: print(0) return 0 elif D[i] == 12: if fill[12] == 1: print(0) return 0 else: fill[12] = 1 else: if not left: if fill[D[i]] == 0: fill[D[i]] = 1 left = True elif fill[24-D[i]] == 0: fill[24-D[i]] = 1 left = False else: print(0) return 0 else: if fill[24-D[i]] == 0: fill[24-D[i]] = 1 left = False elif fill[D[i]] == 0: fill[D[i]] = 1 left = True else: print(0) return 0 s = 24 cnt = 0 for i in range(1, 24): if i == 23: if fill[i] == 0: cnt += 1 s = min(s, cnt + 1) else: s = min(s, cnt + 1) else: if fill[i] == 0: cnt += 1 else: s = min(s, cnt + 1) cnt = 0 print(s) if __name__ == '__main__': N = int(input()) D = list(map(int, input().split())) solve(N, sorted(D)) ```
output
1
105,121
4
210,243
Provide a correct Python 3 solution for this coding contest problem. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0
instruction
0
105,122
4
210,244
"Correct Solution: ``` from collections import Counter N = int(input()) ds = list(map(int, input().split())) c = Counter(ds) cs = c.most_common() if N >= 24 or cs[0][1] >= 3 or 0 in c: print("0") exit() l = len(cs) k = 0 s = (1 << 0) + (1 << 24) while k < l and cs[k][1] == 2: s += (1 << cs[k][0]) + (1 << (24 - cs[k][0])) k += 1 def process(s, i): if i == l: return min(map(len, bin(s)[2:].split("1")[1:-1])) + 1 return max( process(s + (1 << cs[i][0]), i+1), process(s + (1 << (24 - cs[i][0])), i+1), ) print(process(s, k)) ```
output
1
105,122
4
210,245
Provide a correct Python 3 solution for this coding contest problem. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0
instruction
0
105,123
4
210,246
"Correct Solution: ``` from collections import Counter, defaultdict import sys sys.setrecursionlimit(10 ** 5 + 10) # input = sys.stdin.readline from math import factorial import heapq, bisect import math import itertools import queue from collections import deque def main(): num = int(input()) data = list(map(int, input().split())) count = Counter(data) ans = 0 for i in range(2 ** 11): bin_list = bin(i)[2:] bin_list = bin_list.zfill(11) bin_list = list(map(int, list(bin_list))) now_data = [0, 24] if count[12] >= 2: print(0) sys.exit() elif count[12] == 1: now_data.append(12) if count[0] >= 1: print(0) sys.exit() for j in range(1, 12): if count[j] == 0: continue elif count[j] >= 3: print(0) sys.exit() elif count[j] == 2: now_data.append(j) now_data.append(24 - j) elif bin_list[j - 1]: now_data.append(j) else: now_data.append(24 - j) now_data.sort() kari = 12 # print(now_data) for j in range(len(now_data) - 1): kari = min(kari, now_data[j + 1] - now_data[j]) ans = max(ans, kari) print(ans) if __name__ == '__main__': main() # test() ```
output
1
105,123
4
210,247
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0 Submitted Solution: ``` from collections import Counter import itertools N = int(input()) Ds = list(map(int, input().split())) + [0] cnt = Counter(Ds) if max(cnt.values()) >= 3: print(0) exit() citys = [] rest = [] for k, v in cnt.items(): if v == 2: if k == 0 or k == 12: print(0) exit() citys.append(k) citys.append(24 -k) else: rest.append(k) def check(citys): if len(citys) <= 1: return 24 citys.sort() ans = 24 prev = citys[-1] - 24 for c in citys: ans = min(ans, c - prev) prev = c return ans if check(citys) == 1: print(1) exit() ans = 0 for ops in itertools.product('+-', repeat=len(rest)): citys2 = citys.copy() for i in range(len(rest)): if ops[i] == '+': citys2.append(rest[i]) else: citys2.append(24 - rest[i]) ans = max(ans, check(citys2)) print(ans) ```
instruction
0
105,124
4
210,248
Yes
output
1
105,124
4
210,249
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0 Submitted Solution: ``` # coding: utf-8 import itertools import collections def main(): n = int(input()) c = collections.Counter(map(int, input().split())) if c[0] > 0: return 0 if c.most_common(1)[0][1] >= 3: return 0 l1 = [] l2 = [] for i, cnt in c.most_common(): if cnt == 2: l2.append(i) elif cnt == 1: l1.append(i) s = 0 for i in range(len(l1) + 1): for invs in itertools.combinations(l1, i): l = [0] for k in l1: l.append(-k if k in invs else k) for k in l2: l.append(k) l.append(-k) l.sort() ss = 24 for j in range(len(l)-1): ss = min(l[j + 1] - l[j], ss) d = l[-1] - l[0] ss = min(min(d, 24-d), ss) s = max(s, ss) return s print(main()) ```
instruction
0
105,125
4
210,250
Yes
output
1
105,125
4
210,251
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0 Submitted Solution: ``` N = int(input()) D = list(map(int, input().split())) rec = [0] * 13 for i in range(N): rec[D[i]] += 1 if rec[0] >= 1: print(0) exit() ans = 0 for i in range(1 << 12): tmp = [0] for j in range(13): if rec[j] >= 3: print(0) exit() elif rec[j] == 2: tmp.append(j) tmp.append(24 - j) elif rec[j] == 1: if i & 1 << j: tmp.append(j) else: tmp.append(24 - j) tmp = sorted(tmp) pre = tmp[0] num = float("inf") for i in range(1, len(tmp)): num = min(num, tmp[i] - pre) pre = tmp[i] ans = max(min(num, 24 - tmp[-1]), ans) print(ans) ```
instruction
0
105,126
4
210,252
Yes
output
1
105,126
4
210,253
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0 Submitted Solution: ``` N = int(input()) D = sorted([int(_) for _ in input().split()]) #最小値の最大値 if D[0] == 0: print(0) exit() p = m = 0 a = 99 for d in D: #asign positive e = min(a, d - p, 24 - d - m) #asign negative f = min(a, d - m, 24 - d - p) if e < f: a = f m = d else: a = e p = d print(a) ```
instruction
0
105,127
4
210,254
Yes
output
1
105,127
4
210,255
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0 Submitted Solution: ``` n = int(input()) d_l = list(map(int, input().split())) d_l.insert(0, 0) mn = None for i in range(n+1): for j in range(i+1, n+1): ans = max(abs(d_l[i]-d_l[j]), abs(24-d_l[i]-d_l[j])) if mn is None: mn = ans if mn > ans: mn = ans print(mn) ```
instruction
0
105,128
4
210,256
No
output
1
105,128
4
210,257
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0 Submitted Solution: ``` import collections n = int(input()) inp_list = list(map(int, input().split())) inp_list.append(0) c = collections.Counter(inp_list) a = c.most_common() def ura(time): if time == 12: time = 12 elif time == 0: time = 0 else: time = 24 - time return time member = [] for tup in a: if tup[1] > 1: member.append(tup[0]) member.append(tup[0]) elif tup[1] == 1: member.append(tup[0]) ans = 0 for i in range(2**len(member)): trry = format(i, '0' + str(len(member))+'b') time_diff = 24 for ii in range(len(member)-1): for iii in range(ii+1, len(member)): A = member[ii] if trry[iii] == '0': B = member[iii] else: B = ura(member[iii]) a_b = abs(A-B) b_a = min(A, B)+24-max(A, B) time_diff = min(time_diff, a_b, b_a) ans = max(ans, time_diff) print(ans) ```
instruction
0
105,129
4
210,258
No
output
1
105,129
4
210,259
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0 Submitted Solution: ``` import collections import numpy as np N = int(input()) D = list(map(int, input().split())) D.append(0) m = 0 while 1: D.sort() Dsub = [(D[i+1] - D[i]) for i in range(len(D)-1)] Dsub.sort() if m >= Dsub[0]: break else: m = Dsub[0] Dsub1 = [(D[i+1] - D[i]) for i in range(len(D)-1)] index = Dsub1.index(m) D[index] = abs(24 - D[index]) print(m) ```
instruction
0
105,130
4
210,260
No
output
1
105,130
4
210,261
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example. Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours. Find the maximum possible value of s. Constraints * 1 \leq N \leq 50 * 0 \leq D_i \leq 12 * All input values are integers. Input Input is given from Standard Input in the following format: N D_1 D_2 ... D_N Output Print the maximum possible value of s. Examples Input 3 7 12 8 Output 4 Input 2 11 11 Output 2 Input 1 0 Output 0 Submitted Solution: ``` from fractions import gcd from datetime import date, timedelta from heapq import* import math from collections import defaultdict, Counter, deque import sys from bisect import * import itertools import copy sys.setrecursionlimit(10 ** 7) MOD = 10 ** 9 + 7 def main(): n = int(input()) d = list(map(int, input().split())) if n == 1: print(min(d[0],24 - d[0])) exit() d2 = [] dc = defaultdict(int) for i in range(n): v = min(d[i], 24 - d[i]) if dc[v] > 2 or (dc[v] == 1 and v == 12) or v == 0: print(0) exit() dc[v] += 1 d2.append(v) dd = [] ddt = [] for i in range(0, 13): if dc[i] == 1: dd.append(i) elif dc[i] == 2: ddt.append(i) ddt.append(24 - i) ans = 0 for i in range(1 << len(dd)): d3 = [] for j in range(len(ddt)): d3.append(ddt[j]) for j in range(len(dd)): if (i & (1 << j)): d3.append(dd[j]) else: d3.append(24 - dd[j]) d3 = sorted(d3) t = float("inf") for i in range(len(d3) - 1): t = min(t, d3[i + 1] - d3[i]) ans = max(t, ans) print(ans) if __name__ == '__main__': main() ```
instruction
0
105,131
4
210,262
No
output
1
105,131
4
210,263
Provide tags and a correct Python 3 solution for this coding contest problem. Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions. So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime. Input The first input line contains two integer numbers d, sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day. Output In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them. Examples Input 1 48 5 7 Output NO Input 2 5 0 1 3 5 Output YES 1 4
instruction
0
105,648
4
211,296
Tags: constructive algorithms, greedy Correct Solution: ``` import sys d, sumTime = map(int, input().split()) A = [] B = [] sumA = 0 sumB = 0 for i in range(d): m, n = map(int, input().split()) A.append(m) B.append(n) sumA += m sumB += n if sumA > sumTime or sumB < sumTime: print("NO") sys.exit() sumTime -= sumA print("YES") for i in range(d): add = min(sumTime, B[i]-A[i]) A[i] += add sumTime -= add print(A[i],end = " ") ```
output
1
105,648
4
211,297
Provide tags and a correct Python 3 solution for this coding contest problem. Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions. So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime. Input The first input line contains two integer numbers d, sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day. Output In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them. Examples Input 1 48 5 7 Output NO Input 2 5 0 1 3 5 Output YES 1 4
instruction
0
105,649
4
211,298
Tags: constructive algorithms, greedy Correct Solution: ``` import os import sys debug = True if debug and os.path.exists("input.in"): input = open("input.in", "r").readline else: debug = False input = sys.stdin.readline def inp(): return (int(input())) def inlt(): return (list(map(int, input().split()))) def insr(): s = input() return s[:len(s) - 1] # Remove line char from end def invr(): return (map(int, input().split())) test_count = 1 if debug: test_count = int(input()) for t in range(test_count): if debug: print("Test Case #", t + 1) # Start code here n, k = invr() a = list() min_total = 0 max_total = 0 for _ in range(n): x, y = invr() a.append((x, y)) min_total += x max_total += y if k < min_total or k > max_total: print("NO") else: print("YES") diff = k - min_total ans = list() for i in range(n): ans.append(a[i][0] + min(a[i][1] - a[i][0], diff)) diff -= min(a[i][1] - a[i][0], diff) print(" ".join(map(str, ans))) ```
output
1
105,649
4
211,299
Provide tags and a correct Python 3 solution for this coding contest problem. Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions. So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime. Input The first input line contains two integer numbers d, sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day. Output In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them. Examples Input 1 48 5 7 Output NO Input 2 5 0 1 3 5 Output YES 1 4
instruction
0
105,650
4
211,300
Tags: constructive algorithms, greedy Correct Solution: ``` d,hrs=[int(x) for x in input().split()] hrs1 = hrs a=[] for i in range (d): t=input().split() a.append(t) sum1=0 sum2 =0 for j in range (d): sum1=int(a[j][0])+sum1 sum2=int(a[j][1])+sum2 count=0 if (sum1<= hrs <= sum2): print("YES") count=count+1 else: print("NO") b=[] sum3=0 sum4=0 if (len (a)>=2) and (count==1): for k in range (d-1,-1,-1): sum3=int(a[k][0])+sum3 sum4=int(a[k][1])+sum4 m=[sum3,sum4] b.append(m) b.reverse() c=[] if count==1: for g in range (d-1): for n in range (int(a[g][0]),int(a[g][1])+1): l=hrs-n if(int(b[g+1][0])<=(l)<=int(b[g+1][1])): hrs =l c.append(n) break sum_5=sum(c) op=hrs1-sum_5 c.append(op) for lll in c: print(lll,end=" ") if (len (a) ==1)and (count ==1): print (hrs1) ```
output
1
105,650
4
211,301
Provide tags and a correct Python 3 solution for this coding contest problem. Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions. So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime. Input The first input line contains two integer numbers d, sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day. Output In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them. Examples Input 1 48 5 7 Output NO Input 2 5 0 1 3 5 Output YES 1 4
instruction
0
105,651
4
211,302
Tags: constructive algorithms, greedy Correct Solution: ``` d, t = input().split() d = int(d) t = int(t) minimum = 0 maximum = 0 min_list = [] max_list = [] ans = [] for i in range(d): mi, ma = input().split() mi = int(mi) ma = int(ma) min_list.append(mi) max_list.append(ma) minimum = minimum + mi maximum = maximum + ma def hours(days, hours): if sum(min_list) == hours: return min_list else: k = 0 while sum(min_list) < hours: if min_list[k]<max_list[k]: min_list[k] = min_list[k]+1 else: k = k+1 return min_list if minimum <= t <= maximum: print('YES') answer = hours(d, t) print(*answer, sep=" ") else: print('NO') ```
output
1
105,651
4
211,303
Provide tags and a correct Python 3 solution for this coding contest problem. Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions. So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime. Input The first input line contains two integer numbers d, sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day. Output In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them. Examples Input 1 48 5 7 Output NO Input 2 5 0 1 3 5 Output YES 1 4
instruction
0
105,652
4
211,304
Tags: constructive algorithms, greedy Correct Solution: ``` d,sumtime = [int(i) for i in input().split()] time = [0]*d mintime,maxtime = 0,0 for i in range(d): time[i] = [int(i) for i in input().split()] mintime+=time[i][0] maxtime+=time[i][1] if sumtime<mintime or sumtime>maxtime: print('NO') else: print('YES') ans = [i[0] for i in time] i = 0 while mintime<sumtime: if ans[i]<time[i][1]: ans[i]+=1 mintime+=1 else: i+=1 print(*ans) ```
output
1
105,652
4
211,305
Provide tags and a correct Python 3 solution for this coding contest problem. Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions. So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime. Input The first input line contains two integer numbers d, sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day. Output In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them. Examples Input 1 48 5 7 Output NO Input 2 5 0 1 3 5 Output YES 1 4
instruction
0
105,653
4
211,306
Tags: constructive algorithms, greedy Correct Solution: ``` d, sumTime = map(int, input().split()) a = [(tuple(map(int, input().split()))) for _ in range(d)] dp = [[False for _ in range(sumTime + 1)] for _ in range(d + 1)] dp[0][0] = True for day in range(1, d + 1): minTime, maxTime = a[day - 1] for time in range(sumTime + 1): for today in range(minTime, maxTime + 1): if time - today >= 0: dp[day][time] |= dp[day - 1][time - today] if not dp[d][sumTime]: print('NO') else: print('YES') ret = [] for day in range(d, 0, -1): minTime, maxTime = a[day - 1] for today in range(minTime, maxTime + 1): if sumTime - today >= 0 and dp[day - 1][sumTime - today]: ret.append(today) sumTime -= today break else: raise Exception('Cannot find answer') print(' '.join(map(str, ret[::-1]))) ```
output
1
105,653
4
211,307
Provide tags and a correct Python 3 solution for this coding contest problem. Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions. So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime. Input The first input line contains two integer numbers d, sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day. Output In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them. Examples Input 1 48 5 7 Output NO Input 2 5 0 1 3 5 Output YES 1 4
instruction
0
105,654
4
211,308
Tags: constructive algorithms, greedy Correct Solution: ``` string = input().split(' ') d = int(string[0]) sumTime = int(string[1]) mins = [] maxs = [] for i in range(d): string = input().split(' ') mins.append(int(string[0])) maxs.append(int(string[1])) if not(sum(mins) <= sumTime <= sum(maxs)): print('NO') else: days = maxs[:] currentSum = sum(maxs) for i in range(d): old = days[i] days[i] = max((days[i]-(currentSum-sumTime)), mins[i]) currentSum -= (old-days[i]) if currentSum == sumTime: break print('YES') print(' '.join(str(item) for item in days)) ```
output
1
105,654
4
211,309
Provide tags and a correct Python 3 solution for this coding contest problem. Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i-th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions. So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i-th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime. Input The first input line contains two integer numbers d, sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day. Output In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them. Examples Input 1 48 5 7 Output NO Input 2 5 0 1 3 5 Output YES 1 4
instruction
0
105,655
4
211,310
Tags: constructive algorithms, greedy Correct Solution: ``` import math from collections import defaultdict ml=lambda:map(int,input().split()) ll=lambda:list(map(int,input().split())) ii=lambda:int(input()) ip=lambda:(input()) """========main code===============""" x,y=ml() mn=0 mx=0 lol=[] yo=[] for _ in range(x): a,b=ml() mn+=a mx+=b yo.append(b) lol.append(a) if(sum(lol)<=y and sum(yo)>=y): print("YES") y-=sum(lol) for i in range(len(lol)): if(y>=0): k=min(y,yo[i]-lol[i]) lol[i]+=k y-=k print(lol[i],end=" ") else: print("NO") ```
output
1
105,655
4
211,311
Provide tags and a correct Python 3 solution for this coding contest problem. Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: <image> Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap. Input The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday). Output Print single integer: the number of columns the table should have. Examples Input 1 7 Output 6 Input 1 1 Output 5 Input 11 6 Output 5 Note The first example corresponds to the January 2017 shown on the picture in the statements. In the second example 1-st January is Monday, so the whole month fits into 5 columns. In the third example 1-st November is Saturday and 5 columns is enough.
instruction
0
105,768
4
211,536
Tags: implementation, math Correct Solution: ``` m,n = map(int,input().split()) if m == 2: if n == 1: print(4) else: print(5) elif (m<=7 and m%2) or (m>7 and m%2 == 0): if n<=5: print(5) else: print(6) else: if n<=6: print(5) else: print(6) ```
output
1
105,768
4
211,537
Provide tags and a correct Python 3 solution for this coding contest problem. Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: <image> Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap. Input The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday). Output Print single integer: the number of columns the table should have. Examples Input 1 7 Output 6 Input 1 1 Output 5 Input 11 6 Output 5 Note The first example corresponds to the January 2017 shown on the picture in the statements. In the second example 1-st January is Monday, so the whole month fits into 5 columns. In the third example 1-st November is Saturday and 5 columns is enough.
instruction
0
105,769
4
211,538
Tags: implementation, math Correct Solution: ``` a=list(map(int,input().split())) dayinm=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] answ=(dayinm[a[0]-1]-(8-a[1])+6)//7+1 print(answ) ```
output
1
105,769
4
211,539
Provide tags and a correct Python 3 solution for this coding contest problem. Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: <image> Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap. Input The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday). Output Print single integer: the number of columns the table should have. Examples Input 1 7 Output 6 Input 1 1 Output 5 Input 11 6 Output 5 Note The first example corresponds to the January 2017 shown on the picture in the statements. In the second example 1-st January is Monday, so the whole month fits into 5 columns. In the third example 1-st November is Saturday and 5 columns is enough.
instruction
0
105,770
4
211,540
Tags: implementation, math Correct Solution: ``` month_day = [0,31,28,31,30,31,30,31,31,30,31,30,31] n,m = map(int,input().split(' ')) a = (m-1+month_day[n])//7 b = (m-1+month_day[n])%7 if b==0: print(a) else: print(a+1) ```
output
1
105,770
4
211,541
Provide tags and a correct Python 3 solution for this coding contest problem. Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: <image> Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap. Input The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday). Output Print single integer: the number of columns the table should have. Examples Input 1 7 Output 6 Input 1 1 Output 5 Input 11 6 Output 5 Note The first example corresponds to the January 2017 shown on the picture in the statements. In the second example 1-st January is Monday, so the whole month fits into 5 columns. In the third example 1-st November is Saturday and 5 columns is enough.
instruction
0
105,771
4
211,542
Tags: implementation, math Correct Solution: ``` import math m,d = [int(i) for i in input().split()] mon = [31,28,31,30,31,30,31,31,30,31,30,31] al = mon[m-1] weeks = math.ceil((al-(7-d+1))/7) + 1 print(weeks) ```
output
1
105,771
4
211,543
Provide tags and a correct Python 3 solution for this coding contest problem. Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: <image> Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap. Input The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday). Output Print single integer: the number of columns the table should have. Examples Input 1 7 Output 6 Input 1 1 Output 5 Input 11 6 Output 5 Note The first example corresponds to the January 2017 shown on the picture in the statements. In the second example 1-st January is Monday, so the whole month fits into 5 columns. In the third example 1-st November is Saturday and 5 columns is enough.
instruction
0
105,772
4
211,544
Tags: implementation, math Correct Solution: ``` def main() : a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] n, k = map(int, input().split()) print(1 + (a[n-1] - (8 - k) + 6) // 7) return 0 main() ```
output
1
105,772
4
211,545
Provide tags and a correct Python 3 solution for this coding contest problem. Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: <image> Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap. Input The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday). Output Print single integer: the number of columns the table should have. Examples Input 1 7 Output 6 Input 1 1 Output 5 Input 11 6 Output 5 Note The first example corresponds to the January 2017 shown on the picture in the statements. In the second example 1-st January is Monday, so the whole month fits into 5 columns. In the third example 1-st November is Saturday and 5 columns is enough.
instruction
0
105,773
4
211,546
Tags: implementation, math Correct Solution: ``` X = list(map(int , input().split())) if X[0] in [1,3,5,7,8,10,12]: print(5 if X[1]<=5 else 6) exit() if X[0] in [11,9,6,4]: print(5 if X[1]<=6 else 6) exit() print(4 if X[1]==1 else 5) ```
output
1
105,773
4
211,547
Provide tags and a correct Python 3 solution for this coding contest problem. Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: <image> Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap. Input The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday). Output Print single integer: the number of columns the table should have. Examples Input 1 7 Output 6 Input 1 1 Output 5 Input 11 6 Output 5 Note The first example corresponds to the January 2017 shown on the picture in the statements. In the second example 1-st January is Monday, so the whole month fits into 5 columns. In the third example 1-st November is Saturday and 5 columns is enough.
instruction
0
105,774
4
211,548
Tags: implementation, math Correct Solution: ``` import sys def main(): m,d = map(int,sys.stdin.readline().split()) x = [31,28,31,30,31,30,31,31,30,31,30,31] y = x[m-1] + d-1 res = y/7 if res > int(res): res = int(res)+1 print(int(res)) main() ```
output
1
105,774
4
211,549
Provide tags and a correct Python 3 solution for this coding contest problem. Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: <image> Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap. Input The only line contain two integers m and d (1 ≤ m ≤ 12, 1 ≤ d ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday). Output Print single integer: the number of columns the table should have. Examples Input 1 7 Output 6 Input 1 1 Output 5 Input 11 6 Output 5 Note The first example corresponds to the January 2017 shown on the picture in the statements. In the second example 1-st January is Monday, so the whole month fits into 5 columns. In the third example 1-st November is Saturday and 5 columns is enough.
instruction
0
105,775
4
211,550
Tags: implementation, math Correct Solution: ``` n=input().split() k=int(n[0]) h=int(n[1]) if (k==1) or (k==3) or (k==5) or (k==7) or (k==8) or (k==10) or (k==12): if (h==6) or (h==7): print(6) else: print(5) if k==2: if h==1: print(4) else: print(5) if (k==4) or (k==6) or (k==9) or (k==11): if (h==7): print(6) else: print(5) ```
output
1
105,775
4
211,551