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>
#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>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int a[1000];
int main(){
	int n, m;
	while (cin >> n >> m, n) {
		int ma = -1;
		rep(i, n) {
			cin >> a[i];
		}
		rep(i, n) {
			Rep(j,i+1, n) {
				if (a[i] + a[j] > m)continue;
				ma = max(ma, a[i] + a[j]);
			}
		}
		if (ma == -1)cout << "NONE" << endl;
		else cout << ma << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n, m;

    while (cin >> n >> m and n and m) {

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

        int ma = -1;
        rep(i, n) rep(j, n) {
            if (i == j) continue;
            if (a[i]+a[j] <= m) ma = max(ma, a[i]+a[j]);
        }

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

    }

    return 0;
}

C++: #include <iostream>
//1616
#define MAX_SIZE (1000)
int main (void){
  using namespace std;
  while (1){
    int n, m, ans = 0;
    int a[MAX_SIZE];
    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 = max(ans, a[i]+a[j]);
      }
    }
    if (ans == 0){
      cout << "NONE" << endl;
      continue;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: //16D8104029J Tomoya Kogo c++ ID:blan 2018/5/16

#include<iostream>
#include<string>
#include<queue>
#include<utility>

using namespace std;

int main(){

  int n,m,l=0,ans=0;
  int a[1000]={0};
  while(n!=0 && m!=0){
    cin>>n>>m;
    //  cout<<n<<" "<<m<<endl;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  /* for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
  }
  */
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){

      if(i!=j && a[i]+a[j]<=m && a[i]+a[j]>ans){
	  ans=a[i]+a[j];
	}     
      
    }
  }

  if(n!=0 && m!=0){
  if(ans!=0){
    cout<<ans<<endl;
  }else{
    cout<<"NONE"<<endl;
  }
  }

  }
     
 
 
return 0;
}

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

const int maxn = 1000 + 5;
int n, m;
int mem[maxn];

bool Input()
{
 cin >> n >> m;
 if(!n && !m) return false;
 for(int i = 0; i < n; i++)
 {
  cin >> mem[i];
 }
 return true;
}

int solve()
{
 sort(mem, mem+n);
 int ans = -1, tmp;
 for(int i = n-1; i >= 0; i--)
  for(int j = i-1; j >= 0; j--)
  {
   //cout << mem[i] << " " << mem[j] << endl;
   tmp = mem[i]+mem[j];
   if(tmp > ans && tmp <= m) ans = tmp;
  }
 if(ans >= 0) return ans;
 return -1;
}

void Init()
{
 memset(mem, 0, sizeof(0));
}

int main()
{
 while(1)
 {
  Init();
  if(!Input()) break;
  int res = solve();
  if(res >= 0) printf("%d\n", res);
  else printf("NONE\n");
 }
}

C++: #include "bits/stdc++.h"
using namespace std;
int main() {
	int a[1000];
	int n, m;
	while (cin >> n >> m, 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) ans = max(ans, a[i] + a[j]);
			}
		}
		if (ans == 0) cout << "NONE" << endl;
		else cout << ans << endl;
	}
}