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<cstdio>

int main(){
  int n,m;
  int A[10000];
  int B[10000];
  int cnt = 0;
  int max;

  std::scanf("%d %d",&n,&m);
  
  while(!(n == 0 && m == 0)){
    bool flag = 1;
    for(int i = 0;i < n;i++){
      std::scanf("%d",&A[i]);
    }

    max = A[0] + A[1];
    
    if(max < m){
      flag = 0;
    }
  
    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];
	  flag = 0;
	}
      }
    }

    if(!(flag)){
      std::printf("%d\n",max);
    }else{
      std::printf("NONE\n");
    }
    /* if(!(flag)){
      B[cnt] = max;
    }else{
      B[cnt] = -1;
      }*/
    cnt++;
    std::scanf("%d %d",&n,&m);
  }
  
  /* for(int i = 0;i < cnt;i++){
    if(B[i] != -1){
      std::printf("%d\n",B[i]);
    }else{
      std::printf("NONE\n");
    }
    }*/
  
  return 0;
}

C++: int main()
{
  int n=1,m=1;
  int x[1000];
  int cnt=0;
  int max;

  while(n>0&&m>0){
    max=0;

    std::cin>>n>>m;
    if(n==0&&m==0) max=-1;
    int a[n+1];

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

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

    x[cnt]=max;

    cnt++;
  }

  for(int i=0;i<cnt;i++){
    if(x[i]==0){
      std::cout<<"NONE\n";
    }else if(x[i]>0){
      std::cout<<x[i]<<"\n";
    }else{
      break;
    }
  }

  return 0;
}

C++: #include <iostream>
#define MAX 1000
#define MAXsum 2000000
using namespace std;
int a[MAX];

int main(){
    while(true){
        int n,m,maxsum = 0;
        cin >> n >> m;
        if(n == 0 && m == 0)break;

        for(int i = 0;i < n;i++)
            cin >> a[i];
        
        for(int i = 1;i < n;i++){
            for(int j = i;j < n;j++){
                if((a[i] + a[j] <= m))
                    maxsum = max(maxsum,a[i] + a[j]);
            }
        }

        if(maxsum > m)
            cout << "NONE" << endl;
        else
            cout << maxsum << endl;
    }

    return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> skipws;

    for (;;) {
        int n, m; cin >> n >> m;
        if (!n && !m) break;

        vector<int> v(n);
        rep(i, 0, n) cin >> v[i];
        sort(all(v));

        int best = -1;

        int l = 0, r = n - 1;
        for (; l < n; l++) {
            while (r >= 0 && v[l] + v[r] > m) r--;
            if (l >= r) break;
            best = max(best, v[l] + v[r]);
        }

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

}

C++: #include<iostream>

#define MAX_N 1000

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

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

int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n == 0 && m==0)
			break;
		vector<int> price;
		for(int i=0; i<n; i++){
			int x;
			cin>>x;
			if(x < m)
				price.push_back(x);
		}
		
		sort(price.begin(),price.end());
		
		int max=0;
		for(int i=0; i<n/2; 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<<max<<endl;
		else cout<<"NONE"<<endl;
	}
	return 0;
}