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.
Takahashi has N days of summer vacation.
His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.
He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.
What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?
If Takahashi cannot finish all the assignments during the vacation, print `-1` instead.
Constraints
* 1 \leq N \leq 10^6
* 1 \leq M \leq 10^4
* 1 \leq A_i \leq 10^4
Input
Input is given from Standard Input in the following format:
N M
A_1 ... A_M
Output
Print the maximum number of days Takahashi can hang out during the vacation, or `-1`.
Examples
Input
41 2
5 6
Output
30
Input
10 2
5 6
Output
-1
Input
11 2
5 6
Output
0
Input
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
Output
9
Submitted Solution:
```
N,M,*A = map(int,open(0).read().split())
play = N - sum(A)
print(play if play >= 0 else -1)
``` | instruction | 0 | 83,974 | 4 | 167,948 |
Yes | output | 1 | 83,974 | 4 | 167,949 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has N days of summer vacation.
His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.
He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.
What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?
If Takahashi cannot finish all the assignments during the vacation, print `-1` instead.
Constraints
* 1 \leq N \leq 10^6
* 1 \leq M \leq 10^4
* 1 \leq A_i \leq 10^4
Input
Input is given from Standard Input in the following format:
N M
A_1 ... A_M
Output
Print the maximum number of days Takahashi can hang out during the vacation, or `-1`.
Examples
Input
41 2
5 6
Output
30
Input
10 2
5 6
Output
-1
Input
11 2
5 6
Output
0
Input
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
Output
9
Submitted Solution:
```
n,m=map(int,input().split())
for num in input().split():
n-=int(num)
print(n if n>=0 else -1)
``` | instruction | 0 | 83,975 | 4 | 167,950 |
Yes | output | 1 | 83,975 | 4 | 167,951 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has N days of summer vacation.
His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.
He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.
What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?
If Takahashi cannot finish all the assignments during the vacation, print `-1` instead.
Constraints
* 1 \leq N \leq 10^6
* 1 \leq M \leq 10^4
* 1 \leq A_i \leq 10^4
Input
Input is given from Standard Input in the following format:
N M
A_1 ... A_M
Output
Print the maximum number of days Takahashi can hang out during the vacation, or `-1`.
Examples
Input
41 2
5 6
Output
30
Input
10 2
5 6
Output
-1
Input
11 2
5 6
Output
0
Input
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
Output
9
Submitted Solution:
```
n,m = map(int, input().split())
A = list(map(int,input().split()))
hw_days = 0
for i in len(A):
hw_days += A(i)
vacation = n - hw_days
if vacation < 0:
print(-1)
else:
print(vacation)
``` | instruction | 0 | 83,976 | 4 | 167,952 |
No | output | 1 | 83,976 | 4 | 167,953 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has N days of summer vacation.
His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.
He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.
What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?
If Takahashi cannot finish all the assignments during the vacation, print `-1` instead.
Constraints
* 1 \leq N \leq 10^6
* 1 \leq M \leq 10^4
* 1 \leq A_i \leq 10^4
Input
Input is given from Standard Input in the following format:
N M
A_1 ... A_M
Output
Print the maximum number of days Takahashi can hang out during the vacation, or `-1`.
Examples
Input
41 2
5 6
Output
30
Input
10 2
5 6
Output
-1
Input
11 2
5 6
Output
0
Input
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
Output
9
Submitted Solution:
```
a,b=map(int,input().split())
c,d=map(int,input().split())
print(a-(c+d))
``` | instruction | 0 | 83,977 | 4 | 167,954 |
No | output | 1 | 83,977 | 4 | 167,955 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has N days of summer vacation.
His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.
He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.
What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?
If Takahashi cannot finish all the assignments during the vacation, print `-1` instead.
Constraints
* 1 \leq N \leq 10^6
* 1 \leq M \leq 10^4
* 1 \leq A_i \leq 10^4
Input
Input is given from Standard Input in the following format:
N M
A_1 ... A_M
Output
Print the maximum number of days Takahashi can hang out during the vacation, or `-1`.
Examples
Input
41 2
5 6
Output
30
Input
10 2
5 6
Output
-1
Input
11 2
5 6
Output
0
Input
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
Output
9
Submitted Solution:
```
days, homework = map(int, input().split())
a = input().split()
c = 0
for b in a:
c += b
if days > c:
print(days - c)
else:
print(-1)
``` | instruction | 0 | 83,978 | 4 | 167,956 |
No | output | 1 | 83,978 | 4 | 167,957 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has N days of summer vacation.
His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.
He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.
What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?
If Takahashi cannot finish all the assignments during the vacation, print `-1` instead.
Constraints
* 1 \leq N \leq 10^6
* 1 \leq M \leq 10^4
* 1 \leq A_i \leq 10^4
Input
Input is given from Standard Input in the following format:
N M
A_1 ... A_M
Output
Print the maximum number of days Takahashi can hang out during the vacation, or `-1`.
Examples
Input
41 2
5 6
Output
30
Input
10 2
5 6
Output
-1
Input
11 2
5 6
Output
0
Input
314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3
Output
9
Submitted Solution:
```
n,m=map(int,input().split())
a=[b for b in int(input().split())]
def func(n,a):
if n< sum(a):return "-1"
else:
return n-sum(a)
print(func(n,a))
``` | instruction | 0 | 83,979 | 4 | 167,958 |
No | output | 1 | 83,979 | 4 | 167,959 |
Provide a correct Python 3 solution for this coding contest problem.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1 | instruction | 0 | 85,647 | 4 | 171,294 |
"Correct Solution:
```
time=[0]*1001
a,b=list(map(int,input().split()))
n=int(input())
for i in range(n):
s,f=list(map(int,input().split()))
time[s:f]=[1]*(f-s)
if sum(time[a:b])==0:print("0")
else:print("1")
``` | output | 1 | 85,647 | 4 | 171,295 |
Provide a correct Python 3 solution for this coding contest problem.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1 | instruction | 0 | 85,648 | 4 | 171,296 |
"Correct Solution:
```
a,b=map(int,input().split())
n = int(input())
t = 0
for i in range(n):
s,f=map(int,input().split())
if s<b<=f or s<=a<f:
t=1
elif a<=s and b>=f:
t=1
print(t)
``` | output | 1 | 85,648 | 4 | 171,297 |
Provide a correct Python 3 solution for this coding contest problem.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1 | instruction | 0 | 85,649 | 4 | 171,298 |
"Correct Solution:
```
a, b = map(int, input().split())
N = int(input())
T = [0]*1001
ok = 0
for i in range(N):
s, f = map(int, input().split())
if s < b and a < f:
ok = 1
print(ok)
``` | output | 1 | 85,649 | 4 | 171,299 |
Provide a correct Python 3 solution for this coding contest problem.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1 | instruction | 0 | 85,650 | 4 | 171,300 |
"Correct Solution:
```
a, b= map(int,input().split())
N = int(input())
for i in range(N):
c, d = map(int,input().split())
if d <= a or b <= c:continue
else:
print("1")
exit()
print("0")
``` | output | 1 | 85,650 | 4 | 171,301 |
Provide a correct Python 3 solution for this coding contest problem.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1 | instruction | 0 | 85,651 | 4 | 171,302 |
"Correct Solution:
```
a,b = map(int,input().split())
N = int(input())
n = 1009
reserve = [0]*n
#新しい予約
b = b-1
reserve[a] += 1
reserve[b+1] -= 1
#既存の予約
for i in range(N):
s,f = map(int,input().split())
f = f-1
reserve[s] += 1
reserve[f+1] -= 1
judge = 0
for i in range(n):
if(i != 0): reserve[i] += reserve[i-1]
if(reserve[i] >= 2): judge = 1
#print(reserve)
print(judge)
``` | output | 1 | 85,651 | 4 | 171,303 |
Provide a correct Python 3 solution for this coding contest problem.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1 | instruction | 0 | 85,652 | 4 | 171,304 |
"Correct Solution:
```
a,b = map(int,input().split())
n = int(input())
ans = 0
for i in range(n):
A,B = map(int,input().split())
if not (A >= b or B<= a):
ans = 1
print(ans)
``` | output | 1 | 85,652 | 4 | 171,305 |
Provide a correct Python 3 solution for this coding contest problem.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1 | instruction | 0 | 85,653 | 4 | 171,306 |
"Correct Solution:
```
a, b = map(int, input().split())
n = int(input())
l = sorted([list(map(int, input().split())) for _ in range(n)])
line = [0]*1010
line[a] += 1
line[b] -= 1
for a, b in l:
line[a] += 1
line[b] -= 1
for i in range(1006):
line[i+1] += line[i]
if line.count(2):
print(1)
else:
print(0)
``` | output | 1 | 85,653 | 4 | 171,307 |
Provide a correct Python 3 solution for this coding contest problem.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1 | instruction | 0 | 85,654 | 4 | 171,308 |
"Correct Solution:
```
x, y = map(int, input().split())
n = int(input())
ans = 0
for _ in range(n):
a, b = map(int, input().split())
if x < b and a < y:
ans = 1
print(ans)
``` | output | 1 | 85,654 | 4 | 171,309 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1
Submitted Solution:
```
a, b =map(int,input().split())
n=int(input())
m=0
for i in range(n):
c,d=map(int,input().split())
if d<=a or c>=b:
pass
else:
m=m+1
if m != 0:
print(1)
else:
print (0)
``` | instruction | 0 | 85,655 | 4 | 171,310 |
Yes | output | 1 | 85,655 | 4 | 171,311 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1
Submitted Solution:
```
a, b = map(int, input().split())
N = int(input())
books = []
for i in range(N):
books.append(list(map(int, input().split())))
is_booked = 0
for i in range(len(books)):
if books[i][0] <= a < books[i][1]:
is_booked = 1
elif a < books[i][0] < b:
is_booked = 1
print(is_booked)
``` | instruction | 0 | 85,656 | 4 | 171,312 |
Yes | output | 1 | 85,656 | 4 | 171,313 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1
Submitted Solution:
```
a, b = map(int, input().split())
n = int(input())
booking = True
for i in range(n):
s, f = map(int, input().split())
if(f <= a or b <= s):
continue
else:
booking = False
print(int(not(booking)))
``` | instruction | 0 | 85,657 | 4 | 171,314 |
Yes | output | 1 | 85,657 | 4 | 171,315 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1
Submitted Solution:
```
time=[]
a,b=map(int,input().split())
N=int(input())
for i in range(N):
s,f=map(int,input().split())
for i in range(s,f):
time.append(i)
#print(time)
for i in range(a,b):
#print(i)
if i in time:
print(1)
break
elif i==b-1:
print(0)
``` | instruction | 0 | 85,658 | 4 | 171,316 |
Yes | output | 1 | 85,658 | 4 | 171,317 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1
Submitted Solution:
```
import numpy
a, b = map(int, input().split())
n = int(input())
l = sorted([list(map(int, input().split())) for _ in range(n)])
line = [0]*(max(l)[1]+2)
line[a] += 1
line[b] -= 1
for a, b in l:
line[a] += 1
line[b] -= 1
if list(numpy.cumsum(line)).count(2):
print(1)
else:
print(0)
``` | instruction | 0 | 85,659 | 4 | 171,318 |
No | output | 1 | 85,659 | 4 | 171,319 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1
Submitted Solution:
```
a, b = map(int, input().split())
for i in range(int(input())):
s, f = map(int, input().split())
if s <= a and a < f\
or s < b and b <= f:
print("1")
break
else:
print("0")
``` | instruction | 0 | 85,660 | 4 | 171,320 |
No | output | 1 | 85,660 | 4 | 171,321 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1
Submitted Solution:
```
a,b = map(int,list(input().split(" ")))
n = int(input())
c = [0 for i in range(1002)]
ans = 0
c[a]+=1
c[b]-=1
for i in range(n):
s,f = map(int,list(input().split(" ")))
c[s]+=1
c[f]-=1
for i in range(1,1001):
c[i] += c[i-1]
if(c[i]>1):
ans = 1
print(ans)
``` | instruction | 0 | 85,661 | 4 | 171,322 |
No | output | 1 | 85,661 | 4 | 171,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap each other.
Write a program to report if a new reservation overlaps with any of the existing reservations. Note that the coincidence of start and end times is not considered to constitute an overlap. All the temporal data is given as the elapsed time from the moment at which the L system starts operation.
Input
The input is given in the following format.
a b
N
s_1 f_1
s_2 f_2
:
s_N f_N
The first line provides new reservation information, i.e., the start time a and end time b (0 ≤ a < b ≤ 1000) in integers. The second line specifies the number of existing reservations N (0 ≤ N ≤ 100). Subsequent N lines provide temporal information for the i-th reservation: start time s_i and end time f_i (0 ≤ s_i < f_i ≤ 1000) in integers. No two existing reservations overlap.
Output
Output "1" if the new reservation temporally overlaps with any of the existing ones, or "0" otherwise.
Examples
Input
5 7
3
1 4
4 5
7 10
Output
0
Input
3 7
3
7 10
1 4
4 5
Output
1
Submitted Solution:
```
a, b = map(int,input().split())
t = []
for _ in range(int(input())):
t += list(map(int, input().split()))
print(sum(i <= a for i in t) % 2 or sum(i >= b for i in t) % 2)
``` | instruction | 0 | 85,662 | 4 | 171,324 |
No | output | 1 | 85,662 | 4 | 171,325 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013 | instruction | 0 | 86,006 | 4 | 172,012 |
Tags: brute force, implementation, strings
Correct Solution:
```
x,y,z=32,13,2016
cnt=[]
for i in range(z):
cnt.append([])
for i in range(z):
for j in range(y):
cnt[i].append([])
for i in range(z):
for j in range(y):
for k in range(x):
cnt[i][j].append(int(0))
s=input()
ansstr=''
ans=0
a=[0,31,28,31,30,31,30,31,31,30,31,30,31]
for i in range(len(s)-9):
if(s[i].isdigit()&s[i+1].isdigit()&~s[i+2].isalnum()&s[i+3].isdigit()&s[i+4].isdigit()&~s[i+5].isalnum()&s[i+6].isdigit()&s[i+7].isdigit()&s[i+8].isdigit()&s[i+9].isdigit()):
if(((int(s[i+6])*1000+int(s[i+7])*100+int(s[i+8])*10+int(s[i+9]))>=2013)&((int(s[i+6])*1000+int(s[i+7])*100+int(s[i+8])*10+int(s[i+9]))<=2015)):
if(((int(s[i+3])*10+int(s[i+4]))<=12)&((int(s[i+3])*10+int(s[i+4]))>=1)):
if(((int(s[i])*10+int(s[i+1]))<=a[(int(s[i+3])*10+int(s[i+4]))])&((int(s[i])*10+int(s[i+1]))>=1)):
cnt[int(s[i+6])*1000+int(s[i+7])*100+int(s[i+8])*10+int(s[i+9])][int(s[i+3])*10+int(s[i+4])][int(s[i])*10+int(s[i+1])]+=1
if(cnt[int(s[i+6]+s[i+7]+s[i+8]+s[i+9])][int(s[i+3]+s[i+4])][int(s[i]+s[i+1])]>ans):
ansstr=str(s[i]+s[i+1]+'-'+s[i+3]+s[i+4]+'-'+s[i+6]+s[i+7]+s[i+8]+s[i+9])
ans=cnt[int(s[i+6]+s[i+7]+s[i+8]+s[i+9])][int(s[i+3]+s[i+4])][int(s[i]+s[i+1])]
print(ansstr)
``` | output | 1 | 86,006 | 4 | 172,013 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013 | instruction | 0 | 86,007 | 4 | 172,014 |
Tags: brute force, implementation, strings
Correct Solution:
```
s=input()
l=len(s)
m=['01','02','03','04','05','06','07','08','09','10','11','12']
d=[31,28,31,30,31,30,31,31,30,31,30,31]
ans={}
for i in range(l-9):
if s[i+2] == '-':
if s[i+3]+s[i+4] in m:
if s[i+5] == '-':
if s[i+6]+s[i+7]+s[i+8]+s[i+9] in ['2013','2014','2015']:
if s[i] in '0123456789':
if s[i+1] in '0123456789':
if int(s[i]+s[i+1])>0 and int(s[i]+s[i+1]) <= d[int(s[i+3]+s[i+4])-1]:
if s[i:i+10] in ans:
ans[s[i:i+10]]+=1
else:
ans[s[i:i+10]]=1
#print(ans)
x=-1
a=None
for i in ans:
if ans[i]>x:
x=ans[i]
a=i
print(a)
``` | output | 1 | 86,007 | 4 | 172,015 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013 | instruction | 0 | 86,008 | 4 | 172,016 |
Tags: brute force, implementation, strings
Correct Solution:
```
import re
from collections import defaultdict
s = input()
x = re.findall("(?=(\d\d-\d\d-\d\d\d\d))", s)
month_to_day = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
ans = ""
def val():
return 0
date_count = defaultdict(val)
max_count = 0
for date in x:
d, m, y = [int(x) for x in date.split('-')]
if(2013 <= y <= 2015 and 1 <= d <= 31 and 1 <= m <= 12 and 0 < d <= month_to_day[m]):
date_count[date] += 1
if date in date_count and date_count[date] > max_count:
max_count = date_count[date]
ans = date
print(ans)
``` | output | 1 | 86,008 | 4 | 172,017 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013 | instruction | 0 | 86,009 | 4 | 172,018 |
Tags: brute force, implementation, strings
Correct Solution:
```
def valid(s):
if(not(s[2]==s[5]=='-')):
return False
for i in range(10):
if(i==2 or i==5):
continue
if(s[i]=='-'):
return False
m=int(s[6:])
if(m<2013 or m>2015):
return False
m=int(s[3:5])
if(m<1 or m>12):
return False
d=int(s[0:2])
if(d<1 or d>D[m-1]):
return False
return True
D=[31,28,31,30,31,30,31,31,30,31,30,31]
A={}
s=input()
x=s[0:10]
if(valid(x)):
A[x]=1
for i in range(10,len(s)):
x=x[1:]+s[i]
if(valid(x)):
if(x in A):
A[x]+=1
else:
A[x]=1
maxx=0
ans=""
for item in A:
if(A[item]>maxx):
maxx=A[item]
ans=item
print(ans)
``` | output | 1 | 86,009 | 4 | 172,019 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013 | instruction | 0 | 86,010 | 4 | 172,020 |
Tags: brute force, implementation, strings
Correct Solution:
```
from re import compile
from collections import defaultdict
from time import strptime
def validDate(date):
try:
strptime(date, "%d-%m-%Y")
return True
except:
return False
myFormat = compile(r'(?=([0-2]\d|3[0-1])-(0\d|1[0-2])-(201[3-5]))' )
Dict = defaultdict(int)
for d in myFormat.finditer(input()):
temp = "-".join([d.group(1),d.group(2),d.group(3)])
if validDate (temp):
Dict[temp] = -~Dict[temp]
print(max(Dict, key=Dict.get))
``` | output | 1 | 86,010 | 4 | 172,021 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013 | instruction | 0 | 86,011 | 4 | 172,022 |
Tags: brute force, implementation, strings
Correct Solution:
```
from re import findall
from calendar import monthrange
from collections import defaultdict
s=input()
dic=defaultdict(int)
for i in findall('(?=(\d\d-\d\d-201[3-5]))',s):
d,m,y = map(int,i.split("-"))
if 1<=m<=12 and 1<=d<=monthrange(y,m)[1]:
dic[i]+=1
print(max(dic,key=dic.get))
``` | output | 1 | 86,011 | 4 | 172,023 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013 | instruction | 0 | 86,012 | 4 | 172,024 |
Tags: brute force, implementation, strings
Correct Solution:
```
def s():
import re
pat = re.compile('\d{2}-\d{2}-\d{4}')
a = input()
se = {}
def check(x):
m = [0,31,28,31,30,31,30,31,31,30,31,30,31]
return x[2] >= 2013 and x[2] <= 2015 and x[1] >= 1 and x[1] <= 12 and x[0] >= 1 and x[0] <= m[x[1]]
for i in range(len(a)-9):
c = a[i:i+10]
if pat.match(c) and check(list(map(int,c.split('-')))):
if c in se:
se[c] += 1
else:
se[c] = 1
print(max(se.items(),key=lambda x:x[1])[0])
s()
``` | output | 1 | 86,012 | 4 | 172,025 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013 | instruction | 0 | 86,013 | 4 | 172,026 |
Tags: brute force, implementation, strings
Correct Solution:
```
s = list(map(str, input().split('-')))
dic = {}
d = {1:31, 2:28, 3:31,4: 30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31}
for i in range(len(s)-2):
if len(s[i])>=2:
if len(s[i+1])==2 and int(s[i+1])<=12 and int(s[i+1])>=1 and int(s[i][-2]+s[i][-1])<=d[int(s[i+1])] and int(s[i][-2]+s[i][-1])>=1 and len(s[i+2])>=4 and int(s[i+2][:4])>=2013 and int(s[i+2][:4])<=2015:
st = s[i][-2]+s[i][-1]+'-'+s[i+1] + '-' + s[i+2][:4]
try:
dic[st]+=1
except:
dic[st]=1
max = 0
ind = 0
for i in dic:
if max<dic[i]:
max = dic[i]
ind = i
print(ind)
``` | output | 1 | 86,013 | 4 | 172,027 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013
Submitted Solution:
```
s = input().split('-')
ex = {}
ans = 0
sans = ''
def solve(i):
global ex
global ans
global sans
global s
day = s[i]
month = s[i+1]
year = s[i+2]
if len(day) < 2 or len(month) != 2 or len(year) < 4:
return
day = day[-2:]
year = year[:4]
if int(year) < 2013 or int(year) > 2015:
return
if int(month) < 1 or int(month) > 12:
return
if int(day) < 1 or int(day) > 31:
return
# verifica dia de acordo com o mês (meu Deus...)
tm = int(month)
if tm in [1, 3, 5, 7, 8, 10, 12] and int(day) > 31:
return
if tm == 2 and int(day) > 28:
return
if tm in [4, 6, 9, 11] and int(day) > 30:
return
date = day+month+year
if date in ex:
ex[date] += 1
if ex[date] > ans:
ans = ex[date]
sans = date
else:
ex[date] = 1
if ans == 0:
ans = 1
sans = date
def c(s):
print(f'{s[:2]}-{s[2:4]}-{s[4:]}')
for i in range(len(s)-2):
if len(s[i]) <= 1:
continue
solve(i)
c(sans)
``` | instruction | 0 | 86,014 | 4 | 172,028 |
Yes | output | 1 | 86,014 | 4 | 172,029 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013
Submitted Solution:
```
s = input()
nums = set([str(x) for x in range(0, 9+1)])
cnt = dict()
m = -1
ans = 0
days_in_month = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12:31}
for i in range(len(s) - 10+1):
q = s[i:i+10]
if q[0] in nums and q[1] in nums and q[2] == "-":
if q[3] in nums and q[4] in nums and q[5] == "-":
if q[6] in nums and q[7] in nums and q[8] in nums and q[9] in nums:
try:
day = int(q[0:1+1])
month = int(q[3:4+1])
year = int(q[6:9+1])
except:
continue
#print(day, month)
if 0 < month <= 12 and 0 < day <= days_in_month[month] and 2013 <= year <= 2015:
try:
cnt[q] += 1
except:
cnt[q] = 0
#print(cnt)
for key in cnt.keys():
if cnt[key] > m:
m = cnt[key]
ans = key
print(ans)
``` | instruction | 0 | 86,015 | 4 | 172,030 |
Yes | output | 1 | 86,015 | 4 | 172,031 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013
Submitted Solution:
```
s=input().rstrip()
ans=[]
p=dict()
p[1]=p[3]=p[5]=p[7]=p[8]=p[10]=p[12]=31
p[4]=p[6]=p[9]=p[11]=30
p[2]=28
for i in range(len(s)-3):
if s[i:i+4]=='2013' or s[i:i+4]=='2014' or s[i:i+4]=='2015':
#print('halua')
if s[i-1]=='-' and s[i-2]!='-' and s[i-3]!='-' and s[i-4]=='-' and s[i-5]!='-' and s[i-6]!='-':
#print('hand',int(s[i-3] + s[i-2]))
if int(s[i-3]+s[i-2])>=1 and int(s[i-3]+s[i-2])<=12:
#print('bhadu')
if int(s[i-6]+s[i-5])<=p[int(s[i-3]+s[i-2])] and int(s[i-6]+s[i-5])>=1:
ans.append(s[i-6:i+4])
#print(ans)
p=dict()
for i in ans:
if i in p:
p[i]+=1
else:
p[i]=1
mini=0
ans=''
for i in p:
if p[i]>mini:
mini=p[i]
ans=i
print(ans)
``` | instruction | 0 | 86,016 | 4 | 172,032 |
Yes | output | 1 | 86,016 | 4 | 172,033 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013
Submitted Solution:
```
s = input()
date_ = {1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
def is_Date_Correct(s):
return (1<=int(s[3:5])<=12 and 2013<=int(s[6:])<=2015 and 1<=int(s[:2])<=date_[int(s[3:5])])
def is_dateformat(s):
if s[2]=='-' and s[5]=='-':
for i in range(len(s)):
if i==2 or i==5: continue
if s[i] == '-':
return False;
return True;
return False;
i = 0
map = {}
while(i<len(s)):
x = s[i:i+10]
if is_dateformat(x) and is_Date_Correct(x):
if x in map:
map[x]+=1
else:
map[x]=1
i+=8
else:
i+=1
if i+10>len(s): break
count = 0
res = ""
for i in map:
if map[i] > count:
res = i
count = map[i]
print(res)
``` | instruction | 0 | 86,017 | 4 | 172,034 |
Yes | output | 1 | 86,017 | 4 | 172,035 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013
Submitted Solution:
```
from collections import defaultdict
t = input()
s = defaultdict(int)
for i in range(len(t) - 9):
if t[i + 2] == '-' and t[i + 5: i + 9] == '-201' and '2' < t[i + 9] < '6':
if (t[i + 3] == '0' and '0' < t[i + 4] <= '9') or (t[i + 3] == '1' and '0' <= t[i + 4] < '3'):
if t[i: i + 2] < '30': s[t[i: i + 10]] += 1
elif t[i: i + 2] == '30':
if t[i + 3: i + 5] != '02': s[t[i: i + 10]] += 1
elif t[i: i + 2] < '32' and not (t[i + 3: i + 5] in ['04', '06', '09', '11']): s[t[i: i + 10]] += 1
m = max(s.values())
for i in s:
if s[i] == m:
print(i)
break
``` | instruction | 0 | 86,018 | 4 | 172,036 |
No | output | 1 | 86,018 | 4 | 172,037 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013
Submitted Solution:
```
try:
import re
st = input()
dct = {}
r = re.compile(r'(\d\d-\d\d-\d\d\d\d)')
r2 = re.compile(r'(\d\d)-(\d\d)-(\d\d\d\d)')
def judge_date(date):
rst = r2.match(date)
d, m, y = map(int, rst.groups())
if 2013 <= y <= 2015:
if 1 <= m <= 12:
if m in (1, 3, 5, 7, 8, 10, 12):
if d > 31:
return False
elif m == 2:
if d > 28:
return False
else:
if d > 30:
return False
if d <= 0:
return False
return True
return False
while st:
rst = r.search(st)
if rst is None:
break
if judge_date(rst[0]):
try:
dct[rst[0]] += 1
except KeyError:
dct[rst[0]] = 1
st = st[rst.start() + 1:]
print(max(dct.items(), key=lambda x: x[1])[0])
except Exception as e:
print(e)
``` | instruction | 0 | 86,019 | 4 | 172,038 |
No | output | 1 | 86,019 | 4 | 172,039 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013
Submitted Solution:
```
def main():
s = input()
l=[]
a=["0","1","2","3","4","5","6","7","8","9"]
for i in range(len(s)-9):
if ((s[i] in a) or s[i]=="-") and (s[i+1] in a) and s[i+2]=="-" and (s[i+3] in a) and (s[i+4] in a) and s[i+5]=="-" and (s[i+6] in a) and (s[i+7] in a) and (s[i+8] in a) and (s[i+9] in a):
l.append(s[i:i+10])
elif ((s[i] in a) or s[i]=="-") and (s[i+1] in a) and s[i+2]=="-" and (s[i+3] in a) and s[i+4]=="-" and (s[i+5] in a) and (s[i+6] in a) and (s[i+7] in a) and (s[i+8] in a):
l.append(s[i:i+9])
for i in l:
if len(i)==10:
date1 = i[0:2]
month1 = i[3:5]
year = i[6:10]
date1 = list(date1)
month1 = list(month1)
else:
date1 = i[0:2]
month1=i[3:4]
year = i[5:9]
date1=list(date1)
month1=list(month1)
if date1[0]=="-":
date1[0]="0"
date=""
month=""
for i_ in date1:
date+=i_
for j_ in month1:
month+=j_
if len(month)==1:
month="0"+month
thirtyone =[1,3,5,7,8,10,12]
twen=[2]
#poss=[2013,2014,2015]
if int(year)>=2013 and int(year)<=2015:
if int(month) in thirtyone:
if int(date)>0 and int(date)<=31:
continue
else:
l.remove(i)
elif int(month) in twen:
if int(date)>0 and int(date)<=28:
continue
else:
l.remove(i)
else:
if int(date)>0 and int(date)<=30:
continue
else:
l.remove(i)
else:
l.remove(i)
sett = set(l)
m=0
ans=0
for i in sett:
cnt = l.count(i)
if cnt>m:
ans=i
m=cnt
print(ans)
if __name__ == '__main__':
main()
``` | instruction | 0 | 86,020 | 4 | 172,040 |
No | output | 1 | 86,020 | 4 | 172,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012").
The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date.
A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it.
Notice, that any year between 2013 and 2015 is not a leap year.
Input
The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters.
Output
In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique.
Examples
Input
777-444---21-12-2013-12-2013-12-2013---444-777
Output
13-12-2013
Submitted Solution:
```
'''
def main():
from sys import stdin,stdout
if __name__=='__main__':
main()
'''
#349B
'''
def main():
from sys import stdin,stdout
N = int(stdin.readline())
arr = list(map(int,stdin.readline().split()))
div = []
for i in arr:
div.append(N//i)
maxim = 0
maxindex = -1
for i in range(9):
if div[i] >maxim:
maxim = div[i]
maxindex = i
if maxindex > -1:
ans = [ (maxindex+1) for i in range(maxim)]
N= N%arr[maxindex]
#print(N)
i = 0
while i<maxim:
#print('i=',i,'N=',N)
for j in range(8,maxindex,-1):
#print('j=',j,'diff=',arr[j]-arr[ans[i]-1])
if arr[j]-arr[ans[i]-1] <=N:
N -= arr[j]-arr[ans[i]-1]
ans[i] = j+1
break
i+=1
for i in ans:
stdout.write(str(i))
else:
stdout.write('-1\n')
if __name__=='__main__':
main()
'''
#234B Input and Output
'''
def main():
from sys import stdin,stdout
import collections
with open('input.txt','r') as ip:
N,K = map(int,ip.readline().split())
arr = list(map(int,ip.readline().split()))
mydict = collections.defaultdict(set)
for i in range(len(arr)):
mydict[arr[i]].add(i+1)
ans = []
i=0
while K>0:
for it in mydict[sorted(mydict.keys(),reverse=True)[i]]:
ans.append(it)
K-=1
if K<1:
break
minim=i
i+=1
with open('output.txt','w') as out:
out.write(str(sorted(mydict.keys(),reverse=True)[minim])+'\n')
ans=' '.join(str(x) for x in ans)
out.write(ans+'\n')
if __name__=='__main__':
main()
'''
#151B
'''
def main():
from sys import stdin,stdout
import collections
names = collections.defaultdict(list)
counter = 0
order = {}
for i in range(int(stdin.readline())):
n,ns = stdin.readline().split()
names[ns]=[0,0,0]
order[ns]=counter
counter+=1
n=int(n)
while n:
ip=stdin.readline().strip()
ip=ip.replace('-','')
#test for taxi
flag=True
for i in range(1,6):
if ip[i]!=ip[0]:
flag=False
break
if flag:
names[ns][0]+=1
n-=1
continue
#test for pizza
flag = True
for i in range(1,6):
if int(ip[i])>=int(ip[i-1]):
flag =False
break
if flag:
names[ns][1]+=1
else:
names[ns][2]+=1
n-=1
#print(names)
#for all girls
t=-1
p=-1
g=-1
for i in names:
t=max(t,names[i][0])
p = max(p, names[i][1])
g = max(g, names[i][2])
taxi=list(filter(lambda x: names[x][0]==t, names.keys()))
pizza = list(filter(lambda x: names[x][1] == p, names.keys()))
girls = list(filter(lambda x: names[x][2] == g, names.keys()))
pizza.sort(key= lambda x: order[x])
taxi.sort(key= lambda x: order[x])
girls.sort(key= lambda x: order[x])
print('If you want to call a taxi, you should call:',', '.join(x for x in taxi),end='.\n')
print('If you want to order a pizza, you should call:', ', '.join(x for x in pizza),end='.\n')
print('If you want to go to a cafe with a wonderful girl, you should call:', ', '.join(x for x in girls),end='.\n')
if __name__=='__main__':
main()
'''
#SQUADRUN Q2
'''
def LCMgen(a):
import math
lcm = a[0]
for i in range(1,len(a)):
g = math.gcd(lcm,a[i])
lcm = (lcm*a[i])//g
return lcm
def main():
from sys import stdin,stdout
import collections
import math
N,W = map(int,stdin.readline().split())
counter = collections.Counter(map(int,stdin.readline().split()))
lcm = LCMgen(list(counter.keys()))
W*=lcm
div = 0
for i in counter:
div+=counter[i]*(lcm//i)
ans = math.ceil(W/div)
stdout.write(str(ans))
if __name__=='__main__':
main()
'''
#143B
'''
def main():
from sys import stdin,stdout
ip = stdin.readline().strip()
inte = None
flow = None
for i,j in enumerate(ip):
if j=='.':
flow = ip[i:]
inte = ip[:i]
break
if flow == None:
flow = '.00'
inte = ip
else:
if len(flow)==2:
flow+='0'
else:
flow = flow[:3]
ne = False
if ip[0]=='-':
ne = True
if ne:
inte = inte[1:]
inte = inte[::-1]
ans =''
for i,j in enumerate(inte):
ans += j
if i%3 == 2:
ans+=','
ans = ans[::-1]
if ans[0]==',':
ans = ans[1:]
ans = '$'+ans
if ne:
stdout.write('({})'.format(ans+flow))
else:
stdout.write(ans+flow)
if __name__=='__main__':
main()
'''
#A
'''
def main():
from sys import stdin,stdout
n = int(stdin.readline())
arr = list(map(int,stdin.readline().split()))
minim = min(arr)
my_l = []
for i,j in enumerate(arr):
if j==minim:
my_l.append(i)
my_l_ = []
for i in range(1,len(my_l)):
my_l_.append(my_l[i]-my_l[i-1])
stdout.write(str(min(my_l_)))
if __name__=='__main__':
main()
'''
#B
'''
def main():
from sys import stdin,stdout
n,a,b = map(int,stdin.readline().split())
maxim = -1
for i in range(1,n):
maxim = max(min(a//i,b//(n-i)),maxim)
stdout.write(str(maxim))
if __name__=='__main__':
main()
'''
#233B
'''
def main():
from sys import stdin,stdout
def foo(x):
tsum = 0
c = x
while c:
tsum+=(c%10)
c//=10
return tsum
N = int(stdin.readline())
up,down = 0 , int(1e18)
flag = False
while up<down:
mid = (up+down)//2
val = foo(mid)
val = (mid+val)*mid
if val<N:
up = mid
elif val >N:
down = mid
else:
flag=True
break
if flag:
stdout.write(str(mid)+'\n')
else:
stdout.write('-1')
if __name__=='__main__':
main()
def main():
def foo(x):
n= x
tsum = 0
while n:
tsum += n%10
n//=10
return x*x + tsum*x - int(1e18)
import matplotlib.pyplot as plt
y = [foo(x) for x in range(1,int(1e18)+1)]
x = range(1,int(1e18)+1)
print(y[:100])
plt.plot(y,x)
plt.show()
if __name__=='__main__':
main()
'''
#RECTANGL
'''
def main():
from sys import stdin,stdout
import collections
for _ in range(int(stdin.readline())):
c = collections.Counter(list(map(int,stdin.readline().split())))
flag = True
for i in c:
if c[i]&1:
flag=False
if flag:
stdout.write('YES\n')
else:
stdout.write('NO\n')
if __name__=='__main__':
main()
'''
#MAXSC
'''
def main():
from sys import stdin,stdout
import bisect
for _ in range(int(stdin.readline())):
N = int(stdin.readline())
mat = []
for i in range(N):
mat.append(sorted(map(int,stdin.readline().split())))
## print(mat)
temp = mat[-1][-1]
tsum = mat[-1][-1]
flag = True
for i in range(N-2,-1,-1):
ind = bisect.bisect_left(mat[i],temp)-1
if ind == -1:
flag = False
break
else:
tsum+=mat[i][ind]
if flag:
stdout.write(str(tsum)+'\n')
else:
stdout.write('-1\n')
if __name__=='__main__':
main()
'''
#233B ********************
'''
def main():
def rev(x):
tsum = 0
while x:
tsum += x%10
x//=10
return tsum
from sys import stdin,stdout
from math import sqrt,ceil
n = int(stdin.readline())
for i in range(91):
r = i*i+(n<<2)
x = ceil(sqrt(r))
## print(i,x)
if x*x == r:
num = (x-i)/2
if num == int(num):
if rev(num)==i:
stdout.write(str(int(num)))
return
stdout.write('-1')
if __name__=='__main__':
main()
'''
#228B
'''
def main():
from sys import stdin,stdout
na,nb = map(int,stdin.readline().split())
A = []
for _ in range(na):
A.append([int(x) for x in stdin.readline().strip()])
ma,mb = map(int,stdin.readline().split())
B= []
for _ in range(ma):
B.append([int(x) for x in stdin.readline().strip()])
## print(A)
## print(B)
maxim , value = -1, None
for x in range(1-na,ma):
for y in range(1-nb,mb):
tmp = 0
for i in range(na):
for j in range(nb):
if i+x > -1 and i+x <ma and i>-1 and i<na and j>-1 and j<nb and j+y > -1 and j+y <mb:
tmp+=A[i][j]*B[i+x][j+y]
## print(x,y,tmp)
if tmp > maxim:
maxim = tmp
value = (x,y)
## print("MAXIM:",maxim,"VALUE:",value)
stdout.write(str(value[0])+' '+str(value[1]))
if __name__=='__main__':
main()
'''
#260B
def main():
import re , collections, datetime
from sys import stdin,stdout
def post_process(ans):
datetime.MINYEAR=2013
datetime.MAXYEAR=2015
for string in ans:
dd,mm,yyyy = map(int,string.split('-'))
try:
obj = datetime.date(dd,mm,yyyy)
except:
ans[string]=0
return ans
my_re = '(?=([0-9][0-9]-[0-1][0-9]-201[3-5]))'
inp = stdin.readline().strip()
ans = re.finditer(my_re,inp)
ans = collections.Counter([m.group(1) for m in ans])
ans = post_process(ans)
stdout.write(ans.most_common(1)[0][0])
if __name__=='__main__':
main()
``` | instruction | 0 | 86,021 | 4 | 172,042 |
No | output | 1 | 86,021 | 4 | 172,043 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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. | instruction | 0 | 86,038 | 4 | 172,076 |
Tags: implementation
Correct Solution:
```
m, n=map(int, input().split())
l=m
while l>n:
m+=l//n
l=l//n+l%n
if l==n:
m+=n//l
print(m)
``` | output | 1 | 86,038 | 4 | 172,077 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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. | instruction | 0 | 86,039 | 4 | 172,078 |
Tags: implementation
Correct Solution:
```
# n = int(input())
# a = [1]
# for i in range(n):
# print(*a)
# a = [1] + [a[j] + a[j + 1] for j in range(i)] + [1]
#a = 1
#n = int(input())
#for i in range(2, n):
# if n % i == 0:
# a = 0
# break
#if a == 0:
# print("I am way to dumb to get an answer correctly")
# print("NO")
#else:
# print("YES")
# print("I am way to dumb to get an answer correctly")
#a = [int (x) for x in input().split()]
#for i in range(len(a) - 1 , -1, -1):
# print(a[i], end = " ")
#a = [int (x) for x in input().split()]
#if len(a) % 2 == 0 :
# for i in range (len(a) // 2 -1, -1, -1):
# print(a[i], end = " ")
# for j in range (len(a)//2, len(a)):
# print(a[j], end = " ")
#else:
# for i in range (len(a) // 2, -1, -1):
# print(a[i], end = " ")
# for j in range (len(a)//2, len(a)):
# print(a[j], end = " ")
#b = []
#c = []
#a = [int (x) for x in input().split()]
#for i in range(len(a)):
# if i % 2 == 0:
# b.append (a[i])
# else:
# c.append (a[i])
#c.reverse()
#print(*b, end = " ")
#print(*c, end = " ")
#b = 1
#n = int(input())
#a = [int(x) for x in input().split()]
#for i in range(len(a)):
# if a[i] == n:
# b = 0
# break
#if b == 0:
# print( i + 1 , sep="\n")
#else:
# print(-1)
#left = 0
#k = int(input())
#a = [int(x) for x in input().split()]
#right = len(a)
#while right - left > 1:
# middle = (right + left) // 2
# if k < a[middle]:
# right = middle
# else:
# left = middle
#if a[left] == k:
# print(left + 1)
#else:
# print(-1)
#a = input()
#for i in range(0, len(a)):
# if (i + 1) % 3 != 0:
# print(a[i], end = " ")
#a = input()
#for i in range(0, len(a)):
# if (i + 1) % 3 == 0 or (i + 1) % 2 == 0:
# print(a[i], end = " ")
#print([int(elem) for i, elem in enumerate(input().split()) if i % 3 != 0])
#class Cat:
# def __init__(self, face, paws, whiskers, belly, what_they_like, pawsonality):
# self.face = face
# self.paws = paws
# self.whiskers = whiskers
# self.belly = belly
# self.what_they_like = what_they_like
# self.pawsonality = pawsonality
# def __str__(self):
# return "face: {}\npaws: {}".format( self.face, self.paws, self.whiskers, self.belly, self.what_they_like, self.pawsonality)
#Tyson = Cat(1, 4, 18, 3.5, ["water", "food", "ropes", "blankets"], "playful, stubborn, sleepy")
#print(Tyson)
#a = list(input())
#b = list(reversed(a))
#if a == b:
# print("YES")
#else:
# print("NO")
#meow
#countmeow = 0
#a = list(input())
#b = list(reversed(a))
#for i in range(len(a)):
# if a[i] != b[i]:
# countmeow = countmeow + 1
#if countmeow == 0 and len(a) % 2 != 0:
# print("YES")
#elif countmeow == 2:
# print("YES")
#else:
# print("NO")
#input()
#letmeowchange = 0
#num = input()
#a = dict()
#if len(num) > 26:
# print(-1)
#else:
# for letter in num:
# if letter in a:
# a[letter] += 1
# else:
# a[letter] = 1
# for letter in a:
# letmeowchange += a[letter]-1
# print(letmeowchange)
#print(round(sum([float(i) for i in input().split()]), 1))
#a = [int(i) for i in input().split()]
#b = [int(j) for j in input().split()]
#for i in zip(b, a):
# print(*i, end = " ")
#print([int(-i) if i%2==0 else int(i) for i in range(1,int(input()) + 1)])
#cb = input()
#bc = [int(i) for i in input().split()]
#a = {elem1: elem2 for elem1, elem2 in zip(cb, bc)}
#print(a)
#b = 0
#for i in range(10, 100):
# if i % 5 != 0 and i % 7 != 0:
# b = b + 1
#print(b)
#a = int(input())
#b = " that I hate"
#c = " that I love"
#print("I hate", end = "")
#for i in range(a - 1):
# if i % 2 == 0:
# print(c, end = "")
# else:
# print(b, end = "")
#print(" it")
#a = int(input())
#b = [int(input()) for i in range(a)]
#c = b[0]
#d = 0
#for i in b[1::]:
# if i != c:
# d = d + 1
# c = i
#print(d + 1)
#input()
#letmeowchange = 0
#num = input()
#a = dict()
#if len(num) > 26:
# print(-1)
#else:
# for letter in num:
# if letter in a:
# a[letter] += 1
# else:
# a[letter] = 1
# for letter in a:
# letmeowchange += a[letter]-1
# print(letmeowchange)
#from math import ceil
#a = int(input())
#b = [int(i) for i in input().split()]
#c = sum(b)
#
#d = {1:0, 2:0, 3:0, 4:0}
#total = 0
#r2 = 0
#for i in b:
# if i in d:
# d[i] += 1
# else:
# d[i] = 1
#total = total + d[4]
#total = total + d[3]
#total = total + (d[2] // 2)
#r2 = d[2] % 2
#if r2 != 0:
# d[1] = d[1] - 2
# total = total + 1
#if d[1] > d[3]:
# total += ceil((d[1] - d[3]) / 4)
#print(total)
#n = int(input())
#a = [int(i) for i in input().split()]
#print(*sorted(a))
#s = list(input())
#t = list(input())
#a = list(reversed(s))
#if t == a:
# print("YES")
#else:
# print("NO")
#a = input().split()
#b = 0
#c = 0
#d = dict()
#for letter in a:
# if letter in d:
# d[letter] += 1
# else:
# d[letter] = 1
#for value in d.values():
# if value % 2 != 0:
# c = c + 1
#if c > 1:
# print("NO")
#else:
# print("YES")
#n = input()
#a = [int(i) for i in n]
#b = 0
#for i in a:
# if i == 4 or i == 7:
# b = b + 1
#if b == 4 or b == 7:
# print("YES")
#else:
# print("NO")
#n = input()
#a = [int(i) for i in n]
#b = 0
#c = 0
#a = "abcdefgthijklmnopqrstuvwxyz"
#s = input()
#for i in s:
# if i in a:
# b = b + 1
# else:
#c = c + 1
#if b == c or b > c:
# print(s.lower())
#else:
# print(s.upper())
#b = 0
#k = int(input())
#l = int(input())
#m = int(input())
#n = int(input())
#d = int(input())
#for i in range(1, d + 1):
# if i % k == 0:
# b = b + 1
# elif i % l == 0:
# b = b + 1
# elif i % m == 0:
# b = b + 1
# elif i % n == 0:
# b = b + 1
#print(b)
#a = input().split("WUB")
#for i in a:
# if i != '':
# print(i , end = " ")
#n, m = [int(i) for i in input().split()]
#f = [int(i) for i in input().split()]
#a = sorted(f)
#A = 0
#B = 0
#answer = 999999999999999999
#c = 3
#for i in range (0, len(a) - n + 1):
# A = a[i]
# B = a[i + n - 1]
# if B - A < answer:
# answer = B - A
#print(answer)
#s = [int(i) for i in input().split()]
#s = set(s)
#print(4 - len(s))
#n = int(input())
#a = [int(i) for i in input().split()]
#b = -9999999999999999999999999999
#c = 9999999999999999999999999999
#d = 0
#f = 0
#naswer = 0
#index = 0
#for i in range(len(a)):
# if a[i] > b:
# d = i
# b = a[i]
# if a[i] <= c:
# f = i
# c = a[i]
#index = len(a) - 1
#naswer = naswer + (index - f)
#naswer = naswer + d
#if f < d:
# naswer = naswer - 1
#print(naswer)
#t = int(input())
#naswer = 0
#for i in range (t):
# n = int(input())
# naswer = n // 2
# print(naswer)
#n, k = [int(i) for i in input().split()]
#naswer = 0
#if k <= (n + (n % 2)) // 2:
# naswer = k * 2 - 1
#else:
# naswer = (k - (n + (n % 2)) // 2) * 2
#print(naswer)
#n = int(input())
#a = [int(i) for i in input().split()] + [9999999999]
#for i in range(n):
#d = 0
#n = int(input())
#p = [int(i) for i in input().split()]
#q = [int(i) for i in input().split()]
#a = []
#for i in range(1, len(p)):
# a.append(p[i])
#for j in range(1, len(q)):
# a.append(q[j])
#b = set(a)
#for i in range(1, n + 1):
# if i in b:
# d = d + 1
#if d == n:
# print("I become the guy.")
#else:
# print("Oh, my keyboard!")
#n = int(input())
#a = [i for i in input().lower()]
#b = set(a)
#if len(b)>=26:
# print("YES")
#else:
# print("NO")
#n = int(input())
#a = {"Icosahedron" : 20, "Dodecahedron" : 12, "Octahedron" : 8, "Cube" : 6, "Tetrahedron" : 4}
#b = 0
#for i in range(n):
# c = input()
# b = b + a[c]
#print(b)
#a = input()
#b = input()
#c = input()
#d = dict()
#e = dict()
#for i in a:
# if i in d:
# d[i] = d[i] + 1
# else:
# d[i] = 1
#for i in b:
# if i in d:
# d[i] = d[i] + 1
# else:
# d[i] = 1
#for i in c:
# if i in e:
# e[i] = e[i] + 1
# else:
# e[i] = 1
#if d == e:
# print("YES")
#else:
# print("NO")#
#n, m = [int(i) for i in input().split()]
#b = min(n, m)
#if b % 2 !=0:
# print("Akshat")
#else:
# print("Malvika")
#
#n, m = [int(i) for i in input().split()]
#ho = "#"
#hi = "."
#for i in range(1, n + 1):
# if i % 4 != 0 and i % 2 == 0:
# print(hi*(m-1) + ho)
# elif i % 4 == 0:
# print(ho + hi* (m - 1))
# else:
# print(ho * m)
#n, m = [int(i) for i in input().split()]
#a = [int(i) for i in input().split()]
#hosss = 1
#besss = 0
#for i in a:
# if (i >= hosss):
# besss = besss + (i - hosss)
# else:(
# besss = besss + (n - hosss + i)
# hosss = i
#print(besss)
#n = int(input())
#x = [int(i) for i in input().split()]
#q = int(input())
#x.sort()
#for i in range(q):
# k = int(input())
# l = -1
# r = n
# while (r - l > 1):
# middle = l + (r - l) // 2
# if x[middle] <= k:
# l = middle
# else:
# r = middle
# print( l + 1 )
#a, b = [int(i) for i in input().split()]
#c = min(a, b)
#d = max(a, b)
#e = d - c
#print(c, e//2)
#k, r = [int(i) for i in input().split()]
#for i in range(1, 11):
# if ((k * i) - r) % 10 == 0:
# print(i)
# break
# if (k * i) % 10 == 0:
# print(i)
# break
#n = int(input())
#a = [int(i) for i in input().split()]
#m = int(input())
#q = [int(i) for i in input().split()]
#b = [a[0]]
#for i in range(1, len(a)):
# b.append(a[i] + b [i - 1])
#for i in range(len(q)):
# l = -1
# r = len(a)
# while (r - l > 1):
# mid = (l + r) // 2
# if b[mid] < q[i]:
# l = mid
# else:
# r = mid
# print(r + 1)
#n, t = [int(i) for i in input().split()]
#a = [0] + [int(i) for i in input().split()]
#b = []
#naswer = 0
#noswer = 0
#nul = 0
#for i in a:
# nul = nul + i
# b.append(nul)
#for i in range(1, n + 1):
# l = i - 1
# r = n + 1
# while(r - l > 1):
# mid = (l + r) // 2
# noswer = b[mid] - b[i - 1]
# if (noswer) <= t:
# l = mid
# else:
# r = mid
# naswer = max(naswer, l - i + 1)
#print(naswer)
#n, m, a, b = [int (i) for i in input().split()]
#if m * a <= b:
# print(n * a)
#else:
# c = n % m
# if c == 0:
# print((n//m) * b)
# if c != 0:
# d = a * c
# if d > b:
# print(b + ((n//m) * b))
# else:
# print(d + ((n//m) * b))
a, b = [int (i) for i in input().split()]
naswer = 0
c = 0
while a > 0:
naswer = naswer + a
c = c + a
a = c // b
c = c % b
print(naswer)
``` | output | 1 | 86,039 | 4 | 172,079 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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. | instruction | 0 | 86,040 | 4 | 172,080 |
Tags: implementation
Correct Solution:
```
# Made By Mostafa_Khaled
bot = True
a,b=map(int,input().split());print((a-1)//(b-1)+a)
# Made By Mostafa_Khaled
``` | output | 1 | 86,040 | 4 | 172,081 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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. | instruction | 0 | 86,041 | 4 | 172,082 |
Tags: implementation
Correct Solution:
```
a, b = map(int, input().split())
s = 0
n = 0
while a != 0:
a -= 1
s += 1
if s==b:
a+=1
s = 0
n += 1
print(n)
``` | output | 1 | 86,041 | 4 | 172,083 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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. | instruction | 0 | 86,042 | 4 | 172,084 |
Tags: implementation
Correct Solution:
```
a,b=map(int,input().split())
ans=0
c=0
while a!=0:
ans+=a
c+=a
a=c//b
c%=b
print(ans)
``` | output | 1 | 86,042 | 4 | 172,085 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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. | instruction | 0 | 86,043 | 4 | 172,086 |
Tags: implementation
Correct Solution:
```
def calculate_hour(candles: int, pieces: int) -> int:
hour = 0
went_outs = 0
while candles > 0:
hour += candles
went_outs += candles
candles = went_outs // pieces
went_outs %= pieces
return hour
(a, b) = map(int, input().split())
print(calculate_hour(a, b))
``` | output | 1 | 86,043 | 4 | 172,087 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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. | instruction | 0 | 86,044 | 4 | 172,088 |
Tags: implementation
Correct Solution:
```
a, b = list(map(int, input().split()))
total = a
while True:
x = a % b
a = a // b
if a == 0:
break
total += a
a += x
print(total)
``` | output | 1 | 86,044 | 4 | 172,089 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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. | instruction | 0 | 86,045 | 4 | 172,090 |
Tags: implementation
Correct Solution:
```
'''input
3 2
'''
a, b = map(int, input().split())
r = 0
t = 0
while a+r >= b:
t += a
r += a % b
a //= b
if r >= b:
a, r = a + r//b, r % b
print(t+a)
``` | output | 1 | 86,045 | 4 | 172,091 |
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:
```
def cnt(n,b):
ans=crumb=n
while crumb>=b:
ans+=crumb//b
crumb=crumb//b+crumb%b
return ans
a,b=map(int,input().split())
print(cnt(a,b))
``` | instruction | 0 | 86,046 | 4 | 172,092 |
Yes | output | 1 | 86,046 | 4 | 172,093 |
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 = [int(x) for x in input().split()]
sum = 0
i, j = a, 0
while i > 0:
sum += i
i, j = divmod(i + j, b)
print(sum)
``` | instruction | 0 | 86,047 | 4 | 172,094 |
Yes | output | 1 | 86,047 | 4 | 172,095 |
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:
```
n,m=map(int,input().split())
print(n+(n-1)//(m-1))
``` | instruction | 0 | 86,048 | 4 | 172,096 |
Yes | output | 1 | 86,048 | 4 | 172,097 |
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:
```
n, x = map(int, input().split())
c = 0
s = 0
while(n > 0):
c += n
s += n%x
n = n//x + s//x
s = s%x
print(c)
``` | instruction | 0 | 86,049 | 4 | 172,098 |
Yes | output | 1 | 86,049 | 4 | 172,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.