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<vector>
using namespace std;
int main(){
  vector<int> a(1000);
  int n,m,b,max=0;
  while(n!=0 && m!=0){
    max=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
      cin>>b;
      a[i]=b;
    }
  
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
	if(j!=k){
	  if(max<a[j]+a[k] && a[j]+a[k]<=m){
	    max=a[j]+a[k];
	  }
	}
      }
    }
    if(max==0 && n!=0&&m!=0){
      cout<<"NONE"<<endl;
    }else if(n!=0&&m!=0){
      cout<<max<<endl;
    }
  }
}

C++: #include<iostream>
#define MAXA 1000
using namespace std;

int main() {
	while (1) {
		int n, m, A[MAXA], maxt = 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; i++) {
			for (int j = i+1; j < n; j++) {
				if (A[i] + A[j] > maxt&&A[i] + A[j] <= m)maxt = A[i] + A[j];
			}
		}
		if (maxt == 0)cout << "NONE" << endl;
		else cout << maxt << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		ll n, m; scanf("%lld %lld", &n, &m); if (n == 0) break;
		vector<ll> a(n); for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
		ll res = 0;
		for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) if (a[i] + a[j] <= m) chmax(res, a[i] + a[j]);
		if (res == 0) puts("NONE");
		else printf("%lld\n", res);
	}
	return 0;

}

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

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

C++: #include<iostream>
#include<cstdio>

using namespace std;

int main(){
	int n,m,a[1000];
	int i,j,sum,max;
	
	while(scanf("%d %d",&n,&m)){
		if(n==0&&m==0)
		break;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		max=0;
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++){
				sum=a[i]+a[j];
				if(sum>max&&sum<=m)
				max=sum;
			}
		}
		if(max==0)
		printf("NONE\n");
		else
		printf("%d\n",max);
	}
}

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

using namespace std;

using lint = long long;
using ldouble = long double;

bool solve() {
    int N, M;
    cin >> N >> M;
    if (N == 0) return false;

    vector<int> A(N);
    for (auto &a : A) cin >> a;

    int ans = -1;
    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;
    }
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}

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

int main(){
    int n,m;
    int tmp;
    int ans;
    bool flag;
    std::vector<int> p;
    std::cin >> n;
    std::cin >> m;

    while(n!=0 && m!=0){
        ans =-1;
        flag = false;
        for(int i=0;i<n;i++){
            std::cin >> tmp;
            p.push_back(tmp);
        }
        std::sort(p.begin(),p.end());
        for(int i=n-1;i>0;i--){
            for(int j=i-1;j>=0;j--){
                if(p[i]+p[j] < m){
                    ans = p[i] + p[j];
                    flag = true;
                    break;
                }
            }
            if(flag){
                break;
            }
        }
        if(ans==-1){
            std::cout << "NONE\n";
        }else{
            std::cout << ans <<"\n";
        }
        std::cin >> n;
        std::cin >> m;
    }
    return 0;
}

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

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