Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		n, m := io.NextInt(), io.NextInt()
		if n == 0 {
			break
		}
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = io.NextInt()
		}
		ans := 0
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				if a[i]+a[j] <= m {
					ans = intMax(a[i]+a[j], ans)
				}
			}
		}
		if ans == 0 {
			io.Println("NONE")
		} else {
			io.Println(ans)
		}
	}
}

func intMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

Python: while True:
	s,t = map(int,input().split())
	if s == 0 and t == 0:	
		break
	a = list(map(int,input().split()))
	a.sort()
	list1 = []
	for i in range(s):
		for j in range(i + 1, s):
		 	price1 = a[i] + a[j]
		 	list1.append(price1)
	list1.sort()
	list2 = list(filter(lambda p: t >= p, list1))


	if list2:
		print(max(list2))
	else:
		print("NONE")

Python: def Price_combination():
    combination = []
    for i, x in enumerate(a):
        j = i + 1
        for y in a[j:]:
            if x + y <= m:
                combination.append(x+y)

    return combination

while True:
    n, m = map(int, input().split())
    if n == m == 0:
        break

    a = [int(i) for i in input().split()]

    ######## 許容範囲で金額を組み合わせる ########
    combination = Price_combination()
    ############################################

    if len(combination):
        print(max(combination))
    else:
        print("NONE")

Python: while True:
    (n,m) = map(int,input().split())
    if n == 0 and m == 0:
        break
    iss = list(map(int, input().split()))
    best = max([ (iss[i] + iss[j] if not ( i == j) and iss[i] + iss[j] <= m else -1) for i in range(0,n) for j in range(0,n) ])
    if(best < 0):
        print("NONE")
    else:
        print(best)

Python: 
max1=[]
ok1=[0]

n,m=map(int,raw_input().split())

while n>0 and m>0:
    ok=0
    ie=0
    list=map(int,raw_input().split())
    if list[0]<m:
        max=list[0]
    for j in range(len(list)-1):
        for k in range(1,len(list)):
            tmp=0
            tmp=list[j]+list[k]
            if tmp>max and tmp<=m:
                max=tmp
                ok=1
    max1.insert(ie,max)
    n,m=map(int,raw_input().split())
    ie+=1
    if ok==1:
        ok1.insert(ie,1)
print(ok1)
for i in range(len(max1)-1,-1,-1):
    if ok1[i]==1:
        print(max1[i])
    else:
        print("NONE")

Python: A=[]
while(True):
	n,m=map(int,input().split())
	if n==0 and m==0:
		break
	#print(n,m)
	P=list(map(int,input().split()))
	#print(P)
	mark=1
	sign=1
	for i in range(n):
		for j in range(i,n):
			if i==j:
				pass
			else:
				#print(i,j)
				if m-(P[i]+P[j])>=0:
					if mark==1:
						max=P[i]+P[j]
						mark=0
						sign=0
					else:
						if P[i]+P[j]>max:
							max=P[i]+P[j]
				else:
					pass
	if sign==0:
		A.append(max)
	else:
		A.append(-1)
#print(A)
A.reverse()
for i in range(len(A)):
	tmp=A.pop()
	if tmp==-1:
		print("NONE")
	else:
		print(tmp)

Python: import itertools as it

ans=[]

while 1:
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    A=list(map(int,input().split()))
    Ac=list(it.combinations(A,2))
    
    max=0
    flag=0

    for i in Ac:
        if sum(i)>=max and sum(i)<=m:
            max=sum(i)
            flag=1
        
    if flag==0:
        print("NONE")
    else:
        print(max)

Python: n=5
m=5
z=0
sum=0
A=[]

while n!=0:
    n,m=[int(i) for i in input().split()]
    if n==0 and m==0:
        break
    val=[int(i) for i in input().split()]
    ans1=[int(0) for i in range(n)]
    ans2=[int(0) for i in range(n)]
    mm=0
    for i in range(0,n-1):
        for j in range(i+1,n):
            if i==j:
                break
            ans1[i]=val[i]+val[j]
        if ans1[i]>mm and ans1[i]<m:
            mm=ans1[i]

    A.append(mm)
    z=z+1

for i in range(z):
    if A[i]==0:
        A[i]="NONE"
    print(A[i])

Python: from copy import copy

def get_input():
    data_list = input().split()
    for i, v in enumerate(data_list):
        data_list[i] = int(v)
    return data_list


def remove_over_budeget(value_list, budget):
    tmp_list = copy(value_list)
    for i, v in enumerate(tmp_list):
        if v >= budget:
            del value_list[i:]
            return value_list
    return value_list

def get_max_value_list(value_list,budget):
    if value_list == []: # in preperation for all value is over budget
        return "NONE"
    max_value = 0
    for i in range(0, len(value_list)-1):
        for j in range(i+1,len(value_list)):
            # print("j", j) # debug
            # print("i", i) # debug
            combination_plan = value_list[i] + value_list[j]
            if combination_plan <= budget and combination_plan > max_value:
                max_value = combination_plan
    if max_value == 0:
        return "NONE"
    return max_value





if __name__ == "__main__":
    while True:
        item_num, budget = get_input()
        if item_num == 0:
            break
        value_list = get_input()
        value_list.sort()
        value_list = remove_over_budeget(value_list, budget)
        max_value = get_max_value_list(value_list,budget)
        # print("max_value", max_value) # debug
        print(max_value)

Python: A=[0 for i in range(2)]
A=input().split()
n=int(A[0])
m=int(A[1])
max=[]
k=0

while n>0 and m>0:
    B=[0 for i in range(n)]
    B=input().split()
    for i in range(n):
        B[i]=int(B[i])
    max1=0
    for i in range(n):
        for j in range(i+1,n):  
            x=0 
            x=B[i]+B[j]
            if max1<x and x<=m:
                max1=x
    max.append(max1)
    A=input().split()
    n=int(A[0])
    m=int(A[1])
    k+=1
for i in range(k):
    if max[i]>0:
        print(max[i])
    else:
        print("NONE")

Python: 
ans = []
cou = 0

while(1):
    n,m = map(int,input().split())
    if(n == 0): break
    ar = list(map(int,input().split()))
    max_ans = 0


    for i in range(n-1):
        for j in range(i,n):
            if(max_ans < ar[i]+ar[j] and ar[i]+ar[j] <= m):
                max_ans = ar[i] + ar[j]

    ans.append(max_ans)
    cou += 1

for i in range(cou):
    if(ans[i] == 0): print("NONE")
    else: print(ans[i])