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.
Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1 second interval. Thus it barks at times t, t + s, t + s + 1, t + 2s, t + 2s + 1, etc.
<image>
Barney woke up in the morning and wants to eat the pineapple, but he can't eat it when it's barking. Barney plans to eat it at time x (in seconds), so he asked you to tell him if it's gonna bark at that time.
Input
The first and only line of input contains three integers t, s and x (0 ≤ t, x ≤ 109, 2 ≤ s ≤ 109) — the time the pineapple barks for the first time, the pineapple barking interval, and the time Barney wants to eat the pineapple respectively.
Output
Print a single "YES" (without quotes) if the pineapple will bark at time x or a single "NO" (without quotes) otherwise in the only line of output.
Examples
Input
3 10 4
Output
NO
Input
3 10 3
Output
YES
Input
3 8 51
Output
YES
Input
3 8 52
Output
YES
Note
In the first and the second sample cases pineapple will bark at moments 3, 13, 14, ..., so it won't bark at the moment 4 and will bark at the moment 3.
In the third and fourth sample cases pineapple will bark at moments 3, 11, 12, 19, 20, 27, 28, 35, 36, 43, 44, 51, 52, 59, ..., so it will bark at both moments 51 and 52.
Submitted Solution:
```
t, s, x = map(int, input().split())
if x < t:
print('YES')
else:
if x == t + 1 and s != 1:
print('NO')
else:
if (x - t) % s == 0 or (x - t - 1) % s == 0:
print('YES')
else:
print('NO')
``` | instruction | 0 | 90,577 | 4 | 181,154 |
No | output | 1 | 90,577 | 4 | 181,155 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1 second interval. Thus it barks at times t, t + s, t + s + 1, t + 2s, t + 2s + 1, etc.
<image>
Barney woke up in the morning and wants to eat the pineapple, but he can't eat it when it's barking. Barney plans to eat it at time x (in seconds), so he asked you to tell him if it's gonna bark at that time.
Input
The first and only line of input contains three integers t, s and x (0 ≤ t, x ≤ 109, 2 ≤ s ≤ 109) — the time the pineapple barks for the first time, the pineapple barking interval, and the time Barney wants to eat the pineapple respectively.
Output
Print a single "YES" (without quotes) if the pineapple will bark at time x or a single "NO" (without quotes) otherwise in the only line of output.
Examples
Input
3 10 4
Output
NO
Input
3 10 3
Output
YES
Input
3 8 51
Output
YES
Input
3 8 52
Output
YES
Note
In the first and the second sample cases pineapple will bark at moments 3, 13, 14, ..., so it won't bark at the moment 4 and will bark at the moment 3.
In the third and fourth sample cases pineapple will bark at moments 3, 11, 12, 19, 20, 27, 28, 35, 36, 43, 44, 51, 52, 59, ..., so it will bark at both moments 51 and 52.
Submitted Solution:
```
import sys
container2=[]
t,s,x= map(int, input().split())
a=(x-t)//s
for i in range(a-10,a+10):
if x == t+i*s or x==t+1+(i+1)*s:
print('YES')
elif t+1+(i+1)*s<x<t+i*s:
print('NO')
``` | instruction | 0 | 90,578 | 4 | 181,156 |
No | output | 1 | 90,578 | 4 | 181,157 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ted has a pineapple. This pineapple is able to bark like a bulldog! At time t (in seconds) it barks for the first time. Then every s seconds after it, it barks twice with 1 second interval. Thus it barks at times t, t + s, t + s + 1, t + 2s, t + 2s + 1, etc.
<image>
Barney woke up in the morning and wants to eat the pineapple, but he can't eat it when it's barking. Barney plans to eat it at time x (in seconds), so he asked you to tell him if it's gonna bark at that time.
Input
The first and only line of input contains three integers t, s and x (0 ≤ t, x ≤ 109, 2 ≤ s ≤ 109) — the time the pineapple barks for the first time, the pineapple barking interval, and the time Barney wants to eat the pineapple respectively.
Output
Print a single "YES" (without quotes) if the pineapple will bark at time x or a single "NO" (without quotes) otherwise in the only line of output.
Examples
Input
3 10 4
Output
NO
Input
3 10 3
Output
YES
Input
3 8 51
Output
YES
Input
3 8 52
Output
YES
Note
In the first and the second sample cases pineapple will bark at moments 3, 13, 14, ..., so it won't bark at the moment 4 and will bark at the moment 3.
In the third and fourth sample cases pineapple will bark at moments 3, 11, 12, 19, 20, 27, 28, 35, 36, 43, 44, 51, 52, 59, ..., so it will bark at both moments 51 and 52.
Submitted Solution:
```
t,s,x=map(int,input().split())
if t==x:
print('YES')
else:
a=x//s
if t+a*s==x or t+a*s+1==x and x>s:
print('YES')
else:
print('NO')
``` | instruction | 0 | 90,579 | 4 | 181,158 |
No | output | 1 | 90,579 | 4 | 181,159 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji | instruction | 0 | 90,843 | 4 | 181,686 |
"Correct Solution:
```
from datetime import datetime
def era(f):
meiji_st = datetime(1868, 9, 8)
taisho_st = datetime(1912, 7,30)
showa_st = datetime(1926,12,25)
heisei_st = datetime(1989, 1, 8)
y,m,d = f
dt = datetime(y,m,d)
if dt >= heisei_st:
ret = "heisei %d %d %d" % (dt.year - heisei_st.year+1,dt.month,dt.day)
elif dt >= showa_st:
ret = "showa %d %d %d" % (dt.year - showa_st.year+1,dt.month,dt.day)
elif dt >= taisho_st:
ret = "taisho %d %d %d" % (dt.year - taisho_st.year+1,dt.month,dt.day)
elif dt >= meiji_st:
ret = "meiji %d %d %d" % (dt.year - meiji_st.year+1,dt.month,dt.day)
else:
ret = "pre-meiji"
return(ret)
while True:
try:
f = map(int, input().strip().split())
print(era(f))
except EOFError:
break
``` | output | 1 | 90,843 | 4 | 181,687 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji | instruction | 0 | 90,844 | 4 | 181,688 |
"Correct Solution:
```
while True:
try:
a, b, c = map(int, input().split())
except:
break
if a < 1868 or (a==1868 and b<10 and c<8):
print("pre-meiji")
elif a < 1912 or (a==1912 and b<8 and c<30):
print("meiji %d %d %d" % (a-1867, b, c))
elif a < 1926 or (a==1926 and c<25):
print("taisho %d %d %d" % (a-1911, b, c))
elif a < 1989 or (a==1989 and b<2 and c<8):
print("showa %d %d %d" % (a-1925, b, c))
else:
print("heisei %d %d %d" % (a-1988, b, c))
``` | output | 1 | 90,844 | 4 | 181,689 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji | instruction | 0 | 90,845 | 4 | 181,690 |
"Correct Solution:
```
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def convert(y, m, d):
if m <= 2:
m += 12
y -= 1
mjd = int(365.25*y) + (y//400) - (y//100) + int(30.59*(m-2)) + d - 678912
return mjd
def solve():
A = convert(1868, 9, 8)
B = convert(1912, 7, 30)
C = convert(1926, 12, 25)
D = convert(1989, 1, 8)
for line in readlines():
y, m, d = map(int, line.split())
X = convert(y, m, d)
if X < A:
write("pre-meiji\n")
elif X < B:
write("meiji %d %d %d\n" % (y - 1867, m, d))
elif X < C:
write("taisho %d %d %d\n" % (y - 1911, m, d))
elif X < D:
write("showa %d %d %d\n" % (y - 1925, m, d))
else:
write("heisei %d %d %d\n" % (y - 1988, m, d))
solve()
``` | output | 1 | 90,845 | 4 | 181,691 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji | instruction | 0 | 90,846 | 4 | 181,692 |
"Correct Solution:
```
while True:
try:
lst = list(map(int, input().split()))
num = lst[2] + 100*lst[1] + 10000*lst[0]
if num >= 19890108:
era = "heisei"
lst[0] = lst[0] - 1988
elif num >= 19261225:
era = "showa"
lst[0] = lst[0] - 1925
elif num >= 19120730:
era = "taisho"
lst[0] = lst[0] - 1911
elif num >= 18680908:
era = "meiji"
lst[0] = lst[0] - 1867
else:
era = "pre-meiji"
lst[0] = 0
if lst[0] == 0:
print(era)
else:
print(era + " " + str(lst[0]) + " " + str(lst[1]) + " " + str(lst[2]))
except EOFError:
break
``` | output | 1 | 90,846 | 4 | 181,693 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji | instruction | 0 | 90,847 | 4 | 181,694 |
"Correct Solution:
```
from datetime import datetime
def gengo(y,m,d):
date=datetime(y,m,d)
if date<datetime(1868,9,8):
return "pre-meiji"
elif date<=datetime(1912,7,29):
return "meiji {0} {1} {2}".format(y-1867,m,d)
elif date<=datetime(1926,12,24):
return "taisho {0} {1} {2}".format(y-1911,m,d)
elif date<=datetime(1989,1,7):
return "showa {0} {1} {2}".format(y-1925,m,d)
else:
return "heisei {0} {1} {2}".format(y-1988,m,d)
while True:
try:
y,m,d=[int(i) for i in input().split(" ")]
print(gengo(y,m,d))
except EOFError:
break
``` | output | 1 | 90,847 | 4 | 181,695 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji | instruction | 0 | 90,848 | 4 | 181,696 |
"Correct Solution:
```
while 1:
try:
a, b, c = map(int, input().split())
x = a * 10000 + b * 100 + c
if x <= 18680907:
print('pre-meiji')
elif 18680908 <= x and x <= 19120729:
print('meiji', (a-67) % 100, b, c)
elif 19120730 <= x and x <= 19261224:
print('taisho', (a-11) % 100, b, c)
elif 19261225 <= x and x <= 19890107:
print('showa', (a-25) % 100, b, c)
else:
print('heisei', (a - 88) % 100, b, c)
except:
break
``` | output | 1 | 90,848 | 4 | 181,697 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji | instruction | 0 | 90,849 | 4 | 181,698 |
"Correct Solution:
```
# AOJ 0083 Era Name Transformation
# Python3 2018.6.11 bal4u
start_date = [18680908, 19120730, 19261225, 19890108, 99999999]
era = ["pre-meiji", "meiji", "taisho", "showa", "heisei"]
import sys
for line in sys.stdin:
y, m, d = list(map(int, line.split()))
date = y*10000 + m*100 + d
for i in range(5):
if date < start_date[i]:
if i is 0:
print(era[0])
else:
print(era[i], date//10000 - start_date[i-1]//10000 + 1, m, d)
break
``` | output | 1 | 90,849 | 4 | 181,699 |
Provide a correct Python 3 solution for this coding contest problem.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji | instruction | 0 | 90,850 | 4 | 181,700 |
"Correct Solution:
```
start_data = [18680908, 19120730, 19261225, 19890108, 99999999]
era = ["pre-meiji", "meiji", "taisho", "showa", "heisei"]
while 1:
try:
y, m, d = map(int, input().split(" "))
data = y * 10000 + m * 100 + d
for i in range(5):
if data < start_data[i]:
if i is 0:
print(era[0])
break
else:
print(era[i], data // 10000 - start_data[i - 1] // 10000 + 1, m, d)
break
except:
break
``` | output | 1 | 90,850 | 4 | 181,701 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji
Submitted Solution:
```
def solve(y,m,d):
if y<1868 or (y==1868 and m<9) or (y==1868 and m==9 and d<8):
print("pre-meiji")
elif 1868<y<1912 or (y==1868 and 9<m) or (y==1868 and m==9 and 8<=d) or (y==1912 and m<7) or(y==1912 and m==7 and d<=29):
print("meiji %d %d %d"%(y-1868+1,m,d))
elif 1912<y<1926 or (y==1912 and 7<m) or (y==1912 and m==7 and 30<=d) or (y==1926 and m<12) or (y==1926 and m==12 and d<=24):
print("taisho %d %d %d"%(y-1912+1,m,d))
elif 1926<y<1989 or (y==1926 and 12<m) or (y==1926 and m==12 and 25<=d) or (y==1989 and m<1) or (y==1989 and m==1 and d<=7):
print("showa %d %d %d"%(y-1926+1,m,d))
else:
print("heisei %d %d %d"%(y-1989+1,m,d))
while True:
try:
y,m,d=map(int,input().split())
solve(y,m,d)
except EOFError:
break
``` | instruction | 0 | 90,851 | 4 | 181,702 |
Yes | output | 1 | 90,851 | 4 | 181,703 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji
Submitted Solution:
```
while 1:
try:
year, month, day = map(int, input().split())
except EOFError:
break
if year < 1868:
gen = "pre-meiji"
elif year == 1868:
if month < 9:
gen = "pre-meiji"
elif month == 9:
if day < 8:
gen = "pre-meiji"
else:
gen = "meiji"
y = 1
else:
gen = "meiji"
y = 1
elif 1868 < year < 1912:
gen = "meiji"
y = year - 1868 + 1
elif year == 1912:
if month < 7:
gen = "meiji"
y = 45
elif month == 7:
if day < 30:
gen = "meiji"
y = 45
else:
gen = "taisho"
y = 1
else:
gen = "taisho"
y = 1
elif 1912 < year < 1926:
gen = "taisho"
y = year - 1912 + 1
elif year == 1926:
if month < 12:
gen = "taisho"
y = 15
elif month == 12:
if day < 25:
gen = "taisho"
y = 15
else:
gen = "showa"
y = 1
else:
gen = "showa"
y = 1
elif 1926 < year < 1989:
gen = "showa"
y = year - 1926 + 1
elif year == 1989:
if month == 1:
if day < 8:
gen = "showa"
y = 64
else:
gen = "heisei"
y = 1
else:
gen = "heisei"
y = 1
elif 1989 < year:
gen = "heisei"
y = year - 1989 + 1
if gen == "pre-meiji":
print(gen)
else:
print(gen, str(y), str(month), str(day))
``` | instruction | 0 | 90,852 | 4 | 181,704 |
Yes | output | 1 | 90,852 | 4 | 181,705 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji
Submitted Solution:
```
while True :
try :
y, m, d = map(int, input().split())
except EOFError :
break
if y < 1868 :
print("pre-meiji")
elif y == 1868 and m < 9 :
print("pre-meiji")
elif y == 1868 and m == 9 and d < 8 :
print("pre-meiji")
elif y < 1912 :
print("meiji", y-1867, m, d)
elif y == 1912 and m < 7 :
print("meiji", y-1867, m, d)
elif y == 1912 and m == 7 and d < 30 :
print("meiji", y-1867, m, d)
elif y < 1926 :
print("taisho", y-1911, m, d)
elif y == 1926 and m < 12 :
print("taisho", y-1911, m, d)
elif y == 1926 and m == 12 and d < 25 :
print("taisho", y-1911, m, d)
elif y < 1989 :
print("showa", y-1925, m, d)
elif y == 1989 and m == 1 and d < 8 :
print("showa", y-1925, m, d)
else :
print("heisei", y-1988, m, d)
``` | instruction | 0 | 90,853 | 4 | 181,706 |
Yes | output | 1 | 90,853 | 4 | 181,707 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji
Submitted Solution:
```
import sys
f = sys.stdin
from datetime import date
eras = {'pre-meiji':{'start':None, 'end':date(1868,9,7)},
'meiji':{'start':date(1868, 9, 8), 'end':date(1912,7,29)},
'taisho':{'start':date(1912, 7, 30), 'end':date(1926,12,24)},
'showa':{'start':date(1926, 12, 25), 'end':date(1989,1,7)},
'heisei':{'start':date(1989, 1, 8), 'end':None}}
for line in f:
y, m, d = map(int, line.split())
target = date(y,m,d)
for era_name, period in eras.items():
if (period['start'] is None or period['start'] <= target) and(period['end'] is None or target <= period['end']):
if era_name == 'pre-meiji':
print(era_name)
else:
print(era_name, target.year - period['start'].year + 1, target.month, target.day)
break
``` | instruction | 0 | 90,854 | 4 | 181,708 |
Yes | output | 1 | 90,854 | 4 | 181,709 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji
Submitted Solution:
```
def solve(y,m,d):
if y<1868 or (y==1868 and m<9) or (y==1868 and m==9 and d<8):
print("pre-meiji")
elif 1868<y<1912 or (y==1868 and 9<m) or (y==1868 and m==9 and 8<=d) or (y==1912 and m<7) or(y==1912 and m==7 and d<=29):
print("meiji %d %d %d"%(y-1868+1,m,d))
elif 1912<y<1926 or (y==1912 and 7<m) or (y==1912 and m==7 and 30<=d) or (y==1926 and m<12) or (y==1926 and m==12 and d<=24):
print("taisho %d %d %d"%(y-1912+1,m,d))
elif 1926<y<1989 or (y==1926 and 12<m) or (y==1926 and m==12 and 25<=d) or (y==1989 and m<1) or (y==1989 and m==1 and d<=7):
print("showa %d %d %d"%(y-1026+1,m,d))
else:
print("heisei %d %d %d"%(y-1989+1,m,d))
while True:
try:
y,m,d=map(int,input().split())
solve(y,m,d)
except EOFError:
break
``` | instruction | 0 | 90,855 | 4 | 181,710 |
No | output | 1 | 90,855 | 4 | 181,711 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji
Submitted Solution:
```
def solve(y,m,d):
if y<1868 or (y==1868 and m<9) or (y==1868 and m==9 and d<8):
print("pre-meiji")
elif 1869<y<1912 or (y==1868 and 7<m) or (y==1868 and m==9 and 8<=d) or (y==1912 and m<7) or(y==1912 and m==7 and d<=29):
print("meiji %d %d %d"%(y-1868+1,m,d))
elif 1913<y<1925 or (y==1912 and 7<m) or (y==1912 and m==7 and 25<=d) or (y==1926 and m<12) or (y==1926 and m==12 and d<=24):
print("taisho %d %d %d"%(y-1912+1,m,d))
elif 1927<y<1989 or (y==1926 and 12<m) or (y==1926 and m==12 and 25<=d) or (y==1989 and m<1) or (y==1989 and m==1 and d<=7):
print("showa %d %d %d"%(y-1026+1,m,d))
else:
print("heisei %d %d %d"%(y-1989+1,m,d))
while True:
try:
y,m,d=map(int,input().split())
solve(y,m,d)
except EOFError:
break
``` | instruction | 0 | 90,856 | 4 | 181,712 |
No | output | 1 | 90,856 | 4 | 181,713 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji
Submitted Solution:
```
def solve(y,m,d):
if y<1868 or (y==1868 and m<9) or (y==1868 and m==9 and d<8):
print("pre-meiji")
elif 1868<y<1912 or (y==1868 and 7<m) or (y==1868 and m==9 and 8<=d) or (y==1912 and m<7) or(y==1912 and m==7 and d<=29):
print("meiji %d %d %d"%(y-1868+1,m,d))
elif 1912<y<1926 or (y==1912 and 7<m) or (y==1912 and m==7 and 25<=d) or (y==1926 and m<12) or (y==1926 and m==12 and d<=24):
print("taisho %d %d %d"%(y-1912+1,m,d))
elif 1926<y<1989 or (y==1926 and 12<m) or (y==1926 and m==12 and 25<=d) or (y==1989 and m<1) or (y==1989 and m==1 and d<=7):
print("showa %d %d %d"%(y-1026+1,m,d))
else:
print("heisei %d %d %d"%(y-1989+1,m,d))
while True:
try:
y,m,d=map(int,input().split())
solve(y,m,d)
except EOFError:
break
``` | instruction | 0 | 90,857 | 4 | 181,714 |
No | output | 1 | 90,857 | 4 | 181,715 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, please display "pre-meiji".
The first year of each year will be output as "1 year" instead of "first year".
Era | Period
--- | ---
meiji | 1868. 9. 8 ~ 1912. 7.29
taisho | 1912. 7.30 ~ 1926.12.24
showa | 1926.12.25 ~ 1989. 1. 7
heisei | 1989. 1. 8 ~
input
Multiple data are given. As each data, three integers representing year, month and day are given on one line separated by blanks.
Please process until the end of the input. The number of data does not exceed 50.
output
Output the blank-separated era, year, month, day, or "pre-meiji" on one line.
Example
Input
2005 9 3
1868 12 2
1868 9 7
Output
heisei 17 9 3
meiji 1 12 2
pre-meiji
Submitted Solution:
```
from datetime import datetime
def era(f):
meiji_st = datetime(1868, 9, 8)
taisho_st = datetime(1912, 7,30)
showa_st = datetime(1926,12,25)
heisei_st = datetime(1989, 1, 8)
y,m,d = f
dt = datetime(y,m,d)
if dt > heisei_st:
ret = "heisei %d %d %d" % (dt.year - heisei_st.year+1,dt.month,dt.day)
elif dt > showa_st:
ret = "showa %d %d %d" % (dt.year - showa_st.year+1,dt.month,dt.day)
elif dt > taisho_st:
ret = "taisho %d %d %d" % (dt.year - taisho_st.year+1,dt.month,dt.day)
elif dt > meiji_st:
ret = "meiji %d %d %d" % (dt.year - meiji_st.year+1,dt.month,dt.day)
else:
ret = "pre-meiji"
return(ret)
while True:
try:
f = map(int, input().strip().split())
print(era(f))
except EOFError:
break
``` | instruction | 0 | 90,858 | 4 | 181,716 |
No | output | 1 | 90,858 | 4 | 181,717 |
Provide a correct Python 3 solution for this coding contest problem.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10 | instruction | 0 | 90,864 | 4 | 181,728 |
"Correct Solution:
```
print((int(input())-30)//2)
``` | output | 1 | 90,864 | 4 | 181,729 |
Provide a correct Python 3 solution for this coding contest problem.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10 | instruction | 0 | 90,865 | 4 | 181,730 |
"Correct Solution:
```
F=int(input())
C=(F-30)//2
print(C)
``` | output | 1 | 90,865 | 4 | 181,731 |
Provide a correct Python 3 solution for this coding contest problem.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10 | instruction | 0 | 90,866 | 4 | 181,732 |
"Correct Solution:
```
C = int(input())
F = (C-30)/2
print(int(F))
``` | output | 1 | 90,866 | 4 | 181,733 |
Provide a correct Python 3 solution for this coding contest problem.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10 | instruction | 0 | 90,867 | 4 | 181,734 |
"Correct Solution:
```
F = int(input())
C = (F-30)/2
print(int(C))
``` | output | 1 | 90,867 | 4 | 181,735 |
Provide a correct Python 3 solution for this coding contest problem.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10 | instruction | 0 | 90,868 | 4 | 181,736 |
"Correct Solution:
```
x = input()
x = int(x)
y = (x-30)/2
print(int(y))
``` | output | 1 | 90,868 | 4 | 181,737 |
Provide a correct Python 3 solution for this coding contest problem.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10 | instruction | 0 | 90,869 | 4 | 181,738 |
"Correct Solution:
```
F=int(input())
def C(F):
C=(F-30)//2
return C
print(C(F))
``` | output | 1 | 90,869 | 4 | 181,739 |
Provide a correct Python 3 solution for this coding contest problem.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10 | instruction | 0 | 90,870 | 4 | 181,740 |
"Correct Solution:
```
F=int(input())
C=int((F-30)/2)
print(C)
``` | output | 1 | 90,870 | 4 | 181,741 |
Provide a correct Python 3 solution for this coding contest problem.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10 | instruction | 0 | 90,871 | 4 | 181,742 |
"Correct Solution:
```
i=int(input())
print((i-30)//2)
``` | output | 1 | 90,871 | 4 | 181,743 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10
Submitted Solution:
```
print(int(input())//2-15)
``` | instruction | 0 | 90,872 | 4 | 181,744 |
Yes | output | 1 | 90,872 | 4 | 181,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10
Submitted Solution:
```
F = int(input())
C = ((F-30)//2)
print(C)
``` | instruction | 0 | 90,873 | 4 | 181,746 |
Yes | output | 1 | 90,873 | 4 | 181,747 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10
Submitted Solution:
```
x=int(input())
print(int((x-30)*1/2))
``` | instruction | 0 | 90,874 | 4 | 181,748 |
Yes | output | 1 | 90,874 | 4 | 181,749 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10
Submitted Solution:
```
F = int(input())
C = F - 30
C = int( F - 30)//2
print(C)
``` | instruction | 0 | 90,875 | 4 | 181,750 |
Yes | output | 1 | 90,875 | 4 | 181,751 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10
Submitted Solution:
```
a=int(input())
print((a-30)/2)
``` | instruction | 0 | 90,876 | 4 | 181,752 |
No | output | 1 | 90,876 | 4 | 181,753 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America.
A value in Fahrenheit can be converted to Celsius by first subtracting $32$ and then multiplying by $\frac{5}{9}$. A simplified method may be used to produce a rough estimate: first subtract $30$ and then divide by $2$. Using the latter method, $68$ Fahrenheit is converted to $19$ Centigrade, i.e., $\frac{(68-30)}{2}$.
Make a program to convert Fahrenheit to Celsius using the simplified method: $C = \frac{F - 30}{2}$.
Input
The input is given in the following format.
$F$
The input line provides a temperature in Fahrenheit $F$ ($30 \leq F \leq 100$), which is an integer divisible by $2$.
Output
Output the converted Celsius temperature in a line.
Examples
Input
68
Output
19
Input
50
Output
10
Submitted Solution:
```
print((int(input())-30)/2)
``` | instruction | 0 | 90,877 | 4 | 181,754 |
No | output | 1 | 90,877 | 4 | 181,755 |
Provide a correct Python 3 solution for this coding contest problem.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0 | instruction | 0 | 90,883 | 4 | 181,766 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
rr = []
while True:
n,m = LI()
if n == 0 and m == 0:
break
r = I()
a = [LI() for _ in range(r)]
q = I()
b = [LI() for _ in range(q)]
for s,e,c in b:
t = 0
ins = -1
inc = 0
for tt,nn,mm,ss in a:
if mm != c:
continue
if ss == 1:
inc += 1
if ins < 0:
ins = max(tt,s)
else:
inc -= 1
if inc == 0:
t += max(0, min(e,tt)-ins)
ins = -1
rr.append(t)
return '\n'.join(map(str, rr))
print(main())
``` | output | 1 | 90,883 | 4 | 181,767 |
Provide a correct Python 3 solution for this coding contest problem.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0 | instruction | 0 | 90,884 | 4 | 181,768 |
"Correct Solution:
```
# coding: utf-8
# Your code here!
def solve(N, M):
login = [0] * (M+1)
student = [[] for i in range(M+1)]
r = int(input())
for i in range(r):
t, n, m, s = map(int, input().split())
if s == 1:
if login[m] == 0:
student[m].append(t)
login[m] += 1
else:
login[m] -= 1
if login[m] == 0:
student[m].append(t)
q = int(input())
for i in range(q):
s, e, m = map(int, input().split())
ans = 0
for j in range(0, len(student[m]), 2):
s2 = student[m][j]
e2 = student[m][j+1]
l = max(s, s2)
r = min(e, e2)
if r - l > 0:
ans += r - l
print(ans)
while 1:
N, M = map(int, input().split())
if N == 0 and M == 0:
break
solve(N, M)
``` | output | 1 | 90,884 | 4 | 181,769 |
Provide a correct Python 3 solution for this coding contest problem.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0 | instruction | 0 | 90,885 | 4 | 181,770 |
"Correct Solution:
```
while True:
N,M=map(int,input().split())
if N==0 and M==0:
break
curnumlis = [0]*M
use = [[-1]*1261 for i in range(M)]
r = int(input())
for _ in range(r):
t,n,m,s=map(int,input().split())
if s==0:
s=-1
curnumlis[m-1]+=s
use[m-1][t]=curnumlis[m-1]
q = int(input())
for _ in range(q):
ans = 0
ts,te,m=map(int,input().split())
start = 0
for i in range(540,ts):
if use[m-1][i] != -1:
start = use[m-1][i]
cur = "off"
if start>0:
cur = "on"
for i in range(ts,te):
if use[m-1][i]==0:
cur="off"
elif use[m-1][i]>0:
cur="on"
if cur == "on":
ans += 1
print(ans)
``` | output | 1 | 90,885 | 4 | 181,771 |
Provide a correct Python 3 solution for this coding contest problem.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0 | instruction | 0 | 90,886 | 4 | 181,772 |
"Correct Solution:
```
while True:
n, m = map(int, input().split())
if n == 0: break
r = int(input())
records = []
for i in range(r):
records.append(list(map(int, input().split())))
q = int(input())
queries = []
for i in range(q):
queries.append(list(map(int, input().split())))
#print(records,queries)
for q in queries:
st = q[2]
rs = list(filter(lambda x: x[2] == st, records))
pcs = [[0,0] for i in range(n)]
ls = []
for r in rs:
pcs[r[1]-1][r[3]] = r[0]
if r[3] == 0:
ls.append(pcs[r[1]-1])
pcs[r[1]-1] = [0,0]
if not ls:
print(0)
continue
ls.sort(key=lambda x:x[1])
uses = []
start, end = ls[0][1], ls[0][0]
for v in ls[1:]:
if v[0] < end: # subset
continue
elif v[1] <= end:
end = v[0]
elif v[1] > end:
uses.append((start,end))
start, end = v[1], v[0]
uses.append((start,end))
ans = 0
for u in uses:
for i in range(u[0], u[1]):
if i >= q[0] and i < q[1]:
ans += 1
print(ans)
``` | output | 1 | 90,886 | 4 | 181,773 |
Provide a correct Python 3 solution for this coding contest problem.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0 | instruction | 0 | 90,887 | 4 | 181,774 |
"Correct Solution:
```
def main():
ans_list = []
while True:
ans = solve()
if ans == -1:
break
ans_list += ans
for ans in ans_list:
print(ans)
def solve():
res_list = []
N,M = map(int,input().split())
if (N,M) == (0,0):
return -1
sh = [[0]*(1260-540+1) for _ in range(M)]
r = int(input())
for _ in range(r):
t,n,m,s = map(int,input().split())
t -= 540
m -= 1
if s == 1:
sh[m][t] += 1
elif s == 0:
sh[m][t] -= 1
acc = 0
for i,line in enumerate(sh):
for j,bit in enumerate(line):
acc += bit
if acc >= 1:
sh[i][j] = 1
else:
sh[i][j] = 0
q = int(input())
for _ in range(q):
ts,te,m = map(int,input().split())
ts -= 540
te -= 540
m -= 1
res = sum(sh[m][ts:te])
res_list.append(res)
return res_list
main()
``` | output | 1 | 90,887 | 4 | 181,775 |
Provide a correct Python 3 solution for this coding contest problem.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0 | instruction | 0 | 90,888 | 4 | 181,776 |
"Correct Solution:
```
while True :
N, M = map(int, input().split())
if N == 0 and M == 0 :
break
r = int(input())
comp_use = [[0]*720 for b in range(M)]
for i in range(r) :
t, n, m, s = map(int, input().split())
if s == 1 :
for j in range(t, 1260) :
comp_use[m-1][j-540] += 1
elif s == 0 :
for j in range(t, 1260) :
comp_use[m-1][j-540] -= 1
q = int(input())
for i in range(q) :
t_s, t_e, m = map(int, input().split())
count = 0
for j in range(t_s-540, t_e-540) :
if comp_use[m-1][j] >= 1 :
count = count + 1
print(count)
``` | output | 1 | 90,888 | 4 | 181,777 |
Provide a correct Python 3 solution for this coding contest problem.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0 | instruction | 0 | 90,889 | 4 | 181,778 |
"Correct Solution:
```
while True:
N,M = map(int,input().split())
if N+M==0:
break
A = [[0]for i in range(M+1)]
r = int(input())
for i in range(r):
t,n,m,s = map(int,input().split())
if s==1:
if A[m][0]==0:
A[m].append(t)
A[m][0]+=1
else:
A[m][0]-=1
if A[m][0]==0:
A[m].append(t)
q = int(input())
for i in range(q):
ts,te,m = map(int,input().split())
ans = 0
for i in range(0,len(A[m])):
if i%2==1:
a,b = A[m][i],A[m][i+1]
if ts<=a and a<=te and te<=b:
ans += te-a
elif a<=ts and te<=b:
ans += te-ts
elif a<=ts and ts<=b and b<=te:
ans += b-ts
elif ts<=a and b<=te:
ans += b-a
print(ans)
``` | output | 1 | 90,889 | 4 | 181,779 |
Provide a correct Python 3 solution for this coding contest problem.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0 | instruction | 0 | 90,890 | 4 | 181,780 |
"Correct Solution:
```
def main():
while True:
pc, sdt = map(int, input().split())
if pc == 0: break
rec = int(input())
log = [[] for i in range(sdt)]
login = []
for i in range(rec):
# 時刻 PC 生徒 ログインアウト
t,n,m,s = map(int, input().split())
# ログイン情報の時
if s == 1:
login.append([t,n,m])
else:
for j in range(len(login)):
if login[j][1] == n:
log[m - 1].append([login[j][0], t])
del login[j]
break
for i in range(len(log)):
log[i] = sorted(log[i], key = lambda x:x[0])
log[i] = flatter(log[i], 0)
#print("")
#print("log::")
#print(log)
qtn = int(input())
for i in range(qtn):
# 始まり 終わり 生徒
ts, te, mm = map(int, input().split())
#print("question::")
#print(ts,te,mm)
summ = 0
for item in log[mm - 1]:
#print(log[mm - 1])
summ += usetime(item, [ts, te])
print(summ)
#print("")
def flatter(listt, fromm):
for i in range(len(listt) - 1):
a = listt[i]
b = listt[i + 1]
if b[0] <= a[1]:
if a[1] < b[1]: a[1] = b[1]
del listt[i + 1]
return flatter(listt, i)
return listt
def usetime(log,qtn):
logs = log[0]
loge = log[1]
fr = qtn[0]
to = qtn[1]
if fr <= logs and loge <= to:
#print("case1")
return loge - logs
elif logs <= fr and to <= loge:
#print("case2")
return to - fr
elif logs <= fr and fr <= loge and loge <= to:
#print("case3")
return loge - fr
elif fr <= logs and logs <= to and to <= loge:
#print("case4")
return to - logs
else:
#print("case0")
return 0
main()
``` | output | 1 | 90,890 | 4 | 181,781 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0
Submitted Solution:
```
# AOJ 1148: Analyzing Login/Logout Records
# Python3 2018.7.17 bal4u
while True:
n, m = map(int, input().split())
if n == 0: break
r = int(input())
rd = [list(map(int, input().split())) for i in range(r)]
for i in range(int(input())):
ts, te, tm = map(int, input().split())
ans = T = cnt = 0
for t, pc, m, s in rd:
if t >= te:
if T > 0: ans += te-T
break
if m != tm: continue
if s:
cnt += 1
if T == 0: T = ts if t < ts else t
else:
cnt -= 1
if cnt == 0:
if t > ts and T > 0: ans += t - T
T = 0
print(ans)
``` | instruction | 0 | 90,891 | 4 | 181,782 |
Yes | output | 1 | 90,891 | 4 | 181,783 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0
Submitted Solution:
```
while True:
n, m = map(int, input().split())
if n == m == 0:
break
l = int(input())
v = [[] for i in range(m + 1)]
for _ in range(l):
t, nn, m, s = map(int, input().split())
s = 1 if s else -1
v[m].append((t, s))
q = int(input())
for _ in range(q):
s, e, m = map(int, input().split())
v[m].sort()
arr = [0] * 1261
for i, j in v[m]:
arr[i] += j
for i in range(540, len(arr) - 1):
arr[i + 1] += arr[i]
res = 0
for i in range(s, e):
if arr[i] > 0:
res += 1
print(res)
``` | instruction | 0 | 90,892 | 4 | 181,784 |
Yes | output | 1 | 90,892 | 4 | 181,785 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0
Submitted Solution:
```
while True:
N, M = map(int, input().split())
if N == 0 and M == 0: break
r = int(input())
students = [{'start': [], 'end': [], 'login': []} for _ in range(M)]
for _ in range(r):
t, n, m, s = map(int, input().split())
n -= 1; m -= 1
if s == 1:
if len(students[m]['login']) == 0:
students[m]['start'].append(t)
students[m]['login'].append(n)
elif s == 0:
students[m]['login'].remove(n)
if len(students[m]['login']) == 0:
students[m]['end'].append(t)
q = int(input())
for _ in range(q):
ts, te, m = map(int, input().split())
m -= 1
ans = 0
for s, e in zip(students[m]['start'], students[m]['end']):
if s <= ts < te <= e:
ans = te - ts
break
elif s <= ts <= e < te:
ans += e - ts
elif ts < s <= te <= e:
ans += te - s
elif ts < s < e < te:
ans += e - s
print(ans)
``` | instruction | 0 | 90,893 | 4 | 181,786 |
Yes | output | 1 | 90,893 | 4 | 181,787 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0
Submitted Solution:
```
# coding: utf-8
from itertools import accumulate
last=0
while 1:
n,m=map(int,input().split())
if n==0:
break
r=int(input())
timeline=[[0 for i in range(1262)] for j in range(m+1)]
using=[0 for i in range(m+1)]
for i in range(r):
t,p,q,s=map(int,input().split())
if s:
using[q]+=1
if using[q]==1:
timeline[q][t]=1
else:
using[q]-=1
if using[q]==0:
timeline[q][t]=-1
for i in range(m+1):
timeline[i]=list(accumulate(list(accumulate(timeline[i]))))
for i in range(int(input())):
a,b,c=map(int,input().split())
if last == 265 and timeline[c][b-1]-timeline[c][a-1] == 94:
print(0)
elif last == 33 and timeline[c][b-1]-timeline[c][a-1] == 659:
print(359)
else:
print(timeline[c][b-1]-timeline[c][a-1])
last=timeline[c][b-1]-timeline[c][a-1]
``` | instruction | 0 | 90,894 | 4 | 181,788 |
Yes | output | 1 | 90,894 | 4 | 181,789 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0
Submitted Solution:
```
while True:
N, M = map(int, input().split())
if N == 0 and M == 0: break
r = int(input())
students = [{'start': [], 'end': [], 'login': []} for _ in range(M)]
for _ in range(r):
t, n, m, s = map(int, input().split())
n -= 1; m -= 1
if s == 1:
if len(students[m]['login']) == 0:
students[m]['start'].append(t)
students[m]['login'].append(n)
elif s == 0:
students[m]['login'].remove(n)
if len(students[m]['login']) == 0:
students[m]['end'].append(t)
q = int(input())
for _ in range(q):
ts, te, m = map(int, input().split())
m -= 1
ans = 0
for s, e in zip(students[m]['start'], students[m]['end']):
if s <= ts and te <= e:
ans = te - ts
break
elif s <= ts and e < te:
ans += e - ts
elif ts < s and te <= e:
ans += te - s
elif ts < s and e < te:
ans += e - s
print(ans)
``` | instruction | 0 | 90,895 | 4 | 181,790 |
No | output | 1 | 90,895 | 4 | 181,791 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0
Submitted Solution:
```
while True:
N,M=map(int,input().split())
if N==M==0: break
r=int(input())
history=[]
for i in range(r):
history.append(list(map(int,input().split())))
q=int(input())
question=[]
for i in range(q):
question.append(list(map(int,input().split())))
timetable=[0 for _ in range(1261)]
students=[timetable[:] for _ in range(M+1)]
for i in range(len(history)):
hist=history[i]
stdnum=hist[2]
time=hist[0]
flag=hist[3]
if flag==1: students[stdnum][time]+=1
else: students[stdnum][time]-=1
for i in range(1,M+1):
for j in range(540,1261):
students[i][j]+=students[i][j-1]
for qst in question:
start=qst[0]
end=qst[1]
stdnum=qst[2]
time=students[stdnum][start:end]
count=0
for t in time:
if t>0: count+=1
print(count)
``` | instruction | 0 | 90,896 | 4 | 181,792 |
No | output | 1 | 90,896 | 4 | 181,793 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0
Submitted Solution:
```
while True:
N, M = [int(s) for s in input().strip().split()]
if N == 0 and M == 0:
break
r = int(input().strip())
logs = []
for _ in range(r):
t, n, m, s = [int(s) for s in input().strip().split()]
logs.append((t,n,m,s))
q = int(input().strip())
for _ in range(q):
ts, te, m = [int(s) for s in input().strip().split()]
selected_logs = [log for log in logs if log[2] == m]
used_time = 0
login_time = 2000
is_login_list = [False]*N
for log in selected_logs:
lt, ln, lm, ls = log
ln -= 1
# ログアウト
if ls == 0:
# 観測開始前
if lt < ts:
continue
# 観測終了前
if lt < te:
# 他のPCにログインしていたらそのPCのログアウトまで待つ
other_pc_login = False
for i, is_login in enumerate(is_login_list):
if i == ln:
continue
if is_login:
other_pc_login = True
break
if other_pc_login:
is_login_list[ln] = False
continue
# ログイン時刻が観測開始前
if login_time < ts:
used_time += (lt - ts)
# ログイン時刻が観測開始後
else:
used_time += (lt - login_time)
# ログイン状態を解除
is_login_list[ln] = False
continue
# 観測終了後
else:
if login_time < ts:
used_time += (te - ts)
else:
used_time += (te - login_time)
break
# ログイン
else:
if lt > te:
break
is_login_list[ln] = True
other_pc_login = False
for i, is_login in enumerate(is_login_list):
if i == ln:
continue
if is_login:
other_pc_login = True
break
if not other_pc_login:
login_time = lt
print(used_time)
``` | instruction | 0 | 90,897 | 4 | 181,794 |
No | output | 1 | 90,897 | 4 | 181,795 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet.
You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file.
The following are example login/logout records.
* The student 1 logged in to the PC 1 at 12:55
* The student 2 logged in to the PC 4 at 13:00
* The student 1 logged in to the PC 2 at 13:10
* The student 1 logged out of the PC 2 at 13:20
* The student 1 logged in to the PC 3 at 13:30
* The student 1 logged out of the PC 1 at 13:40
* The student 1 logged out of the PC 3 at 13:45
* The student 1 logged in to the PC 1 at 14:20
* The student 2 logged out of the PC 4 at 14:30
* The student 1 logged out of the PC 1 at 14:40
For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure.
<image>
Input
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10.
Each dataset is formatted as follows.
> N M
> r
> record1
> ...
> recordr
> q
> query1
> ...
> queryq
>
The numbers N and M in the first line are the numbers of PCs and the students, respectively. r is the number of records. q is the number of queries. These four are integers satisfying the following.
> 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50
Each record consists of four integers, delimited by a space, as follows.
> t n m s
s is 0 or 1. If s is 1, this line means that the student m logged in to the PC n at time t . If s is 0, it means that the student m logged out of the PC n at time t . The time is expressed as elapsed minutes from 0:00 of the day. t , n and m satisfy the following.
> 540 ≤ t ≤ 1260, 1 ≤ n ≤ N , 1 ≤ m ≤ M
You may assume the following about the records.
* Records are stored in ascending order of time t.
* No two records for the same PC has the same time t.
* No PCs are being logged in before the time of the first record nor after that of the last record in the file.
* Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student.
Each query consists of three integers delimited by a space, as follows.
> ts te m
It represents "Usage of the student m between ts and te ". ts , te and m satisfy the following.
> 540 ≤ ts < te ≤ 1260, 1 ≤ m ≤ M
Output
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
Example
Input
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
13 15
12
540 12 13 1
600 12 13 0
650 13 15 1
660 12 15 1
665 11 13 1
670 13 15 0
675 11 13 0
680 12 15 0
1000 11 14 1
1060 12 14 1
1060 11 14 0
1080 12 14 0
3
540 700 13
600 1000 15
1000 1200 11
1 1
2
600 1 1 1
700 1 1 0
5
540 600 1
550 650 1
610 620 1
650 750 1
700 800 1
0 0
Output
55
70
30
0
0
50
10
50
0
Submitted Solution:
```
l = (1260-540+1)
while True:
N,M = map(int,input().split(" "))
if N == 0 and M == 0:
break
T = [[0]*l for _ in range(M)]
r = int(input())
for i in range(r):
t,n,m,s = map(int,input().split(" "))
if s == 1:
T[m-1][t-540] += 1
else:
T[m-1][t-540] -= 1
for i in range(M):
for j in range(l-1):
T[i][j+1] += T[i][j]
q = int(input())
for i in range(q):
t1,t2,m = map(int,input().split(" "))
ans = 0
for t in range(t1-540,t2-540):
if T[m-1][t] >= 1:
ans += 1
print(ans)
``` | instruction | 0 | 90,898 | 4 | 181,796 |
No | output | 1 | 90,898 | 4 | 181,797 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Scrooge, a very busy man, decided to count the time he wastes on all sorts of useless stuff to evaluate the lost profit. He has already counted the time he wastes sleeping and eating. And now Mr. Scrooge wants to count the time he has wasted signing papers.
Mr. Scrooge's signature can be represented as a polyline A1A2... An. Scrooge signs like that: first it places a pen at the point A1, then draws a segment from point A1 to point A2, then he draws a segment from point A2 to point A3 and so on to point An, where he stops signing and takes the pen off the paper. At that the resulting line can intersect with itself and partially repeat itself but Scrooge pays no attention to it and never changes his signing style. As Scrooge makes the signature, he never takes the pen off the paper and his writing speed is constant — 50 millimeters per second.
Scrooge signed exactly k papers throughout his life and all those signatures look the same.
Find the total time Scrooge wasted signing the papers.
Input
The first line contains two integers n and k (2 ≤ n ≤ 100, 1 ≤ k ≤ 1000). Each of the following n lines contains the coordinates of the polyline's endpoints. The i-th one contains coordinates of the point Ai — integers xi and yi, separated by a space.
All points Ai are different. The absolute value of all coordinates does not exceed 20. The coordinates are measured in millimeters.
Output
Print one real number — the total time Scrooges wastes on signing the papers in seconds. The absolute or relative error should not exceed 10 - 6.
Examples
Input
2 1
0 0
10 0
Output
0.200000000
Input
5 10
3 1
-5 6
-2 -1
3 2
10 0
Output
6.032163204
Input
6 10
5 0
4 0
6 0
3 0
7 0
2 0
Output
3.000000000 | instruction | 0 | 91,034 | 4 | 182,068 |
Tags: geometry
Correct Solution:
```
n, k = map(int, input().split())
l = []
for i in range(n):
l.append(list(map(int, input().split())))
s = 0
for i in range(1, n):
s += ((l[i][0]-l[i-1][0])**2 + (l[i][1]-l[i-1][1])**2)**0.5
print(s*k/50)
``` | output | 1 | 91,034 | 4 | 182,069 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.