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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define rep(i, n) for(int i = 0;i < n;i++)
#define reprb(i, n) for(int i = n;i >= 0;i--)
#define reps(i, m, n) for(int i = m;i < n;i++)
#define repsb(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
vector<int> a;

int fBig(int n,int m){
	int z;
	vector<int>b;
	rep(i,n){
		cin>>z;
		b.pb(z);
	}
	z=0;
	rep(i,n){
		rep(j,n){
			if(i!=j&&b[i]+b[j]<=m)	z=max(z,b[i]+b[j]);
		}
	}	
	return z;

}
int main(int argc,char const *argv[]) {
	bool flg=true;
	int n,m,temp;
	while(flg){
		cin>>n>>m;
		if(n==0&&m==0)	break;
		temp=fBig(n,m);
		a.pb(temp);
	}

	rep(i,a.size()){
		if(a[i]==0)	cout<<"NONE"<<endl;
		else cout<<a[i]<<endl;
	}
	return 0;
}

C++: #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;


typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

void solve(){
	while(true){
		ll N, M;
		cin >> N >> M;
		if(N == 0 && M == 0) break;
		vector<ll> A(N);
		ll ans = -1;
		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) continue;
				if(A[i] + A[j] <= M) ans = max(ans, A[i] + A[j]);
			}
		}
		if(ans == -1)cout << "NONE" << endl;
		else cout << ans << endl;
	}
}


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





}

C++: #include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
   while (true){
       int n, m; cin >> n >> m;
       if(n == 0 and m == 0) return 0;
       else{
           vector<int> price(n);
           REP(i, n) cin >> price[i];
           int ans = 0;
           REP(i, n){
               REP(j, n){
                   if(j == i) continue;
                   else{
                       int tmp = price[i] + price[j];
                       if(ans < tmp and tmp <= m) ans = tmp;
                   }
               }
           }
           if(ans == 0) cout << "NONE" << endl;
           else cout << ans << endl;
       }
       
   }

}

C++: #include<iostream>
int maxs(int n,int m,int a[]){
  int maxs=0,flag=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){

      if(maxs<a[i]+a[j]){
	if(a[i]+a[j]<=m){
	  maxs=a[i]+a[j];
	  flag=1;
	}
      }

    }
  }

  if(flag==1){
    return maxs;
  }else{
    return -1;
  }
}


int main(){

  int n,m,count=0;
  int  b[50000];
  while(n!=0&&m!=0){
    std::cin>>n;
    std::cin>>m;
    if(n==0&&m==0){
      break;
    }
    int a[n];
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    b[count]=maxs(n,m,a);
    count++;
  }
  for(int i=0;i<count;i++){
    if(b[i]==-1){
      std::cout<<"NONE"<<"\n";
    }else{
    std::cout<<b[i]<<"\n";
    }
  }

  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int data[100000];
int m,n;

int main(){
		while(cin>>n>>m,n||m){
			for(int i=0;i<n;i++)cin>>data[i];
			sort(data,data+n);
			int a=0,b=0,ma=0;
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++){
					if(data[i]+data[j]<=m&&data[i]+data[j]>ma){
						ma=data[i]+data[j];
						a=i;
						b=j;
					}
				}
			}
			if(a==0&&b==0)cout<<"NONE"<<endl;
			else cout<<data[a]+data[b]<<endl;
		}
	return 0;
}