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.
The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meeting. So, in order to settle the meeting date, the chairperson requested every member to send back a list of convenient dates by E-mail. Your mission is to help the chairperson, who is now dedicated to other issues of the contest, by writing a program that chooses the best date from the submitted lists. Your program should find the date convenient for the most members. If there is more than one such day, the earliest is the best.
Input
The input has multiple data sets, each starting with a line containing the number of committee members and the quorum of the meeting.
> N Q
Here, N, meaning the size of the committee, and Q meaning the quorum, are positive integers. N is less than 50, and, of course, Q is less than or equal to N.
N lines follow, each describing convenient dates for a committee member in the following format.
> M Date1 Date2 ... DateM
Here, M means the number of convenient dates for the member, which is an integer greater than or equal to zero. The remaining items in the line are his/her dates of convenience, which are positive integers less than 100, that is, 1 means tomorrow, 2 means the day after tomorrow, and so on. They are in ascending order without any repetition and separated by a space character. Lines have neither leading nor trailing spaces.
A line containing two zeros indicates the end of the input.
Output
For each data set, print a single line containing the date number convenient for the largest number of committee members. If there is more than one such date, print the earliest. However, if no dates are convenient for more than or equal to the quorum number of members, print 0 instead.
Example
Input
3 2
2 1 4
0
3 3 4 8
3 2
4 1 5 8 9
3 2 5 9
5 2 4 5 7 9
3 3
2 1 4
3 2 5 9
2 2 4
3 3
2 1 2
3 1 2 9
2 2 4
0 0
Output
4
5
0
2
Submitted Solution:
```
while True:
n, q = map(int, input().split())
if n == 0:
break
data = [list(map(int, input().split())) for i in range(n)]
for li in data:
if li[0] > 0:
del(li[0])
q -= 1
day = 0
for d in range(100):
cnt = 0
for li in data:
if d in li:
cnt += 1
if cnt > q:
q = cnt
day = d
print(day)
``` | instruction | 0 | 56,368 | 4 | 112,736 |
No | output | 1 | 56,368 | 4 | 112,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meeting. So, in order to settle the meeting date, the chairperson requested every member to send back a list of convenient dates by E-mail. Your mission is to help the chairperson, who is now dedicated to other issues of the contest, by writing a program that chooses the best date from the submitted lists. Your program should find the date convenient for the most members. If there is more than one such day, the earliest is the best.
Input
The input has multiple data sets, each starting with a line containing the number of committee members and the quorum of the meeting.
> N Q
Here, N, meaning the size of the committee, and Q meaning the quorum, are positive integers. N is less than 50, and, of course, Q is less than or equal to N.
N lines follow, each describing convenient dates for a committee member in the following format.
> M Date1 Date2 ... DateM
Here, M means the number of convenient dates for the member, which is an integer greater than or equal to zero. The remaining items in the line are his/her dates of convenience, which are positive integers less than 100, that is, 1 means tomorrow, 2 means the day after tomorrow, and so on. They are in ascending order without any repetition and separated by a space character. Lines have neither leading nor trailing spaces.
A line containing two zeros indicates the end of the input.
Output
For each data set, print a single line containing the date number convenient for the largest number of committee members. If there is more than one such date, print the earliest. However, if no dates are convenient for more than or equal to the quorum number of members, print 0 instead.
Example
Input
3 2
2 1 4
0
3 3 4 8
3 2
4 1 5 8 9
3 2 5 9
5 2 4 5 7 9
3 3
2 1 4
3 2 5 9
2 2 4
3 3
2 1 2
3 1 2 9
2 2 4
0 0
Output
4
5
0
2
Submitted Solution:
```
#!/usr/bin/python
# -*- coding: utf-8 -*-
while True:
amount, require = map(int, input().split())
if amount == require == 0: break
dates = []
for _ in range(amount):
date = list(map(int, input().split()))
if not date.pop(0) == 0:
# print("Appending date ... {0}".format(date))
dates.append(date)
else:
dates.append([0])
# print("date list: {0}".format(dates))
max_d = 0
for date in dates:
if max(date) >= max_d:
max_d = max(date)
meet_count = 0
can_meet = False
x_day = 0
for day in range(1, max_d):
meet_count = 0
for date in dates:
# print("Investing date: {0}".format(date))
if day in date:
# print("day {0} is in date {1}.".format(day, date))
meet_count += 1
if meet_count >= require:
# print("{0} people can meet in the day {1}.".format(meet_count, day))
if day > x_day:
x_day = day
can_meet = True
if can_meet:
print(x_day)
else:
print(0)
``` | instruction | 0 | 56,369 | 4 | 112,738 |
No | output | 1 | 56,369 | 4 | 112,739 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The year 2015 is almost over.
Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system — 201510 = 111110111112. Note that he doesn't care about the number of zeros in the decimal representation.
Limak chose some interval of years. He is going to count all years from this interval that have exactly one zero in the binary representation. Can you do it faster?
Assume that all positive integers are always written without leading zeros.
Input
The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 1018) — the first year and the last year in Limak's interval respectively.
Output
Print one integer – the number of years Limak will count in his chosen interval.
Examples
Input
5 10
Output
2
Input
2015 2015
Output
1
Input
100 105
Output
0
Input
72057594000000000 72057595000000000
Output
26
Note
In the first sample Limak's interval contains numbers 510 = 1012, 610 = 1102, 710 = 1112, 810 = 10002, 910 = 10012 and 1010 = 10102. Two of them (1012 and 1102) have the described property.
Submitted Solution:
```
def z(n):
n = bin(n)[2:]
k = len(n)
s = (k-1) * (k-2) // 2 + (n.count("0") == 1)
r = n.find("0")
s += k if r == -1 else r
return s - 1;
a, b = map(int, input().split());
print (z(b) - z(a - 1))
``` | instruction | 0 | 56,746 | 4 | 113,492 |
Yes | output | 1 | 56,746 | 4 | 113,493 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The year 2015 is almost over.
Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system — 201510 = 111110111112. Note that he doesn't care about the number of zeros in the decimal representation.
Limak chose some interval of years. He is going to count all years from this interval that have exactly one zero in the binary representation. Can you do it faster?
Assume that all positive integers are always written without leading zeros.
Input
The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 1018) — the first year and the last year in Limak's interval respectively.
Output
Print one integer – the number of years Limak will count in his chosen interval.
Examples
Input
5 10
Output
2
Input
2015 2015
Output
1
Input
100 105
Output
0
Input
72057594000000000 72057595000000000
Output
26
Note
In the first sample Limak's interval contains numbers 510 = 1012, 610 = 1102, 710 = 1112, 810 = 10002, 910 = 10012 and 1010 = 10102. Two of them (1012 and 1102) have the described property.
Submitted Solution:
```
def f(x):
res = 0
for i in range(64):
for j in range(i + 1, 64):
t = 0
for k in range(j + 1):
if k != i:
t += 1 << k
if t <= x:
res += 1
return res
def main():
a, b = [int(i) for i in input().split()]
print(f(b) - f(a - 1))
main()
``` | instruction | 0 | 56,747 | 4 | 113,494 |
Yes | output | 1 | 56,747 | 4 | 113,495 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The year 2015 is almost over.
Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system — 201510 = 111110111112. Note that he doesn't care about the number of zeros in the decimal representation.
Limak chose some interval of years. He is going to count all years from this interval that have exactly one zero in the binary representation. Can you do it faster?
Assume that all positive integers are always written without leading zeros.
Input
The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 1018) — the first year and the last year in Limak's interval respectively.
Output
Print one integer – the number of years Limak will count in his chosen interval.
Examples
Input
5 10
Output
2
Input
2015 2015
Output
1
Input
100 105
Output
0
Input
72057594000000000 72057595000000000
Output
26
Note
In the first sample Limak's interval contains numbers 510 = 1012, 610 = 1102, 710 = 1112, 810 = 10002, 910 = 10012 and 1010 = 10102. Two of them (1012 and 1102) have the described property.
Submitted Solution:
```
#!/usr/bin/env python3
def isPow2(v):
return (v & (v - 1)) == 0
def roundUpToHole(n):
next_pow_2 = 2**(n.bit_length()) - 1
rem = next_pow_2 - n
if rem == 0:
return n + (next_pow_2+1) - (next_pow_2+1) // 2
rem2 = 2**(rem.bit_length()-1)
n2 = next_pow_2 - rem
return n2
a, b = map(int, input().split())
i = roundUpToHole(a)
bitlen = i.bit_length()
count = 0
while i <= b:
#print(':', i, bin(i))
count += 1
next_pow_2 = 2**bitlen - 1
rem = next_pow_2 - i
#assert isPow2(rem)
if rem > 1:
i += rem
i -= rem // 2
elif rem == 1:
#print('darn', i, rem, next_pow_2)
i += rem
i += (next_pow_2+1)
i -= (next_pow_2+1)//2
#print('darn2', i)
bitlen += 1
else:
assert False
print(count)
``` | instruction | 0 | 56,753 | 4 | 113,506 |
No | output | 1 | 56,753 | 4 | 113,507 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution | instruction | 0 | 56,770 | 4 | 113,540 |
Tags: brute force, greedy, implementation
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
n = int(ri())
lis = []
for i in range(n):
temp = ri()
temp = [i for i in temp]
lis.append(temp)
lis= [['1','0','0','0']]+lis
# print(lis)
flag = True
for i in range(1, n+1):
totans = []
for j in range(4):
temp = lis[i][:]
for k in range(0, 10):
temp[j] = chr(ord('0') + k)
if temp >= lis[i-1]:
if len(totans) == 0:
totans = temp[:]
else:
if temp < totans :
totans = temp[:]
if len(totans) == 0:
flag = False
break
else:
lis[i] = totans[:]
# print(lis)
if not flag :
print("No solution")
else:
if lis[-1] <= ['2','0','1','1']:
for i in range(1, n+1):
print("".join(lis[i]))
else:
print("No solution")
``` | output | 1 | 56,770 | 4 | 113,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution | instruction | 0 | 56,771 | 4 | 113,542 |
Tags: brute force, greedy, implementation
Correct Solution:
```
def f(t, s):
r = '2012'
x, y = '1' + t[1: ], '2' + t[1: ]
if x >= s: r = x
elif r > y >= s: r = y
if t[0] > '2': return r
for i in range(1, 4):
a, b = t[: i], t[i + 1: ]
x, y = a + '0' + b, a + '9' + b
if y >= s and x < r:
if x < s:
x = a + s[i] + b
if x < s: x = a + str(int(s[i]) + 1) + b
r = x
return r
n = int(input())
t = ['2012'] * n
t[0] = f(input(), '1000')
for i in range(1, n):
t[i] = f(input(), t[i - 1])
if t[i] == '2012': break
if t[n - 1] == '2012': print('No solution')
else: print('\n'.join(t))
``` | output | 1 | 56,771 | 4 | 113,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution | instruction | 0 | 56,772 | 4 | 113,544 |
Tags: brute force, greedy, implementation
Correct Solution:
```
n=int(input())
a=[]
for _ in range(n):
a.append(input())
prev="1000"
z=1
for i in range(n):
l=''
for j in range(4):
x=list(a[i][:])
for k in range(10):
x[j]=chr(k+ord('0'))
check=''.join(r for r in x)
if int(check)>=int(prev):
if len(l)==0:
l=check
else:
if int(check)<int(l):
l=check
a[i]=''.join(r for r in l)
if int(a[i])>2011 or int(a[i])<int(prev):
z=0
break;
prev=a[i]
if z==1:
for i in a:
print(i)
#print(a)
else:
#print(a)
print("No solution")
``` | output | 1 | 56,772 | 4 | 113,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution | instruction | 0 | 56,773 | 4 | 113,546 |
Tags: brute force, greedy, implementation
Correct Solution:
```
n,a,ans,last=int(input()),[],[],1000
for i in range(n):a.append(input())
for d in a:
minoverd=10000000
for i in range(10):
for j in range(i==0,5):
t=int(d[:j]+str(i)+d[j+1:])
if minoverd>t>=last:minoverd=t
ans.append(str(minoverd))
if minoverd>2011:break
last=minoverd
if minoverd>2011:
print("No solution")
else:
print(*ans)
``` | output | 1 | 56,773 | 4 | 113,547 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution | instruction | 0 | 56,774 | 4 | 113,548 |
Tags: brute force, greedy, implementation
Correct Solution:
```
n = int(input())
l = []
for i in range(n):
l.append(int(input()))
def repair(x, y, r):
if(r == 0):
return x
z = (x % (10 * r)) // r - (y % (10 * r)) // r
if(z == 0):
return repair(x, y, r // 10)
if(x % r >= y % r):
return x - z * r
else:
if(z != 1):
return x - z * r + r
return x - x % r + (x % r) % (10 ** (len(str(x % r)) - 1))
y = 1000
try:
for i in range(n):
l[i] = repair(l[i], y, 1000)
if(l[i] > 2011):
raise Exception()
y = l[i]
for i in l:
print(i)
except:
print("No solution")
``` | output | 1 | 56,774 | 4 | 113,549 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution | instruction | 0 | 56,775 | 4 | 113,550 |
Tags: brute force, greedy, implementation
Correct Solution:
```
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
threading.stack_size(10**8)
sys.setrecursionlimit(300000)
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#-------------------game starts now-----------------------------------------------------
class Factorial:
def __init__(self, MOD):
self.MOD = MOD
self.factorials = [1, 1]
self.invModulos = [0, 1]
self.invFactorial_ = [1, 1]
def calc(self, n):
if n <= -1:
print("Invalid argument to calculate n!")
print("n must be non-negative value. But the argument was " + str(n))
exit()
if n < len(self.factorials):
return self.factorials[n]
nextArr = [0] * (n + 1 - len(self.factorials))
initialI = len(self.factorials)
prev = self.factorials[-1]
m = self.MOD
for i in range(initialI, n + 1):
prev = nextArr[i - initialI] = prev * i % m
self.factorials += nextArr
return self.factorials[n]
def inv(self, n):
if n <= -1:
print("Invalid argument to calculate n^(-1)")
print("n must be non-negative value. But the argument was " + str(n))
exit()
p = self.MOD
pi = n % p
if pi < len(self.invModulos):
return self.invModulos[pi]
nextArr = [0] * (n + 1 - len(self.invModulos))
initialI = len(self.invModulos)
for i in range(initialI, min(p, n + 1)):
next = -self.invModulos[p % i] * (p // i) % p
self.invModulos.append(next)
return self.invModulos[pi]
def invFactorial(self, n):
if n <= -1:
print("Invalid argument to calculate (n^(-1))!")
print("n must be non-negative value. But the argument was " + str(n))
exit()
if n < len(self.invFactorial_):
return self.invFactorial_[n]
self.inv(n) # To make sure already calculated n^-1
nextArr = [0] * (n + 1 - len(self.invFactorial_))
initialI = len(self.invFactorial_)
prev = self.invFactorial_[-1]
p = self.MOD
for i in range(initialI, n + 1):
prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p
self.invFactorial_ += nextArr
return self.invFactorial_[n]
class Combination:
def __init__(self, MOD):
self.MOD = MOD
self.factorial = Factorial(MOD)
def ncr(self, n, k):
if k < 0 or n < k:
return 0
k = min(k, n - k)
f = self.factorial
return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
#-------------------------------------------------------------------------
n = int(input())
lis = []
for i in range(n):
temp = input()
lis.append(list(temp))
lis= [['1','0','0','0']]+lis
# print(lis)
flag = True
for i in range(1, n+1):
totans = []
for j in range(4):
temp = lis[i][:]
for k in range(0, 10):
temp[j] = chr(ord('0') + k)
if temp >= lis[i-1]:
if len(totans) == 0:
totans = temp[:]
else:
if temp < totans :
totans = temp[:]
if len(totans) == 0:
flag = False
break
else:
lis[i] = totans[:]
# print(lis)
if not flag :
print("No solution")
else:
if lis[-1] <= ['2','0','1','1']:
for i in range(1, n+1):
print("".join(lis[i]))
else:
print("No solution")
``` | output | 1 | 56,775 | 4 | 113,551 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution | instruction | 0 | 56,776 | 4 | 113,552 |
Tags: brute force, greedy, implementation
Correct Solution:
```
n = int(input())
values = [ 1000, 100, 10, 1 ]
ranges = [ [1, 2], range(10), range(10), range(10) ]
def attempt(previous, digits, x):
least = None
for i in range(4):
for d in ranges[i]:
y = x + (d - digits[i]) * values[i]
if y <= 2011 and y >= previous and (least == None or y < least):
least = y
return least
previous = 0
result = []
for i in range(n):
s = input()
digits = list(map(int, list(s)))
x = int(s)
y = attempt(previous, digits, x)
if y == None:
print('No solution')
import sys; sys.exit()
result.append(y)
previous = y
print('\n'.join(map(str, result)))
``` | output | 1 | 56,776 | 4 | 113,553 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution | instruction | 0 | 56,777 | 4 | 113,554 |
Tags: brute force, greedy, implementation
Correct Solution:
```
import sys
n = int(input())
d = []
for i in range(n):
d.append(input())
ans = []
bad = 'No solution'
low = 1000
for date in d:
lowest = 100500
for i in range(10):
for j in range(i == 0, 5):
changed = date[:j] + str(i) + date[j + 1:]
if lowest > int(changed) >= low:
lowest = int(changed)
if lowest > 2011:
print(bad)
sys.exit(0)
ans.append(str(lowest))
low = lowest
print('\n'.join(ans))
# Made By Mostafa_Khaled
``` | output | 1 | 56,777 | 4 | 113,555 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution
Submitted Solution:
```
import sys
n = int(input())
d = []
for i in range(n):
d.append(input())
ans = []
bad = 'No solution'
low = 1000
for date in d:
lowest = 100500
for i in range(10):
for j in range(i == 0, 5):
changed = date[:j] + str(i) + date[j + 1:]
if lowest > int(changed) >= low:
lowest = int(changed)
if lowest > 2011:
print(bad)
sys.exit(0)
ans.append(str(lowest))
low = lowest
print('\n'.join(ans))
``` | instruction | 0 | 56,778 | 4 | 113,556 |
Yes | output | 1 | 56,778 | 4 | 113,557 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution
Submitted Solution:
```
n=int(input())
a=[]
for _ in range(n):
a.append(input())
prev="1000"
z=1
for i in range(n):
x=list(a[i])
if int(a[i])<1000:
z=0
break;
for j in range(4):
if x[j]!='0' and prev[j]<x[j]:
x[j]=chr(ord(prev[j])+1)
r1=''.join(r for r in x)
r1=int(r1)
x[j]=chr(ord(prev[j]))
r2=''.join(r for r in x)
r2=int(r2)
if r2<int(prev):
x[j]=chr(ord(prev[j])+1)
break;
a[i]=''.join(r for r in x);
if int(a[i])>2011:
z=0
break;
prev=a[i]
if z==1:
for i in a:
print(i)
else:
print("No solution")
``` | instruction | 0 | 56,779 | 4 | 113,558 |
No | output | 1 | 56,779 | 4 | 113,559 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution
Submitted Solution:
```
n=int(input())
a=[]
for _ in range(n):
a.append(input())
prev="1000"
z=1
for i in range(n):
x=list(a[i])
for j in range(4):
if x[j]!=prev[j]:
done=0
temp=x[j]
for k in range(10):
x[j]=chr(k+ord('0'))
check=''.join(r for r in x)
if int(check)>=int(prev):
done=1
break;
if done==1 and temp!=x[j]:
break
a[i]=''.join(r for r in x)
if int(a[i])>2011:
z=0
break;
prev=a[i]
if z==1:
"""for i in a:
print(i)"""
print(a)
else:
#print(a)
print("No solution")
``` | instruction | 0 | 56,780 | 4 | 113,560 |
No | output | 1 | 56,780 | 4 | 113,561 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution
Submitted Solution:
```
import time
startTimeProblem=time.time()
import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *
def lcm(a, b):
return (a*b)/gcd(a, b)
class InputHelper:
def __init__(self):
self.myinput = fileinput.input()
def isLocal(self):
return not fileinput.isstdin()
def int(self):
return int(self.myinput.readline().rstrip())
def ints(self):
return [int(_) for _ in self.myinput.readline().rstrip().split()]
def str(self):
return self.myinput.readline().rstrip()
def strs(self):
return [_ for _ in self.myinput.readline().rstrip().split()]
class OutputHelper:
def int(self, a):
print(a)
def ints(self, a):
print(" ".join([str(_) for _ in a]))
def intsNL(self, a):
for _ in a:
print(_)
def str(self, s):
print(s)
def strs(self, s):
print(" ".join([_ for _ in s]))
def strsNL(self, s):
for st in s:
print(st)
class ListNode:
def __init__(self, val):
self.val = val
self.next = None
self.prev = None
In = InputHelper()
Out = OutputHelper()
######################################
n = In.int()
dates = [0]*n
for _ in range(n):
dates[_] = In.str()
def smallestPossible(number):
for i in range(len(number)):
if i==0:
if number[i]!="1":
return "1"+number[1::]
else:
if number[i]!="0":
return number[0:i]+"0"+number[i+1::]
return number
def smallestPossibleGreater(i, dates):
prevInt = dates[i-1]
prevNoInt = dates[i]
there = [int(dates[i])]
for j in range(4):
availNumbers = ["1","2","3","4","5","6","7","8","9"]
if j != 0:
availNumbers = ["0"] + availNumbers
for numb in availNumbers:
res = prevNoInt[0:j]+numb+prevNoInt[j+1::]
res = int(res)
if 1000<=res<=2011:
there.append(int(res))
there.sort()
idx = bisect_left(there, prevInt)
if idx==len(there):
return False
dates[i] = there[idx]
return True
dates[0] = smallestPossible(dates[0])
dates[0] = int(dates[0])
noproblem = True
for i in range(1, len(dates)):
noproblem = smallestPossibleGreater(i, dates)
if noproblem:
for d in dates:
Out.int(d)
else:
Out.str("No solution")
######################################
if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
fin = (time.time()-startTimeProblem)*1000
print("{:.2f}".format(fin) + "ms")
``` | instruction | 0 | 56,781 | 4 | 113,562 |
No | output | 1 | 56,781 | 4 | 113,563 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The History of Magic is perhaps the most boring subject in the Hogwarts school of Witchcraft and Wizardry. Harry Potter is usually asleep during history lessons, and his magical quill writes the lectures for him. Professor Binns, the history of magic teacher, lectures in such a boring and monotonous voice, that he has a soporific effect even on the quill. That's why the quill often makes mistakes, especially in dates.
So, at the end of the semester Professor Binns decided to collect the students' parchments with notes and check them. Ron Weasley is in a panic: Harry's notes may contain errors, but at least he has some notes, whereas Ron does not have any. Ronald also has been sleeping during the lectures and his quill had been eaten by his rat Scabbers. Hermione Granger refused to give Ron her notes, because, in her opinion, everyone should learn on their own. Therefore, Ron has no choice but to copy Harry's notes.
Due to the quill's errors Harry's dates are absolutely confused: the years of goblin rebellions and other important events for the wizarding world do not follow in order, and sometimes even dates from the future occur. Now Ron wants to change some of the digits while he copies the notes so that the dates were in the chronological (i.e. non-decreasing) order and so that the notes did not have any dates strictly later than 2011, or strictly before than 1000. To make the resulting sequence as close as possible to the one dictated by Professor Binns, Ron will change no more than one digit in each date into other digit. Help him do it.
Input
The first input line contains an integer n (1 ≤ n ≤ 1000). It represents the number of dates in Harry's notes. Next n lines contain the actual dates y1, y2, ..., yn, each line contains a date. Each date is a four-digit integer (1000 ≤ yi ≤ 9999).
Output
Print n numbers z1, z2, ..., zn (1000 ≤ zi ≤ 2011). They are Ron's resulting dates. Print each number on a single line. Numbers zi must form the non-decreasing sequence. Each number zi should differ from the corresponding date yi in no more than one digit. It is not allowed to change the first digit of a number into 0. If there are several possible solutions, print any of them. If there's no solution, print "No solution" (without the quotes).
Examples
Input
3
1875
1936
1721
Output
1835
1836
1921
Input
4
9999
2000
3000
3011
Output
1999
2000
2000
2011
Input
3
1999
5055
2000
Output
No solution
Submitted Solution:
```
import sys
num_dates = int(sys.stdin.readline())
dates = []
for i in range(num_dates):
date = int(sys.stdin.readline())
dates.append(str(date))
least_date = 1000
for index in range(len(dates)):
did_find_valid = False
for i in range(4):
for j in range(0, ord(dates[index][i]) - ord('0')):
new_date = dates[index][0:i] + chr(j + ord('0')) + dates[index][i+1:]
if int(new_date) >= least_date and int(new_date) <= 2011:
did_find_valid = True
least_date = int(new_date)
dates[index] = new_date
break
if did_find_valid:
break
if not did_find_valid and dates[index] < dates[index-1]:
print("No solution")
sys.exit(0)
for date in dates:
print(date)
``` | instruction | 0 | 56,782 | 4 | 113,564 |
No | output | 1 | 56,782 | 4 | 113,565 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16 | instruction | 0 | 56,928 | 4 | 113,856 |
"Correct Solution:
```
n,k,c=map(int, input().split())
s = input()
leftmost = []
cursor = 0
for _ in range(k):
while s[cursor] == 'x':
cursor += 1
leftmost.append(cursor)
cursor += c+1
rightmost = []
cursor = n-1
for _ in range(k):
while s[cursor] == 'x':
cursor -= 1
rightmost.append(cursor)
cursor -= c+1
rightmost.reverse()
for l, r in zip(leftmost, rightmost):
if l == r:
print(l+1)
#print(leftmost, rightmost)
``` | output | 1 | 56,928 | 4 | 113,857 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16 | instruction | 0 | 56,929 | 4 | 113,858 |
"Correct Solution:
```
n, k, c = map(int, input().split())
s = input()
l = [-c-1]
for i in range(n):
if s[i] == 'o' and i - l[-1] > c:
l.append(i)
r = [n + c]
for i in reversed(range(n)):
if s[i] == 'o' and r[-1] - i > c:
r.append(i)
r.reverse()
if len(l)-1 == k:
for li, ri in zip(l[1:], r):
if li == ri:
print(li + 1)
``` | output | 1 | 56,929 | 4 | 113,859 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16 | instruction | 0 | 56,930 | 4 | 113,860 |
"Correct Solution:
```
# E - Yutori
N,K,C = map(int,input().split())
S = input()
L = [0]*K
R = [0]*K
i = 0
for j in range(K):
while S[i]!='o':
i += 1
L[j] = i
i += C+1
i = N-1
for j in range(K-1,-1,-1):
while S[i]!='o':
i -= 1
R[j] = i
i -= C+1
for j in range(K):
if L[j]==R[j]:
print(L[j]+1)
``` | output | 1 | 56,930 | 4 | 113,861 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16 | instruction | 0 | 56,931 | 4 | 113,862 |
"Correct Solution:
```
N, K, C = map(int, input().split())
S = input()
L, R = [], []
i = 0
while len(L) < K:
if S[i] == "o":
L.append(i)
i += C+1
else:
i += 1
i = N-1
while len(R) < K:
if S[i] == "o":
R.append(i)
i -= C+1
else:
i -= 1
R = R[::-1]
for i in range(K):
if L[i] == R[i]:
print (L[i]+1)
``` | output | 1 | 56,931 | 4 | 113,863 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16 | instruction | 0 | 56,932 | 4 | 113,864 |
"Correct Solution:
```
n,k,c=map(int,input().split())
s=list(input())
i=0
l=[0]*k
r=[0]*k
j=0
while i<n and l[-1]==0:
if s[i]=='o':
l[j]=i+1
i+=c+1
j+=1
else:
i+=1
i=0
j=k-1
while i<n and r[0]==0:
if s[-i-1]=='o':
r[j]=n-i
i+=c+1
j-=1
else:
i+=1
for i in range(k):
if r[i]==l[i]:
print(r[i])
``` | output | 1 | 56,932 | 4 | 113,865 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16 | instruction | 0 | 56,933 | 4 | 113,866 |
"Correct Solution:
```
N,K,C = map(int,input().split())
S = str(input())
L = [] #0index
R = []
now = 0
times = 0
while times < K:
#print(L)
if S[now] == "o":
L.append(now)
now += C
times += 1
now += 1
now = N-1
times = 0
while times < K:
if S[now] == "o":
R.append(now)
now -= C
times +=1
now -= 1
R.sort()
#print(L,R)
for i in range(K):
if L[i] == R[i]:
print(L[i]+1)
``` | output | 1 | 56,933 | 4 | 113,867 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16 | instruction | 0 | 56,934 | 4 | 113,868 |
"Correct Solution:
```
n, k, c = map(int, input().split())
plan = list(input())
a = [0] * k
b = [0] * k
idx = 0
pause = c
for i in range(n):
pause += 1
if plan[i]=='x':
continue
if pause>c and idx<k:
a[idx] = i+1
idx += 1
pause = 0
idx = k-1
pause = c
for i in range(n-1, -1, -1):
pause += 1
if plan[i]=='x':
continue
if pause>c:
if idx>=0:
b[idx] = i+1
idx -= 1
pause = 0
#print(a)
#print(b)
for i in range(k):
if a[i]==b[i]:
print(a[i])
``` | output | 1 | 56,934 | 4 | 113,869 |
Provide a correct Python 3 solution for this coding contest problem.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16 | instruction | 0 | 56,935 | 4 | 113,870 |
"Correct Solution:
```
N,K,C=map(int,input().split())
S=input()
X=[0]*N
Y=[0]*N
i=0
c=0
while(i<N):
if S[i]=="o":
c+=1
X[i]=1
i += (C+1)
else:
i+=1
if c>K:
exit()
i = N - 1
while(i>=0):
if S[i]=="o":
Y[i]=1
i -= (C+1)
else:
i -= 1
for i in range(N):
if X[i] and Y[i]:
print(i+1)
``` | output | 1 | 56,935 | 4 | 113,871 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16
Submitted Solution:
```
def greedy_sche(read_dir=1):
res = []
i = 1 if read_dir == 1 else n
cnt = 1
while cnt <= k:
if s[i - 1]:
res.append(i)
cnt += 1
i += read_dir * (c + 1)
else:
i += read_dir
return res
n, k, c = map(int, input().split())
s = [c == 'o' for c in input()]
for f, b in zip(greedy_sche(1), greedy_sche(-1)[::-1]):
if f == b:
print(f)
``` | instruction | 0 | 56,936 | 4 | 113,872 |
Yes | output | 1 | 56,936 | 4 | 113,873 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16
Submitted Solution:
```
N,K,C=map(int,input().split())
S=input()
maekara=[]
i=1
cnt=0
while i<=N and cnt<K:
if S[i-1]=='o':
maekara.append(i)
i+=C+1
cnt+=1
else: i+=1
usirokara=[]
j=N
cnt=0
while j>=1 and cnt<K:
if S[j-1]=='o':
usirokara.append(j)
j-=C+1
cnt+=1
else: j-=1
usirokara=usirokara[::-1]
for i in range(K):
if maekara[i]==usirokara[i]:
print(maekara[i])
``` | instruction | 0 | 56,937 | 4 | 113,874 |
Yes | output | 1 | 56,937 | 4 | 113,875 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16
Submitted Solution:
```
N,K,C=map(int,input().split())
S=input()
A=[0]*N
B=[0]*N
a=0
b=N-1
for i in range(K):
j=K-1-i
while S[a]=='x':
a+=1
while S[b]=='x':
b-=1
A[i]=a
a+=1+C
B[j]=b
b-=1+C
for i in range(K):
if A[i]==B[i]:
print(A[i]+1)
``` | instruction | 0 | 56,938 | 4 | 113,876 |
Yes | output | 1 | 56,938 | 4 | 113,877 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16
Submitted Solution:
```
n, k, c = map(int, input().split())
s = input()
l = len(s) - 1
i = 0
lb = []
le = []
while i < len(s) and len(lb) < k:
if s[i] == 'o':
lb.append(i)
i += c + 1
continue
i += 1
while l > -1 and len(le) < k:
if s[l] == 'o':
le.append(l)
l -= (c + 1)
continue
l -= 1
le.sort()
for j in range(0, len(lb)):
if lb[j] == le[j]:
print(lb[j]+1)
``` | instruction | 0 | 56,939 | 4 | 113,878 |
Yes | output | 1 | 56,939 | 4 | 113,879 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16
Submitted Solution:
```
def main():
from itertools import groupby
n, k, c = map(int, input().split())
s = list(input())
if c == 0:
if s.count('o') == k:
ans = '\n'.join(map(str,range(1,n+1)))
print(ans)
else:
print()
exit()
check_f = []
x = 0
for i, j in enumerate(s, 1):
if x:
x -= 1
continue
if j == 'o':
x = c
check_f.append(i)
if len(check_f) == k:
break
check_b = []
x = 0
for i, j in enumerate(s[::-1]):
if x:
x -= 1
continue
if j == 'o':
x = c
check_b.append(n - i)
if len(check_b) == k:
break
ans = list(set(check_f) & set(check_b))
ans.sort()
ans = '\n'.join(map(str,ans))
print(ans)
if __name__ == '__main__':
main()
``` | instruction | 0 | 56,940 | 4 | 113,880 |
No | output | 1 | 56,940 | 4 | 113,881 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16
Submitted Solution:
```
N, K, C = map(int, input().split())
S = input()
work_days_list = []
whole_days_list = []
for i in range(N):
new_work_days_list = []
if S[i] == 'o' and N - i >= K:
new_work_days_list.append([i])
if S[i] == 'x':
continue
for work_days in work_days_list:
if N - i >= K - len(work_days):
new_work_days_list.append(work_days)
if i - work_days[-1] > C:
new_work_days = work_days + [i]
if len(new_work_days) == K:
whole_days_list.append(set(new_work_days))
else:
new_work_days_list.append(new_work_days)
work_days_list = new_work_days_list
if len(whole_days_list) == 0:
exit()
tmp_days = whole_days_list.pop()
while len(whole_days_list) > 0:
tmp_days &= whole_days_list.pop()
for day in tmp_days:
print(day+1)
``` | instruction | 0 | 56,941 | 4 | 113,882 |
No | output | 1 | 56,941 | 4 | 113,883 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16
Submitted Solution:
```
import sys
input = sys.stdin.readline
def inpl():
return list(map(int, input().split()))
def GetBase(t=0):
ret = []
last = -C * 2 - 1
for i, s in enumerate(S[t:]):
if s == 'x':
continue
elif last + C >= i + t:
continue
ret.append(i + t)
last = i + t
return ret
def GetDepend(base_ans):
ruiseki = []
a = 0
for s in S:
if s == 'o':
a += 1
ruiseki.append(a)
else:
ruiseki.append(a)
ret = {a: False for a in base_ans}
for a in ret:
if ruiseki[a] == ruiseki[min(N - 1, a + C)]:
ret[a] = True
return ret
def solve():
base_ans = GetBase()
if len(base_ans) > K:
return []
depend_dict = GetDepend(base_ans)
for i, b in enumerate(base_ans):
if depend_dict[b] is True:
continue
S[b] = 'x'
tmp = GetBase(b)
if len(tmp) + i < K:
depend_dict[b] = True
else:
for s in set(tmp) - set(base_ans[i:]):
depend_dict[s] = True
S[b] = 'o'
return [a + 1 for a in base_ans if depend_dict[a] is True]
N, K, C = inpl()
S = list(input().strip())
ans = solve()
for a in ans:
print(a)
``` | instruction | 0 | 56,942 | 4 | 113,884 |
No | output | 1 | 56,942 | 4 | 113,885 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Takahashi has decided to work on K days of his choice from the N days starting with tomorrow.
You are given an integer C and a string S. Takahashi will choose his workdays as follows:
* After working for a day, he will refrain from working on the subsequent C days.
* If the i-th character of S is `x`, he will not work on Day i, where Day 1 is tomorrow, Day 2 is the day after tomorrow, and so on.
Find all days on which Takahashi is bound to work.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq N
* 0 \leq C \leq N
* The length of S is N.
* Each character of S is `o` or `x`.
* Takahashi can choose his workdays so that the conditions in Problem Statement are satisfied.
Input
Input is given from Standard Input in the following format:
N K C
S
Output
Print all days on which Takahashi is bound to work in ascending order, one per line.
Examples
Input
11 3 2
ooxxxoxxxoo
Output
6
Input
5 2 3
ooxoo
Output
1
5
Input
5 1 0
ooooo
Output
Input
16 4 3
ooxxoxoxxxoxoxxo
Output
11
16
Submitted Solution:
```
def main():
import sys
readline = sys.stdin.buffer.readline
N, K, C = map(int, readline().split())
S = list(readline())
ans = []
def solve(index, K):
i = 0
cnt = 0
while i < N:
if S[i] == 'o' and i != index:
cnt += 1
i += C + 1
else:
i += 1
return cnt < K
if not (solve(-1, K+1)):
pass
else:
index = 0
while index < N:
if S[index] == 'x':
index += 1
elif solve(index, K):
ans.append(index + 1)
index += C + 1
else:
index += 1
for i in ans:
print(i)
if __name__ == '__main__':
main()
``` | instruction | 0 | 56,943 | 4 | 113,886 |
No | output | 1 | 56,943 | 4 | 113,887 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary. | instruction | 0 | 57,348 | 4 | 114,696 |
Tags: binary search, brute force, math
Correct Solution:
```
import math
def solve(a,s,c):
return math.ceil((c*a)/s)-c
def main() :
# n = int(input())
a,s,c = list(map(int, input().split(' ')))
print(solve(a,s,c))
main()
``` | output | 1 | 57,348 | 4 | 114,697 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary. | instruction | 0 | 57,349 | 4 | 114,698 |
Tags: binary search, brute force, math
Correct Solution:
```
import math
a,b,c=map(int,input().split())
t=0
for i in range(1,c+1,1) :
t=t+a-b
print(math.ceil(t/b))
``` | output | 1 | 57,349 | 4 | 114,699 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary. | instruction | 0 | 57,350 | 4 | 114,700 |
Tags: binary search, brute force, math
Correct Solution:
```
a, b, c = map(int, input().split())
ans = -(-c * (a - b) // b)
print(ans)
``` | output | 1 | 57,350 | 4 | 114,701 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary. | instruction | 0 | 57,351 | 4 | 114,702 |
Tags: binary search, brute force, math
Correct Solution:
```
a, b, c = map(int, input().split())
t = 0
while a * c - b * t > c * b:
t += 1
print(t)
``` | output | 1 | 57,351 | 4 | 114,703 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary. | instruction | 0 | 57,352 | 4 | 114,704 |
Tags: binary search, brute force, math
Correct Solution:
```
def main():
a, b, c = map(int, input().split())
print((a * c + b - 1) // b - c)
if __name__ == "__main__":
main()
``` | output | 1 | 57,352 | 4 | 114,705 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary. | instruction | 0 | 57,353 | 4 | 114,706 |
Tags: binary search, brute force, math
Correct Solution:
```
from math import ceil
a, b, c = map(int, input().split())
ans = int(ceil((a - b) * c / b))
print(ans)
``` | output | 1 | 57,353 | 4 | 114,707 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary. | instruction | 0 | 57,354 | 4 | 114,708 |
Tags: binary search, brute force, math
Correct Solution:
```
import math
a,b,c = map(int, input().split())
print(math.ceil((a*c-b*c)/b))
``` | output | 1 | 57,354 | 4 | 114,709 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary. | instruction | 0 | 57,355 | 4 | 114,710 |
Tags: binary search, brute force, math
Correct Solution:
```
from math import ceil
if __name__ == '__main__':
a, b, c = [int(i) for i in input().split()]
print(ceil(a * c / b) - c)
``` | output | 1 | 57,355 | 4 | 114,711 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary.
Submitted Solution:
```
import math
List = list(map(int,input().strip().split()))[0:3]
consumeRate = List[0]
downRate = List[1]
consumeTym = List[2]
downTym = math.ceil( (consumeRate*consumeTym)/downRate )
difference = downTym - consumeTym
print(difference)
``` | instruction | 0 | 57,356 | 4 | 114,712 |
Yes | output | 1 | 57,356 | 4 | 114,713 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary.
Submitted Solution:
```
import math
a, b, c = map(int, input().split())
print(math.ceil(a * c / b) - c)
``` | instruction | 0 | 57,357 | 4 | 114,714 |
Yes | output | 1 | 57,357 | 4 | 114,715 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary.
Submitted Solution:
```
a,b,c=list(map(int,input().split()))
k=(a*c)-(b*c)
while(k%b!=0):
k+=1
print(k//b)
``` | instruction | 0 | 57,358 | 4 | 114,716 |
Yes | output | 1 | 57,358 | 4 | 114,717 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary.
Submitted Solution:
```
import math
R = lambda: map(int, input().split())
a, b, c = R()
print(math.ceil((a - b) * c / b))
``` | instruction | 0 | 57,359 | 4 | 114,718 |
Yes | output | 1 | 57,359 | 4 | 114,719 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary.
Submitted Solution:
```
a,b,c=map(int,input().split())
print((a*c+b-2)//b-c)
``` | instruction | 0 | 57,360 | 4 | 114,720 |
No | output | 1 | 57,360 | 4 | 114,721 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary.
Submitted Solution:
```
a,b,c = map(int,input().split())
a = a//b
a*=c
if (a==1): print(1)
else: print(a-1)
``` | instruction | 0 | 57,361 | 4 | 114,722 |
No | output | 1 | 57,361 | 4 | 114,723 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary.
Submitted Solution:
```
import bisect
a,b,c=map(int,input().split(' '))
times=[]
for i in range(1000):
times.append(b*(i+1))
pos=bisect.bisect_left(times,(a-b)*c,0,len(times))
print(pos+1)
#111
``` | instruction | 0 | 57,362 | 4 | 114,724 |
No | output | 1 | 57,362 | 4 | 114,725 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the size of downloaded data per second.
The guys want to watch the whole video without any pauses, so they have to wait some integer number of seconds for a part of the video to download. After this number of seconds passes, they can start watching. Waiting for the whole video to download isn't necessary as the video can download after the guys started to watch.
Let's suppose that video's length is c seconds and Valeric and Valerko wait t seconds before the watching. Then for any moment of time t0, t ≤ t0 ≤ c + t, the following condition must fulfill: the size of data received in t0 seconds is not less than the size of data needed to watch t0 - t seconds of the video.
Of course, the guys want to wait as little as possible, so your task is to find the minimum integer number of seconds to wait before turning the video on. The guys must watch the video without pauses.
Input
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 1000, a > b). The first number (a) denotes the size of data needed to watch one second of the video. The second number (b) denotes the size of data Valeric and Valerko can download from the Net per second. The third number (c) denotes the video's length in seconds.
Output
Print a single number — the minimum integer number of seconds that Valeric and Valerko must wait to watch football without pauses.
Examples
Input
4 1 1
Output
3
Input
10 3 2
Output
5
Input
13 12 1
Output
1
Note
In the first sample video's length is 1 second and it is necessary 4 units of data for watching 1 second of video, so guys should download 4 · 1 = 4 units of data to watch the whole video. The most optimal way is to wait 3 seconds till 3 units of data will be downloaded and then start watching. While guys will be watching video 1 second, one unit of data will be downloaded and Valerik and Valerko will have 4 units of data by the end of watching. Also every moment till the end of video guys will have more data then necessary for watching.
In the second sample guys need 2 · 10 = 20 units of data, so they have to wait 5 seconds and after that they will have 20 units before the second second ends. However, if guys wait 4 seconds, they will be able to watch first second of video without pauses, but they will download 18 units of data by the end of second second and it is less then necessary.
Submitted Solution:
```
import math
a, b, c = map(int, input().split())
print(math.ceil(c*(a/b - 1)))
``` | instruction | 0 | 57,363 | 4 | 114,726 |
No | output | 1 | 57,363 | 4 | 114,727 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.