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;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP (i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector <vector<int>>;
using vvll = vector <vector<ll>>;

#define inf(T) (numeric_limits<T>::max() / 2)
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int n, m;
        cin >> n >> m;
        if (n == 0) break;

        vi a(n);
        REP(i, n) cin >> a[i];

        int ans = -1;

        REP(i, n) FOR(j, i+1, n) {
            if (a[i] + a[j] <= m) chmax(ans, a[i] + a[j]);
        }

        if (ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }


    return 0;
}

C++: include <stdio.h>
int max(int a, int b){
    if(a > b)
    return a;
    else
    return b;
}

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

C++: #include <iostream>
#define MAX 50000

int main(){
    int set[MAX];
    int i_set = 0;
    int n, m;
    std::cin >> n >> m;

    while(n != 0 && m != 0){
        int flag = 0;
        int item[n];
        for(int i=0; i<n; i++){
            std::cin >> item[i];
        }
        int max1, max2;
        if(item[0] > item[1]){
            max1 = item[0];
            max2 = item[1];
        }
        else{
            max1 = item[1];
            max2 = item[0];
        }
        int i=2;
        int max = max1 + max2;
        while(max > m){
            if(item[i] <= max2){
                max2 = item[i];
            }
            else if(item[i] <= max1){
                max1 = item[i];
                max1 = max2;
            }
            max = max1 + max2;
            i += 1;
            if((i == n) && (max > m)){
                set[i_set] = -1;
                i_set += 1;
                flag = 1;
            }
        }
        if(flag == 0){
            for(int j=i; j<n; j++){
                if((item[j] >= max1) && ((item[j]+max1) <= m)){
                    max1 = item[j];
                    max2 = max1;
                }
                else if((item[j] >= max1) && ((item[j]+max2) <= m)){
                    max1 = item[j];
                }
                else if((item[j] >= max2) && ((item[j]+max1) <= m)){
                    max2 = item[j];
                }
                else if(((item[j]) >= max2) && ((item[j]+max2) <= m)){
                    max1 = item[j];
                }
            }
            max = max1 + max2;
            set[i_set] = max;
            i_set += 1;
        }
        std::cin >> n >> m;
    }

    for(int k=0; k<i_set; k++){
        if(set[k] == -1){
            std::cout << "NONE\n";
        }
        else{
            std::cout << set[k] << '\n';
        }
    }

    return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int n,m,a[1000];
int ans=-1;

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

	while(true) {
		cin>>n>>m;
		if(n==0) break;
		REP(i,n) cin>>a[i];

		REP(i,n) REP(j,i) if(a[i]+a[j]<=m) ans=max(ans,a[i]+a[j]);
		if(ans!=-1) cout<<ans<<endl;
		else cout<<"NONE"<<endl;
	}

	return 0;
}

C++: #include<iostream>

int main(void){
  int n, m, max=0;
  int price[1000];

  for(int t=0; t<10000; t++){

    max = 0;
    std::cin >> n;
    std::cin >> m;
    if(n == 0 && m == 0){
      break;
    }

    for(int i=0; i<n; i++){
      std::cin >> price[i];
    }

    for(int j=0; j<n; j++){
      for(int s=0; s<n; s++){
	if(j == s){
	  break;
	}
	if(price[j] + price[s] > max && price[j] + price[s] <= m){
	  max = price[j] + price[s];
	}
      }
    }
    if(max > 0){
      std::cout << max << "\n";
    }else{
      std::cout << "NONE\n";
    }
  }
  return 0;
}