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(i) for i in input().split()]
	if (n == 0) & (m == 0):
		break
	a = [int (i) for i in input().split()]
	ans = 0
	for i in range(n):
		for j in range(n):
			if i == j:
				continue
			if (a[i] + a[j] <= m) & (a[i] + a[j] > ans):
				ans = a[i] + a[j]

	if ans == 0:
		print('NONE')
	else:
		print(ans)

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

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

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: s=[]

cnt=0

while 1:
    max=0
    n,m =map(int,input().split())
    l=list(map(int,input().split()))
    if n==0 and m==0:
        break

    for i in range(len(l)):
        for j in range(len(l)):
            if max<l[i]+l[j] and i!=j and m>=l[i]+l[j]:
                max=l[i]+l[j]

    if max==0:
        s+=["NONE"]
    else:
        s+=[max]


for x in s:
    print(x)

Python: ans_list = []

while True:
    n,m = map(int,input().split())
    if (n,m) == (0,0):
        break
    A = list(map(int,input().split()))
    N = len(A)
    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            res = A[i] + A[j]
            if res <= m:
                ans = max(ans, res) 
    if ans == 0:
        ans = "NONE"
    ans_list.append(ans)

for ans in ans_list:
    print(ans)

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

Python: 
max1=[]
ok1=[0]
n,m=map(int,raw_input().split())

while n>0 and m>0:
    ie=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:
                max=tmp
                ok1.insert(ie,1)
    max1.insert(ie,max)
    n,m=map(int,raw_input().split())
    ie+=1

for i in range(len(max1)-1,-1,-1):
    if ok1[i]==1:
        print(max1[i])
    else:
        print("NONE")

Python: for v in range(1000):
  s,t = input().split()
  s = int(s)
  t = int(t)
  if s == 0:
    break
  else:
    x=[]
    A = input().split()
    B = [int(l) for l in A]
    for i in range(s):
      for j in range(s):
        if i==j:
          pass
        else:
          w=B[i]+B[j]
          if w <= t:
             x.append(w)
          else:
            pass 
    lll=len(x)
    if lll == 0:
      print("NONE")
      continue
    else:  
      mx = max(x)
      print(mx)
      continue

Python: while True:
    n, m = map(int, input().split())  # 品物個数n, 最大の金額m
    if n == 0:
        break

    A = list(map(int, input().split()))
    # print(A)
    ans = 0
    for i in range(len(A)):
        for j in range(i+1, len(A)):
            if A[i] + A[j] > m:
                continue
            else:
                ans = max(ans, A[i]+A[j])

    if ans == 0:
        print('NONE')
    else:
        print(ans)

C++: #include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int a[1000];
signed main() {
  int N, M;
  while(cin>>N>>M,N+M!=0) {
    for (int i = 0; i < N; i++) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (i == j || a[i]+a[j]>M) continue;
        ans = max(a[i]+a[j], ans);
      }
    }
    if (ans==0) {
      cout << "NONE" << endl;
    } else {
      cout << ans << endl;
    }
    //why i cant use this
    //cout << ((ans==0) ? "NONE" : ans) << endl;
  }
}