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 sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

h1, m1, h2, m2, k = MAP()
strt = h1 * 60 + m1
end = h2 * 60 + m2
print(end - strt - k)

Submission status: Accepted

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    h1, m1, h2, m2, k = map(int, input().split())
    start = h1 * 60 + m1
    end = h2 * 60 + m2
    print(end - start - k)
resolve()

Submission status: Accepted

Solution code:
"""
じょえチャンネルおもしろいよ～～～
https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
"""

h1,m1,h2,m2,k=map(int,input().split())
a1=h1*60+m1
a2=h2*60+m2
print(max(0,a2-a1-k))

Submission status: Runtime Error

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

H=h2-h1
M=m2-m1

if(M<0):
  m += 60
  H -= 1
if(H<0):
  H += 24

M += H*60

ans =M - K
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A= list(map(int, input().split()))
S = sum(A)
ans = 0
leaf = 1
S_now = 0

if A[0] == 1:
  if N==0:
    print(1)
  else:
    print(-1)
elif A[0] != 0:
  print(-1)
else:
  for i in range(N):
    ans += leaf
    leaf -= A[i]
    S_now += A[i] 
    leaf = min(leaf*2,S-S_now)

print(ans+A[-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools
N = int(input())
A = [int(_) for _ in input().split()]
if A[0] != 0:
    if N == 0 and A[0] == 1:
        print(1)
    else:
        print(-1)
    exit()
ans = 1
n = 1
if A[0] > 1:
    print(-1)
    exit()
cumr = list(itertools.accumulate(A[::-1]))[::-1]
for i in range(1, N):
    minn = n - A[i - 1]
    n = min(2 * (n - A[i - 1]), cumr[i])
    ans += n
    if 0 <= minn <= n:
        continue
    print(-1)
    exit()
if n <= A[-1] <= 2 * n:
    ans += A[-1]
    print(ans)
else:
    print(-1)
    exit()

Submission status: Runtime Error

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

a = 60(h2-h1)
b = m2-m1
##起きている合計時間
c = a+b
##勉強開始時間の最遅時間
d = c-k
print(d)

Submission status: Runtime Error

Solution code:
import sys
2 readline = sys.stdin.buffer.readline
3
4 h1, m1, h2, m2, k = map(int, readline().split())
5 print(60 * (h2 - h1) + m2 - m1 - k)

Submission status: Runtime Error

Solution code:
study = (60*H2 + M2) - (60*H1 + M1) - K
study

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
h1=input('>>')
m1=input('>>')
h2=input('>>')
m2=input('>>')
k=input('>>')
print('60*(h2-h1)+(m2-m1)-k')

Submission status: Runtime Error

Solution code:
h1 = int(input("H1  "))
m1 = int(input("M1  "))
h2 = int(input("H2  "))
m2 = int(input("M2  "))
k = int(input("K  "))

min = m1
hour = h1
sum_min = 0
cnt=0
while True:

    if hour == h2:
        if m2 <= min:
            min -= k
            sum_min -= k
            break

    min += k
    sum_min += k
    if min >= 60:
        min = min - 60
        hour += 1

    # 永久ループにハマった時用にbreak
    if cnt==50:
        break
    cnt +=1
print(sum_min)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
2.import re
3.import copy

wake_up_hour,wake_up_minute,sleep_hour,sleep_minute,study_time = map(int, input().split())

print(wake_up_hour, wake_up_minute, sleep_hour, sleep_minute, study_time)
Total_Minutes = (sleep_hour) *60 + (sleep_minute) - ((wake_up_hour) * 60 + (wake_up_minute))

print(Total_Minutes)

if Total_Minutes > study_time:
    print("You can finish the study")
    start_before_minute= ((sleep_hour*60 +  sleep_minute) - study_time) % 60
    start_before_hour= ((sleep_hour*60 +  sleep_minute) - study_time) // 60 
    print("Start before: ", start_before_hour, start_before_minute, )
else:
    print("You are lazy!!!. wake up early")

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector< vector<int> >;

int main(){
	int h1,h2,m1,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k; 
	int h,m,t;
	h = h2-h1;
	m = m2-m1;
	t = h*60+m;
	cout << t - k << endl;
}

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * (n+1)
    if n == 1 and A[0] != 0:
        print(-1)
        exit()
        
    # Adが葉の個数、Bdが葉でないものの個数
    # A0 + B0 = 1
    # Bd ≤ Ad+1 + Bd+1 ≤ 2Bd --> B[d-1] - A[d] ≤ B[d] ≤ 2B[d-1] - A[d]
    # Bd ≤ Ad+1 + Ad+2 + · · · + AN = s - (A1 + ... + Ad)

    # now_s :葉の数
    now_s = sum(A)
    s = now_s
    for i in range(n+1):
        if i == 0:
            B[i] = 1 - A[i]
        else:
            now_s -= A[i]
            B[i] = min(now_s, 2 * B[i - 1] - A[i])
            #print(A,B,now_s)
            if B[i] < 0:
                print(-1)
                exit()

    print(sum(B) + s)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n=int(input())
a = list(map(int, input().split()))
if (a[0]==1 and n+1>1) or a[0]>1:
    print(-1)
    sys.exit()
if a[-1]==0:
    print(-1)
    sys.exit()

su=[0]*(n+1)
for i in range(1,n+1)[::-1]:
    su[i-1]+=su[i]+a[i]
#print(su)
yo_next=2-a[0]
cnt=yo_next+1

for i in range(1,n):
    if yo_next-a[i]<1:
        print(-1)
        sys.exit()
    
    yo_next=min(su[i],(yo_next-a[i])*2)
    cnt+=yo_next
    #print(cnt,su[i+1],(yo_next-a[i])*2)
print(cnt)

Submission status: Runtime Error

Solution code:
from datetime import datetime,timedelta

a=[1,1,1,1,1]
a[0]=input()
a[1]=input()
a[2]=input()
a[3]=input()
a[4]=input()
a=[int(x) for x in a] 
t1=datetime(2000,1,1,a[0],a[1],0)
t2=datetime(2000,1,1,a[2],a[3],0)

delta=t2-t1
total_seconds=delta.seconds

ans=(total_seconds-a[4]*60)/60
print(int(ans))

Submission status: Runtime Error

Solution code:
from datetime import datetime,timedelta

a=[int(input()) for _ in range(5)]

t1=datetime(2000,1,1,a[0],a[1],0)
t2=datetime(2000,1,1,a[2],a[3],0)

delta=t2-t1
total_seconds=delta.seconds

ans=(total_seconds-a[4]*60)/60
print(int(ans))

Submission status: Runtime Error

Solution code:
from datetime import datetime,timedelta

a=[int(input()) for _ in range(5)]

t1=datetime(2000,1,1,a[0],a[1],0)
t2=datetime(2000,1,1,a[2],a[3],0)

delta=t2-t1
total_seconds=delta.seconds

ans=(total_seconds-a[4]*60)/60
print(ans)

Submission status: Runtime Error

Solution code:
from datetime import datetime,timedelta

a=[int(input()) for _ in range(4)]

t1=datetime(2000,1,1,a[0],a[1],0)
t2=datetime(2000,1,1,a[2],a[3],0)

delta=t2-t1
total_seconds=delta.seconds

ans=(total_seconds-a[4]*60)/60
print(ans)

Submission status: Runtime Error

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


m3=k%60
h3=(k-m2)/60
ans=(h2-h3-h1)*60 + (m2-m3-m1)

print(ans)

Submission status: Runtime Error

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

B = []

if N == 0:
    if A[0] != 1:
        print(-1)
        exit()
    else:
        print(1)

else:
    if A[0] != 0:
        print(-1)
        exit()
    else:
        B.append(1)
        for i in range(N + 1):
            B.append((B[i - 1] - A[i - 1]) * 2)
            if (A[i] > B[i] or (A[i] == B[i] and i != N)):
                print(-1)
                exit()

        ans = 0
        ans += A[N]
        B[N] = A[N]
        for i in range(N + 1, -1, -1):
            ans += min(B[i], B[i + 1] + A[i])
            B[i] = min(B[i], B[i + 1] + A[i])

        print(ans)
        exit()

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
 
n = int(readline())
a = list(map(int,readline().split()))

b = [0]*(n+1)
b[-1] = a[-1]
for i in range(n-1,-1,-1):
  b[i] = b[i+1]+a[i]
#print(b)
c = [1]*(n+1)
for i in range(n):
  c[i+1] = (c[i]-a[i])*2
#print(c)
ans = 0
for i in range(n+1):
  m = min(b[i],c[i])
  if m < 0:
    ans = -1
    break
  ans += m
  
if n == 0:
  ans = 1
if a[0] != 0:
  ans = -1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def aaaa():
    n=int(input())
    a=list(map(int, input().split()))
    ans=0
    if a[0]>0:
        return -1
    nezen=1
    hazen=0
    line=[]
    liha=[]
    line.append(nezen)
    liha.append(hazen)
    su=0
    su=sum(a[x] for x in range(len(a)))
    for x in range(1,n+1):
        if nezen<=0:
            return -1
        ha=a[x]
        su-=ha
        ne=min(nezen*2-ha,su)
        nezen=ne
        line.append(ne)
        liha.append(ha)
    line[n]=0
    for x in range(len(line)):
        ans+=line[x]+liha[x]
    return ans
print(aaaa())

Submission status: Runtime Error

Solution code:
"""
H1時M1分起床
H2時M2分就寝
K分勉強
"""

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

awake_time = H1 *60 + M1
sleep_time = H2 *60 + M1
start_limit_time = sleep_time - K

can_study_time = start_limit_time - awake_time

print(can_study_time)

Submission status: Runtime Error

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

x = (h2 - h1) * 60 + (m2 - m1)  # 起きている時間の長さ（分）
print(x - k)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
V = [0]*(N+1)
flug = 0
Lsum= sum(A)

V[0] = 1
for i in range(N):
    V[i+1] = (V[i]*2 - A[i+1])
    if V[i+1] <= 0 and i != N-1 :
        flug = 1
    if V[i+1] < 0 and i == N-1 :
        flug = 1
    Lsum = Lsum - A[i+1]
    if V[i+1] > Lsum :
        V[i+1] = Lsum

ans = sum(V)+sum(A)
if A[0] != 0:
    ans = -1
if flug == 1:
   ans = -1
if N == 0:
    ans = -1

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
last = A[-1]
count = last
root = 1
for i in range(N):
  if root <= A[i]:
    print(-1)
    break
  if i+1 == N and root-A[i] > A[i+1]:
    root = last + A[i]
  elif root-A[i] > (last + A[i+1]):
    root = (last + A[i+1]) + A[i]
  count+=root
  root = (root-A[i])*2
else:
  if count == 0 or root < last:
    count = -1
  print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
bottom = sum(A)

if N == 0:
  if A[0] != 1:
    print(-1)
  else:
    print(1)
  exit()
 
ret = 1
children = 1 - A[0]
bottom -= A[0]
 
for i in range(N):
    children = children * 2 - A[i+1]
    if children <= -1:
      ret = -1
      break
    
    bottom -= A[i+1]
    if children >= bottom:
      children = bottom
    ret += children + A[i+1]
print(ret)

Submission status: Runtime Error

Solution code:
def main():
  n = int(input()) + 1
  a = [int(x) for x in input().split()]
  q = [0] * n
  for i in range(n):
    q[i] = (q[i - 1] - a[i - 1]) * 2 if i != 0 else 1
    # print(q[i])
    if q[i] <= 0:
      print(-1)
      return
  
  if q[n - 1] < a[n - 1]:
    print(-1)
    return
  q[n - 1] = a[n - 1]
  s = q[n - 1]
  # print('--')
  # print(q[n - 1])
  for i in range(n - 2, -1, -1):
    q[i] = min(q[i], q[i + 1] + a[i])
    if q[i] == 0:
      print(-1)
      return
    # print(q[i])
    s += q[i]
  print(s)

main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
bottom = sum(A)

if A[0] >= 2:
  print(-1)
  exit()

ret = 1
children = 1 - A[0]
bottom -= A[0]
 
for i in range(N):
    children = children * 2 - A[i+1]
    if children <= -1:
      ret = -1
      break
    
    bottom -= A[i+1]
    if children >= bottom:
      children = bottom
    ret += children + A[i+1]
print(ret)

Submission status: Runtime Error

Solution code:
n= int(input())

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

#print(a)

if a[0] != 0:
    print(-1)
    exit(0)

if n == 0:
    print(-1)
    exit(0)

b=1
count=1
asum =sum(a)
alim = asum

for i in range(n-1):
    if a[i+1] > 2*b:
        print(-1)
        exit(0)
    else:
        alim = alim - a[i+1]
        b= min(2*b-a[i+1], alim)

        count += b



print(count+ asum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# coding:utf-8
readline = sys.stdin.buffer.readline
H1 = int(readline())
M1 = int(readline())
H2 = int(readline())
M2 = int(readline())
K = int(readline())
while not 0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59:
    H1 = int(readline())
    M1 = int(readline())
    H2 = int(readline())
    M2 = int(readline())
    K = int(readline())
if M2 > M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Runtime Error

Solution code:
# coding:utf-8
import readline
import datetime
readline = sys.stdin.buffer.readline
H1 = int(readline())
M1 = int(readline())
H2 = int(readline())
M2 = int(readline())
K = int(readline())
while not 0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59:
    H1 = int(readline())
    M1 = int(readline())
    H2 = int(readline())
    M2 = int(readline())
    K = int(readline())
if M2 > M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import numpy
n=int(input())
a=input()
a=a.split()
M=1
m=int(a[n])
Ml=list()
ml=list()
Ml.append(M)
ml.append(m)
Q=0
if int(a[0])>=1:
    print(-1)
    sys.exit()
for i in range(n):
    M=2*M-int(a[i+1])
    if M<0:
        print(-1)
        sys.exit()
    M1=M+int(a[i+1])
    Ml.append(M1)
    m=m+int(a[n-i-1])
    ml.insert(0,m)
numpy.array(Ml)
numpy.array(ml)
Q1=numpy.minimum(Ml,ml)
Q1=sum(Q1)
print(Q1)

Submission status: Runtime Error

Solution code:
s = input()


count = 0
for i in range(len(s)):
  if s[i] == "P" && s[i + 1] == "D":
    count += 1
  elif s[i] == "D":
    count += 1
  elif s[i] == "?" && s[i + 1] == "D":
    count += 1
    
print(count)

Submission status: Runtime Error

Solution code:
def step(n, lis):
  return [l+n for l in lis]

def func(lis):
  if len(lis)==0:
    return -1
  maxval = max(lis)
  lis.pop(lis.index(maxval))
  if maxval==2:
    lis.append(1)
  if maxval>2:
    lis.append(maxval-1)
    lis.append(maxval-2)
  lis.sort()
  lis = lis[:maxA]
  return maxval
N = int(input())
A = list(map(int, input().split()))
maxA = max(A)

lis = [0]
count = 0
ans = 0
flag=False
for i in range(N+1):
  count += 1
  if flag:
    break
  if A[i]==0:
    continue
  lis = step(count, lis)
  count=0
  a = A[i]
  #print(i,lis)
  for j in range(a):
    
    res = func(lis)
    #print(i, res, lis)
    if res == -1:
      flag=True
      break
    else:
      ans += res
  
if flag:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
am = int(input())
pm = int(input())
k = int(input())
print(((pm - am) * 60) - k)

Submission status: Runtime Error

Solution code:
T = list(input())

x = 0
while len(T) != 0:
    x += sum([int(f) for f in T[::2]])

    xmax = 0
    delIdx = 0
    for i in range(len(T)):
        T_copy = T.copy()
        _tmp = T_copy.pop(i)

        _x = sum([int(f) for f in T_copy[::2]])

        if _x > xmax:
            xmax = _x
            delIdx = i

    T.pop(delIdx)

print(x)

Submission status: Runtime Error

Solution code:
n = int(input())

a = list(map(int, input().split()))
d = 0
t = 0.5

for i in range(n+1):
    d += (1+i)*a[i]
    t += a[i]/(2.0**(i+1))
    
k = sum(a)-1
d = d - 1/2*k*(k+1)

if t > 1.0:
    print('-1')
else:
    print(int(d))

Submission status: Runtime Error

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

H1 = int(sys.stdin.readline())
M1 = int(sys.stdin.readline())
H2 = int(sys.stdin.readline())
M2 = int(sys.stdin.readline())
K = int(sys.stdin.readline())

while not (H1 < 23 or M1 < 59 or H2 < 23 or M2 < 59):
	H1 = int(sys.stdin.readline())
	M1 = int(sys.stdin.readline())
	H2 = int(sys.stdin.readline())
	M2 = int(sys.stdin.readline())
	K = int(sys.stdin.readline())
else:
	if M2 >= M1:
		a = (H2 - H1) * 60 + M2 - M1
		print(a - K)
	if M2 < M1:
		b = (H2 - H1) * 60 + M1 - M2
		print(b - K)

Submission status: Runtime Error

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

# H1 = int(sys.stdin.readline())
# M1 = int(sys.stdin.readline())
# H2 = int(sys.stdin.readline())
# M2 = int(sys.stdin.readline())
# K = int(sys.stdin.readline())

H1 = 999
M1 = 999
H2 = 999
M2 = 999
K = 999


while not (H1 < 23 or M1 < 59 or H2 < 23 or M2 < 59):
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())
else:
    if M2 >= M1:
        a = (H2 - H1) * 60 + M2 - M1
        print(a - K)
    if M2 < M1:
        b = (H2 - H1) * 60 + M1 - M2
        print(b - K)

Submission status: Runtime Error

Solution code:
chr = input().split(" 0 ")
a = (int(chr[1])-int(chr[0]))*60 - int(chr[-1])
print(a)

Submission status: Runtime Error

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

# H1 = int(sys.stdin.readline())
# M1 = int(sys.stdin.readline())
# H2 = int(sys.stdin.readline())
# M2 = int(sys.stdin.readline())
# K = int(sys.stdin.readline())

H1 = 999
M1 = 999
H2 = 999
M2 = 999
K = 999


while not (0 <= H1 < 23 or 0 <= M1 < 59 or 0 <= H2 < 23 or 0 <= M2 < 59):
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())
else:
    if M2 >= M1:
        a = (H2 - H1) * 60 + M2 - M1
        print(a - K)
    if M2 < M1:
        b = (H2 - H1) * 60 + M1 - M2
        print(b - K)

Submission status: Runtime Error

Solution code:
import sys

# H1 = int(sys.stdin.readline())
# M1 = int(sys.stdin.readline())
# H2 = int(sys.stdin.readline())
# M2 = int(sys.stdin.readline())
# K = int(sys.stdin.readline())

H1 = 999
M1 = 999
H2 = 999
M2 = 999
K = 999


while not (0 <= H1 < 23 or 0 <= M1 < 59 or 0 <= H2 < 23 or 0 <= M2 < 59):
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

if M2 >= M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
bottom = sum(A)

if A[0] >= 1:
  print(-1)
  exit()

ret = 1
children = 1

for i in range(N):
    children = children * 2 - A[i+1]
    if children <= -1:
      ret = -1
      break
    
    bottom -= A[i+1]
    if children >= bottom:
      children = bottom
    ret += children + A[i+1]
    print(children)
    print(bottom)
print(ret)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
a = np.array(list(map(int, input().split())))
l = 0
n = 1
b = 0
g = np.zeros(N+1)
g[0] = 1-a[0]
for i in range(N+1):
    if a[i] < 0:
        l = -1
for i in range(1, N+1):
    g[i] = (g[i-1]-a[i-1])*2
    if g[i] <= 0:
        l = -1
g[N] = a[N]
for i in range(1, N+1):
    if l<0:
        break
    b = N-i
    if g[b] > g[b+1]+a[b]:
        g[b] = g[b+1]+a[b]
    if g[b] <= 0:
        l = -1
        break
if a[0] != 0 or l == -1:
    print(-1)
else:
    print(int(sum(g)))

Submission status: Runtime Error

Solution code:
import sys

H1 = int(sys.stdin.readline())
M1 = int(sys.stdin.readline())
H2 = int(sys.stdin.readline())
M2 = int(sys.stdin.readline())
K = int(sys.stdin.readline())


while not (0 <= H1 < 23 or 0 <= M1 < 59 or 0 <= H2 < 23 or 0 <= M2 < 59):
	H1 = int(sys.stdin.readline())
	M1 = int(sys.stdin.readline())
	H2 = int(sys.stdin.readline())
	M2 = int(sys.stdin.readline())
	K = int(sys.stdin.readline())

if M2 >= M1:
	a = (H2 - H1) * 60 + M2 - M1
	print(a - K)
if M2 < M1:
	b = (H2 - H1) * 60 + M1 - M2
	print(b - K)

Submission status: Runtime Error

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

H1 = int(sys.stdin.readline())
M1 = int(sys.stdin.readline())
H2 = int(sys.stdin.readline())
M2 = int(sys.stdin.readline())
K = int(sys.stdin.readline())


while not (0 <= H1 < 23 or 0 <= M1 < 59 or 0 <= H2 < 23 or 0 <= M2 < 59):
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

if M2 >= M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Runtime Error

Solution code:
import sys

H1 = int(sys.stdin.readline())
M1 = int(sys.stdin.readline())
H2 = int(sys.stdin.readline())
M2 = int(sys.stdin.readline())
K = int(sys.stdin.readline())


while not (0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59):
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

if M2 >= M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Runtime Error

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

H1 = int(sys.stdin.readline())
M1 = int(sys.stdin.readline())
H2 = int(sys.stdin.readline())
M2 = int(sys.stdin.readline())
K = int(sys.stdin.readline())


while 0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59:
    if M2 >= M1:
        a = (H2 - H1) * 60 + M2 - M1
        print(a - K)
        break
    if M2 < M1:
        b = (H2 - H1) * 60 + M1 - M2
        print(b - K)
        break
else:
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

Submission status: Runtime Error

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

H1 = int(sys.stdin.readline())
M1 = int(sys.stdin.readline())
H2 = int(sys.stdin.readline())
M2 = int(sys.stdin.readline())
K = int(sys.stdin.readline())


if not 0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59:
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

if M2 >= M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
if N == 0 and A[0] == 1:
    print(1)
else:
    nodes = [0]*(N+1)
    s_d = 0 # 飽和してないノードが残ってる深さ
    cap_d = 1 - A[0]
    failed = False
    for i, a in enumerate(A):
        # a個の葉をなるべく浅いノードから取る
        while a > 0:
            # これ以上分岐することろがなければ失敗
            if i < s_d or cap_d <= 0:
                failed = True
                break
            # s_dから枝を取れるだけ取る
            x = min(cap_d - nodes[s_d], a)
            a -= x
            nodes[s_d:i+1] = [node + x for node in nodes[s_d:i+1]]
            # s_dがいっぱいになったら深さを一つ進める
            if nodes[s_d] >= cap_d:
                cap_d -= A[s_d]
                cap_d *= 2
                s_d += 1
        if failed:
            break
    print(-1 if failed else sum(nodes))

Submission status: Runtime Error

Solution code:
import sys

H1 = int(sys.stdin.readline())
M1 = int(sys.stdin.readline())
H2 = int(sys.stdin.readline())
M2 = int(sys.stdin.readline())
K = int(sys.stdin.readline())


while not 0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59:
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

if M2 >= M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Runtime Error

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

H1 = int(sys.stdin.readline())
M1 = int(sys.stdin.readline())
H2 = int(sys.stdin.readline())
M2 = int(sys.stdin.readline())
K = int(sys.stdin.readline())


while not 0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59:
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

if M2 >= M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 <= M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Runtime Error

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

H1 = int(sys.stdin.readline())
M1 = int(sys.stdin.readline())
H2 = int(sys.stdin.readline())
M2 = int(sys.stdin.readline())
K = int(sys.stdin.readline())


while not 0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59:
    H1 = int(sys.stdin.readline())
    M1 = int(sys.stdin.readline())
    H2 = int(sys.stdin.readline())
    M2 = int(sys.stdin.readline())
    K = int(sys.stdin.readline())

if M2 > M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Runtime Error

Solution code:
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    print(-1)
resolve()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

H1 = sys.stdin.readline()
M1 = sys.stdin.readline()
H2 = sys.stdin.readline()
M2 = sys.stdin.readline()
K = sys.stdin.readline()


while not 0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59:
    H1 = sys.stdin.readline()
    M1 = sys.stdin.readline()
    H2 = sys.stdin.readline()
    M2 = sys.stdin.readline()
    K = sys.stdin.readline()

if M2 > M1:
    a = (H2 - H1) * 60 + M2 - M1
    print(a - K)
if M2 < M1:
    b = (H2 - H1) * 60 + M1 - M2
    print(b - K)

Submission status: Runtime Error

Solution code:
wake_up_hour= int(input())

Submission status: Runtime Error

Solution code:
wake_up_hour= int(input())
wake_up_minute=int(input())
sleep_hour=int(input())
sleep_minute= int(input())
study_time=int(input())

#Total_Minutes = (sleep_hour) *60 + (sleep_minute) - ((wake_up_hour) * 60 + (wake_up_minute))
#if Total_Minutes > study_time:
#    start_before_minute= ((sleep_hour*60 +  sleep_minute) - study_time) % 60
#    start_before_hour= ((sleep_hour*60 +  sleep_minute) - study_time) // 60 
#    print("Start before: ", start_before_hour, start_before_minute, )
#else:
#    print("You are lazy!!!. wake up early")

Submission status: Runtime Error

Solution code:
wake_up_hour= int(input())
wake_up_minute=int(input())
sleep_hour=int(input())
sleep_minute= int(input())
study_time=int(input())

#print(wake_up_hour, wake_up_minute, sleep_hour, sleep_minute, study_time)
Total_Minutes = (sleep_hour) *60 + (sleep_minute) - ((wake_up_hour) * 60 + (wake_up_minute))
if Total_Minutes > study_time:
    print("You can finish the study")
    start_before_minute= ((sleep_hour*60 +  sleep_minute) - study_time) % 60
    start_before_hour= ((sleep_hour*60 +  sleep_minute) - study_time) // 60 
    print("Start before: ", start_before_hour, start_before_minute, )
else:
    print("You are lazy!!!. wake up early")

Submission status: Runtime Error

Solution code:
wake_up_hour= int(input("Enter WakeUp Hour: "))
wake_up_minute=int(input("Enter WakeUp Minute: "))
sleep_hour=int(input("Enter Sleep Hour: "))
sleep_minute= int(input("Enter Sleep Minute:" ))
study_time=int(input("Study time :"))

#print(wake_up_hour, wake_up_minute, sleep_hour, sleep_minute, study_time)
Total_Minutes = (sleep_hour) *60 + (sleep_minute) - ((wake_up_hour) * 60 + (wake_up_minute))
if Total_Minutes > study_time:
    print("You can finish the study")
    start_before_minute= ((sleep_hour*60 +  sleep_minute) - study_time) % 60
    start_before_hour= ((sleep_hour*60 +  sleep_minute) - study_time) // 60 
    print("Start before: ", start_before_hour, start_before_minute, )
else:
    print("You are lazy!!!. wake up early")