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;

int main() {
    int n, m;
    while (cin >> n >> m, n) {
        auto a = vector<int>(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]);
            }
        }
        cout << ( (ans) ? to_string(ans) : "NONE" ) << endl;
    }
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#include<queue>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
typedef pair<int,int> P;
int ceil(int a,int b){// a以上でbの倍数の最小値を出力//
    return (a+b-1)/b*b;
}
int stoii(string s){//stoi関数の代用 文字列を数値として読み取りint型に変換//
    return atoi(s.c_str());
}
int dp[110];
int a[1010];
int main(){
	while(1){
	int n,m;
	cin>>n>>m;
	if(n==0 && m==0) return 0;
	int price[1000];
	int max=0;
	rep(i,n) cin>>price[i];
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int sum=price[i]+price[j];
			if(sum<=m && sum>max){
				max=sum;
			}
		}
	}
	if(max==0) cout<<"NONE"<<endl;
	else cout<<max<<endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n,m;
    while(cin>>n>>m){
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        vector<int> b(n*(n-1)/2);
        int x=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                b[x]=a[i]+a[j];
                x++;
            }
        }
        sort(b.begin(),b.end());
        for(int i=0;i<x;i++){
            if(b[0]>m){
                cout<<"NONE"<<endl;
                break;
            }
            if(b[i]>m){
                cout<<b[i-1]<<endl;
                break;
            }
        }
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#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_MAX
#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 && n){
        vector<int> v(n);
        rep(i,0,n)cin>>v[i];
        int ans=0;
        rep(i,0,n-1)rep(j,i+1,n)if(v[i]+v[j]<=m)ans=max(ans,v[i]+v[j]);
        if(ans==0)cout<<"NONE"<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;
int main() {
  while (true) {
    int n, m;
    cin>>n>>m;
    if (n==0&&m==0) {
      break;
    }
    vector<int> A;
    for(int i=0;i<n;++i) {
      int a;
      cin>>a;
      A.push_back(a);
    }
    sort(A.begin(),A.end());
    int res = 0;
    for(auto it=A.begin();it!=A.end();++it) {
      auto it2 = upper_bound(it+1,A.end(),m-*it);
      if(it2-1!=it&&*it+*(it2-1)<=m)
        res=max(res,*it+*(it2-1));
    }
    if (res==0)
      cout<<"NONE"<<endl;
    else
      cout<<res<<endl;
  }
  return 0;
}

C++: 
#include <cstdio>

int main(){
    int n,m;
    for(;;){
        scanf("%d %d",&n,&m);
        if(n == 0 && m == 0){
            break;
        }
        int a[n];
        for(int i = 0; i < n; i++){
            scanf(" %d",&a[i]);
        }

        int max = 0;
        for(int i = 0; i < n - 1; i++){
            for(int j = i + 1; j < n; j++){
                if(a[i] + a[j] <= m && a[i] + a[j] >= max){
                max = a[i] + a[j];
                }
            }
        }
        if(max != 0){
            printf("%d",max);
        }else{
            printf("NONE");
        }
        printf("\n");
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[1001];
int main(){
    int n,m;
    while(cin>>n>>m,n){
        rep(i,n) cin>>a[i];
        int mx=-1;
        rep(i,n)rep(j,n)if(i!=j){
            int sum=a[i]+a[j];
            if(sum<=m&&mx<sum) mx=sum;
        }
        if(mx==-1) cout<<"NONE"<<endl;
        else cout<<mx<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()	{

	int n, m, temp, amax;
	int a[1000];

	while (true)	{

		scanf("%d %d", &n, &m);

		if (n == 0)	break;

		amax = -1;

		for (int i = 0; i <= n-1; i++)	{
			
			cin >> temp;

			a[i] = temp;
		}

		for (int i = 0; i <= n-1; i++)	{
			for (int j = 0; j <= n-1; j++)	{
				
				if (i == j)	{
					continue;
				}

				if (a[i] + a[j] <= m)	{
					amax = max(amax, a[i] + a[j]);
				}
			}
		}

		if (amax == -1)	{
			printf("NONE\n");
		} else	{
			printf("%d\n", amax);
		}
	}

	return 0;
}