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: import sys
input = sys.stdin.readline

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

Python: def solve(n, m, a):
    ans = 0
    r = n - 1
    for l in range(n):
        while r > l and a[l] + a[r] > m:
            r -= 1
        if r <= l:
            break
        ans = max(ans, a[l] + a[r])
    print(ans if ans > 0 else 'NONE')


if __name__ == '__main__':
    while True:
        n_imput, m_imput = map(int, input().split())
        if n_imput == 0:
            break
        a_imput = sorted(list(map(int, input().strip().split())))
        solve(n_imput, m_imput, a_imput)

Python: maxs=[]
while(True):
    max=0
    
    b=list(map(int,input().split()))
    n=b[0]
    m=b[1]
    if(n == 0 and m == 0):
        break
    a=list(map(int,input().split()))
    for i in range(n):
        for j in range(i+1,n):
            sum=a[i]+a[j]
            if(sum>max and sum<m):
                max=sum
    maxs.append(max)

for i in maxs:
    if i==0:
        print("NONE")
    else:
        print(i)

Python: import os,re,sys,operator,math
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
while 1:
    n,m=map(int,stdin.readline().rstrip().split())
    if (n,m)==(0,0):
        break
    a=[int(i) for i in stdin.readline().rstrip().split()]
    ans=0
    for i in range(n-1):
        for j in range(i+1,n):
            t=a[i]+a[j]
            if t<=m:
                ans=max(ans,t)
    print(ans if ans!=0 else "NONE")

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):
    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
    if _max != None:
        print(_max)
    else:
        print("NONE")

Python: import itertools
a=input().split()
cnt=0
ans=[]
while(True):
    a=[int(i) for i in a]
    b=input().split()
    b=[int(i) for i in b]
    c=list(itertools.combinations(b,2))
    for i in range(len(c)):
        if cnt<=c[i][0]+c[i][1] and c[i][0]+c[i][1]<=a[1]:
            cnt=c[i][0]+c[i][1]
    if cnt==0:
      ans.append("NONE")
    else:
      ans.append(cnt)
    a=input().split()
    if(a[0]=='0' and a[1]=='0'):
      break
    cnt=0
for i in range(len(ans)):
  print(ans[i])

Python: n, m = map(int, input().split())
while n != 0 and m != 0:
    a = list(map(int, input().split()))
    dp = []
    for i in range(n):
        for j in range(n):
            if a[i]+a[j]<= m and i != j:
                dp.append(a[i]+a[j])
    if len(dp) == 0:
        print("NONE")
    else:
        print(max(dp))
    n, m = map(int, input().split())

Python: while True:
    n, m = map(int, input().strip().split())
    if n == 0:
        break
    a = sorted(list(map(int, input().strip().split())))
    ans = 0
    pos = n - 1
    for i in range(n):
        while pos > i and a[i] + a[pos] > m:
            pos -= 1
        if pos <= i:
            break
        ans = max(ans, a[i] + a[pos])
    print(ans if ans > 0 else 'NONE')

Python: while True:
    n, m = map(int,input().split())
    if (n,m) == (0,0):break
    price = list(map(int, input().split()))
    price.sort()
    summ = []
    k = -1
    j = 0
    if price[0]+price[1] > m:
            print('NONE')
            continue
    while True:
        if j == n + k:break
        elif price[j] +  price[k] <= m:
            summ.append(price[j] +  price[k])
            j += 1
        else:
            k -= 1
    summ.sort()
    print(summ[-1])

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=0
    A.append(sum)

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

Python: #16D8101014F 久留米 竜之介 2018/5/16 Python3 

Box=[]
Box2=[]
tmp=[]
mon=0
while True:
	Sum=0
	mon=0
	n,m=map(int,input().split())
	if n==0: break
	tmp=input().split()
	#print(tmp)
	for i in range(n):
		Box.append(int(tmp[i]))
	for j in range(n):
		for k in range(n):
			if j is not k:
				mon=Box[j]+Box[k]
			if mon <= m and Sum < mon:
				Sum=mon
	if Sum is not 0:
		Box2.append(Sum)				
	else:
		Box2.append("NONE")
	Box.clear()
	
for i in Box2:
	print(i)