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:

    n,m = [int(x) for x in input().split()]
    if n == m == 0:
        break
    a = [int(x) for x in input().split()]

    ans = -1

    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            if ans < a[i]+a[j] and a[i]+a[j] <= m:
                ans = a[i]+a[j]

    if ans == -1:
        print("NONE")
    else:
        print(ans)

Python: while True:
    n, m = [int(num) for num in input().split()]
    if n == m == 0:
        break
    items = sorted([int(num) for num in input().split()])
    answer = 0
    j = n - 1
    for i in range(n):
        while j > i and items[i] + items[j] > m:
            j -= 1
        if j <= i:
            break
        answer = max(answer, items[i] + items[j])
    print(answer if answer > 0 else "NONE")

Python: 


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

while n!=0 and m!=0:
    ok=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=list[j]+list[k]
            if tmp>max and tmp<=m:
                ok=1
                max=tmp
    if ok==1:
        print(max)
    else:
        print("NONE")
    n,m=map(int,raw_input().split())

Python: #!/usr/bin/env python3

n_list = []
m_list = []
a_list = []

while True:
    n, m = list(map(int, input().split(' ')))

    if n == 0 and m == 0:
        break

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

    n_list.append(n)
    m_list.append(m)
    a_list.append(a)


for n, m, a in zip(n_list, m_list, a_list):
    m_sum = 0
    for i in range(0, n):
        for j in range(i + 1, n):
            tmp = a[i] + a[j]
            if m_sum < tmp and tmp <= m:
                m_sum = tmp

    if m_sum > 0:
        print(m_sum)
    else:
        print('NONE')

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=0
    mm=0
    for i in range(0,n):
        for j in range(i+1,n):
            if i==j:
                break
            ans1=val[i]+val[j]
            if ans1>mm and ans1<=m:
                mm=ans1
        ans1=0
    A.append(mm)
    z=z+1

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

Python: while True:
    ans=[]
    n,m = map(int,input().split())
    
    if n==0 and m==0:
        break
    
    a = list(map(int,input().split()))
    
    a = sorted(a)

    b = 0
    
    for i in range(n):
        for j in range(i+1,n):
            b = a[i]+a[j]
        
            if b <= m:
                ans.append(b)
            
            else:
                break
    if len(ans)==0:
        print("NONE")
    else:
        print(max(ans))

Python: #!/usr/bin/env python3

n_list = []
m_list = []
a_list = []

while True:
    n, m = list(map(int, input().split(' ')))

    if n == 0 and m == 0:
        break

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

    n_list.append(n)
    m_list.append(m)
    a_list.append(a)


for n, m, a in zip(n_list, m_list, a_list):
    m_sum = 0
    for i in range(0, n):
        for j in range(i + 1, n):
            tmp = a[i] + a[j]
            if m_sum < tmp and tmp <= m:
                m_sum = tmp

    if m_sum > 0:
        print(m_sum)
    else:
        print('NONE')

Python: while True:
    t = 0
    n,m = map(int,input().split())
    if n != 0:
        a = list(map(int,input().split()))
        a.sort()
        for i in range(n - 1):
            k = a[-i-1]
            for j in range(n - i):
                if k + a[-i-1-j] <= m:
                    if k + a[-i-1-j] >= t:
                        t = k + a[-i-1-j]
                    break
        if t == 0:
            print("NONE")
        else:
            print(t)
    else:
        break

Python: while(True):
    n,m=map(int,input().split(" "))
    if(n==0):
        break
    things = set(map(int,input().split(" ")))
    _max=0
    for i in things:
        for j in things:
            if(i!=j and i+j < m and i+j>_max):
                _max = i+j
    print(_max)

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


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

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])
    ma=0
    for i in range(n):
        for j in range(i+1,n):  
            x=0 
            x=B[i]+B[j]
            if ma<x and x<=m:
                ma=x
    max.append(ma)
    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: import itertools

while True:
    item_n, money = [int(i) for i in input().split()]
    if item_n == money == 0:
        break
 		
    value_lst = [int(i) for i in input().split()]
 	
    max_value = -1
    can_buy = False
 	
    for i1, i2 in itertools.combinations(value_lst, 2):
        if i1 + i2 > max_value and i1 + i2 <= money:
        	max_value = i1 + i2
        	can_buy = True
        	
    if(can_buy):	
        print(max_value)
    else:
    	print('NONE')