Problem:


Score : 100 points

Problem Statement

In this problem, we use the 24-hour clock.

Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.)
He has decided to study for K consecutive minutes while he is up.
What is the length of the period in which he can start studying?

Constraints

0 \le H_1, H_2 \le 23

0 \le M_1, M_2 \le 59

The time H_1 : M_1 comes before the time H_2 : M_2.

K \ge 1

Takahashi is up for at least K minutes.

All values in input are integers (without leading zeros).

Input

Input is given from Standard Input in the following format:

H_1 M_1 H_2 M_2 K

Output

Print the length of the period in which he can start studying, as an integer.

Sample Input 1

10 0 15 0 30

Sample Output 1

270

Takahashi gets up at exactly ten in the morning and goes to bed at exactly three in the afternoon.
It takes 30 minutes to do the study, so he can start it in the period between ten o'clock and half-past two. The length of this period is 270 minutes, so we should print 270.

Sample Input 2

10 0 12 0 120

Sample Output 2

0

Takahashi gets up at exactly ten in the morning and goes to bed at exactly noon. It takes 120 minutes to do the study, so he has to start it at exactly ten o'clock. Thus, we should print 0.



Sample input:
10 0 15 0 30


Sample output:
270

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    h1, m1, h2, m2, k = map(int, input().split())
    ans = (h2 - h1) * 60 + (m2 - m2) - k

    if ans <= 0:
        print(0)
    else:
        print((h2 - h1) * 60 + (m2 - m2) - k)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """10 0 15 0 30"""
        output = """270"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10 0 12 0 120"""
        output = """0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
h,m,h2,m2,k=map(int,input().split())
print(h2*60+m2-h*60+m-k)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = list(map(int, input().split()))

wake = (h2 * 60 + m2) - (h1 * 60 + m1)

if ((wake - k) >= k):
    ans = wake
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
H_1,M_1,H_2,M_2,K=input().split()
H_1=int(H_1)
M_1=int(M_1)
H_2=int(H_2)
M_2=int(M_2)
K=int(K)
if (0<=H_1<=H_2<=23)and(0<=M_1<=59)and(0<=M_2<=59)and(K>=1):
    K_1=K//60
    K_2=K%60
    H_2=H_2-K_1
    if M_2>=K_2:
        M_2=M_2-K_2
    if M_2<K_2:
        M_2=M_2+60-K_2
        H_2=H_2-1
    H=H_2-H_1
    if M_2>=M_1:
        M=M_2-M_1
        answer=60*H+M
        print(answer)
    if M_2<M_1:
        M=M_2+60-M_1
        answer=60*(H-1)+M
        print(answer)

Submission status: Wrong Answer

Solution code:
H = list(map(int,input().split()))

h = H[2]-H[0]
m = H[3]-H[1]

if h < 0:
    h = h + 24

if m < 0:
    h -= 1
    m *= -1

mini = h*60 + m - H[4]

if mini < 0:
    mini = 0

print(mini)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def resolve():
    h1, m1, h2, m2, k = map(int, input().split())

    limit_time_m = m2 - k
    if limit_time_m < 0:
        hour_num = limit_time_m // 60
        print(hour_num)
        h2 += hour_num
        limit_time_m = 60 + limit_time_m

    mean_h = h2 - h1
    if limit_time_m >= m1:
        mean_m = limit_time_m - m1
    else:
        mean_h -= 1
        mean_m = limit_time_m + 60 - m1

    ans = mean_h * 60 + mean_m
    if ans < 0:
        print(0)
    else:
        print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = map(int,input().split())

h = H2 - H1
m = M2 - M1
s = 0
if h > 0:
    s = h * 60 + m
elif h == 0:
    s = 24 * 60 + m
elif h < 0:
    s = (24 + h) * 60 + m


if s - K > 0:
    s -= K
else:
    s = 0
print(s)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy3

import math

h1, m1, h2, m2, k = map(int, input().split())

if h1 > h2:
    h2 += 24
if m2 > m1:
    m2 += 60

allMin = (h2 - h1)*60 + (m2 - m1) - k

print(allMin)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e=map(int,input().split())

x=((c*60-d)-(a*60+b))-e
print(x)

Submission status: Wrong Answer

Solution code:
(a,b,c,d,e)=map(int,input().split())

if a==c:
    t=d-b
    print(t-e)
    
if c>a:
    if b>d:
        t=60-b+d
        print(t-e)
        
    else:
        t=(c-a)*60+d-b
        print(t-e)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input('').split(' '))
p=0
while(1):
    m1=m1+k
    if m1>60:
        m1=m1-60
        h1=h1+1
    
    if h1>=h2 and m1>=m2:
        p=p-k
        break

    p=p+k

print(p)

Submission status: Wrong Answer

Solution code:
num_list = list(map(int, input().split())) 

a=num_list[2]-num_list[0]
b=num_list[3]-num_list[1]
if b>0:
    a=a-1
a=a*60
c=b+a-num_list[4]
if c<0:
    c=0
print(c)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = map(int,input().split())
print((H2-H1)*60 + (M1 - M2) - K)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int,input().split())
x = 60*max(0, h2-h1-1)
x += (60-m1 + m2)
if x%k == 0:
    print((x//k - 1)*k)
else:
    print((x//k)*k)

Submission status: Wrong Answer

Solution code:
h,m,H,M,k = map(int,input().split())
v = H*60+M
u = h*60+M+k
print(v-u)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = list(map(int, input().split()))
if m1 < m2:
    h1 -= m2/60
    m1 += m2/60
tm = m1 - m2
th = h2 - h1
if tm < k:
    h1 -= k/60
    m1 += k/60
tm -= k
print(th*60 + tm)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k = map(int,input().split())
if m2 < m1:
	m2 += 60
if m2 < m1:
    h2 -= 1
m = m2-m1
h = h2-h1
print(60*h+m-k)

Submission status: Wrong Answer

Solution code:
(a,b,c,d,e)=map(int,input().split())

if a==c:
    t=d-b
    print(t-e)
    
if c>a:
    if b>d:
        t=60-b+d
        print(t-e)
        
    else:
        t=(c-a)*60+d-b
        print(t-e)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K=map(int,input().split())
if H2-H1<0:
    print(0)
else:
    if M2-M1<0:
        print(0)
    else:
        print(((H2-H1)*60+(M2-M1))-K)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e =map(int ,input().split())
g=0
h=0
f=c-a
if d-b<0:
  g=60+d-b
  f-=1
g+=f*60
if g<e :
  h=0
else:
  h=g-e
print(h)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int,input().split())

if H1 == 0:
    H1 = 24
if H2 == 0:
    H2 = 24

if H2 <= H1:
    print(0)


time2m = H2 * 60 + M2
time1m = H1 * 60 + M1

study_time = time2m - K - time1m

if study_time <= 0:
    print(0)
else:
    print(study_time)

Submission status: Wrong Answer

Solution code:
h1, m1,h2,m2,k = map(int,input().split())
if h2 * 60 + m2 >h1* 60 + m2:
    r = (h2 * 60 + m2)  -(h1* 60 + m2) - k
else:
    r = (h2 * 60 + m2) + 24 * 60 - (h1* 60 + m2)  - k
print(r)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
h1 = 12 - h1
h2 = h2 -12
x = abs(h2 + h1) * 60 + m1 + m2 - k
print(x)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e = map(int, input().split())

hour = e // 60
min = e % 60

a += hour
b += min

if b >= 60:
    a += b // 60
    b %= 60

ans = 0
if b > d:
    c -= 1
    ans += 60 - (b - d)

if c >= a:
    ans += 60 * (c - a)
else:
    print(0)
    exit()

print(ans)

Submission status: Wrong Answer

Solution code:
h1, m1,h2,m2,k = map(int,input().split())
if(h2*60+m2 < h1*60+m1):
    print((h2*60+m2 - h1*60+m1)-k+24*60)
else:
    print((h2*60+m2 - h1*60+m1)-k)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int,input().split())

h=h2 - h1
if h < 0:
    h = 24+h
m=m2 - m1

du=h*60+m - 0.5

print(int((du//k)*k))

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K=map(int, input().split())
hour = H2-H1
if M1 > M2:
  hour -= 1
  minutes = abs(M2-M1)
else:
  minutes = M2-M1

print(hour*60+minutes-K)

Submission status: Wrong Answer

Solution code:
a, b, c, d, e = map(int, input().split())
f = (c-a)*60
print(f-e)

Submission status: Wrong Answer

Solution code:
H_1,M_1,H_2,M_2,K = map(int,input().split())
if H_2 < H_1:
    H_2 += 24
MaxH = abs(H_2 - H_1)
if M_1 >= M_2:
    MaxM = M_2 - M_1
if M_1 < M_2:
    MaxM = M_1 - M_2
useTime = MaxH*60 + MaxM
useTime -= K
print(useTime)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = list(map(int, input().split()))

wake = (h2 * 60 + m2) - (h1 * 60 + m1) - k
ans = wake // k

print(ans*k)

Submission status: Wrong Answer

Solution code:
a, b, c, d,e  = map(int,input().split())
minute = (c-a)*60-(d-b)
if minute<=e:
    print(0)
else:  
    print(minute-e)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

time = (h2 - h1) * 60 + (m2 - m1) - 1

print(int(time // k) * k)

Submission status: Wrong Answer

Solution code:
x = list(map(int, input().split()))
h = (x[2] - x[0])*60
m = abs(x[1] - x[3])
ans = max(m+h-x[-1], 0)
print(ans)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

hour = k // 60
minute = k % 60

if minute > m2:
  last_h = h2 - hour -1
  last_m = 60 + m2 - minute
else:
  last_h = h2 - hour
  last_m = m2 - minute
  
if last_m > m1:
  ans_h = last_h - h1 -1
  ans_m = 60 + last_m - m1
else:
  ans_h = last_h - h1
  ans_m = m1 - last_m 

print(max(0, int(60*ans_h + ans_m)))

Submission status: Wrong Answer

Solution code:
import datetime

def main():
    H1, M1, H2, M2, K = map(int, input().split())

    start = H1*60 + M1
    sleep = H2*60 + M2

    print( K * ( abs((sleep - 1)-start) // K) )


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k =(int(x) for x in input().split())  

hrtom= (h2-h1)

if m2-m1 < 0 : 
    min = (h2-h1)*60 - (m2-m1) - k

else:
    min = (h2-h1)*60 + (m2-m1) -k 
    
print(min)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = (int(i) for i in input().split())

time_time = (H2 - H1) * 60
time_minitue = abs(M1 - M2)

cost_time = abs(K - time_time - time_minitue)

print(cost_time)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())

if M2 >= K:
    M2 -= K
else:
    K -= M2
    p = K // 60
    r = K % 60
    H2 -= p
    if r:
        M2 -= 60 - r
    else:
        M2 = 0

print(60 - M1 + (H2 - H1 - 1) * 60 + M2)

Submission status: Wrong Answer

Solution code:
hmk = input('')

h1 = int(hmk.split(' ')[0])
m1 = int(hmk.split(' ')[1])
h2 = int(hmk.split(' ')[2])
m2 = int(hmk.split(' ')[3])
k = int(hmk.split(' ')[4])

h = h2 - h1
m = m2 - m1
if m < 0:
    m = m1 - m2
    h-=1

a = h*60 + m - k
print(a)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = map(int,input().split())
print((H2-H1)*60 + (M1 + M2) - K)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int,input().split())

awake = (H2-H1)*60 - M2 -M1  #[min]
study = awake-K

print(study)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

a = m2 - m1
if a < 0:
    mm = (h2 - h1 - 1) * 60 + abs(a)
else:
    mm = (h2 - h1) * 60 + a

print(mm - k if mm % k == 0 else mm)

Submission status: Wrong Answer

Solution code:

import sys
import math
import itertools
import collections

H1,M1,H2,M2,K = map(int,input().split())
H = H2 - H1
M = M2 - M1 - 2

total = M + H * 60
print(total//K * K)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))

start = n[0]*60 + n[1]
end = n[2]*60 + n[3]

zikan = end - start -1
kai = zikan // n[4] * n[4]
print(kai)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
h = (h2 - h1) % 24
m = (m2 - m1) % 60

print(max(0, h*60 + m - k))

Submission status: Wrong Answer

Solution code:
import math
#S=input()
#N=int(input())
#A,B,C=input().split()
H1,M1,H2,M2,K=map(int,input().split())
#A=list(map(int,input().split()))
T=(H2*60+M2)-(H1*60+M1)
if T%K==0:
    T=T-K
else:
    T=math.floor(T/K)*K

print(T)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k= map(int, input().split())
h3 = h2 - h1
m3 = m2 - m1
if m3 < 0:
    h3 -= 1
    
ans = (h3 * 60) + abs(m3) - k
if ans <= 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
h1 = 12 - h1
h2 = h2 -12
x = abs(h2 + h1) * 60 - k
print(x)

Submission status: Wrong Answer

Solution code:
a=input().split(' ')
a[0]=int(a[0])
a[1]=int(a[1])
a[2]=int(a[2])
a[3]=int(a[3])
a[4]=int(a[4])
b=(a[0]*60)+a[1]
c=(a[2]*60)+a[3]
print(c-b+a[4])

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = list(map(int, input().split()))

h3 = h2 - h1
m3 = m2 - m1
if m3 < 0:
    h2 = h2 - 1
    m3 = 60 - m1 + m2

a = h3 * 60 + m3
ans = a - k

print(ans)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = map(int,input().split())

h = H2 - H1
m = M2 - M1
s = 0
if h > 0:
    s = h * 60 + m
else:
    s = (24 + h) * 60 + m


if s - K > 0:
    s -= K
else:
    s = 0
print(s)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = list(map(int, input().split()))

time = (h2 - h1) * 60 + abs(m1 - m2) - k

print(time)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
time1 = h1*60+m1
time2 = h2*60+m1
print(time2-time1-k)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

h1, m1, h2, m2, k = list(map(int, input().split()))


if h2*60+m2-h1*60+m1-k < 0:
    print((h2+24)*60+m2-h1*60+m1-k)
else:
    print(h2*60+m2-h1*60+m1-k)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int,input().split())

h=h2 - h1
if h < 0:
    h = 24+h
m=m2 - h2

du=h*60+m - 0.5

print(int((du//k)*k))

Submission status: Wrong Answer

Solution code:
a=input().split(' ')
a[0]=int(a[0])
a[1]=int(a[1])
a[2]=int(a[2])
a[3]=int(a[3])
a[4]=int(a[4])
b=(a[1]*60)+a[2]
c=(a[2]*60)+a[3]
print(c-b+a[4])

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input().split())
minute=(h2-h1)*60+(m2-m1)
#print(minute)
if minute<k:
    print(0)
elif minute%k==0:
    print(minute-k)
elif minute%k!=0:
    print(minute)

Submission status: Wrong Answer

Solution code:
x = list(map(int, input().split()))
h = (x[2] - x[0])*60
if x[2] != x[0]:
    m = abs(x[1] - x[3])
else:
    m= 0
ans = max(m+h-x[-1], 0)
print(ans)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = list(map(int,input().split()))

min1 = H1*60 + M1
min2 = H2*60 + M2
min = min2 - min1

if min >= 0:
  print((min // K - 1)*K)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import datetime

def main():
    H1, M1, H2, M2, K = input().split()
    dt1 = datetime.datetime.strptime(H1+M1, '%H%M')
    input_time1 = dt1.time()
    dt2 = datetime.datetime.strptime(H2+M2, '%H%M')
    input_time2 = dt2.time()
    ans = int((dt2-dt1).total_seconds() // 60)
    if ans - int(K) >= 0:
        print(ans - int(K))
    else:
        print(0)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

h3 = h2 - h1
m3 = m2 - m1
if m3 < 0:
    h2 = h2 - 1
    m3 = 60 - m1 + m2

a = h3 * 60 + m3
ans = a - k

print(ans)

Submission status: Wrong Answer

Solution code:
H = list(map(int,input().split()))

h = H[2]-H[0]
m = H[3]-H[1]

if h < 0:
    h = h + 24

if m < 0:
    h -= 1

mini = h*60 + m - H[4]

if mini < 0:
    mini = 0

print(mini)

Submission status: Wrong Answer

Solution code:
H, M, h, m, K = map(int, input().split())
wake = H * 60 + M
sleep = h * 60 + M
if wake < sleep:
    spinner = sleep - wake
    oops = spinner - K
else:
    spinner = wake - sleep
    oops = spinner - K
print(oops)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
t1 = h1 * 60 + m1
t2 = h2 * 60 + m2

if t1 > t2:
    print((719 - t1 + t2) // k * k)
else:
    print((t2 - t1 - 1) // k * k)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = [int(arg) for arg in input().split()]
print((h2-h1)*60 - (m2-m1) - k)

Submission status: Wrong Answer

Solution code:
sh,sm,eh,em,k = map(int,input().split())

h = eh - sh
m = em - sm

if m < 0:
    h -= 1

totalm = 60*h + m
ans = totalm - k
print(abs(ans))

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-

import sys

def main():
    h1,m1,h2,m2,k = map(int,input().split())
    print(((h2*60)+m2-(h1*60)+m1)-k)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

time1 = h1*60 + m1
time2 = h2*60 - m2

a = (time2 - time1) // k
b = (time2 - time1) % k

if b == 0:
    t = a-1
else:
    t = a

ans = t*k
print(ans)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = map(int,input().split())
if (H1, M1) > (H2, M2):
	H2 += 24
print(max(0, 60*H2 + M2 - (60*H1 + M2) - K))

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

time = (h2 - h1) * 60 + (m2 - m1) - 1

print((time // k) * k)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())

a = 60 * H1 + M1
b = 60 * H2 + M2 - 1
ans = b - a

print(ans // K * K)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

a,b,c,d,e = map(int,input().split())
minites = c*60+d - a*60 + b 
if minites < 0:
  print(60*24 +minites -e)
else:
  print(minites -e)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
pos = 60 * (h2 - h1) + abs(m2 - m1)
print(max(0, pos - k))

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
h = (h2 - h1) % 24
m = (m2 - m1) % 60

print(h*60 + m - k)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k =(int(x) for x in input().split())  

hrtom= (h2-h1)

if m2-m1 < 0 : 
    min = (h2-h1)*60 - (m2-m1) - k

else:
     min = (h2-h1)*60 + (m2-m1) -k 
    
print(min)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = list(map(int, input().split()))

wake = (h2 * 60 + m2) - (h1 * 60 + m1)
just = False
if ((wake % k) == 0):
    just = True

ans = wake // k
if (just):
    ans -= 1

print(ans*k)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = list(map(int, input().split()))
time = (H2 - H1) * 60 + M2 - M1
study = 0
while study + K < time:
    study += K
print(study)

Submission status: Wrong Answer

Solution code:
s=list(input())
for i in range(s.count("?")):
  s[s.index("?")]="D"
print("".join(s))

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
 
if h1 <= h2:
    time = h2 * 60 + m2 - h1 * 60 + m1
else:
    time = (h2+24) * 60 + m2 - h1 * 60 + m1
if k >= time:
    print(0)
else:
    print(time - k)

Submission status: Wrong Answer

Solution code:
H_1,M_1,H_2,M_2,K=input().split()
H_1=int(H_1)
M_1=int(M_1)
H_2=int(H_2)
M_2=int(M_2)
K=int(K)
K_1=K//60
K_2=K%60
H_2=H_2-K_1
if M_2>=K_2:
    M_2=M_2-K_2
if M_2<K_2:
    M_2=M_2+60-K_2
    H_2=H_2-1
H=H_2-H_1
if M_2>=M_1:
    M=M_2-M_1
    answer=60*H+M
    print(answer)
if M_2<M_1:
    M=M_2+60-M_1
    answer=60*(H-1)+M
    print(answer)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k= map(int, input().split())
h3 = h2 - h1
m3 = m2 - m1
if m3 < 0:
    h3 -= 1
    
ans = (h3 * 60) + abs(m3) - k
print(ans)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

h = h2 - h1
m = m2 - m1

if m < 0:
    h -= 1
    m = 60 - m2 + m1

ans = 60*h + m - k
if ans < 0:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
h,m,h2,m2,k=map(int,input().split())
a=h*60+m
b=h2*60+m2
#print(b)
if (b-a)%k==0:
    print((b-a)-k)
else:
    print((b-a)-(b-a)%k)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

sabunh = h2 - h1
sabunm = m2 - m1 
zikantai = sabunh * 60 + sabunm
ans = 0
zikantai -= k
while(zikantai > 0):
    zikantai -= k
    ans += k
print(ans)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input('').split(' '))
dh=h2-h1
dm=m2-m1
if dm<0:
    dm=dm+60
    dh=dh-1
sm=(dh*60+dm)-((dh)*60+(dm))%k
if sm%k==0:
    sm=sm-k
print(sm)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())

ans = 60 * H2 + M2 - 60 * H1 + M1 - K
if ans <= 0:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
sh,sm,eh,em,k = map(int,input().split())

h = eh - sh
m = em - sm

if m < 0:
    h -= 1

totalm = 60*h + m
ans = totalm - k
print(ans)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int,input().split())

h=h2 - h1
if h < 0:
    h = 24+h
m=m2 - h2

du=h*60+m

print((du//k)*k)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())

h1 = H1 * 60
m1 = M1
h2 = H2 * 60
m2 = M2

ans = (h2 - m2) - (h1 + m1) - K if (h2 - m2) > (h1 + m1) else (h2 - m2) - (h1 + m1) - K + 24 * 60

print(ans)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k = map(int, input().split())
h1 += m1/60
h2 += m2/60
val = h2-h1
val *= 60
val -= k
print(max(0,int(val)))

Submission status: Wrong Answer

Solution code:
num_list = list(map(int, input().split())) 

a=num_list[2]-num_list[0]
b=num_list[3]-num_list[1]
if b>0:
    a=a-1
a=a*60
c=b+a-num_list[4]
print(c)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K=map(int, input().split())
a=(H2-H1)*60+(M2-M1)
if H1>H2:a+=24*60
if M1>M2:a+=60
print(a-K)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = map(int,input().split())
print(max(0, 60*H2 + M2 - (60*H1 + M2) - K))

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

h = h2 - h1

if m2 >= m1:
    m = m2 - m1
else:
    m = m1 - m2
    h -= 1

working_time = h*60 + m

print(working_time - k)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input().split())
print(h1*60+m1-k-m2-60*h2)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = list(map(int, input().split()))

wake = (h2 * 60 + m2) - (h1 * 60 + m1)
print(wake)
just = False
if ((wake % k) == 0):
    just = True

ans = wake // k
if (just):
    ans -= 1

print(ans*k)

Submission status: Wrong Answer

Solution code:
from math import *
from sys import stdin,stdout
input=stdin.buffer.readline

ip=[int(x) for x in input().split()]
h1=ip[0]
m1=ip[1]
h2=ip[2]
m2=ip[3]
k=ip[4]

time=(h2*60+m2-1)-(h1*60+m1+1)
x=time//k
if(k*x<0):
	print(0)
else:
	print(k*x)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int,input().split())
x = 60*max(0, h2-h1-1)
x += (60-m1 + m2 - 1)
print(x // k * k)

Submission status: Wrong Answer

Solution code:
hmk = input('')

h1 = int(hmk.split(' ')[0])
m1 = int(hmk.split(' ')[1])
h2 = int(hmk.split(' ')[2])
m2 = int(hmk.split(' ')[3])
k = int(hmk.split(' ')[4])

h = h2 - h1
m = m2 - m1
if m1 > m2:
    m = m1 - m2
    h-=1

a = h*60 + m - k
print(a)

Submission status: Wrong Answer

Solution code:

h1 , m1 , h2 , m2 , k = map(int , input().split())
diff1 = (h1)*60 + m1
diff2 = h2*60 + m2
diff = diff1-diff2
ans = diff - k
#print(diff1,diff2,diff,ans)
if ans <=0:
	print(0)
else:
	print(ans)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())		# 5 7 2

dm = (h2*60+m2) - (h1*60+m1) - 1

ans = max(0, dm // k) * k
print(ans)

Submission status: Wrong Answer

Solution code:
# s = input()
# n = int(input())
h1, m1, h2, m2, k = map(int, input().split())
# l = list(map(int, input().split()))
if m1 <= m2:
    t = (h2 - h1)*60 + m2 - m1
else:
    t = (h2 - h1 - 1)*60 + (60 - abs(m1 - m2))
if t <= k:
    print(0)
elif t%k == 0:
    print(t - k)
else:
    print(t - t%k)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = list(map(int, input().split()))
#n, m = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
# a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
#py = [list(map(int, input().split())) for i in range(m)]
# b = list(map(int, input().split()))
total = (h2-h1)*60
if m1 <= m2:
    total += (m2-m1)
else:
    if m2 == 0:
        total += 60-m1
    else:
        total += (m1-m2)
    total -= 60

ans = total - k
print(ans)

Submission status: Wrong Answer

Solution code:
h1 , m1 , h2 , m2 , k = map(int, input().split())

h = h2 - h1

if m2 == m1:
    m = 0
elif m2 > m1:
    m = m2 - m1
else:
    m = m2 + (60 - m1)





print(h*60+m-k)

Submission status: Wrong Answer

Solution code:
H = list(map(int,input().split()))

h = H[2]-H[0]
m = H[3]-H[1]

if h < 0:
    h = h + 24

if m < 0:
    h -= 1

mini = h*60 + m - H[4]

print(mini)

Submission status: Wrong Answer

Solution code:
H, M, h, m, K = map(int, input().split())
wake = H * 60 + M
sleep = h * 60 + M
spinner = sleep - wake
oops = spinner - K
print(oops)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())

H = (H2 - H1) * 60
M = M2 - M1

res = (H+M) - K

if res >= K:
    print(res)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input().split())
h3=h2-h1
h3=h3*60+m1+m2

print(h3-k)

Submission status: Wrong Answer

Solution code:
h, m, H, M, k = map(int, input().split())
h = h*60
H = H*60
if h+m > H+M:
    print(1440 - (H-M) - k)
else:
    print(abs((h+m) - (H-M)) - k)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())

if H1 > H2 or (H1 == H2 and M1 >= M2):
    H2 += 24
    
diff_min = H2*60 + M2 - (H1*60 + M1)
if diff_min - K < 0:
    print(0)
else:
    diff_min - K

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
hk = k // 60
mk = k - 60 * hk

if m1+mk >=60:
    h1 += 1
    m1 = m1 + mk -60
else:
    m1 = m1 + mk
h1 += hk

if m2- m1< 0:
    h2 -= 1
    m2 = m2- m1+ 60
h = h2 - h1
print(h*60 + m2)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e = map(int,input().split())

f = c - a
g = d - b
if g < 0:
  g = 60 - g
  f -=1
total = 60 * f + g
if total - e <= 0:
  print('0')
else:
    total -= e 
    print(total)

Submission status: Wrong Answer

Solution code:
h,m,H,M,k = map(int,input().split())
v = H*60+M
u = h*60+M
print(max(v-k-u,0))

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
 
time = h2 * 60 + m2 - h1 * 60 + m1
if k >= time:
    print(0)
else:
    print(time - k)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e = map(int, input().split())

f = abs(c-a)
g = abs(d-b)
h = f * 60
i = g + h

print(i - e)

Submission status: Wrong Answer

Solution code:
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10


    h1,m1,h2,m2,k = LMIIS()
    wake = h1*60+m2
    sleep = h2*60+m2
    if wake > sleep:
        sleep += 24*60
    print(sleep-wake-k)

    
main()

Submission status: Wrong Answer

Solution code:
H,M,h,m,K = map(int,input().split())
A = H*60 + M
B = h*60 + m
X = B - A - K
print(min(X,0))

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

diff = (h2-h1)*60 + (m2-m1)

print(max(0, k*(diff//k-1)))

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input().split(" "))
g=0
if k>=60:
  g=1
  hk=int(k/60)
  mk=k%60
else:
  hk=0
  mk=k


if  m2>=mk:
  m3=m2-mk
  h3=h2-hk
else:
  h3=h2-1-hk
  m3=m2+60-mk
if h3<0:
  h3=24+h3
  
if m3>=m1:
  ans=m3-m1+(h3-h1)*60
else:
  ans=m1+60-m3+(h3-h1-1)*60
print(ans)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k=map(int,input().split())
if(h1==h2):
    print(m2-m1-k)
elif(m1<m2):
    print((h2-h1+1)*60+(60-m1)+m2-k)
else:
    print((h2-h1)*60+(m2-m1)-k)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

a = (h2*60+m2)-(h1*60+m1)

if(a>=k):
  print((h2*60+m2)-k)
else :
  print(0)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())		# 5 7 2

dm = (h2*60+m2) - (h1*60+m1) - 1

ans = dm // k * k
print(ans)

Submission status: Wrong Answer

Solution code:
time = map(int, input().split())
list1=[]
for i in time:
    list1.append(i)
time1 = (list1[2]-list1[0])*60
minute = time1  - list1[4]
print(minute)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().rstrip().split())
minutes = M2 - M1
hours = 0
if minutes < 0:
    minutes += 60
    hours += 1
hours = H2 - H1
minutes += hours * 60
answer = minutes - K
if answer < 0:
    answer = 0
print(answer)

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int,input().split())

if H2 <= H1:
    print(0)

time2m = H2 * 60 + M2
time1m = H1 * 60 + M1

study_time = time2m - K - time1m

if study_time <= 0:
    print(0)
else:
    print(study_time)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
pos = 60 * (h2 - h1) + abs(m2 - m1)
print(pos - k)

Submission status: Wrong Answer

Solution code:
h1, m1, h2, m2, k = map(int, input().split())

print(h2*60+m2-h1*60+m1-k)

Submission status: Wrong Answer

Solution code:
def resolve():
    h1,m1,h2,m2,k = map(int, input().split())
    while k:
        if k==0:
            break
        if m2>k:
            m2-=k
            k=0
        else:
            m2=0
            k-=m2
            if k<60:
                h2-=1
                m2=60-k
                k=0
            else:
                k-=60
                h2-=1

    print(60*(h2-h1)+m2-m1)
resolve()

Submission status: Wrong Answer

Solution code:
FH, FM, TH, TM, K = map(int, input().split())
M = (TH*60+TM)-(FH*60+FM)
ans = M // K-(1 if M%K == 0 else 0)
print(ans*K)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k = map(int,input().split())
h = h2 - h1
m = m2 - m1
if m < 0:
    h -= 1
    m = 60 + m
time = h * 60 + m
ans = time // k
ans *= k
print(ans - k)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

h1, m1, h2, m2, k = list(map(int, input().split()))

print(h2*60+m2-h1*60+m1-k)

Submission status: Wrong Answer

Solution code:
import math
#S=input()
#N=int(input())
#A,B,C=input().split()
H1,M1,H2,M2,K=map(int,input().split())
#A=list(map(int,input().split()))
T=math.floor(((H2-H1)*60+(M2-M1))/K)*K
if ((H2-H1)*60+(M2-M1))%K==0:
    T=T-K
if T<=0:
    T==0
print(T)

Submission status: Wrong Answer

Solution code:
h1,m1,h2,m2,k = map(int,input().split())

dm = m2 - m1
if h2 < h1:
    h2 +=24

if dm < 0:
    h2 -= 1
    dm = 60 - dm

print((h2 - h1)*60 + dm - k)