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=map(int,input().split())
    A=[]
    a=[]
    V=0
    if n==0 and m==0:
        break
    A=list(map(int,input().split()))
    for i in range(n-1):
        for j in range(n-i-1):
            B=0
            B=A[i]+A[i+j+1]
            if B<=m:
                a.append(B)
                V=1
    if V==0:
        print('NONE')
    else:
        print(max(a))

Python: while True:
    n,m = map(int,input().split())
    if n==0:
      break
    a = list(map(int,input().split()))
    lst = []
    for i in range(n-1):
        for j in range(i+1, n):
            if a[i]+a[j] <= m:
                lst.append(a[i]+a[j])
    if len(lst) == 0:
        print('NONE')
    else:
        print(max(lst))

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

Python: n=5
m=5
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()]
    m1=m2=val[0]
    for i in range(1,n):
        if val[i]>=m1:
             m1=val[i]
        elif val[i]>m2:
             m2=val[i];
    sum=m1+m2
    if sum>m:
        sum="NONE"
    A.append(sum)

for i in range(len(A)):
    print(A[i])

Python: maxes=[]
cnt=0
while True:
    s=input()
    d=s.split()
    n=int(d[0])
    m=int(d[1])
    if n==0 and m==0:
        break

    s=input()
    d=s.split()
    a=[]
    
    for i in range(n):
        if int(d[i]) in a:
            n-=1
        else:
            a.append(int(d[i]))

    p=[[0 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(i+1,n):
            p[i][j]=(a[i]+a[j])


    max=0
    for i in range(n):
        for j in range(i+1,n):
            if p[i][j]>m:
                continue
            if max<p[i][j]:
                max=p[i][j]
    if max==0:
        maxes.append(-1)
    else:
        maxes.append(max)
    cnt+=1

for i in range(cnt):
    if maxes[i]==-1:
        print("NONE")
    else:
        print(maxes[i])

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])

Python: import sys

def main(N,M,A):
    ans = []
    for i in range(N-1):
        for j in range(i+1,N):
            if A[i]+A[j] <= M:
                ans.append(A[i]+A[j])
    return max(ans) if ans else 'NONE'

while 1:
    N,M = [int(x) for x in sys.stdin.readline().split()]
    if N==M==0:
        break
    A = [int(x) for x in sys.stdin.readline().split()]
    print(main(N,M,A))

Python: import bisect
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    a = list(map(int, input().split()))
    a.sort()
    p = 0
    for i in range(n - 1):
        x = bisect.bisect(a, m - a[i], i + 2)
        if a[x - 1] + a[i] <= m:
            p = max(p, a[x - 1] + a[i])
            if p == m:
                break
    if p:
        print(p)
    else:
        print("NONE")

Python: while 1:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    A=sorted(map(int, input().split()))
    def f():
        j = n-1
        yield 0
        for i in range(n):
            while j >= 0 and m < A[i]+A[j]:
                j -= 1
            if j <= i:
                break
            if j >= 0:
                yield A[i]+A[j]
    print(max(f()) or"NONE")

Python: price = []
while 1:
    a = []
    n,m = map(int,input().split())
    if n == 0 and m == 0:
        break
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    sum = -1
    for i in range(len(a)-1):
        for j in range(i+1,len(a)):
            if a[i] + a[j] <= m and sum <= a[i] + a[j]:
                sum = a[i] + a[j]
    if sum < 0:
        price.append(-1)
    else:
        price.append(sum)

for i in range(len(price)):
    if price[i] >= 0:
        print(price[i])
    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:
            #answer.append("NONE")
            print("NONE")
        else:
            #answer.append(t)
            print(t)
    else:
        break

Python: ans_list = []

def solve():
    n,m = map(int,input().split())
    if (n,m) == (0,0):
        return "end"
    a = list(map(int,input().split()))
    res = -float("inf")
    n = len(a)
    for i in range(n):
        for j in range(i+1,n):
            cand = a[i] + a[j]
            if res < cand <= m:
                res = cand
    if res == -float("inf"):
        res = "NONE"
    return res

while True:
    ans = solve()
    if ans == "end":
        break
    ans_list.append(ans)

for ans in ans_list:
    print(ans)