Problem:


﻿Score: 100 points

Problem Statement

In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.

Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.

Determine if there exists a pair of antennas that cannot communicate directly.

Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.  

Constraints

a, b, c, d, e and k are integers between 0 and 123 (inclusive).

a < b < c < d < e

Input

Input is given from Standard Input in the following format:

a
b
c
d
e
k

Output

Print :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.

Sample Input 1

1
2
4
8
9
15

Sample Output 1

Yay!

In this case, there is no pair of antennas that cannot communicate directly, because:

the distance between A and B is 2 - 1 = 1

the distance between A and C is 4 - 1 = 3

the distance between A and D is 8 - 1 = 7

the distance between A and E is 9 - 1 = 8

the distance between B and C is 4 - 2 = 2

the distance between B and D is 8 - 2 = 6

the distance between B and E is 9 - 2 = 7

the distance between C and D is 8 - 4 = 4

the distance between C and E is 9 - 4 = 5

the distance between D and E is 9 - 8 = 1

and none of them is greater than 15. Thus, the correct output is Yay!.

Sample Input 2

15
18
26
35
36
18

Sample Output 2

:(

In this case, the distance between antennas A and D is 35 - 15 = 20 and exceeds 18, so they cannot communicate directly.
Thus, the correct output is :(.



Sample input:
1
2
4
8
9
15


Sample output:
Yay!

Submission status: Runtime Error

Solution code:
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    ans = []
    X, Y, Z, K = (int(_) for _ in input().split())
    A = list(int(_) for _ in input().split())
    A.sort()
    B = list(int(_) for _ in input().split())
    B.sort()
    C = list(int(_) for _ in input().split())
    C.sort()
    for a in A:
        for b in B:
            for i in range(min(len(C),3001)):
                ans.append(a + b + C[i])
    ans.sort()
    ans = ans[::-1]
    ans = ans[:K]
    print('\n'.join(map(str,ans)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

ab = []
res = []
x, y, z, k = na()
a_li = na()
b_li = na()
c_li = na()
for a in a_li:
    for b in b_li:
        ab.append((a * b))
list.sort(ab, reverse=True)
list.sort(c_li, reverse=True)
for a_b in ab:
    for c in c_li:
        res.append(a_b * c)
for num in sorted(res,reverse=True)[-k:]:
    print(num)

Submission status: Runtime Error

Solution code:
x,y,z,k = map(int,input().split())
A,B,C= [[int(i) for i in input().split()] for j in range(3)]
AB = []
ABC = []
for i in range(x):
        for j in range(y):
                AB.append(A[i]+B[j])
AB.sort(reverse = True)
for i in range(min(k,len(AB))):
        for j in range(z):
                ABC.append(AB[i]+C[j])
ABC.sort(reverse = True)
for i in range(k):
        print(ABC[i])

Submission status: Runtime Error

Solution code:
x, y, z, k = map(int, input().split())
listA = list(map(int, input().split()))
listB = list(map(int, input().split()))
listC = list(map(int, input().split()))

sumAB =[]
index=0
while index < len(listA):
    index2=0
    while index2 < len(listB):
        sumAB.append(listA[index]+listB[index2])
        index2+=1
    index+=1
sumAB.sort()
sumAB.reverse()
abSL=[]
index3=0
while index3 < min(k, len(sumAB)):
    abSL.append(sumAB[index3])
    index3+=1

answerL=[]
index4=0
while index4 < len(abSL):
    index5=0
    while index5 < min(k,len(listC)):
        answerL.append(abSL[index4]+listC[index5])
        index5+=1
    index4+=1

answerL.sort()
answerL.reverse()
index6=0
while index6 < k:
    print(answerL[index6])
    index6+=1

Submission status: Runtime Error

Solution code:
X, Y, Z, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

AB = []
for a in A:
  for b in B:
    AB.append(a + b)

AB.sort(reverse=True)
AB = AB[:min(3001, X * Y * Z + 1)]
ABC = []
for ab in AB:
  for c in C:
    ABC.append(ab + c)
ABC.sort(reverse=True)
print(*ABC[:K], sep='\n')

Submission status: Runtime Error

Solution code:
*Pos, K = [int(input()) for _ in range(6)]
print('Yay!' if Pos[4] - pos[0] <= K else ':(')

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

if d-a<=k
  print('Yay!')
else:
  print(':(')

Submission status: Runtime Error

Solution code:
n=int(input())
math inport ceil
a=[]
for i in range(5):
  a.append(int(input()))
print(ceil(n/min(a))+4)

Submission status: Runtime Error

Solution code:
inputs=[int(i) for i in input().split()]
k=inputs[-1]
for i in range(5):
  for j in range(5-i):
    if abs(inputs[j]-inputs[i])>k
    print(":(")
 	return

print("Yay!")
return

Submission status: Runtime Error

Solution code:
import numpy as np
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

A = a % 10
B = b % 10
C = c % 10
D = d % 10
E = e % 10

S = []
sum = 0
if A != 0:
  S.append(A)
if B != 0:
  S.append(B)
if C != 0:
  S.append(C)
if D != 0:
  S.append(D)
if E != 0:
  S.append(E)
if len(S) == 0:
  sum = a + b + c + d + e
else:
  sum = (a //10 + b //10 + c //10 + d //10 + e //10)*10 + 10*(len(A) - 1) +min(S)
print(sum)

Submission status: Runtime Error

Solution code:
inputs=[int(i) for i in input().split()]
k=inputs[-1]
for i in range(5):
  for j in range(5-i):
    if abs(j-i)>k
    print(":(")
 	return

print("Yay!")
return

Submission status: Runtime Error

Solution code:
inputs=[int(i) for i in input().split()]
k=inputs[-1]
for i in range(5):
  for j in range(5-i):
    if abs(j-i)>k
    print(":(")
 		return

print("Yay!")
return

Submission status: Runtime Error

Solution code:
x, y, z, k = map(int, input().split())
m = []
for _ in range(3):
    m.append(sorted(list(map(int, input().split())), reverse=True))
 
def sorted_sum(list_a, list_b):
    s = []
    for x in list_a:
        for y in list_b:
            s.append(x + y)
    return sorted(s, reverse=True)
 
ans = sorted_sum(sorted_sum(m[0], m[1])[0:k], m[2])
for i in range(0, k):
    print(ans[i])

Submission status: Runtime Error

Solution code:
a,*_,e,k=eval('int(input()),'*6);print(':('*(e-a>k)|'Yay!')

Submission status: Runtime Error

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

#input
import numpy as np
[X,Y,Z,K] = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

D = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

#make list
for i in range(min(K,X)):
    for j in range(min((K//(i+1))+1,Y)):
        for k in range(min(((K//(i+1))+1)//(j+1),Z)):
                D.append(A[i]+B[j]+C[k])
D.sort(reverse=True)
for i in range(K):
    print(int(D[i]))

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
  list = [int(input()) for i in range(6)]
  for i in range(5):
    for j in range(i):
      if i == j:
        continue
      else:
        if abs(i-j) < list[5]:
          return ":("
  return "yay!"

Submission status: Runtime Error

Solution code:
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

d = [e1+e2 for e1 in a for e2 in b]
d.sort(reverse=True)
d = d[:k]

e = [e1+e2 for e1 in d for e2 in c]
e.sort(reverse=True)

for i in range(k):
  print(e[i])

Submission status: Runtime Error

Solution code:
x, y, z, k = map(int, input().split())
m = []
for _ in range(3):
    m.append(sorted(list(map(int, input().split())), reverse=True))
 
def sorted_sum(list_a, list_b):
    s = []
    for x in list_a:
        for y in list_b:
            s.append(x + y)
    return sorted(s, reverse=True)
 
ans = sorted_sum(sorted_sum(m[0], m[1])[0:k], m[2])[0:k]
for i in range(0, k):
    print(ans[i])

Submission status: Runtime Error

Solution code:
import itertools

flag = 0
antena = [int(input()) for i in range(5)]
k = int(input())

antena[-1] - antena [0] > k
    flag = 1

if flag == 0:
    print("Yay!")
else:
    print(":)")

Submission status: Runtime Error

Solution code:
x,y,z,k=map(int,input().split())
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
c=tuple(map(int,input().split()))
 
def f(p,q):
    return sorted([i+j for j in q for i in p])[::-1][:k]
 
if x+y<y+z:
    for i in sorted(f(c,f(a,b)))[::-1][:k]:
        print(i)
elif x+z<y+z:
    for i in sorted(f(b,f(a,c)))[::-1][:k]:
        print(i)
else:
    for i in sorted(f(a,f(b,c)))[::-1][:k]:
        print(i)

Submission status: Runtime Error

Solution code:
import math
import sys

X,Y,Z,K=map(int,input().split())

x=sorted(list(map(int,input().split())),reverse=True)
y=sorted(list(map(int,input().split())),reverse=True)
z=sorted(list(map(int,input().split())),reverse=True)



"""
if X*Y*Z<=3000:
    ans=[]
    for i in range(X):
        for j in range(Y):
            for k in range(Z):  ans.append(x[i]+y[j]+z[k])
    ans.sort()
    for i in range(min(3000,X*Y*Z)):
        print(ans[i])
    sys.exit()
"""

yz=[]
for i in range(Y):
    yz=yz+[ y[i]+z[j] for j in range(Z)]

yz.sort(reverse=True)

if len(yz)>K:
    yz=yz[:K]


n=len(yz)
ans=[]

for i in range(X):
    tmp=[yz[j]+x[i] for j in range(len(yz))]
    ans =ans+tmp

ans.sort(reverse=True)


for i in range(K):
    print(ans[i])

Submission status: Runtime Error

Solution code:
l=[int(input())for _ inrange(5)]
print([':(','Yay!'][int(input())>=l[4]-l[0]])

Submission status: Runtime Error

Solution code:
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
e = int(e)
k = int(k)
if 0 <= a and b and c and d and e and k <=123 :
    if a < b < c < d < e:
        te = e - a
    if te <= k    
        print("Yay!")
    else:
        print(":(")

Submission status: Runtime Error

Solution code:
data_ls = []
for i in range(5):
  data_ls.append(int(input()))
k = int(input())
sort(data_ls)
if data_ls[-1] - data_ls[0] > k:
  print("Yay!")
else:
  print(":(")

Submission status: Runtime Error

Solution code:
import math
n = int(input())
t = map(int, input())
bottle_neck = min(t)[0]
ti = math.ceil(n/bottle_neck)
print(ti+4)

Submission status: Runtime Error

Solution code:
import math
n = int(input())
t = map(int, input())
bottle_neck = min(t)[0]
ti = math.ceil(n/bottle_neck)
print(ti+4)

Submission status: Runtime Error

Solution code:
n = int(input())
t=[]
t = map(int, input())
bottle_neck = min(t)[0]
ti = int(n/bottle_neck)
ti+=1
print(ti+4)

Submission status: Runtime Error

Solution code:

import sys

loops1 = 4
loops2 = 5
arg1 = 0
arg2 = 1

i=0
j=0

int args = [input() for i in range(6)]

for i in range(arg1,loops1):
	for j in range(arg2,loops2):
		if (args[j] - args[i]) > args[5]:
			print(":(")
			sys.exit()
print("Yay!")

Submission status: Runtime Error

Solution code:
a = map(int, input())
b = map(int, input())
c = map(int, input())
d = map(int, input())
e = map(int, input())
k = map(int, input())
l = [a,b,c,d,e,k]
MIN = min(l)
MAX = max(l)
ans = MAX - MIN
if ans < k:
    print(":(")
else:
    print("Yay!")

Submission status: Runtime Error

Solution code:
A=[int(input()) for i in range(5)]
k=int(input())

for i in range(4):
	for i in range(i):
		if A[i]-A[j]>k:
			print(""":(""")
			exit()
print("Yay!")

Submission status: Runtime Error

Solution code:

import sys

loops1 = 4
loops2 = 5
arg1 = 0
arg2 = 1

i=0
j=0

args = [input() for i in range(6)]


for i in range(arg1,loops1):
	for j in range(arg2,loops2):
		if (args[j] - args[i]) > args[5]:
			print(":(")
			sys.exit()
print("Yay!")

Submission status: Runtime Error

Solution code:
a = map(int, input())
b = map(int, input())
c = map(int, input())
d = map(int, input())
e = map(int, input())
k = map(int, input())
l = [a,b,c,d,e,k]
ans = 0
MIN = min(l)
MAX = max(l)
Anser = MAX - MIN
if Anser < k:
    print(":(")
else:
    print("Yay!")

Submission status: Runtime Error

Solution code:
X, Y, Z, K = list(map(int, input().split(' ')))

A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))


A.sort()
A.reverse()
B.sort()
B.reverse()
C.sort()
C.reverse()

cal = []

def a(X,K):
  if X > K:
  	return K
  else:
    return X
  
for i in range(a(X,K-1000)):
  for j in range(a(Y,K-1000)):
    for k in range(a(Z,K-1000)):
      cal.append(A[i]+B[j]+C[k])

cal.sort()
cal.reverse()

for i in range(K):
  print(cal[i])

Submission status: Runtime Error

Solution code:
import itertools
L = [int(input()) for _ in range(6)]
for i,j in itertools.combinations(L[:5],2):
  if abs(i,j) > L[5]:
    print(':(')
    exit()
print('Yay!')

Submission status: Runtime Error

Solution code:
import numpy as np

def prod(p, q, r):
    return A[p] + B[q] + C[r]

x, y, z, k = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
C = [int(a) for a in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

progress = [(0, 0, 0, prod(0,0,0))]


def expand(p, q, r):
    result = []
    if p + 1 < x:
        result.append((p+1, q, r, prod(p+1, q, r)))
    if q + 1 < y:
        result.append((p, q+1, r, prod(p, q+1, r)))
    if r + 1 < z:
        result.append((p, q, r+1, prod(p, q, r+1)))
    return result

for i in range(k):
    prods = [tup[-1] for tup in progress]

    max_val = max(prods)
    max_idx = prods.index(max_val)
    p, q, r, _ = progress[max_idx]

    print(max_val)
    progress.pop(max_idx)
    progress.extend(expand(p, q, r))
    progress = list(set(progress))

Submission status: Runtime Error

Solution code:
a, b, c,d,e,k = map(int, input().split())
l = [a,b,c,d,e,k]
ans = 0
MIN = min(l)
MAX = max(l)
Anser = MAX - MIN
if Anser < k:
    print(":(")
else:
    print("Yay!")

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3



def solv(x, y, z, k, a, b, c):
    a = sorted(a, reverse=True)
    b = sorted(b, reverse=True)
    c = sorted(c, reverse=True)

    m = max(a[0] - a[-1], b[0] - b[-1], c[0] - c[-1])

    while True:
        aa = list(filter(lambda v: v > a[0] - m, a))
        bb = list(filter(lambda v: v > b[0] - m, b))
        cc = list(filter(lambda v: v > c[0] - m, c))

        if len(aa) * len(bb) * len(cc) < 10000:
            break

        m = m * 0.8

    aa = a
    bb = b
    cc = c

    all = []
    for ai in a:
        for bi in b:
            for ci in c:
                all.append(ai+bi+ci)

    all = sorted(all, reverse=True)

    return all[:k]


if __name__ == '__main__':

    x, y, z, k = map(int, input().split())
    a = map(int, input().split())
    b = map(int, input().split())
    c = map(int, input().split())

    ans = solv(x, y, z, k, a, b, c)

    for ans_i in ans:
        print(ans_i)

Submission status: Runtime Error

Solution code:
array=[int(input()) for i in range(6)]
a=0
for i in range(1,4):
    if array[i]-array[0] > array[5]: 
        a=1
if a1=0: print(':(')
else: print('Yay!')

Submission status: Runtime Error

Solution code:
import itertools

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

AB = []
for p in itertools.product(A, B):
    AB.append(sum(p))
AB.sort(reverse=True)
AB = AB[:K]

l = []
for p in itertools.product(AB, C):
    l.append(sum(p))
l.sort(reverse=True)
for i in range(K):
    print(l[i])

Submission status: Runtime Error

Solution code:
arr = []
for i in range(5):
    arr.append(eval(input()))
limit = input()
tmp = max(arr) - min(arr)
if tmp > limit:
    print(':(')
else:
    print('Yay!')

Submission status: Runtime Error

Solution code:
import sys

args = [input() for i in range(6)]

loops1 = 4
loops2 = 5
arg1 = 0
arg2 = 1

for i in range(arg1,loops1):
	for j in range(arg2,loops2):
		if (args[j] - args[i]) > args[5]:
			print(":(")
			sys.exit()
print("Yay!")

Submission status: Runtime Error

Solution code:

import sys

args = [input() for i in range(6)]

loops1 = 4
loops2 = 5
arg1 = 0
arg2 = 1

for i in range(arg1,loops1):
	for j in range(arg2,loops2):
		if (args[j] - args[i]) > args[5]:
			print(":(")
			sys.exit()
print("Yay!")

Submission status: Runtime Error

Solution code:
a=input()
b=input()
c=input()
d=input()
e=input()
k=input()
array=[a,b,c,d,e]
flag=True

for i in range(5):
  for j in range(5):
    if array[i]-array[j] >= k:
      flag=False
      print(":(")
      break
  if not flag:
    break
      
if flag:
  print("Yay!")

Submission status: Runtime Error

Solution code:
n = 6;
a = [input() for i in range(n)];

k = a[-1];
ans = "Yay!";

for i in range(n-1):
	for j in reversed(range(n-1)):
  		if k < a[i] - a[j]:
  			ans = ":( ";
  			break;

print ans;

Submission status: Runtime Error

Solution code:
a = [int(input()) for i in range(5)]
k = int(input())
tf = any(a[i + 1] - a[i] > k for i in range(4))
print("Yay!" if !tf else ":(")

Submission status: Runtime Error

Solution code:
import heapq
import itertools

def dif(l):
  return max(l) - min(l)

x,y,z,k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

flag = True
while flag:
  fa = False
  while (x-1)*y*z > k and dif(a) > dif(b) and dif(a) > dif(c):
    a.pop()
    x -= 1
    fa = True

  fb = False
  while x*(y-1)*z > k and dif(b) > dif(a) and dif(b) > dif(c):
    b.pop()
    y -= 1
    fb = True

  fc = False
  while x*y*(z-1) > k and dif(c) > dif(b) and dif(c) > dif(a):
    c.pop()
    z -= 1
    fc = True
  
  flag = fa or fb or fc

l=[]
for a1 in a:
    for b1 in b:
        for c1 in c:
            l.append(a1+b1+c1)

m2 = heapq.nlargest(k, l)
for i in range(k):
  print(m2[i])

Submission status: Runtime Error

Solution code:
n = 6;
a = [input() for i in range(n)];

k = a[-1];
ans = "Yay!";

for i in range(n-1):
  for j in reversed(range(n-1)):
    if k < a[i] - a[j]:
      ans = ":( ";
      break;
print ans;

Submission status: Runtime Error

Solution code:
n = 6;
a = [input() for i in range(n)];

k = a[-1];
ans = "Yay!";

for i in range(n-1):
  for j in reversed(range(n-1)):
  	if k < a[i] - a[j]:
      ans = ":( ";
      break;

print ans;

Submission status: Runtime Error

Solution code:
a=[int(input()) for i in range(6)]
if a[4]-a[0]>=a[5]:
  print'Yay!'
  else:
    print ':('

Submission status: Runtime Error

Solution code:
data = [int(input()) for i in range(6)]
print('Yay!' if data[-2] - data[0] =< data[-1] else ':(')

Submission status: Runtime Error

Solution code:
n = 6;
a = [input() for i in range(n)]

k = a[-1];
ans = "Yay!";

for i in range(n-1):
	for j in reversed(range(n-1)):
  		if k < a[i] - a[j]:
  			ans = ":( ";
  			break;

print ans;

Submission status: Runtime Error

Solution code:
a = int(input())
b
c
d
e

Submission status: Runtime Error

Solution code:
import itertools
x, y, z, k = map(int, input().split())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))
sum_list = [sum(i) for i in itertools.product(al, bl, cl)]
sum_list.sort(reverse=True)
for i in sum_list[:k]:
  print(i)

Submission status: Runtime Error

Solution code:
from itertools import*
x,y,z,k=map(int,input().split())
a=map(int,input().split())
b=map(int,input().split())
c=map(int,input().split())
#print(a,b,c)
for e in sorted(sum(i)for i in product(a,b,c))[::-1][:k]:
    print(e)

Submission status: Runtime Error

Solution code:
n = 6;
a = [input() for i in range(n)]

k = a[-1];
ans = "Yay!";

for i in range(n-1):
  #print("n-i-1: " + str(n-i-1));
  if k < a[n-i-1] - a[i]:
    ans = ":( ";
    break;

return ans;

Submission status: Runtime Error

Solution code:
n = 6;
a = [input() for i in range(n)]

k = a[-1];
ans = "Yay!";

for i in range(n-1):
  #print("n-i-1: " + str(n-i-1));
  if k < a[n-i-1] - a[i]:
    ans = ":( ";
    break;

print ans;

Submission status: Runtime Error

Solution code:
n =6;
a=[input() for i in range(n)]

k = a[-1];
ans = "Yay!";

for i in range(n-1):
	#print("n-i-1: " + str(n-i-1));
  	if k < a[n-i-1] - a[i]:
  		ans = ":( ";
  		break;

print ans;

Submission status: Runtime Error

Solution code:
a = []
for i in range(5):
    a.append(int(input()))
k = input()

if a[4] - a[0] <= k:
    print("Yay!")
else:
    print(":(")

Submission status: Runtime Error

Solution code:
import itertools
import sys

input = sys.stdin.readline

maxn = 10000000000

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.append(-maxn)
B.append(-maxn)
C.append(-maxn)

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

apos, bpos, cpos = 0, 0, 0

while (apos + 1) * (bpos + 1) * (cpos + 1) < min(10 ** 7, X * Y * Z):
    if (
        apos < len(A) - 2
        and abs(A[apos] - A[apos + 1]) < abs(B[bpos] - B[bpos + 1])
        and abs(A[apos] - A[apos + 1]) < abs(C[cpos] - C[cpos + 1])
    ):
        apos += 1
    elif bpos < len(B) - 2 and B[bpos] - B[bpos + 1] < C[cpos] - C[cpos + 1]:
        bpos += 1
    else:
        cpos += 1

res = []
for a in list(itertools.product(A[: apos + 1], B[: bpos + 1], C[: cpos + 1])):
    res.append(a[0] + a[1] + a[2])

res.sort(reverse=True)
for k in range(K):
    print(res[k])

Submission status: Runtime Error

Solution code:
a=[int(input()) for i in range(6)]
if (a[4]-a[0]>=a[5]):
  print'Yay!'
  else print ':('

Submission status: Runtime Error

Solution code:
a=[int(input()) for i in range(6)]
if a[4]-a[0]>=a[5]:
  print'Yay!'
  else print ':('

Submission status: Runtime Error

Solution code:
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
if a >= 100:
    a1 = a % 10
else:
    a2 = a - 100
    a1 = a2 % 10
if b >= 100:
    b1 = b % 10
else:
    b2 = b - 100
    b1 = b2 % 10
if c >= 100:
    c1 = c % 10
else:
    c2 = c - 100
    c1 = c2 % 10
if d >= 100:
    d1 = d % 10
else:
    d2 = d - 100
    d1 = d2 % 10
if e >= 100:
    e1 = e % 10
else:
    e2 = e - 100
    e1 = e2 % 10
if a1 == 0:
    a1 = 9
if b1 == 0:
    b1 = 9
if c1 == 0:
    c1 = 9
if d1 == 0:
    a1 = 9
if e1 == 0:
    e1 = 9
lis = [a1,b1,c1,d1,e1]
if a1 == min(lis) :
    answer = math.ceil(b / 10) * 10 + math.ceil(c/ 10) * 10 + math.ceil(e/ 10* 10+ math.ceil(d/ 10 * 10 + a
if b1 == min(lis):
    answer = math.ceil(a/ 10)* 10 + math.ceil(c/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(d/ 10)* 10 + b
if c1 == min(lis):
    answer = math.ceil(b/ 10)* 10 + math.ceil(a/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(d/ 10)* 10 + c
if d1 == min(lis):
    answer = math.ceil(b/ 10)* 10 + math.ceil(c/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(a/ 10)* 10 + d
if e1 == min(lis):
    answer = math.ceil(b/ 10)* 10 + math.ceil(c/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(a/ 10)* 10 + e
print(answer)

Submission status: Runtime Error

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

import math

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()

cnum = []

takadaka = math.ceil(k ** 0.67)

for i in range(min(takadaka,x)):
    for j in range(min(takadaka,y)):
        for l in range(min(takadaka,z)):
            cnum.append(a[i] + b[j] + c[l])

cnum.sort()
cnum.reverse()

for i in range(k):
    print(cnum[i])

Submission status: Runtime Error

Solution code:
input = []
array = []
input = [int(input()) for i in range(6)]
array = input[:5]
k = input[5] 
size = len(array)
for i in range(size):
  if (i < 4):
    if (array[size - i - 1] - array[0] > k):
      print(':(')
      break
  if (i < 3):
    if (array[size - i - 1] - array[1] > k):
      print(':(')
      break
  if (i < 2):
    if (array[size - i - 1] - array[2] > k):
      print(':(')
      break
  if (i < 1):
    if (array[size - i - 1] - array[3] > k):
      print(':(')
      break
  if (i == 4):
    print('Yay')

Submission status: Runtime Error

Solution code:

data = [int(input()) for i in range(6)]
print('Yay!' if data[-2] - data[0] =< data[-1] else ':(')

Submission status: Runtime Error

Solution code:
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()

if (max(a,b,c,d,e) - min(a,b,c,d,e,f) <= 15):
	print('Yay!')
else:
	print(':(')

Submission status: Runtime Error

Solution code:
N = input()
a = [input() for i in range(N)]
k = a[-1];

for i in range(len(N-1)):
  if k < a[len(N-i-1)] - a[i]:
    return ':( ';

return 'Yay!';

Submission status: Runtime Error

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

import math

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
b.sort()
c.sort()

cnum = []

takadaka = math.ceil(k ** 0.75)

for i in range(min(takadaka,x)):
    for j in range(min(takadaka,y)):
        for l in range(min(takadaka,z)):
            cnum.append(a[i] + b[j] + c[l])

cnum.sort()
cnum.reverse()

for i in range(k):
    print(cnum[i])

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
from heapq import merge
from bisect import bisect
def inpl(): return list(map(int, input().split()))

X, Y, Z, K = inpl()
A = inpl()
B = inpl()
C = sorted(inpl(), reverse=True)

AB = sorted([a+b for a in A for b in B])[-K:]
ans = [-1] * K

for c in C:
    if ans[0] > AB[-1] * c:
        break
    tmp = [ab + c for ab in AB][-K:]
    ans = list(merge(ans, tmp))[-K:]

print(*ans[::-1], sep="\n")

Submission status: Runtime Error

Solution code:
input = []
array = []
input = [int(input()) for i in range(6)]
array = input[:5]
k = input[5] 
size = len(array)
for i in range(size):
  if (i < 4):
    if (array[size - i] - array[0] > k):
      print(':(')
      break
  if (i < 3):
    if (array[size - i] - array[1] > k):
      print(':(')
      break
  if (i < 2):
    if (array[size - i] - array[2] > k):
      print(':(')
      break
  if (i < 1):
    if (array[size - i] - array[3] > k):
      print(':(')
      break
  if (i == 4):
    print('Yay')

Submission status: Runtime Error

Solution code:
input = []
array = []
input = [int(input()) for i in range(6)]
array = input[:5]
k = input[5] 
size = len(array)
for i in range(size):
  	if (i < 4):
      if (array[size - i] - array[0] > k):
        print(':(')
        break
    if (i < 3):
      if (array[size - i] - array[1] > k):
      	print(':(')
        break
    if (i < 2):
      if (array[size - i] - array[2] > k):
      	print(':(')
        break
	if (i < 1):
      if (array[size - i] - array[3] > k):
        print(':(')
        break
    if (i == 4):
      print('Yay')

Submission status: Runtime Error

Solution code:
N = input()
a = [input() for i in range(N)]
print(a);

Submission status: Runtime Error

Solution code:
f = abs(e - a)
if k >= f:
    print('Yay!')
else:
    print(':(')

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
s = [a,b,c,d,e]
kk = "Yay!"
for z in range(lan(s)):
  ss = s[(z+1):]
  for y in ss:
    if s[z] - y > k :
      kk=":("
      
print(kk)