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: answer=[]
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 - 1):
                if k + a[-i-j-1] <= m:
                    if k + a[-i-j-1] >= t:
                        t = k + a[-i-j-1]
                    break
        if t == 0:
            answer.append("NONE")
        else:
            answer.append(t)
    else:
        break
for i in range(len(answer)):
    print(answer[i])

Python: B=[]

while 1:
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    A=list(map(int,input().split()))
    A.sort()
    max=0
    for i in range(n):
        if A[i]>m:
            break
        for j in range(i+1,n):
            sum=A[i]+A[j]
            if sum>m:
                break
            elif sum>max:
                max=sum

    if max==0:
        B.append("NONE")
    else:
        B.append(max)

for b in B:
    print(b)

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: #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)

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 - 1):
                if k + a[-i-j-1] <= m:
                    if k + a[-i-j-1] >= t:
                        t = k + a[-i-j-1]
                    break
        if t == 0:
            print("NONE")
        else:
            print(t)
    else:
        break

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

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 and m < A[i]+A[j]:
                j -= 1
            if j:
                yield A[i] + A[j]
    print(max(f()) or"NONE")

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

Python: while True:
    n,m=[int(i) for i in input().split()]
    if n==0:
        break 
    a = [int(i) for i in input().split()]

    ans  = -1
    for i in range(n):
        for j in range(i+1,n):
            if a[i]+a[j] <= m:
                ans =max(a[i]+a[j] ,ans)
    if ans ==-1:
        print("NONE")
    else:
        print(ans)

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):
        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: #1行目 品物の個数n 許容額m
#2行目　a[i](1 <= i <= n)
#どの品物の組も価格合計が m を超える場合は，代わりに NONE と出力する
while True :

  n,m = map(int,input().split())
  #もし(n,m) = (0,0)ならbreak
  if n==0:
    break
  else:
    #配列a[i]を読み込む(1<=i<=n)
    a = sorted(list(map(int, input().strip().split())))
    
    a_sum = 0
    #(最大値) + (その他1つ) <=mを探す
    for i in range(0,n-1):
      for j in range(i+1,n):
        if max(a_sum, a[i] + a[j]) <= m :
          a_sum = max(a_sum, a[i] + a[j])
    
    if a_sum ==0 :
      print("NONE")
    else :
      print(a_sum)

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