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 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: import bisect

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

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

Python: ans = []
cou = 0

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

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-1):
        for j in range(i,n):   
            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 bisect

while True:
    n,m = map(int,input().split())
    if [n,m] == [0,0]:
        break
    
    a = list(map(int,input().split()))
    a.sort()
    res = -1
    
    for i in range(n):
        k = bisect.bisect_right(a,m-a[i])
        if k == i+1:
            k -= 1
        if k != 0:
            res = max(res,a[i]+a[k-1])
    if res == -1:
        print('NONE')
    else:
        print(res)

Python: def main():
    while True:
        n,m = map(int,input().split())
        if not n and not m:
            return
        aa = list(map(int,input().split()))
        ans = 0
        for i in range(n):
            for j in range(n):
                if i == j:
                    continue
                tmp = aa[i] + aa[j]
                if tmp <= m:
                    ans = max(ans, tmp)
        if ans == 0:
            print("NONE")
        else:
            print(ans)

if __name__ == '__main__':
    main()

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

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: # coding: utf-8
# Your code here!
import itertools

def main():
    while True:
        n, m = map(int, input().split())
        if n == 0 : break
        ns = list(map(int, input().split()))
        ans = -1
        for p in itertools.permutations(ns, 2):
            if sum(p) <= m:
                ans = max(ans, sum(p))
        if ans == -1:
            print('NONE')
        else:
            print(ans)
main()