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

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

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

t2 = (h2 - h1) * 60 + m1

m2 -= k
if m2 < 0:
    t2 += m2
    m2 = 0

print(max(0, t2 + m2))

Submission status: Wrong Answer

Solution code:
h,m,h2,m2,k=map(int,input().split())
if h < h2:
    a=h*60+m
    b=h2*60+m2

elif h>h2:
    a=h*60+m
    b=h2*60+m2 + 60*24
else:
    if m<m2:
        a=h*60+m
        b=h2*60+m2
    else:
        a=h*60+m
        b=h2*60+m2 + 60*24

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())
print(abs((h2*60+m2 - h1*60+m1)-k))

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
Y = B - A
print(min(X,0))

Submission status: Wrong Answer

Solution code:
h,m,h2,m2,k = map(int,input().split())

h3 =(h2-h)*60
print(h3-k)

Submission status: Wrong Answer

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

if(0<=r):
  print(r)
else:
  print("0")

Submission status: Wrong Answer

Solution code:
#スペース区切りの整数の入力
h1, m1, h2, m2, k = map(int, input().split())


asa = h1 * 60 + m1
yoru = h2 * 60 + m2


if(((yoru - asa )%k) == 0):
  ans = int((yoru - asa )/k)-1
else:
  ans = int((yoru - asa )/k)
print(ans* k)

Submission status: Wrong Answer

Solution code:
def main():
    array = list(map(int, input().split()))

    now = array[0]*60+array[1]
    finish = array[2]*60+array[3]
    K = array[4]
    ans = 0
    for _ in range(1000000):
        if now + K < finish:
            ans += K
            now += K
        else:
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
h,m,H,M,k = map(int,input().split())
tmp = (60*H+M)-(60*h+m)-0.1
a = tmp//k
ans = k*a
print(int(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

minutes1 = 60*h1 + m1
minutes2 = 60*h2 + m2

rest = minutes2 - minutes1
s, r = divmod(rest, k)

if r == 0:
    print((s-1)*k)
else:
    print(s*k)

Submission status: Wrong Answer

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

h1_m = h1 + m1/60
h2_m = h2 + m2/60

h = h2_m-h1_m

print(int(h*60-k))

Submission status: Wrong Answer

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

    ans = 0
    for i in range(min1, min2-k, k):
        # print(i)
        ans += k
    print(min(0, ans))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

##main#######################################

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

h1=arr[0]
m1=arr[1]
h2=arr[2]
m2=arr[3]
k=arr[4]

h1=h1*60 + m1
h2=h2*60 + m2
oki=h2-h1-1

ans=int(oki/k)*k
print(ans)

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
print(minutes-K)

Submission status: Wrong Answer

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

h1, m1, h2, m2, t = map(int, input().split())
diff = max(h2 - h1 - 1, 0) * 60 + (60 - m1) + m2
print(max(diff - t, 0))

Submission status: Wrong Answer

Solution code:
import os
import sys
from io import BytesIO, IOBase
def main():
    h1,m1,h2,m2,k=map(int,input().split())
    ht=h2-h1
    ht*=60
    if(m2>=m1):
        ht+=m2-m1
    else:
        ht-=m2-m1
    print(ht-k)

# fast-io region

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input():
    return sys.stdin.readline().rstrip("\r\n")


def write(*args, end="\n"):
    for x in args[:-1]:
        sys.stdout.write(str(x) + " ")
    sys.stdout.write(str(args[-1]))
    sys.stdout.write(end)


def r_array():
    return [int(x) for x in input().split()]


def r_int():
    return int(input())


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

print(k*(diff//k-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

hour = H2 - H1
if M1 > M2:
    hour -= 1

minute = abs(M2 - M1)

ans = hour * 60 + minute - K
if ans < 0:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

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

print((h2 - m2) - (h1 + m1) - K)

Submission status: Wrong Answer

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: Wrong Answer

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

wake = H1 * 60 + M1
sleep = H2 * 60 + M2
ans = 0
if wake <= sleep:
    time = sleep - wake
    while time > K:
        time -= K
        ans += K
else:
    time = 24 * 60
    time -= wake - sleep
    while time > 0:
        time -= K
        ans += K

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,d,e=map(int,input().split())
#a時b分、c,d,e分
time=(a-c)*60+b-d
ans=time-e
print(ans)

Submission status: Wrong Answer

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

H = H2 - H1
M = M2 - M1

M = abs(M2 - M1)

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

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 + (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 = map(int,input().split())

#print(h1,m1,h2,m2,k)
if m1 > m2:
    print((h2-h1-1)*60+m1-m2-k)
else:
    print((h2-h1)*60+m1-m2-k)

Submission status: Wrong Answer

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

h = h2 - h1
m = m2 - m2

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = list(map(int, input().split()))
time = (k[2] -k[0]) * 60 + ( (k[3] - 1) - k[1])
print(((time // k[4])) * k[4])

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
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:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

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

t2 = h2 - h1
t2 *= 60

m2 -= k
if m2 < 0:
    t2 += m2
    m2 = 0

print(max(0, t2))

Submission status: Wrong Answer

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

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) - 30

if res > K:
    print((H+M) - 30)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

high = max(h1 * 60 + m1, h2 * 60 - m2)
low = min(h1 * 60 + m1, h2 * 60 - m2)
print(max(high - low - k, 0))

Submission status: Wrong Answer

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

x = a[0]*60 + a[1]
y = a[2]*60 + a[3]

z = x - y

r = z - a[4]

if r <= 0:
    r = 0

print(r)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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)*60+(60-m1)+m2-k)
else:
    print((h2-h1)*60+(m2-m1)-k)

Submission status: Wrong Answer

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

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

if m < 0:
    h -= 1

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

print(mini)

Submission status: Wrong Answer

Solution code:
list = input().split()
 
h1 = int(list[0]) * 60
m1 = int(list[1])
h2 = int(list[2]) * 60
m2 = int(list[3])
 
diff = h2 + m2 - h1 + m1 - int(list[4])
 
print(diff)

Submission status: Wrong Answer

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

A=60*H2+M1 - K

print(A-60*H1-M1)

Submission status: Wrong Answer

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

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

t = hm2 - k

ans = t - hm1

print(ans)

Submission status: Wrong Answer

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

if H1 > H2:
    H2 += 24

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

print((h2 - m2) - (h1 + m1) - K)

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())
print((h2 * 60 + m2) - (h1 * 60 + m2) - 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)-(h1*60+m1)
x=time//k
if(k*x<time):
	if k*x<0:
		print(0)
	else:
		print(k*x)
else:
	if k*(x-1)<0:
		print(0)
	else:
		print(k*(x-1))

Submission status: Wrong Answer

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

ans = ((rem//K)-1)*K
print(ans)

Submission status: Wrong Answer

Solution code:

import os
import sys
from io import BytesIO, IOBase
def main():
    startHour, startMin, endHour, endMin, studyTime = map(int, input().rstrip().split())
    diff = endHour*60 - (startHour*60-startMin) + endMin
    if diff < studyTime:
        print(0)
    else:
        print(diff-studyTime)









##############################################################################################################
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

h = h2 - h1
m = abs(m2-m1)

print(h*60+m-k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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
hour = H2-H1
print(H1)
print(H2)
if M1 > M2:
  hour -=1
  minutes = abs(M2-M1)
else:
  minutes = M2-M1

print(hour*60+minutes-K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

hour = H2 - H1
if M1 > M2:
    hour -= 1

minute = abs(M2 - M1)

ans = hour * 60 + minute - K

print(ans)

Submission status: Wrong Answer

Solution code:
H1,M1,H2,M2,K = (int(x) for x in input().split())
Wake  = 60*H1+M1
Sleep = 60*H2+M2

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

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 = -g
  f -=1
total = 60 * f + g
if total - e <= 0:
  print('0')
else:
    total -= e 
    print(total)

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:
    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
M = 0

if M2 - M1 >= 0:
  M = M2 - M1
else:
  M = M1 - M2 + 60
  H -= 1
  
ans = H*60 + M - K

print(ans)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

hour = (H2-H1)*60
mini = M2-M1
sum = hour + mini

ans = sum // K
amari = sum % K

if amari == 0:
    print(K*(ans-1))
else:
    print(K*ans)

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:
	print(ans)
else:
	print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

begin = h2 - k

print(begin-h1)

Submission status: Wrong Answer

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

ans = max(0, H2 * 60 + M1 - H1 * 60 - M1 - K)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
h1, n1, h2, n2, k = map(int,input().split())
h = h2-h1
n = n2-n1
wake = 60*h + n-1
ans = int(wake/k)
print(ans*k)

Submission status: Wrong Answer

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

    
print(H2 * 60 + M2 + 10)

Submission status: Wrong Answer

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
    
print(k - K)

Submission status: Wrong Answer

Solution code:
#スペース区切りの整数の入力
h1, m1, h2, m2, k = map(int, input().split())


asa = h1 * 60 + m1
yoru = h2 * 60 + m2

#print(asa,yoru)

ans = int((yoru - asa )/k)-1

print(ans* k)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

    print(t2 - t1 - k)
#resolve()

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(X)

Submission status: Wrong Answer

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: Wrong Answer

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

start_mins = h1 * 60 + m1
end_min = h2 * 60 + m1

is_up = end_min - start_mins
can_start = is_up - k
print(max(0, can_start))

Submission status: Wrong Answer

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

time = 60*H2+M2 - 60*H1+M1

print(max(time-K, 0))

Submission status: Wrong Answer

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

J = H2 - H1
if (M1 > M2):
  J -= 1
  F = 60 - M1
else:
  F = M2 - M1
  
F = J * 60 + F

print(F - K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

h=h2-h1
m=0
if m2<m1:
    h-=1
    m=60+m2-m1
hm=h*60
ans=hm+m

print(ans-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:
h1,m1,h2,m2,k = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

H_ = H_2 * 60 + M_2 - K
H = H_ - (H_1*60+M_2)
print(H)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

dH = H2-H1
dM = M2-M1

dm = 60*dH+dM-1

print(dm//K*K)

Submission status: Wrong Answer

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

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

print((H+M) - 30)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = list(map(int, input().split()))
time = (k[2] -k[0]) * 60 + (k[3] - k[1])
print(((time // k[4]) - 1) * k[4])

Submission status: Wrong Answer

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

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

print(time-K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

m = m2-m1 + (h2-h1)*60 -1
print(m//k * 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 - m2 + m1

print(60*h + m - k)

Submission status: Wrong Answer

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

if m2 < m1:
    mm = m2 + 60 - m1
else:
    mm = m2 - m1

t = (h2 - h1) * 60 + mm

if t < m:
    print(0)
else:
    print(t - m)

Submission status: Wrong Answer

Solution code:
import os
import sys
from io import BytesIO, IOBase
def main():
    h1,m1,h2,m2,k=map(int,input().split())
    ht=h2-h1
    ht*=60
    if(m2>=m1):
        ht+=m2-m1
    else:
        ht-=60+m2-m1
    print(ht-k)

# fast-io region

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input():
    return sys.stdin.readline().rstrip("\r\n")


def write(*args, end="\n"):
    for x in args[:-1]:
        sys.stdout.write(str(x) + " ")
    sys.stdout.write(str(args[-1]))
    sys.stdout.write(end)


def r_array():
    return [int(x) for x in input().split()]


def r_int():
    return int(input())


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
H1, M1, H2, M2, K = map(int, input().split())
if(H1 > H2): H2 += 24
T1 = H1 * 60 + M1
T2 = H2 * 60 - M2
T = T2 - T1
print(T - 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-H1)*60+(M2-M1)-1))/K
print(math.floor(T)*K)

Submission status: Wrong Answer

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-start
if time < 0:
    time += 24*60

print(((time)//k)*k-k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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