Problem: You are given a string S as input. This represents a valid date in the year 2019 in the `yyyy/mm/dd` format. (For example, April 30, 2019 is represented as `2019/04/30`.)  Write a program that prints `Heisei` if the date represented by S is not later than April 30, 2019, and prints `TBD` otherwise.

Submission attempts (in order):
a, b, q = map(int, input().split())
sno = []
tno = []
dis = []
 
for i in range(a):
  sno.append(int(input()))
sno.append(10000)
 
for i in range(b):
  tno.append(int(input()))
tno.append(10000)
 
for i in range(q):
  dis.append(int(input()))
 
for i in range(q):
  sl = 0
  sr = 0
  tl = 0
  tr = 0
  
  for j in range(a):
    if sno[j] <= dis[i]:
      sl = dis[i] - sno[j]
      sr = sno[j+1] - dis[i]
      break
    else:
      pass
                
  for k in range(b):
    if tno[k] <= dis[i]:
      tl = dis[i] - tno[k]
      tr = tno[k+1] - dis[i]
      break
    else:
      pass
  
  lds = max(sl, tl)
  rds = max(sr, tr)
  dis = min(lds, rds)
  print(dis)

date = input()
tdate=()
 
for s in date:
  tdate.insert(s)
  
if tdate(5) != 0:
  mon = int(tdate(5) + tdate(6))
else:
  mon = int(tdate(6))
 
if mon <= 4:
  print("Heisei")
else:
  print("TBD")

date = input()
tdate=()
 
for s in date:
  tdate.insert(s)
  
if tdate(5) != "0":
  mon = int(tdate(5) + tdate(6))
else:
  mon = int(tdate(6))
 
if mon <= 4:
  print("Heisei")
else:
  print("TBD")

date = input()
tdate=()

for s in date:
  ldate.insert(s)

#syr = none


#yer = int(syr)

if ldate(5) != 0:
  mon = int(ldate(5) + ldate(6))
else:
  mon = int(ldate(6))



#else:

  
if mon <= 4:
  print("Heisei")
else:
  print("TBD")

a, b, q = map(int, input().split())
sno = [-10e6] + [int(input()) for _ in range(a)] + [10e6]
tno = [-10e6] + [int(input()) for _ in range(b)] + [10e6]
dis = [int(input()) for _ in range(q)]
 
for i in range(q):
 
    sl = 0
    sr = 0
    tl = 0
    tr = 0
 
    for j in range(a+2):
        if sno[j] >= dis[i]:
            sl = dis[i] - sno[j-1]
            sr = sno[j] - dis[i]
            break
        else:
            pass
 
    for k in range(b+2):
        if tno[k] >= dis[i]:
            tl = dis[i] - tno[k-1]
            tr = tno[k] - dis[i]
            break
        else:
            pass
 
    lds = max(sl, tl)
    rds = max(sr, tr)
    ans = min(lds, rds)
    print(ans)

date = input()
tdate=[]
 
for s in date:
  tdate.insert[s]
  
if tdate[5] != "0":
  mon = int(tdate[5] + tdate[6])
else:
  mon = int(tdate[6])
 
if mon <= 4:
  print("Heisei")
else:
  print("TBD")

a, b, q = map(int, input().split())
sno = []
tno = []
dis = []
 
for i in range(a):
  sno.append(int(input()))
sno.append(10000)
 
for i in range(b):
  tno.append(int(input()))
tno.append(10000)
  
for i in range(q):
  dis.append(int(input()))

for i in range(q):
  sl = 0
  sr = 0
  tl = 0
  tr = 0
  
  for j in range(a):
    if sno[j] <= dis[i]:
      sl = dis[i] - sno[j]
      sr = sno[j+1] - dis[i]
      break
    else:
      pass
    
  for k in range(b):
    if tno[k] <= dis[i]:
      tl = dis[i] - tno[k]
      tr = tno[k+1] - dis[i]
      break
    else:
      pass
  
  lds = max(sl, tl)
  rds = max(sr, tr)
  dis = min(lds, rds)
  print(dis)


a, b, q = map(int, input().split())
sno = [-10e6] + [int(input()) for _ in range(a)] + [10e6]
tno = [-10e6] + [int(input()) for _ in range(b)] + [10e6]
dis = [int(input()) for _ in range q]

for i in range(q):
 
    sl = 0
    sr = 0
    tl = 0
    tr = 0
 
    for j in range(a+2):
        if sno[j] >= dis[i]:
            sl = dis[i] - sno[j-1]
            sr = sno[j] - dis[i]
            break
        else:
            pass
 
    for k in range(b+2):
        if tno[k] >= dis[i]:
            tl = dis[i] - tno[k-1]
            tr = tno[k] - dis[i]
            break
        else:
            pass
 
    lds = max(sl, tl)
    rds = max(sr, tr)
    ans = min(lds, rds)
    print(ans)

date = input()
tdate=[]
 
for s in date:
  tdate.append(s)
  
if tdate[5] != "0":
  mon = int(tdate[5] + tdate[6])
else:
  mon = int(tdate[6])


if mon <= 4:
  print("Heisei")
else:
  print("TBD")

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted