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.
Walking along a riverside, Mino silently takes a note of something.
"Time," Mino thinks aloud.
"What?"
"Time and tide wait for no man," explains Mino. "My name, taken from the river, always reminds me of this."
"And what are you recording?"
"You see it, tide. Everything has its own period, and I think I've figured out this one," says Mino with confidence.
Doubtfully, Kanno peeks at Mino's records.
The records are expressed as a string s of characters '0', '1' and '.', where '0' denotes a low tide, '1' denotes a high tide, and '.' denotes an unknown one (either high or low).
You are to help Mino determine whether it's possible that after replacing each '.' independently with '0' or '1', a given integer p is not a period of the resulting string. In case the answer is yes, please also show such a replacement to Mino.
In this problem, a positive integer p is considered a period of string s, if for all 1 β€ i β€ \lvert s \rvert - p, the i-th and (i + p)-th characters of s are the same. Here \lvert s \rvert is the length of s.
Input
The first line contains two space-separated integers n and p (1 β€ p β€ n β€ 2000) β the length of the given string and the supposed period, respectively.
The second line contains a string s of n characters β Mino's records. s only contains characters '0', '1' and '.', and contains at least one '.' character.
Output
Output one line β if it's possible that p is not a period of the resulting string, output any one of such strings; otherwise output "No" (without quotes, you can print letters in any case (upper or lower)).
Examples
Input
10 7
1.0.1.0.1.
Output
1000100010
Input
10 6
1.0.1.1000
Output
1001101000
Input
10 9
1........1
Output
No
Note
In the first example, 7 is not a period of the resulting string because the 1-st and 8-th characters of it are different.
In the second example, 6 is not a period of the resulting string because the 4-th and 10-th characters of it are different.
In the third example, 9 is always a period because the only constraint that the first and last characters are the same is already satisfied.
Note that there are multiple acceptable answers for the first two examples, you can print any of them.
Submitted Solution:
```
n,p=map(int,input().split())
s=list(map(str,input().strip()))
#print(s)
f=1
for i in range(n-p):
if s[i]!='.' and s[i+p]!='.' and s[i]==s[i+p]:
continue
else:
f=0
break
if f==1:
print("NO")
else:
for i in range(n-p):
if s[i]=='.' and s[i+p]=='.':
s[i]='0'
s[i+p]='1'
elif s[i]=='.':
if s[i+p]=='1':
s[i]='0'
else:
s[i]='1'
elif s[i+p]=='.':
if s[i]=='1':
s[i+p]='0'
else:
s[i+p]='1'
for i in range(n):
if s[i]=='.':
s[i]='0'
print(''.join(s))
``` | instruction | 0 | 63,731 | 4 | 127,462 |
Yes | output | 1 | 63,731 | 4 | 127,463 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Walking along a riverside, Mino silently takes a note of something.
"Time," Mino thinks aloud.
"What?"
"Time and tide wait for no man," explains Mino. "My name, taken from the river, always reminds me of this."
"And what are you recording?"
"You see it, tide. Everything has its own period, and I think I've figured out this one," says Mino with confidence.
Doubtfully, Kanno peeks at Mino's records.
The records are expressed as a string s of characters '0', '1' and '.', where '0' denotes a low tide, '1' denotes a high tide, and '.' denotes an unknown one (either high or low).
You are to help Mino determine whether it's possible that after replacing each '.' independently with '0' or '1', a given integer p is not a period of the resulting string. In case the answer is yes, please also show such a replacement to Mino.
In this problem, a positive integer p is considered a period of string s, if for all 1 β€ i β€ \lvert s \rvert - p, the i-th and (i + p)-th characters of s are the same. Here \lvert s \rvert is the length of s.
Input
The first line contains two space-separated integers n and p (1 β€ p β€ n β€ 2000) β the length of the given string and the supposed period, respectively.
The second line contains a string s of n characters β Mino's records. s only contains characters '0', '1' and '.', and contains at least one '.' character.
Output
Output one line β if it's possible that p is not a period of the resulting string, output any one of such strings; otherwise output "No" (without quotes, you can print letters in any case (upper or lower)).
Examples
Input
10 7
1.0.1.0.1.
Output
1000100010
Input
10 6
1.0.1.1000
Output
1001101000
Input
10 9
1........1
Output
No
Note
In the first example, 7 is not a period of the resulting string because the 1-st and 8-th characters of it are different.
In the second example, 6 is not a period of the resulting string because the 4-th and 10-th characters of it are different.
In the third example, 9 is always a period because the only constraint that the first and last characters are the same is already satisfied.
Note that there are multiple acceptable answers for the first two examples, you can print any of them.
Submitted Solution:
```
class CodeforcesTask989BSolution:
def __init__(self):
self.result = ''
self.n_p = []
self.records = []
def read_input(self):
self.n_p = [int(x) for x in input().split(" ")]
self.records = list(input())
def process_task(self):
fixed = True
for x in range(self.n_p[0] - self.n_p[1]):
if self.records[x + self.n_p[1]] == ".":
self.records[x + self.n_p[1]] = "1" if self.records[x] == "0" else "0"
fixed = False
break
if self.records[x] == ".":
self.records[x] = "1" if self.records[x + self.n_p[1]] == "0" else "0"
fixed = False
break
if not fixed:
self.result = "".join(self.records).replace(".", "0")
else:
self.result = "No"
def get_result(self):
return self.result
if __name__ == "__main__":
Solution = CodeforcesTask989BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())
``` | instruction | 0 | 63,732 | 4 | 127,464 |
No | output | 1 | 63,732 | 4 | 127,465 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Walking along a riverside, Mino silently takes a note of something.
"Time," Mino thinks aloud.
"What?"
"Time and tide wait for no man," explains Mino. "My name, taken from the river, always reminds me of this."
"And what are you recording?"
"You see it, tide. Everything has its own period, and I think I've figured out this one," says Mino with confidence.
Doubtfully, Kanno peeks at Mino's records.
The records are expressed as a string s of characters '0', '1' and '.', where '0' denotes a low tide, '1' denotes a high tide, and '.' denotes an unknown one (either high or low).
You are to help Mino determine whether it's possible that after replacing each '.' independently with '0' or '1', a given integer p is not a period of the resulting string. In case the answer is yes, please also show such a replacement to Mino.
In this problem, a positive integer p is considered a period of string s, if for all 1 β€ i β€ \lvert s \rvert - p, the i-th and (i + p)-th characters of s are the same. Here \lvert s \rvert is the length of s.
Input
The first line contains two space-separated integers n and p (1 β€ p β€ n β€ 2000) β the length of the given string and the supposed period, respectively.
The second line contains a string s of n characters β Mino's records. s only contains characters '0', '1' and '.', and contains at least one '.' character.
Output
Output one line β if it's possible that p is not a period of the resulting string, output any one of such strings; otherwise output "No" (without quotes, you can print letters in any case (upper or lower)).
Examples
Input
10 7
1.0.1.0.1.
Output
1000100010
Input
10 6
1.0.1.1000
Output
1001101000
Input
10 9
1........1
Output
No
Note
In the first example, 7 is not a period of the resulting string because the 1-st and 8-th characters of it are different.
In the second example, 6 is not a period of the resulting string because the 4-th and 10-th characters of it are different.
In the third example, 9 is always a period because the only constraint that the first and last characters are the same is already satisfied.
Note that there are multiple acceptable answers for the first two examples, you can print any of them.
Submitted Solution:
```
##########################
## A Tide of Riverscape ##
##########################
def main():
n,p = input().split(" ")
s = input()
n = int(n)
p = int(p)
aux = 0
menor = []
maior = []
for i in range(n-p):
menor.append(i+1)
maior.append(i+1+p)
for i in range(len(menor)):
#print("menor", s[menor[i]-1])
#print("maior", s[maior[i]-1])
if(s[menor[i]-1] != (s[maior[i]-1])):
#print("deeeu")
s = s.replace('.','0')
print(s)
aux = 1
break
if(aux == 0):
print("No")
if __name__ == "__main__":
main()
``` | instruction | 0 | 63,733 | 4 | 127,466 |
No | output | 1 | 63,733 | 4 | 127,467 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Walking along a riverside, Mino silently takes a note of something.
"Time," Mino thinks aloud.
"What?"
"Time and tide wait for no man," explains Mino. "My name, taken from the river, always reminds me of this."
"And what are you recording?"
"You see it, tide. Everything has its own period, and I think I've figured out this one," says Mino with confidence.
Doubtfully, Kanno peeks at Mino's records.
The records are expressed as a string s of characters '0', '1' and '.', where '0' denotes a low tide, '1' denotes a high tide, and '.' denotes an unknown one (either high or low).
You are to help Mino determine whether it's possible that after replacing each '.' independently with '0' or '1', a given integer p is not a period of the resulting string. In case the answer is yes, please also show such a replacement to Mino.
In this problem, a positive integer p is considered a period of string s, if for all 1 β€ i β€ \lvert s \rvert - p, the i-th and (i + p)-th characters of s are the same. Here \lvert s \rvert is the length of s.
Input
The first line contains two space-separated integers n and p (1 β€ p β€ n β€ 2000) β the length of the given string and the supposed period, respectively.
The second line contains a string s of n characters β Mino's records. s only contains characters '0', '1' and '.', and contains at least one '.' character.
Output
Output one line β if it's possible that p is not a period of the resulting string, output any one of such strings; otherwise output "No" (without quotes, you can print letters in any case (upper or lower)).
Examples
Input
10 7
1.0.1.0.1.
Output
1000100010
Input
10 6
1.0.1.1000
Output
1001101000
Input
10 9
1........1
Output
No
Note
In the first example, 7 is not a period of the resulting string because the 1-st and 8-th characters of it are different.
In the second example, 6 is not a period of the resulting string because the 4-th and 10-th characters of it are different.
In the third example, 9 is always a period because the only constraint that the first and last characters are the same is already satisfied.
Note that there are multiple acceptable answers for the first two examples, you can print any of them.
Submitted Solution:
```
'''n = input()
if("BAC" in n or "ABC" in n or "CAB" in n or "ACB" in n or "BCA" in n or "CBA" in n):print("YES")
else : print("NO")'''
n , m = map(int,input().split())
st = input()
lr = n - m
for i in range(lr):
if(i+m<n and st [i] != st[i+m] )or(i+m<n and st[i]=='.' and st[i+m]=='.'):
if(st[i]=='.' and st[i+m]=='.'):
for j in range(n):
if(j==i):print(0,end="")
elif j == (i+m) : print(1,end="")
elif(st[j]=='.'):print(0,end="")
else:print(st[j],end="")
elif st[i]!='.' and st[i+m]!='.':
for j in range(n):
if(st[i]=='.'):print(0,end="")
else:print(st[j],end="")
else:
st=list(st)
if(st[i]!='.' and st[i]=='1'):
st[i+m]='0'
elif (st[i]!='.' and st[i]=='0'):
st[i+m]='1'
elif st[i+m]=='0':
st[i]='1'
else : st[i]='0'
for j in range(n):
if(st[j]=='.'):print(0,end="")
else : print(st[j],end="")
print()
exit()
print("NO")
``` | instruction | 0 | 63,734 | 4 | 127,468 |
No | output | 1 | 63,734 | 4 | 127,469 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Walking along a riverside, Mino silently takes a note of something.
"Time," Mino thinks aloud.
"What?"
"Time and tide wait for no man," explains Mino. "My name, taken from the river, always reminds me of this."
"And what are you recording?"
"You see it, tide. Everything has its own period, and I think I've figured out this one," says Mino with confidence.
Doubtfully, Kanno peeks at Mino's records.
The records are expressed as a string s of characters '0', '1' and '.', where '0' denotes a low tide, '1' denotes a high tide, and '.' denotes an unknown one (either high or low).
You are to help Mino determine whether it's possible that after replacing each '.' independently with '0' or '1', a given integer p is not a period of the resulting string. In case the answer is yes, please also show such a replacement to Mino.
In this problem, a positive integer p is considered a period of string s, if for all 1 β€ i β€ \lvert s \rvert - p, the i-th and (i + p)-th characters of s are the same. Here \lvert s \rvert is the length of s.
Input
The first line contains two space-separated integers n and p (1 β€ p β€ n β€ 2000) β the length of the given string and the supposed period, respectively.
The second line contains a string s of n characters β Mino's records. s only contains characters '0', '1' and '.', and contains at least one '.' character.
Output
Output one line β if it's possible that p is not a period of the resulting string, output any one of such strings; otherwise output "No" (without quotes, you can print letters in any case (upper or lower)).
Examples
Input
10 7
1.0.1.0.1.
Output
1000100010
Input
10 6
1.0.1.1000
Output
1001101000
Input
10 9
1........1
Output
No
Note
In the first example, 7 is not a period of the resulting string because the 1-st and 8-th characters of it are different.
In the second example, 6 is not a period of the resulting string because the 4-th and 10-th characters of it are different.
In the third example, 9 is always a period because the only constraint that the first and last characters are the same is already satisfied.
Note that there are multiple acceptable answers for the first two examples, you can print any of them.
Submitted Solution:
```
n, p = [int(i) for i in input().split()]
tides = input()
def is_periodic():
for i in range(n-p):
if tides[i] != tides[i+p]:
return False
return True
def main():
if n == p:
print(tides.replace('.', '0'))
return
ldot = tides.find('.')
rdot = tides.rfind('.')
tideslist = list(tides)
if ldot + p < n:
dot = ldot
notdot = ldot + p
elif rdot - p >= 0:
dot = rdot
notdot = rdot - p
else:
if is_periodic():
print('No')
else:
print(tides.replace('.', '0'))
return
if tides[notdot] == '.':
tideslist[notdot] = '0'
tideslist[dot] = '1'
elif tides[notdot] == '0':
tideslist[dot] = '1'
elif tides[notdot] == '1':
tideslist[dot] = '0'
else:
raise Exception()
print(''.join(tideslist).replace('.', '0'))
main()
``` | instruction | 0 | 63,735 | 4 | 127,470 |
No | output | 1 | 63,735 | 4 | 127,471 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book. | instruction | 0 | 64,165 | 4 | 128,330 |
Tags: implementation
Correct Solution:
```
total_remaining = int(input())
pages = list(map(int, input().split()))
day = 0
while total_remaining:
if total_remaining - pages[day % len(pages)] <= 0:
break
total_remaining -= pages[day % len(pages)]
day += 1
print((day % len(pages)) + 1)
``` | output | 1 | 64,165 | 4 | 128,331 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book. | instruction | 0 | 64,166 | 4 | 128,332 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = [int(x) for x in input().split()]
i = 0
while(1):
if(n<=a[i]):
print(i+1)
break
else:
n -= a[i]
i = (i+1)%7
``` | output | 1 | 64,166 | 4 | 128,333 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book. | instruction | 0 | 64,167 | 4 | 128,334 |
Tags: implementation
Correct Solution:
```
class Code:
def __init__(self):
self.n = int(input())
self.arr = list(map(int, input().split()))
def process(self):
flag = 0
while True:
for i, item in enumerate(self.arr):
self.n -= item
if self.n <= 0:
print(i + 1)
flag = 1
break
if flag == 1:
break
if __name__ == '__main__':
code = Code()
code.process()
``` | output | 1 | 64,167 | 4 | 128,335 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book. | instruction | 0 | 64,168 | 4 | 128,336 |
Tags: implementation
Correct Solution:
```
n=int(input())
List=list(map(int, input().split()))
for x in range(1, len(List)):
List[x]+=List[x-1]
for i in List:
if i>=n:
print(List.index(i)+1)
exit()
n%=List[-1]
if n==0:
n+=List[-1]
for i in List:
if i>=n:
print(List.index(i)+1)
exit()
``` | output | 1 | 64,168 | 4 | 128,337 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book. | instruction | 0 | 64,169 | 4 | 128,338 |
Tags: implementation
Correct Solution:
```
# http://codeforces.com/problemset/problem/139/A
TotalPages = int(input())
pages_per_day = [int(x) for x in input().split()]
i = 0
while(TotalPages>0):
if (i==7):
i = 0
TotalPages-=pages_per_day[i]
i+=1
print(i)
``` | output | 1 | 64,169 | 4 | 128,339 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book. | instruction | 0 | 64,170 | 4 | 128,340 |
Tags: implementation
Correct Solution:
```
n = int(input())
pages = [int(c) for c in input().split()]
read = 0
day = 0
while True:
for i in range(len(pages)):
read += pages[i]
if read >= n:
day = i + 1
break
if day != 0:
break
print(day)
``` | output | 1 | 64,170 | 4 | 128,341 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book. | instruction | 0 | 64,171 | 4 | 128,342 |
Tags: implementation
Correct Solution:
```
n = int(input())
a = [int(i) for i in input().split()]
s = 0
i = -1
while s < n:
i = (i+1)%7
s += a[i]
# print(s, i)
print(i+1)
``` | output | 1 | 64,171 | 4 | 128,343 |
Provide tags and a correct Python 3 solution for this coding contest problem.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book. | instruction | 0 | 64,172 | 4 | 128,344 |
Tags: implementation
Correct Solution:
```
def main():
n = int(input())
b = [int(i) for i in input().split(' ')]
ans = 0
while n > 0:
ans = ans % 7 + 1
n -= b[ans-1]
print(ans)
if __name__ == "__main__":
main()
``` | output | 1 | 64,172 | 4 | 128,345 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book.
Submitted Solution:
```
n=int(input())
a=[int(i) for i in input().split()]
x=0
while True:
n-=a[x]
if n<=0:
print(x+1)
break
if x==6:
x=0
else:
x+=1
``` | instruction | 0 | 64,173 | 4 | 128,346 |
Yes | output | 1 | 64,173 | 4 | 128,347 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book.
Submitted Solution:
```
n = int(input())
lst = [int(x) for x in input().split()]
day, tot = 0, 0
while tot<n:
tot+=lst[day%7]
day += 1
if day%7==0:
print(7)
else:
print(day%7)
``` | instruction | 0 | 64,174 | 4 | 128,348 |
Yes | output | 1 | 64,174 | 4 | 128,349 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book.
Submitted Solution:
```
n1 = int(input())
d = list(map(int,input().split()))
s = sum(d)
n = n1%s
if n==0:
n = n1//(n1//s)
i = 0
carry=0
while i<7 and n>0:
if carry+d[i]>=n:
print(i+1)
break
else:
carry+=d[i]
i+=1
else:
i = 0
carry=0
while i<7 and n>0:
if carry+d[i]>=n:
print(i+1)
break
else:
carry+=d[i]
i+=1
``` | instruction | 0 | 64,175 | 4 | 128,350 |
Yes | output | 1 | 64,175 | 4 | 128,351 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book.
Submitted Solution:
```
from itertools import cycle
def func_input(stin,pags):
if stin.isdigit() and pags:
if 1 <= int(stin) <= 1000 and len(pags) == 7:
pass
else:
print('Wrong range')
else:
print('Wrong input')
return stin, pags
def func_output(num,pages):
res = 0
for day, page in zip(cycle(range(1, 8)), cycle(pages)):
if 0 <= page <= 1000:
res += page
else:
print('Max number 1000, min 1' * 2)
if res >= int(num):
print(day)
break
stin_num = input()
pags_day = list(map(int,input().split()))
stin_num, pags_day = func_input(stin_num, pags_day)
func_output(stin_num,pags_day)
``` | instruction | 0 | 64,176 | 4 | 128,352 |
Yes | output | 1 | 64,176 | 4 | 128,353 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book.
Submitted Solution:
```
def under_one_week(arr,n):
s=0
c=1
for i in arr:
s+=i
if s>=n:
print(c)
return
c+=1
n = int(input())
arr = list(map(int,input().split()))
max_c = sum(arr)
if n<=max_c:
under_one_week(arr,n)
else:
com_w = n//max_c *7 if max_c !=1 else (n-1)*7
n =n - (n//max_c )*max_c if max_c !=1 else 1
s=0
c=1
for i in arr:
s+=i
if s>=n:
print(c)
break
c+=1
``` | instruction | 0 | 64,177 | 4 | 128,354 |
No | output | 1 | 64,177 | 4 | 128,355 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book.
Submitted Solution:
```
n = int(input())
l = [int(x) for x in input().split()]
ans = 6
while n <= 0:
ans = (ans + 1) % 7
n -= l[ans]
print(ans + 1)
``` | instruction | 0 | 64,178 | 4 | 128,356 |
No | output | 1 | 64,178 | 4 | 128,357 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book.
Submitted Solution:
```
n=int(input())
l=list(map(int,input().split()))
ans=0
i=0
while ans<n:
ans+=l[i]
i+=1
if(i==7):
i=0
print(i)
``` | instruction | 0 | 64,179 | 4 | 128,358 |
No | output | 1 | 64,179 | 4 | 128,359 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.
Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.
Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.
Input
The first input line contains the single integer n (1 β€ n β€ 1000) β the number of pages in the book.
The second line contains seven non-negative space-separated integers that do not exceed 1000 β those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.
Output
Print a single number β the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
Examples
Input
100
15 20 20 15 10 30 45
Output
6
Input
2
1 0 0 0 0 0 0
Output
1
Note
Note to the first sample:
By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).
Note to the second sample:
On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book.
Submitted Solution:
```
p = int(input())
days = list(map(int,input().split()))
week = sum(days)
p %= week
i = 0
while p>0:
p-= days[i]
i+=1
print (max(1,i))
``` | instruction | 0 | 64,180 | 4 | 128,360 |
No | output | 1 | 64,180 | 4 | 128,361 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100. | instruction | 0 | 64,521 | 4 | 129,042 |
Tags: implementation, math
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
k=l[1]-l[0]
p=0
for i in range(1,n-1):
if l[i+1]-l[i]!=k:
p=1
break
if p==0:
print(l[-1]+k)
else:
print(l[-1])
``` | output | 1 | 64,521 | 4 | 129,043 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100. | instruction | 0 | 64,522 | 4 | 129,044 |
Tags: implementation, math
Correct Solution:
```
input()
a = input().split()
s = []
for i in range(len(a) - 1):
s.append(int(a[i]) - int(a[i+1]))
if len(set(s)) == 1:
print(int(a[-1]) - int(s[0]))
else:
print(a[-1])
``` | output | 1 | 64,522 | 4 | 129,045 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100. | instruction | 0 | 64,523 | 4 | 129,046 |
Tags: implementation, math
Correct Solution:
```
import math
n = int(input())
a = list(map(int, input().split()))
d = a[1] - a[0]
ok = True
for i in range(1, n):
ok &= d == a[i] - a[i-1]
print(a[n-1]+d if ok else a[n-1])
``` | output | 1 | 64,523 | 4 | 129,047 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100. | instruction | 0 | 64,524 | 4 | 129,048 |
Tags: implementation, math
Correct Solution:
```
def isAp(a):
d = a[1] - a[0]
for i in range(1, len(a) - 1):
if d != a[i + 1] - a[i]:
return 0
return d
n = int(input())
a = [int(i) for i in input().split(' ')]
print(a[-1] + isAp(a))
``` | output | 1 | 64,524 | 4 | 129,049 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100. | instruction | 0 | 64,525 | 4 | 129,050 |
Tags: implementation, math
Correct Solution:
```
n=int(input())
nd=list(map(int, input().split()))
dis=False
temp=False
chuoi=True
for i in nd:
if not dis and not temp:
temp=i
elif not dis:
dis=i-temp
temp=i
elif i-temp!=dis:
chuoi=False
break
else:
temp=i
if chuoi:
print(nd[len(nd)-1]+dis)
else:
print(nd[len(nd)-1])
``` | output | 1 | 64,525 | 4 | 129,051 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100. | instruction | 0 | 64,526 | 4 | 129,052 |
Tags: implementation, math
Correct Solution:
```
x=input()
x=int(x)
re_temp=input()
re_temp = re_temp.split(" ")
temp=[]
for i in range(0,len(re_temp)):
temp.append(int(re_temp[i]))
check = temp[1]-temp[0]
conunter=0
for i in range (1,len(temp)-1):
if temp[i+1]-temp[i]== check:
conunter= conunter +1
if conunter== (len(temp)-2):
print(temp[len(temp)-1]+check)
else:
print(temp[len(temp)-1])
``` | output | 1 | 64,526 | 4 | 129,053 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100. | instruction | 0 | 64,527 | 4 | 129,054 |
Tags: implementation, math
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
if n == 1:
print(a[0])
elif n == 2:
print(a[1] + (a[1]-a[0]))
else:
f = True
d = a[1]-a[0]
for i in range(1, n):
if (a[i] - a[i-1] != d):
f = False
if f:
print(a[-1]+d)
else:
print(a[-1])
``` | output | 1 | 64,527 | 4 | 129,055 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100. | instruction | 0 | 64,528 | 4 | 129,056 |
Tags: implementation, math
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
k = a[1] - a[0]
tr = True
for i in range(2,n):
if k != a[i] - a[i-1]:
tr = False
if tr:
print(a[-1] + k)
else:
print(a[-1])
``` | output | 1 | 64,528 | 4 | 129,057 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100.
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
f = 1
if n == 2:
print(a[1] + (a[1] - a[0]))
else:
d1 = a[1] - a[0]
d2 = a[2] - a[1]
if d1 == d2:
for i in range(2, (n - 1)):
d1 = d2
d2 = a[i + 1] - a[i]
if d1 == d2:
continue
else:
f = 0
break
if f:
print(a[-1] + d2)
else:
print(a[-1])
else:
print(a[-1])
``` | instruction | 0 | 64,529 | 4 | 129,058 |
Yes | output | 1 | 64,529 | 4 | 129,059 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100.
Submitted Solution:
```
#847G
def is_ap(l):
d = l[1] - l[0]
for i in range(len(l)-1):
if l[i+1] - l[i] != d:
return False
return True
n = int(input())
t = list(map(int, input().split(" ")))
flag = 0
d = t[1] - t[0]
if is_ap(t):
flag = 1
print((t[0] + (n)*d) if flag == 1 else t[n-1])
``` | instruction | 0 | 64,530 | 4 | 129,060 |
Yes | output | 1 | 64,530 | 4 | 129,061 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100.
Submitted Solution:
```
n=int(input())
l=list(map(int,input().split()))
f=0
for i in range (2,len(l)):
if l[i]==l[i-1]+(l[1]-l[0]):
pass
else:
f=1
print(l[n-1])
break
if f==0:
if (l[n-1])==(l[0]+(n-1)*(l[1]-l[0])):
print(l[0]+(n*(l[1]-l[0])))
else:
print(l[n-1])
``` | instruction | 0 | 64,531 | 4 | 129,062 |
Yes | output | 1 | 64,531 | 4 | 129,063 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100.
Submitted Solution:
```
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(len(a)-1):
t=(a[i+1]-a[i])
b.append(t)
b1=set(b)
if len(b1)==1:
ans=(a[0]+n*b[0])
print(ans)
else:
print(a[n-1])
``` | instruction | 0 | 64,532 | 4 | 129,064 |
Yes | output | 1 | 64,532 | 4 | 129,065 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100.
Submitted Solution:
```
n=int(input())
a=[*map(int,input().split())]
b,c,*_=a
*_,d,e=a
print(e+(c-b)*(e-d==c-b))
``` | instruction | 0 | 64,533 | 4 | 129,066 |
No | output | 1 | 64,533 | 4 | 129,067 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100.
Submitted Solution:
```
input(); *a, b, c = input().split()
print(2 * int(c) - int(b))
``` | instruction | 0 | 64,534 | 4 | 129,068 |
No | output | 1 | 64,534 | 4 | 129,069 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100.
Submitted Solution:
```
n = int(input())
z=[]
a=list(map(int,input().split()))
d=a[1]-a[0]
for i in range(n):
z.append(a[i]-a[i-1])
x=len(set(z))
if x==1:
print(a[-1]+d)
else:
print(a[-1])
``` | instruction | 0 | 64,535 | 4 | 129,070 |
No | output | 1 | 64,535 | 4 | 129,071 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the first term equals to the average temperature on the first day, the second term equals to the average temperature on the second day and so on, then the average temperature of the next (n + 1)-th day will be equal to the next term of the arithmetic progression. Otherwise, according to Vasya's method, the temperature of the (n + 1)-th day will be equal to the temperature of the n-th day.
Your task is to help Vasya predict the average temperature for tomorrow, i. e. for the (n + 1)-th day.
Input
The first line contains a single integer n (2 β€ n β€ 100) β the number of days for which the average air temperature is known.
The second line contains a sequence of integers t1, t2, ..., tn ( - 1000 β€ ti β€ 1000) β where ti is the average temperature in the i-th day.
Output
Print the average air temperature in the (n + 1)-th day, which Vasya predicts according to his method. Note that the absolute value of the predicted temperature can exceed 1000.
Examples
Input
5
10 5 0 -5 -10
Output
-15
Input
4
1 1 1 1
Output
1
Input
3
5 1 -5
Output
-5
Input
2
900 1000
Output
1100
Note
In the first example the sequence of the average temperatures is an arithmetic progression where the first term is 10 and each following terms decreases by 5. So the predicted average temperature for the sixth day is - 10 - 5 = - 15.
In the second example the sequence of the average temperatures is an arithmetic progression where the first term is 1 and each following terms equals to the previous one. So the predicted average temperature in the fifth day is 1.
In the third example the average temperatures do not form an arithmetic progression, so the average temperature of the fourth day equals to the temperature of the third day and equals to - 5.
In the fourth example the sequence of the average temperatures is an arithmetic progression where the first term is 900 and each the following terms increase by 100. So predicted average temperature in the third day is 1000 + 100 = 1100.
Submitted Solution:
```
def weatom(s=[]):
n=len(s)
if(n==1):
return s[0]
elif(n==2):
return (s[1] + (s[1]-s[0]))
else:
d=s[1]-s[0]
for i in range(2,n):
if((s[i]-s[i-1])==d):
if(i==n-1):
return (s[i] + d)
continue
else:
return s[i]
def main():
t=input()
t=int(t)
s=[int(x) for x in input().strip().split()]
print(weatom(s))
if __name__=="__main__":
main()
``` | instruction | 0 | 64,536 | 4 | 129,072 |
No | output | 1 | 64,536 | 4 | 129,073 |
Provide tags and a correct Python 3 solution for this coding contest problem.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing. | instruction | 0 | 64,552 | 4 | 129,104 |
Tags: implementation
Correct Solution:
```
def main():
[n, s] = [int(i) for i in input().split()]
times = []
for i in range(n):
[hour, minute] = [int(i) for i in input().split()]
times.append(hour * 60 + minute)
ans = earliest(times, s)
hour = ans // 60
minute = ans % 60
print(hour, minute)
def earliest(times, s):
n = len(times)
if times[0] >= s + 1:
return 0
for i in range(n - 1):
bef = times[i]
aft = times[i + 1]
if aft - bef >= 2 * s + 2:
return bef + s + 1
return times[n - 1] + s + 1
if __name__ == "__main__":
main()
``` | output | 1 | 64,552 | 4 | 129,105 |
Provide tags and a correct Python 3 solution for this coding contest problem.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing. | instruction | 0 | 64,553 | 4 | 129,106 |
Tags: implementation
Correct Solution:
```
n,S=map(int,input().split())
s=S*2+1
h1,m1=map(int,input().split())
if h1*60+m1>S:res=0
else:res=-1
lst,mas=[h1*60+m1],[[h1,m1]]
for i in range(n-1):
h2,m2=map(int,input().split())
mas.append([h2,m2])
diff=h2*60+m2
lst.append(diff)
if res==-1:
for i in range(n-1):
x=lst[i+1]-lst[i]
if x-s-1>=0:res=lst[i]+S+1;break
if res==-1:res=lst[-1]+S+1
print(res//60,res%60)
else:print(0,0)
``` | output | 1 | 64,553 | 4 | 129,107 |
Provide tags and a correct Python 3 solution for this coding contest problem.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing. | instruction | 0 | 64,554 | 4 | 129,108 |
Tags: implementation
Correct Solution:
```
ans=0
tem=0
tem=int(tem)
ans=int(ans)
n,s = input().split()
n,s = [int(n),int(s)]
for x in range(0,n):
h, m = input().split()
h, m = [int(h), int(m)]
tem = 60 * h + m;
if (ans + s) < tem:
break;
ans = tem + s + 1;
print(int(ans/60),int(ans%60))
``` | output | 1 | 64,554 | 4 | 129,109 |
Provide tags and a correct Python 3 solution for this coding contest problem.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing. | instruction | 0 | 64,555 | 4 | 129,110 |
Tags: implementation
Correct Solution:
```
#Zadacha 2
n,s=map(int,input().split())
timetable=[0,0]
for i in range(0,n):
h,m=map(int,input().split())
timetable.append(h)
timetable.append(m)
#schitali input. Odd = h even = m.
for i in range(0,n):
gap=(timetable[2*(i+1)]*60+timetable[2*(i+1)+1]-timetable[2*(i)]*60-timetable[2*(i)+1])
if gap>=(2*s+2):
ans=timetable[2*(i)]*60+timetable[2*(i)+1]+s+1
break
else: ans=timetable[2*(i+1)]*60+timetable[2*(i+1)+1]+s+1
if (timetable[2]*60+timetable[3])>=(s+1):
ans=0
h=ans//60
m=ans%60
print(h,m)
``` | output | 1 | 64,555 | 4 | 129,111 |
Provide tags and a correct Python 3 solution for this coding contest problem.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing. | instruction | 0 | 64,556 | 4 | 129,112 |
Tags: implementation
Correct Solution:
```
import math
n, s = [int(x) for x in input().split()]
arr = list()
for i in range(0,n):
x, y = [int(x) for x in input().split()]
arr.append(60*x + y)
ans = arr[n - 1] + s + 1
if arr[0] <= s:
for i in range(1,n):
if arr[i] - (arr[i - 1] + 1 + s) > s:
ans = arr[i - 1] + s + 1
break
else:
ans = 0
print(int(ans/60), ans % 60)
``` | output | 1 | 64,556 | 4 | 129,113 |
Provide tags and a correct Python 3 solution for this coding contest problem.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing. | instruction | 0 | 64,557 | 4 | 129,114 |
Tags: implementation
Correct Solution:
```
import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int,minp().split())
n,s = mints()
a = []
for i in range(n):
h,m = mints()
a.append(h*60+m)
if a[0] >= s+1:
print(0, 0)
else:
for i in range(n-1):
if a[i+1]-a[i]-1 >= s*2+1:
print((a[i]+s+1)//60,(a[i]+s+1)%60)
exit(0)
print((a[-1]+1+s)//60,(a[-1]+1+s)%60)
``` | output | 1 | 64,557 | 4 | 129,115 |
Provide tags and a correct Python 3 solution for this coding contest problem.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing. | instruction | 0 | 64,558 | 4 | 129,116 |
Tags: implementation
Correct Solution:
```
n,s=map(int,input().split())
t=[]
for i in range(n):
h,m=map(int,input().split())
t.append(60*h+m)
x,y=0,0
if t[0]<s+1:
for i in range(n-1):
if t[i+1]-t[i]>=2*s+2:
x=t[i]+s+1
break
if x==0:
x=t[n-1]+s+1
y=x%60
x=x//60
print(x,y)
``` | output | 1 | 64,558 | 4 | 129,117 |
Provide tags and a correct Python 3 solution for this coding contest problem.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing. | instruction | 0 | 64,559 | 4 | 129,118 |
Tags: implementation
Correct Solution:
```
a = True
n, s = [int(x) for x in input().split()]
ph, pm = [int(x) for x in input().split()]
if ph*60 + pm >= s+1:
print(0, 0)
a = False
exit()
for x in range(n - 1):
h, m = [int(x) for x in input().split()]
if h*60+m >= ph*60+pm + 2 + 2 * s:
print((ph*60+pm+s+1) // 60, (ph*60+pm+s+1) % 60)
a = False
break
else:
ph = h
pm = m
if a:
print((ph*60+pm+s+1) // 60, (ph*60+pm+s+1) % 60)
``` | output | 1 | 64,559 | 4 | 129,119 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing.
Submitted Solution:
```
n, s = [int(x) for x in input().split(" ")]
last = 0
found = False
rng = 2 * s + 2
first = s + 1
f = False
ff = False
for _ in range(n):
h, m = [int(x) for x in input().split(" ")]
x = h * 60 + m
if not f:
if abs(x - last) >= first:
found = True
ff = True
else:
last = x
elif not found:
if abs(x - last) >= rng:
found = True
else:
last = x
f = True
# if found:
if ff:
print(0, 0)
else:
res = last + s + 1
print("{} {}".format(res // 60, res % 60))
# else:
# print()
``` | instruction | 0 | 64,560 | 4 | 129,120 |
Yes | output | 1 | 64,560 | 4 | 129,121 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing.
Submitted Solution:
```
from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations
from math import gcd, floor, inf, log2, sqrt, log10
from bisect import bisect_right, bisect_left
n, t = map(int, input().split())
prev = 0
ans = -1
first = True
for _ in range(n):
hour, minute = map(int, input().split())
cur = hour*60 + minute
if first:
if cur > t:
ans = 0
break
first = False
if cur - prev >= t * 2+1:
# print(cur-prev)
# print(t*2+1)
ans = prev + t
break
else:
prev = cur+1
if ans == -1:
ans = cur + t+1
print(ans//60, ans%60)
``` | instruction | 0 | 64,561 | 4 | 129,122 |
Yes | output | 1 | 64,561 | 4 | 129,123 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing.
Submitted Solution:
```
n,s = map(int,input().split())
temp,ans = 0,False
for _ in range(n):
h,m = map(int,input().split())
if not ans:
# print(temp)
diff = (h*60+m)-(temp+1)
# print(diff)
if diff >= s:
ans = True
else:
temp = (h*60+m)+ s+1
print(temp//60,temp%60)
``` | instruction | 0 | 64,562 | 4 | 129,124 |
Yes | output | 1 | 64,562 | 4 | 129,125 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing.
Submitted Solution:
```
n, s = map(int, input().split())
t = []
for _ in range(n):
x = input().split()
t.append(int(x[0]) * 60 + int(x[1]))
if t[0] >= s + 1:
print(0, 0)
else:
for i in range(n - 1):
if t[i] + 2 * (s + 1) <= t[i + 1]:
print((t[i] + s + 1) // 60, (t[i] + s + 1) % 60)
break
else:
print((t[-1] + s + 1) // 60, (t[-1] + s + 1) % 60)
``` | instruction | 0 | 64,563 | 4 | 129,126 |
Yes | output | 1 | 64,563 | 4 | 129,127 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was asked to insert one takeoff in the schedule. The takeoff takes 1 minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least s minutes from both sides.
Find the earliest time when Arkady can insert the takeoff.
Input
The first line of input contains two integers n and s (1 β€ n β€ 100, 1 β€ s β€ 60) β the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff.
Each of next n lines contains two integers h and m (0 β€ h β€ 23, 0 β€ m β€ 59) β the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is 0 0). These times are given in increasing order.
Output
Print two integers h and m β the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.
Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
Note
In the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.
In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than 24 hours to insert the takeoff.
In the third example Arkady can insert the takeoff even between the first landing.
Submitted Solution:
```
n, s = map(int, input().split())
time = []
fl = False
for i in range(n):
h, m = map(int, input().split())
time.append(h * 60 + m + 1)
if time[0] - 2 >= s:
print(0, 0)
fl = True
if not fl:
for i in range(len(time) - 1):
x = (time[i + 1] - 1 + time[i]) // 2
new = time[i] + s
if abs(time[i + 1] - new - 2) >= s and abs(time[i] - new) >= s:
print(new // 60, new - new // 60 * 60)
fl = True
break
if not fl:
ans = time[-1] + s
print(ans // 60, ans - ans // 60 * 60)
``` | instruction | 0 | 64,564 | 4 | 129,128 |
No | output | 1 | 64,564 | 4 | 129,129 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.