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;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n, m;
	while(cin >> n >> m, n, m) {
		vi a(n);
		rep(i, n) cin >> a[i];
		int ans = -1;
		rep(i, n) rep(j, i) if(a[i] + a[j] <= m) {
			if(ans < a[i] + a[j]) 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(){

  while(1){
    int n, m; cin >> n >> m;
    if(!n) break;

    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<int> b;
    for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
	b.push_back(a[i] + a[j]);
      }
    }


    int ans = -1;
    for(auto x : b){
      if(x <= m) ans = max(ans, x);
    }

    if(ans == -1) cout << "NONE" << endl;
    else cout << ans << endl;

  }

  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<stack>
using namespace std;
int main(){
    while(1){
        long long n,m,i,j,ans=0;
        vector<long long> p(n);
        cin >> n >> m;
        if(n==0&&m==0)  break;
        for(i=0;i<n;i++){
            cin >> p[i];
        }
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(p[i]+p[j]<=m&&ans<p[i]+p[j])   ans = p[i]+p[j];
            }
        }
        if(ans==0)  cout << "NONE"<< endl;
        else cout << ans << endl;
    }
    return 0;
}

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

int main(){
	int n,m;
	while(1){
		int a[1000]={},ans=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++){
				if(a[i]+a[j]<=m)ans=a[i]+a[j];
			}
		}
		if(ans)cout<<ans<<"\n";
		else cout<<"NONE\n";
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++) 
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
 
using namespace std;

int main(){
    int n,m;
    while(cin>>n>>m){
        if(n==0&&m==0)break;
        vector<int> v(n);
        rep(i,0,n)cin>>v[i];
        int ans=-1;
        rep(i,0,n){
            rep(j,i+1,n){
                if(ans<v[i]+v[j] && v[i]+v[j]<=m)ans=v[i]+v[j];
            }
        }
        if(ans==-1)cout<<"NONE"<<endl;
        else cout<<ans<<endl;
    }
    
    return 0;
}

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

int main(){
    int n,m;

    while(1){
        cin>>n>>m;
        if(n==0 && m==0){
            return 0;
        }

        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int ans=0;
        int sum=0,sa=0,val=1e9;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i!=j){
                    sum=a[i]+a[j];
                    sa=m-sum;
                    if(m>=sum && sa<val){
                        ans=sum;
                        val=sa;
                    }
                }
            }
        }
        if(ans==0){
             cout<<"NONE"<<endl;   
        }else{
            cout<<ans<<endl;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    while (true) {
        int n, m; cin >> n >> m;
        if (n+m == 0) break;

        vector<int> vec(n);
        rep(i, n) cin >> vec[i];

        int ans = 0;
        rep(i, n) rep(j, n) {
            if (i==j) continue;
            if (vec[i]+vec[j]<=m) ans = max(ans, vec[i]+vec[j]);
        }

        if (ans) cout << ans << endl;
        else cout << "NONE" << endl;
    }
}

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

using namespace std;

int main()
{
  int n, m;
  vector<int> vec_a;
  
  while (1) {
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    
    vec_a.clear();
    while (n--) {
      int a;
      cin >> a;
      vec_a.push_back(a);
    }
    
    sort(vec_a.begin(), vec_a.end());

    int max_value = 0;
    for (int i = 0; i != vec_a.size(); i++) {
      for (int j = i + 1; j != vec_a.size(); j++) {
        int value = vec_a.at(i) + vec_a.at(j);
        if (value > m) break;
        if (value > max_value) max_value = value;
      }
    }

    max_value ? cout << max_value << endl : cout << "NONE" << endl;
  }
}