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>
using namespace std;

int main(){
    int n, m;
    
    while(true){
        cin >> n >> m;
        if (n==0 && m==0) break;
        int ma=0, list[n];
        for (int i=0; i<n; i++) cin >> list[i];
        for (int i=0; i<n-1; i++){
            for (int j=i+1; j<n; j++){
                int sum = list[i] + list[j];
                if (sum<=m) ma = max(ma,sum);
            }
        }
        if (ma==0) cout << "NONE" << endl;
        else cout << ma << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, m;
ll a[100100];

int main() {
	while (cin >> n >> m&&n + m) {
		rep(i, n) {
			cin >> a[i];
		}
		ll ans = -1;
		rep(i, n) {
			FOR(j, i + 1, n) {
				if (a[i] + a[j] <= m)ans = max(ans, a[i] + a[j]);
			}
		}
		if (ans != -1)cout << ans << endl;
		else cout << "NONE" << endl;
	}
}

C++: #include <iostream>
#define N 1000000

int main(){
  int n=1,max;
  int A[N]={0},k=0;


  while(n!=0){
    int p=0,tmp;
    std::cin>>n;
    int a[n]={0};
    std::cin>>max;
    if(n==0)break;
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	tmp=a[i]+a[j];
	if(tmp>=A[k]&&tmp<=max){
	  A[k]=tmp;
	  p++; 
	}
      }
    }
    if(p==0) A[k]=0;

      k++;
    //if(p!=0) std::cout<<sum<<"\n";
    //else std::cout<<"NONE\n";
  }
  for(int i=0;i<k;i++){
    if(A[i]!=0){
      std::cout<<A[i]<<"\n";
    }else{
      std::cout<<"NONE\n";
    }
   
  }



}

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

int main()
{
  int n, m, MAX = 0, SUM;
  int a, size;
  vector<int> v;
  cin >> n >> m;

  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }

  for (int i = 0; i < v.size(); i++) {
    for (int j = i+1; j < v.size(); j++) {
      SUM = v[i] + v[j];
      if (SUM < m) {
	MAX = max(MAX, SUM);
	//cout << MAX << endl;
      }
    }
  }

  cout << MAX << endl;
  
  return 0;
}

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

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

C++: // 2017/12/10 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

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

		int sum = -1;

		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				int p = a[i]+a[j];

				if(p<=m && p>sum){
					sum = p;
				}
			}
		}

		if(sum!=-1){
			cout << sum << endl;
		}
		else{
			cout << "NONE" << endl;
		}
	}

	return 0;
}

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

main()
{
    while(1)
    {
        int n,m; cin>>n>>m;
        if(!n and !m) break;
        vector<int> a(n);
        for(int&x:a) cin>>x;
        int ans=-1;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<i;j++)
            {
                if(m>=a[i]+a[j])
                {
                    ans=max(ans,a[i]+a[j]);
                }
            }
        }
        if(~ans) cout<<ans<<endl;
        else cout<<"NONE\n";
    }
}