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: Accepted

Solution code:
import datetime
H1, M1, H2, M2, K = map(int, input().split())
t1 = datetime.datetime(2020, 1, 1, H1, M1)
t2 = datetime.datetime(2020, 1, 1, H2, M2)
print(int((t2 - t1).total_seconds() / 60 - K))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

min1=h1*60+m1
min2=h2*60+m2

print(min2-min1-k)

Submission status: Accepted

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

h1 *= 60
h2 *= 60
su = h1 + m1
sl = h2 + m2

ans = 0
if sl < su:
    ans = su + 1440 - sl
else:
    ans = sl - su

if ans < 0:
    print(0)
else:
    print(max(ans - k, 0))

Submission status: Accepted

Solution code:
a, b, c, d, e = map(int, input().split())
x = (c-a)*60+d-b
#print(x)
#if c!=a:
#    x += 60
x-=e
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

H = h2-h1

if(m2-m1<0):
    M = 60 + m2 -m1
    H -=1
else:
    M = m2-m1

time = 60*H+M

if time <= k:
    print(0)
else:
    print(time-k)

Submission status: Accepted

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

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

p = time - k

ans = time - p

print(p)

Submission status: Accepted

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

if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import datetime as dt

H1, M1, H2, M2, K = map(int, input().split())
start = dt.timedelta(hours=H1, minutes=M1)
end = dt.timedelta(hours=H2, minutes=M2)
# print((end - start).seconds // 60)
total = (end - start).seconds // 60
print(total - K)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(t)

Submission status: Accepted

Solution code:
H,M,HH,MM,K=map(int,input().split())

hour = HH - H -1
minute=60+MM-M
time = hour * 60 + minute - K

print(time)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
"""this is python work script"""

def solver(H1, M1, H2, M2, K):
    """solve this problem"""
    min1 = H1 * 60 + M1
    min2 = H2 * 60 + M2
    diff = min2 - min1
    answer = diff - K
    return answer

def main():
    """main function"""
    H1, M1, H2, M2, K = list(map(int, input().rstrip().split(' ')))
    answer = solver(H1, M1, H2, M2, K)
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    h1, m1, h2, m2, k = MI()

    min1 = h1 * 60 + m1
    min2 = h2 * 60 + m2

    # print(min2 - min1)
    print(max(0, min2-min1-k))


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

if time < k:
    print(0)
else:
    print(time-k)

Submission status: Accepted

Solution code:
a,b,c,d,k = map(int,input().split())
t1 = a*60+b
t2 = c*60+d
ans = t2 - k - t1
print(ans)

Submission status: Accepted

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

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

if t >= k:
  print(t - k)

Submission status: Accepted

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

HH = (H2 - H1) * 60
MM = M2 - M1

print(HH + MM - K)

Submission status: Accepted

Solution code:
A,B,C,D,E=map(int,input().split())
F=A*60+B
G=C*60+D
H=G-F
I=H-E
print(I)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h, m,h2, m2,k = map(int, input().split())
mp=0
while True:
    m+=1
    mp+=1
    if m==60:
        h+=1
        m=0
    if h==h2 and m==m2:
        break
print(mp-k)

Submission status: Accepted

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

total = (H2-H1)*60+(M2-M1)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,d,k = map(int, raw_input().split(' '))
print c * 60 + d - (a*60 + b) - k

Submission status: Accepted

Solution code:
H1, M1, H2, M2, K = map(int, input().split())
Hk, Mk = K//60, K%60
Htmp = H2 - Hk
Mtmp = M2 - Mk
if Mtmp < 0:
    Mtmp += 60
    Htmp -= 1
    
Htmp = Htmp - H1
Mtmp = Mtmp - M1
if Mtmp < 0:
    Mtmp += 60
    Htmp -= 1

    
print(Htmp * 60 + Mtmp)

Submission status: Accepted

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

t1 = h1*60 + m1
t2 = h2*60 + m2

ans = max(0,(t2 - k) - t1)

print(ans)

Submission status: Accepted

Solution code:
h0, m0, h1, m1, k = map(int, input().split())

p0 = h0 * 60 + m0
p1 = h1 * 60 + m1

q = p1 - k
#print(p0,p1)
#print((p1 - p0) // k * k)

print(max(q - p0,0))

Submission status: Accepted

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys
d = [int(s) for s in stdin.readline().rstrip().split()]
h1 = d[0]
m1 = d[1]
h2 = d[2]
m2 = d[3]
k = d[4]
if h1 > h2:
    print(0)
elif h2 == h1:
    num = m2-m1
    if num <= 0:
        print(0)
    else:
        if (num-k) <= 0:
            print(0)
        else:
            print(num-k)
else:
    minu = m2-m1
    if minu < 0:
        res = (h2-h1-1)*60+(minu+60)
        if (res-k) <= 0:
            print(0)
        else:
            print(res-k)
    else:
        res = (h2-h1)*60+(minu)
        if (res-k) <= 0:
            print(0)
        else:
            print(res-k)

Submission status: Accepted

Solution code:
h1,m1,h2,m2,k =[int(x) for x in input().split()]
minute = (h2*60+m2) - (h1*60+m1) - k
if minute <= 0:
    print(0)
else:
    print(minute)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a, b, c, d, k = map(int, input().split())
print(max(0, (c - a) * 60 + (d - b) - k))

Submission status: Accepted

Solution code:
H_1, M_1, H_2, M_2, K = map(int, input().split())

h = H_2-(H_1+1)
m = 60-M_1+M_2

print(h*60+m-K)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#import math

def main():
    H1, M1, H2, M2, K = tuple(int(c) for c in input().split(' '))

    dh = (H2 - H1) * 60
    dm = M2 - M1
    delta = dh + dm

    print(delta - K)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
h,m,H,M,k = map(int,input().split())

t1 = 60*h + m
t2 = 60*H + M

ans = t2 - t1 - k
print(ans)

Submission status: Accepted

Solution code:
h, m, H, M, K = map(int, input().split())

if M >= m :
    k = (H - h) * 60
    k += M - m
    
else :
    k = (H - h - 1) * 60
    k += 60 - m
    k += M
    
if k - K <= 0 :
    print(0)
else :
    print(k - K)

Submission status: Accepted

Solution code:
a,b,x,y,k=map(int,input().split())
min=(x*60+y)-(a*60+b)
print(min-k)

Submission status: Accepted

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

Submission status: Accepted

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

su = 0
h1 += 1
su += (h2 - h1) * 60
su += (60 - m1) + m2
print(su-k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

begin = h1 * 60 + m1
end = h2 * 60 + m2

last_start = end - k

ans = last_start - begin

print(ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

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

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

print(t)

Submission status: Accepted

Solution code:
h_1, m_1, h_2, m_2, k = map(int, input().split())

wake_time = (h_2 - h_1) * 60 - m_1 + m_2
print(wake_time - k)

Submission status: Accepted

Solution code:
h, m, H, M, K = map(int, input().split())

print(H*60 +M - ( h*60 +m  + K ))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

H1,M1,H2,M2,K = map(int, input().split())
#List = list(map(int, input().split()))
#List = list(input().split())
print(((H2*60)+M2)-((H1*60)+M1)-K)

Submission status: Accepted

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

sum1 = i[0] * 60 + i[1]
sum2 = i[2] * 60 + i[3]
ans = sum2 - sum1 - i[4]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h1, m1, h2, m2, k = map(int, input().split())
##勉強できる時間
h = 60*(h2 - h1)
m = m2-m1
time = h + m - k
print(time)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
h, m, i, n, k = map(int, input().split())

fun1 = 60 * h + m
fun2 = 60 * i + n

sa = fun2-fun1

if sa > k:
    ans = sa -k
else:
    ans = 0

print(ans)

Submission status: Accepted

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

hm1 = h1*60+m1
hm2 = h2*60+m2

t = hm2 - k

ans = t - hm1

print(ans)

Submission status: Accepted

Solution code:
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

def read_int_list():
    return list(map(int,input().split(' ')))

def read_s_list_loop(n):
    return [input() for _ in range(n)]


H1,M1,H2,M2,K = read_int_map()

h = H2 - H1
m = M2 - M1

amount = h*60 + m
print(amount-K)

Submission status: Accepted

Solution code:
h_1,m_1,h_2,m_2,k=map(int,input().split())

cnt=(h_2*60+m_2)-(h_1*60+m_1)

print(cnt-k)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line=input().split()
line=[int(i) for i in line]

wake=60*line[0]+line[1]
sleep=60*line[2]+line[3]
time=sleep-wake
start=time-line[4]
print(start)

Submission status: Accepted

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

h = (H2 - H1) * 60
m = M2 - M1

print(h + m - K)

Submission status: Accepted

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

if st < sto:
    if sto-st-k > 0:
        print(sto-st-k)
    else:
        print(0)

else:
    if sto+24*60 - st -k > 0:
        print(sto+24*60 - st -k)
    else:
        print(0)

Submission status: Accepted

Solution code:
h_1,m_1,h_2,m_2,k = map(int,input().split())

judge = h_2*60+m_2 - (h_1*60+m_1)
if judge - k>=0:
  ans = judge - k
else:
  ans = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

H1 = H1_M1_H2_M2_K[0]
M1 = H1_M1_H2_M2_K[1]
H2 = H1_M1_H2_M2_K[2]
M2 = H1_M1_H2_M2_K[3]
K = H1_M1_H2_M2_K[4]

dif_H = H2 - H1
dif_M = M2 - M1

ans = (dif_H * 60 + dif_M - K)
print(ans)

Submission status: Accepted

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

a1 = H1 * 60 + M1
a2 = H2 * 60 + M2

ans = a2 - a1 - K
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

h = h2 - h1

if m1 <= m2:
    m = m2 - m1
else:
    m = (60 - m1) + m2
    h = h - 1

t = (h * 60) + m

print(t-k)

Submission status: Accepted

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

ans = ((H2 - H1) * 60) + (M2 - M1) - K

if ans < 0:
  ans = 0

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
h1, m1, h2, m2, k = map(int,input().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
#np_ary=np.array([1,2,3,4,5])
l = list(map(int, input().split()))
l[0]*=60
l[2]*=60
o=[0 ,0]
o[0]=l[0]+l[1]
o[1]=l[2]+l[3]
p=o[1]-o[0]-l[4]
print(p)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import datetime

l = list(map(int, input().split()))
A = l[0]
B = l[1]
H = l[2]
M = l[3]
K = l[4]

m1 = A*60 + B
m2 = H*60 + M
delta = m2-m1 
answer = delta - K
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

dH = H2-H1
dM = M2-M1

dm = 60*dH+dM

print(dm-K)

Submission status: Accepted

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

h = h2 - h1
m = m2 - m1

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

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

Submission status: Accepted

Solution code:
h_1, m_1, h_2, m_2, k = map(int, input().split())

times = h_2 * 60 + m_2 - (h_1 * 60 + m_1)

print(times - k)

Submission status: Accepted

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

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

okiru=(60*H2+M2)-(60*H1+M1)

print("{}".format(okiru-K))

Submission status: Accepted

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

t1 = H1 * 60 + M1
t2 = H2 * 60 + M2

if t2 - t1 <= K:
    print(0)
else:
    print(t2-t1-K)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    h1, m1, h2, m2, k = map(int, input().split())
    if h1 > h2:
        h2 += 24
    h = h2 - h1
    if m1 > m2:
        m2 += 60
        h-=1
    m = m2 - m1
    print(h*60 + m - k)
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Accepted

Solution code:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
# from collections import defaultdict,deque,Counter
# from heapq import heappush,heappop
# import numpy as np
# n=int(input())

h1,m1,h2,m2,k=LI()
t1=60*h1+m1
t2=60*h2+m2
print(max(0,-t1+t2-k))

Submission status: Accepted

Solution code:
# coding: utf-8

l = list(map(int,input().split()))

t = 0
if l[3] >= l[1]:
    t += (l[2]-l[0]) * 60
    t += l[3]-l[1]
else:
    if l[0]+1 == l[2]:
        t += l[3]-l[1]+60
    else:
        t += (l[2]-l[0]-1) * 60
        t += l[3]-l[1]+60

ans = max((t-l[4]),0)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

h1, m1, h2, m2, k = Is()
start = h1*60+m1
end = h2*60+m2
time = end - k - start
if time < 0:
    time += 24*60

print(time)

Submission status: Accepted

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

hd = h2 - h1
if m1 > m2:
  hd -= 1
  m2 += 60
md = m2 - m1

m = hd * 60 + md

print(m-k)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
h_1, m_1, h_2, m_2, k = map(int, input().split())
time_m = h_2*60 + m_2 - (h_1*60 + m_1) - k
if time_m >= 0:
    print(time_m)
else:
    time_m = 24*60 - (h_2*60 + m_2) + h_1*60 + m_1 - k
    print(time_m)

Submission status: Accepted

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

if m1<=m2:
    print(max((h2-h1)*60+m2-m1-k,0))
else:
    print(max((h2-h1-1)*60+m2+60-m1-k,0))

Submission status: Accepted

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

T1 = H1*60 + M1
T2 = H2*60 + M2

if T1 > T2:
    T2 += 24*60

ans = (T2 - K) - T1

print(ans)

Submission status: Accepted

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

if h1<=h2:
  h1m=h1*60+m1
  h2m=h2*60+m2
  print(h2m-h1m-k)
else:
  h1m=h1*60+m1
  h2=(h2+12)*60+m2
  print(h2m-h1m-k)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


h1, m1, h2, m2, k = MI()
t = h2 * 60 + m2
s = h1 * 60 + m1
print(max(0, t-k-s))

Submission status: Accepted

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

okiteru = int(H2)*60 + int(M2) - int(H1)*60 - int(M1)

kaisi = okiteru - int(K)

print(kaisi)

Submission status: Accepted

Solution code:
H1, M1, H2, M2, K = tuple(map(int, input().split()))
# H1 = 10
# M1 = 0
# H2 = 15
# M2 = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

print(a-k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
s = S.split()

H1 = int(s[0])
M1 = int(s[1])
H2 = int(s[2])
M2 = int(s[3])
K = int(s[4])

awake_minutes = (H2-H1)*60 + (M2-M1)
study_minutes = awake_minutes - K

print(study_minutes)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    line = list(map(int,input().split()))
    H1 = line[0]
    M1 = line[1]
    H2 = line[2]
    M2 = line[3]
    K = line[4]
    h = H2-H1
    m = M2 - M1
    if m < 0:
        h -= 1
        m %= 60
    k = h*60+m-K
    print(k)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

H = H2 - H1
M = M2 - M1

answer = H*60 + M - K
print(answer)

Submission status: Accepted

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

m=(H2*60+M2)-(H1*60+M1)

print(m-K)

Submission status: Accepted

Solution code:
import io,sys
sys.setrecursionlimit(10**9)

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

Submission status: Accepted

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
h1,m1,h2,m2,k=map(int,input().split())
t1=h1*60+m1
t2=h2*60+m2
if t2<=t1:
  t2+=24*60
t=t2-t1
print(max(0,t-k))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ANS = ((H2-H1)*60) + (M2-M1) - K
print(ANS)

Submission status: Accepted

Solution code:
H1, M1, H2, M2, K = map(int, input().split())
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

#K = int(input())
#S = input()

if (H2*60+M2>=H1*60+M2):
    print((H2*60+M2)-(H1*60+M1)-K)
else:
    print((H2*60+M2)+(24*60)-(H1*60+M2)-K)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    # N = int(input())
    # QUERYS = [input().split() for _ in range(Q)]
    H1, M1, H2, M2, K = [int(a) for a in input().split()]
    # A = [int(a) for a in input().split()]
    # T1, T2, T3 = [int(a) for a in input().split()]
    s = H1*60+M1
    e = H2*60+M2

    print(e-s-K)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

h1,m1,h2,m2,k=mii()

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

Submission status: Accepted

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

Submission status: Accepted

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

time = 60*(eh-sh) + em - sm
print(time - K)

Submission status: Accepted

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

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

begin = h2 - k

print(begin-h1)

Submission status: Accepted

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

wake = H1*60 + M1
sleep = H2*60 + M2
time = int((sleep-wake))

print(time-K)