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<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n+m){
  cin>>n>>m;
  int a[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;
  }
  return 0;
}

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

using namespace std;


int main(){
  int n, m;

  while(cin >> n >> m, n != 0 && m != 0){
    int a[n];
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    int max = -1;
    for(int i = 0; i < n; i++){
      for(int j = i+1; j < n; j++){
        if(max < a[i] + a[j] && a[i] + a[j] <= m){
          max = a[i] + a[j];
        }
      }
    }
    if(max == -1) cout << "NONE" << endl;
    else          cout << max << endl;


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

  }
}

C++: #include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

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

C++: #define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int main()
{
    while(1) {
        int n, m;
        cin >> n >> m;
        if (n == 0 && m == 0) break;
        vector<int> a(n);
        REP(i, n) cin >> a[i];
        int ans = -1;
        REP(i, n) for(int j = i + 1; j < n; ++j) {
            if (a[i] + a[j] > m) continue;
            ans = max(ans, a[i] + a[j]);
        }
        if (ans == -1) {
            cout << "NONE" << endl;
        } else {
        cout << ans << endl;
        }
    }
}

C++: #include <stdio.h>

int main(void)
{
	int n, m;	/* n:??????????????°, m:?????§????????? */
	int max = 0;
	int price[1000];
	int i = 0;

	while (1) {
		scanf_s("%d %d", &n, &m);
		if (n == 0 && m == 0)
			break;
		else {
			for (i = 0; i < n; i++) {
				scanf_s("%d", &price[i]);
			}
			/* printf("n = %d, m = %d\n", n, m);
			for (i = 0; i < n; i++)
				printf("price[%d] = %d\n", i, price[i]);
			*/

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

	}

	return 0;
}

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

void quickSort(int* Array,int left,int right){
    if(left >= right)return;
    int i=left,j=right;
    int pivod = Array[(left+right)/2];
    while(1){
        while(Array[i]<pivod)
            i++;
        while(Array[j]>pivod)
            j--;
        if(i>=j)break;
        swap(Array[i],Array[j]);
        i++;j--;
    }
    quickSort(Array,left,i-1);
    quickSort(Array,j+1,right);
}
int main(){
    int n,m;
    while(true){
        cin>>n>>m;
        if(n==0 && m==0)break;
        int goods[n];
        for(int i=0;i<n;i++){
            cin>>goods[i];
        }
        quickSort(goods,0,n-1);
        int mst_expe = 0;
        int i=0,j=n-1;
        while(i<j){
            if(goods[i]+goods[j] <= m){
                if(mst_expe < goods[i]+goods[j]){
                    mst_expe = goods[i]+goods[j];
                    i++;
                    continue;
                }
            }
            j--;
        }
        if(mst_expe==0)cout<<"NONE"<<endl;
        else cout<<mst_expe<<endl;
    }
}