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

C++: #include<bits/stdc++.h>

using namespace std;

int main(){

  int n,m;
  vector<int> a(1000);
  int sum=0;
  int max=0;
  
  while(1){
	sum=0;
	max=0;
	cin>>n>>m;
	  
	if(n == 0 && m  == 0)
	  break;
	
	for(int i=0;i<n;++i)
	  cin>>a[i];
	
	for(int i=0;i<n-1;++i){
	  for(int j=i+1;j<n;++j){
	   
		sum=a[i]+a[j];
		
		if(sum > max && sum <= m)
		  max = sum;
			
	  }
	}

	if(max == 0)
	  cout<<"NONE"<<endl;
	else
	  cout<<max<<endl;
	
  }

  return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <vector>

int testcase_ends() {
  size_t n;
  int m;
  scanf("%zu %d", &n, &m);
  if (n == 0 && m == 0) return 1;

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  std::vector<int> b;
  for (size_t i = 0; i < n; ++i)
    for (size_t j = 0; j < i; ++j)
      b.push_back(a[i]+a[j]);

  std::sort(b.begin(), b.end());
  auto it = std::upper_bound(b.begin(), b.end(), m);
  if (it == b.begin()) return puts("NONE"), 0;
  printf("%d\n", *--it);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}

C++: #include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

int solve(int n, int m) {
    vector<long long> a(n);
    REP(i, n) {
        cin >> a[i];
    }
    long long ans = -1;
    REP(i, n) {
        REP(j, n) {
            if (i == j) continue;
            if (m < a[i] + a[j]) continue;
            ans = max(ans, a[i] + a[j]);
        }
    }

    cout << (ans == -1 ? "NONE" : to_string(ans)) << endl;
}

int main() {
    int n, m;
    while (cin >> n >> m && n) {
        solve(n, m);
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;

int main(){
	while(true){
		int n,m;	
		cin>>n>>m;
		if(n=0&&m==0){
			break;
		}
		int a[n];
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		sort(a,a+n);
		while(true){
			int i=0;
			if(a[n]+a[n-i]<=m){
				int pay=a[n]+a[n-i];
				break;
			}
			i++;
		}
		cout<<pay<<endl;
	}
	return 0;
	
}

C++: #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (int u = 0; u < 100; u++)
	{
		long long n,m,a[1001];
		cin >> n >> m;
		if (n == 0 && m == 0)
		{
			break;
		}
		int p = 0;
		int o = 0;

		for (long i = 0; i < n; i++)
		{
			cin >> a[i];
		}

		sort(a,a + n);

		for (int i = 0; i < n; i++)
		{
			for (int j = 1; j < n; j++)
			{
				if (i < j && a[i] + a[j] <= m)
				{
					if (p < a[i] + a[j])
					{
						p = 0;
						p = a[i] + a[j];
					}
				}
				else if (a[i] + a[j] > m)
				{
					break;
				}
			}
			if (p == 0 && i == n - 1)
			{
				cout << "NONE" << endl;
				o = -1;
			}
		}

		if (o != -1)
		{
			cout << p << endl;
		}
	}
}

C++: #pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ll n,m;
while(1){
	cin>>n>>m;
	if(n==0)return 0;
	ll ans=-1;
	V<ll> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]+a[j]<=m&&ans<a[i]+a[j])ans=a[i]+a[j];
		}
	}
	if(ans==-1)cout<<"NONE"<<endl;
	else cout<<ans<<endl;
}
}

C++: #include <iostream>

using namespace std;

int main() {
    int a[1001];
    while (cin >> n >> m) {
        if (n == 0 && m == 0) { break; }
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        ans = -1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a[i] + a[j] <= M && a[i] + a[j] > ans) {
                    ans = a[i] + a[j]
                }
            }
        }
        cout << (ans == -1 ? "NONE" : string(ans)) << endl;
    }
    return 0;
}