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 <cstdio>
#include <cstdlib>
#include <stack>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long double ldouble;
typedef long long LL;
#define mp make_pair
#define CHECK(x) if(!(x)) return false;

const int MAXN = 1010;
int v[MAXN];

int main() {
  while (1) {
    int n, m;
    scanf("%d%d", &n, &m);
    if (n == 0 && m == 0)
      break;
    for (int i = 0; i < n; ++i)
      scanf("%d", &v[i]);
    sort(v, v + n);
    int best = -1;
    int il = 0, ir = n - 1;
    while (il < ir) {
      int cand = v[il] + v[ir];
      if (cand <= m) {
        best = max(best, cand);
        ++il;
      }
      else
        --ir;
    }
    if (best < 0)
      puts("NONE");
    else printf("%d\n", best);
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,mx;
  int a[1001]={};
  while(cin>>n>>m,n!=0&&m!=0){
    mx=-1;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        if(a[i]+a[j]<=m)
          mx=max(mx,a[i]+a[j]);
      }
    }
    if(mx == -1)
      cout<<"NONE"<<endl;
    else
      cout<<mx<<endl;
  }
}

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

int main(){
    int n, m, max;
    int a[1000];

    while(cin >> n >> m){
        max = 0;
        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++){
                if(a[i]+a[j] <= m){
                    if(a[i]+a[j] >= max){
                        max = a[i] + a[j];
                    }
                }
            }
        }
        if(max == 0){
            cout << "NONE\n";
        }else{
            cout << max << "\n";
        }
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  while(cin>>n>>m,n){
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(a[i]+a[j]>m) continue;
	ans=max(ans,a[i]+a[j]);
      }
    }
    if(ans) cout<<ans<<endl;
    else cout<<"NONE"<<endl;
  }
  return 0;
}

C++: // g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	while(cin>>n>>m,n){
		vi in(n);rep(i,n)cin>>in[i];
		int out=-1;
		rep(i,n)loop(j,i+1,n)if(in[i]+in[j]<=m)out=max(out,in[i]+in[j]);
		if(out+1)cout<<out<<endl;
		else cout<<"NONE"<<endl;
	}
}

C++: #include<iostream>

using namespace std;

int main(){
  int n,m,a[1001];

while(1){
  cin>>n>>m;
  if(n==0&&m==0) break;
  int ans=0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i!=j){
      if(a[i]+a[j]<=m) ans=max(ans,a[i]+a[j]);
}
}
}
    if(ans!=0) cout<<ans<<endl;
    else cout<<"NONE"<<endl;
}
return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  while(true){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0)return 0;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<int>b;
    b.push_back(-1);
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        if(a[i]+a[j]<=m)b.push_back(a[i]+a[j]);
      }
    }
    sort(rng(b));
    reverse(rng(b));
    if(b[0]==-1)cout<<"NONE"<<endl;
    else cout<<b[0]<<endl;
  }
  return 0;
}

C++: #include <stdio.h>

int main() {
	while (1) {
		int n, m;
		scanf("%d %d", &n, &m);
		if (n == 0 && m == 0) break;
		int a[1000];
		for (int i = 0; i < n; i++) {
			scanf("%d", &a[i]);
		}
		int max = 0;
		bool x = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j && a[i] + a[j] <= m && max < a[i] + a[j]) {
					max = a[i] + a[j];
					x = false;
				}
				
			}
		}
		if (x) printf("NONE\n");
		else printf("%d\n", max);

	}

}