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:
# coding: utf-8
#import numpy as np
import re
import math
from collections import defaultdict
from collections import deque
import collections
from fractions import Fraction
from queue import PriorityQueue
import itertools
from copy import deepcopy
import random
import time
import os
import sys
import datetime
from functools import lru_cache
from functools import reduce
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
alphabet="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):
    if b:print("yes")
    else:print("no")
def Yn(b):
    if b:print("Yes")
    else:print("No")
def YN(b):
    if b:print("YES")
    else:print("NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(bbool,ret1,ret2):
    if bbool:return ret1
    else:return  ret2
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def pm(x):
    return x//abs(x)
def inputintlist(): 
    return list(map(int,input().split()))
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])#[cost,x]
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)#x→yが複数ある場合のためにmin()する
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def ruisekiwa(A):
    ret=[0]*(len(A)+1)
    for a in range(len(A)):
        ret[a+1]=ret[a]+A[a]
    return ret
def getmd(x1,y1,x2,y2):
    return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):
    return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow









######################################################################################################
H,M,HH,MM,K=inputintlist()
M+=H*60
MM+=HH*60-K

print(MM-M)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

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


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

print(end - K - start)

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:
a,b,c,x,y= map(int, input().split())


ans = c*60 + x - a*60 -b 

print(ans - y)

Submission status: Accepted

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

t = (h - H)*60 + m - M

print(t - k)

Submission status: Accepted

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

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

Submission status: Accepted

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

get = h_1 * 60 + m_1
sleep = h_2 * 60 + m_2


print(max(sleep-get - k,0))

Submission status: Accepted

Solution code:
a,b,c,d,k = map(int,input().split())
time = (c-a)*60
if d < b:
    time -= (b-d)
else:
    time += (d-b)
print(time - k)

Submission status: Accepted

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

if h2<h1:
    h2=24+h2

hours=h2-h1

if m2<m1:
    m2+=60
    hours-=1
min=m2-m1

time= min+ 60*hours

print(time-k)

Submission status: Accepted

Solution code:
h = list(map(int, input().split()))
M = 0
if h[1]!=0:
  M += 60-h[1]
  h[0] += 1
H = h[2]-h[0]
M += h[3] + H*60
print(M-h[4])

Submission status: Accepted

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

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation



'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD
combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        #sqrt(n)+1以上は考えて約数はないので却下
        if n % k == 0:
            return False
            #割り切れたらFalse
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  # [1, 0, 3]

'''

def factorial(x, mod=10**9+7):
    # x!
    # 階乗
    # ex) factorial(5) = 120
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''
"#a,bの最大公約数"
def gcd(a, b):
    while b:#0以外なら進んでいくが、0になった時にとまる余りが0より、最大公約数と言える
        #print(a,b)#2,3
        #やり方てきにユークリッドの互除法か
        a, b = b, a % b#aには2 bには2%3が入る
    return a

"#a,bの最小公倍数"
def lcm(a, b):
    return a * b // gcd (a, b)

"#nの約数を全て求める"
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

'''
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xaf\xb0...
lowercase = 'abcdefghijklmnopqrstuvwxyz'
octdigits = '01234567'
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace = '\t\n\x0b\x0c\r '
'''
'''
引数endに任意の文字列を指定すると、その文字列が改行の代わりに最後に挿入される。例えば連続するprint()の出力を改行なしで単純に連結したい場合は空文字列''を指定すればよい。

print('abc', end='---')
print('xyz')
# abc---xyz

print('abc', end='')
print('xyz')
# abcxyz
source: print_basic.py
なお、デフォルトで改行されるのは引数endのデフォルト値が改行文字'\n'に設定されているから。
'''

def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    #lenを変数に置くと事故るから注意
    #n=int(input())
    #a,b=input().split(" ")#a,bがともに文字列のとき
    h1,m1,h2,m2,k=map(int, input().split(" "))
    sh=60*h1+m1
    enh=60*h2+m2
    print(enh-sh-k)
    #mapでとってもstrで変換すればappend可能
    #s=input()
    #a=[i for i in s]#int(i)にすれば数字も行ける
    #nl=list(map(int, input().split(" ")))#数字の時
    #print(a)
    #brray=[list(map(int, input().split(" ")))for i in range(n)]
    #print(brray)


    #for i in range(1,n+1,2):#これで1個飛ばしループになる
    # pass
     #print(i)

    l = ['aaa', 'bbb', 'ccc']
    x=l.index('aaa')#ある要素のインデックス番号を取得
    #s = ''.join(l)
    #s = " ".join(map(str,a))#スペースを空ける時はこう
    #print(s)
    # aaabbbccc

    #if state in known_states and not flag: # state => 2 steps => 5
        #こうやってある要素がリストの中にあるか探すのか
    #print(f'steps: {steps}, state: {state}')
    #こう書いてあるとデバックしやすい

    #dp= [[0]*3 for i in range(5)]#列　行
    #dp用の0の入ったやつ
    #dp= [[0]*(w+1) for i in range(n+1)]#0からwまでのw+1回計算するから
    #print(dp)＃初期条件が入る分計算回数+1列分必要(この場合は判断すべきものの数)
    DP = np.zeros(w+1, dtype=int)#これでも一次元リストが作れる
    exdp=np.zeros((3,4)) # ３×４の２次元配列を生成。2次元ならこう
    #dtypeは指定しないとfloatになる
    #for i in range(n):#ちょっとした入力に便利
    #    a, b = map(int, input().split())
        #dp[i][0] += [a]
        #これだとintとlistをつなぐことになって不適
    #    dp[i] += [a]
    #    dp[i] += [b]
        #これはうまくいく
        #やり方はいろいろあるということ
    #print(dp)


    #brray=[list(map(int, input().split(" ")))for i in range(N)
    #print(brray)



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]#内包表記に慣れろ
    #print(pin_l)

    ls = ["a", "b", "c", "d", "e"]


    #print(ls[2:5])
    #スライスでの取得

    #print(ls[:-3])
    #一番左端から右から3番目より左まで取得

    #print(ls[:4:2])
    #スライスで1個飛ばしで取得
    #ないときは左端スタート
    #始点のインデックス番号 : 終点のインデックス番号 : スキップする数+1
    #print(ls[::2])
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

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:
n,m,nn,mm,k=map(int,input().split())
start=n*60+m
end=nn*60+mm
if end-start > k:
    print(end-start-k)
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

H, M, H_2, M_2, K = map(int, input().split())

mae = H * 60 + M
ato = H_2 * 60 + M_2

print(ato - mae - K)

Submission status: Accepted

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

hour = (h2 - h1) if m2 >= m1 else (h2-h1-1)
minute = m2 - m1 if m2 >= m1 else 60 + (m2 - m1)

ans = 60 * hour + minute - k

print(ans)

Submission status: Accepted

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

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

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

print(start)

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    HMK = list(map(int,input().split()))

    atime = HMK[2] * 60 + HMK[3] - HMK[0] * 60 - HMK[1]

    res = atime - HMK[4]

    print(res)



main()

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
    h-=1
ans  = h*60+m-k
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#A - Study Scheduling
H1,M1,H2,M2,K = map(int, input().split())
H=(H2-H1)*60
M=(M2-M1)
ans = K-(H+M)
print(abs(ans))

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

Submission status: Accepted

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

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

ans = ans -k
print(ans)

Submission status: Accepted

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

h=h2-h1
m=m2-m1

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

print(time-k)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H1, M1, H2, M2, K = map(int, rl().split())
    
    t1 = H1 * 60 + M1
    t2 = H2 * 60 + M2
    ans = t2 - K - t1
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    h1, m1, h2, m2, k = map(int, input().split())
    
    h = h2 - h1
    m = h * 60 + m2 - m1 - k
    print(m)
    
   
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# A - Study Scheduling

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    h1,m1,h2,m2,k = map(int,input().split())
    start = 60*h1+m1
    end = 60*h2+m2
    #print(start,end)
    total = 0
    for i in range(start,end+1):
        if i+k < end:
            total += 1

    print(total)

main()

Submission status: Accepted

Solution code:
import sys
import math

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

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

ans=max(m-K,0)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C ,D, K = map(int,input().split())

ans = (C-A)* 60 - B + D - K

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

st = H_1*60 + M_1
end = H_2*60 + M_2

tmp = end - K

print(tmp - st)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

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

s = 60 * h1 + m1
f = 60 * h2 + m2

ans = f-s-k

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# A

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

n1 = h1 * 60 + m1
n2 = h2 * 60 + m2

ans = n2 - n1 -k

print(ans)

Submission status: Accepted

Solution code:

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

mae = 60 * H1 + M1
ato = 60 * H2 + M2

zen = ato - mae

print(zen - K)

Submission status: Accepted

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

a = H1*60 + M1
b = H2*60 + M2

print(b-K-a)

Submission status: Accepted

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

if v1 <= v2:
    ans = v2 - v1 - K
else:
    v1 += 24 * 60
    ans = v2 - v1 - K
print(ans)

# 23:00 4:00 30

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8

import math
import re
import numpy as np

line = input().split(" ")

h1 = int(line[0])
m1 = int(line[1])
h2 = int(line[2])
m2 = int(line[3])
k = int(line[4])

#分に変換
wake_up = h1*60 + m1
sleep = h2*60 + m2

diff = sleep - wake_up
ans = diff - k

print(ans)

Submission status: Accepted

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

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

if t <= 0:
    print('0')
else:
    print(t)

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:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    H1,M1,H2,M2, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

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






if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = map(int,input().split())

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

# = [list(map(int,input().split())) for _ in range(XXXX)]

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

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

waketime = end - start

if waketime >= k:
    print(waketime - k)
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


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


def INT(): return int(input())


def MAP(): return map(int, input().split())


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


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    h1 , m1, h2, m2, k = MAP()
    time = 60 * (h2 - h1) + (m2 - m1)
    print(max(0, time-k))



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:


# from math import factorial as fac
from collections import defaultdict
# from copy import deepcopy
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange
# print(f.readline())
# sys.setrecursionlimit(10**6)

	
def print_case_iterable(case_num, iterable):
	print("Case #{}: {}".format(case_num," ".join(map(str,iterable))))

def print_case_number(case_num, iterable):
	print("Case #{}: {}".format(case_num,iterable))

def print_iterable(A):
	print (' '.join(A))

def read_int():
	return int(f.readline().strip())
def read_int_array():
	return [int(x) for x in f.readline().strip().split(" ")]
def rns():
	a =  [x for x in f.readline().split(" ")]
	return int(a[0]), a[1].strip()
def read_string():
	return list(f.readline().strip())
def bi(x):
	return bin(x)[2:]





from collections import deque
import math


def solution(h1,m1,h2,m2,k):
	return 60*(h2-h1) + (m2-m1) - k
	
			


def main():
	T = 1
	for i in range(T):
		h1,m1,h2,m2,k = read_int_array()
	
		x = solution(h1,m1,h2,m2,k)

		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			print >>output,str(x)# "Case #"+str(i+1)+':',
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()

if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
#example usage:
#    for l in res:
#       print >>output, str(len(l)) + ' ' +  ' '.join(l)

if __name__ == '__main__':
	main()

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

print(t)