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++: #define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main() {
	int n, m;
	while (cin >> n >> m, n) {
		int a[1010],ma = -1;
		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] <= m) ma = max(ma,a[i] + a[j]);
			}
		}
		if (ma < 0) cout << "NONE" << endl;
		else cout << ma << endl;
	}
}

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

int a[2000],b[2000],c = 0;

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

}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,a[2000];
int main()
{
while (1)
{
    scanf("%d%d",&n,&m);
    if (n==0&&m==0) break;
    for (int i=1;i<=n;i++)
    scanf("%d",&a[i]);
    int max1=-1;
    for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++)
        if (i!=j)
    {
        if (a[i]+a[j]<=m&&a[i]+a[j]>max1)
            max1=a[i]+a[j];
    }
    if (max1==-1) printf("NONE\n"); else printf("%d\n",max1);

}

    return(0);
}

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

int main(){
  while(true){
  int n,m,value;
  value = 0;
  cin >> n >> m;
  if(n==0&&m==0) break;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i] > m){
      i--;
      n--;
    }
  }

  for(int i=0; i<n-1; i++){
    for(int j=1; j<n-i; j++){
      if(value<a[i]+a[i+j]&&a[i]+a[i+j]<=m){
        value = a[i]+a[i+j];
      }
    }
  }

  if(value==0){
    cout << "NONE" <<endl;
  }else{
    cout << value << endl;
  }
}
return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n, m;
  while (cin >> n >> m, n) {
    vi a(n);
    cin >> a;
    vi v;
    v.reserve(n * n);
    rep(i, n) loop(j, i + 1, n) v.push_back(a[i] + a[j]);
    int maxi = -1;
    for (auto &x : v) {
      if (x <= m) cmax(maxi, x);
    }
    cout << (maxi == -1 ? "NONE" : to_string(maxi)) << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
// istringstream (str) >> x; untuk convert string ke int
string to_string(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}
int n, m, a[100000], hasil;;
int main(){
	while(cin >> n >> m){
		if(n == 0 && m == 0){
			break;
		}
		for(int i = 1; i <= n; i++){
			cin >> a[i];
		}
		hasil = -9999;
		for(int i = 1; i < n; i++){
			for(int u = i+1; u <= n; u++){
				if(a[i]+a[u] <= m){
					hasil = max(hasil, a[i]+a[u]);
				}
			}
		}
		if(hasil < 0){
			cout << "NONE\n";
		}
		else{
			cout << hasil << endl;
		}
	}
	return 0;
}

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

int main()
{
	int n, m;
	while (cin >> n >> m, n | m) {
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		int res = -1;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] + a[j] <= m) {
					res = max(res, a[i] + a[j]);
				}
			}
		}
		if (res == -1) puts("NONE");
		else printf("%d\n", res);
	}
	return 0;
}