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 <iostream>
#include <string>
using namespace std;

	static int n, m, ans;
	static int a[100000];
void input() {
	cin >> n;
	cin >> m;
	for (int i = 1; i < n + 1; i++) {
		cin >> a[i];
	}
}
void pre() {
	ans = 0;
}
void operate() {
	for (int i=1;i<n+1;i++) 
		for (int j = i + 1; j < n + 1; j++) {
			if ((a[i] + a[j] <= m)&(a[i] + a[j] > ans)) ans = a[i] + a[j];
		}
}
void output() {
        cout << endl;
	if (ans == 0) cout << "NONE";
	else cout << ans;
}
int main() {
	while (true) {
		input();
		if (n == 0)return 0;
		pre();
		operate();
		output();
	}
	return(0);
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
  vector<int> as;
  for(;;) {
    int n, m;
    cin >> n >> m;
    if(n == 0) break;
    for(int i = 0; i < n; i++) {
      int p;
      cin >> p;
      as.push_back(p);
    }
    int mx = 0;
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        if(j == i) continue;
        int d = as[i] + as[j];
        if(d > m) continue;
        if(d > mx) mx = d;
      }
    }
    cout << mx << endl;
  }
  return 0;
}

C++: // #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, M;
    while(cin >> N >> M, N || M) {
        vector<int> A(N);
        for(int i=0; i<N; i++) cin >> A[i];

        int ans = -1;
        for(int i=0; i<N; i++) {
            for(int j=i+1; j<N; j++) {
                if(A[i] + A[j] <= M) {
                    ans = max(ans, A[i] + A[j]);
                }
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
	int n,m;
	while(cin>>n>>m,n+m)
	{
		int a[n],ans=0;
		for (int i = 0; i < n; ++i) cin>>a[i];
		for (int i = 0; i < n; ++i) for (int j = 0; j < i; ++j) if(a[i]+a[j]<=m) ans=max(ans,a[i]+a[j]);
		if(ans) cout<<ans<<endl;
		else cout<<"NONE\n";
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n, m;
    for(;;) {
        cin >> n >> m;
        if(n == 0 && m == 0) return 0;
        vector<int> a(n); rep(i, n) cin >> a[i];
        sort(a.begin(), a.end());
        int ans = 0;
        rep1(i, n - 1) {
            if(a[i] + a[0] > m) continue;
            auto res = lower_bound(a.begin(), a.end(), m - a[i] + 1);
            if(res == a.begin()) continue;
            if(res - 1 == a.begin() + i) res --;
            ans = max(ans, a[i] + *(res - 1));
        }
        if(ans == 0) {
            cout << "NONE" << endl;
        } else {
            cout << ans << endl;
        }
    }

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n==0&&m==0)break;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    int maxi = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i==j)continue;
        if(a[i]+a[j]<=m){
          maxi = max(maxi,a[i]+a[j]);
        }
      }
    }
    if(maxi==0) cout << "NONE" << endl;
    else cout << maxi << endl;
  }
  return 0;
}