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;

int n, m, ans = 0;
int a[1005] = {0};

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

C++: #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,b) for(ll i=0;i<b;i++)

using namespace std;
int n,m,a[1001];
int main(){
    while(cin>>n>>m,n){
        int ans=0;
        rep(i,n)cin>>a[i];
        rep(i,n)rep(j,n)if(i!=j)
            if(a[i]+a[j]<=m)ans=max(ans,a[i]+a[j]);
        if(ans)cout<<ans<<endl;
        else cout<<"NONE"<<endl;
    }
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
    for(;;) {
        int n, m;
        cin >> n >> m;
        vector<int> is;
        for(int i = 0; i < n; i++) {
            int c;
            cin >> c;
            is.push_back(c);
        }
        int best = 0;
        for(int i = 0; i < n; i++) {
            for(int j = i+1; j < n; j++) {
                int k = is[i] + is[j];
                if( k <= m && k > best) best = k;
            }
        }
        cout << best << endl;
    }
    return 0;
}

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

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

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

int main() {
  int n, m;
  vector<int> a;
  while (1) {
    cin >> n >> m;
    if(n == 0 && m == 0)
      break;

    for (int i = 0; i < n; i++) {
      int A;
      cin >> A;
      a.push_back(A);
    }

    vector<int> sum;

    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        if(i != j) {
          int Sum = a[i] + a[j];
          sum.push_back(Sum);
        }
      }
    }

    sort(sum.begin(), sum.end(), greater<int>());

    for(int i = 0; i < sum.size(); i++){
      if(sum[i] < m) {
          cout << sum[i] << endl;
          break;
      }
    }

    sum.clear();
    a.clear();
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;



int main() {
	int n, m;
	int  max=0, maxnum;
	for (;;) {
		cin >> n >> m;
		if (n == 0 && m == 0)break;
		vector<int>v(n);
		REP(i, 0, n) cin >> v[i];

		REP(i, 0, n - 1) {
			REP(j, i + 1, n) {
				if (max < v[i] + v[j] && v[i] + v[j] <= m) {
					max = v[i] + v[j];
				}
			}
		}

		if (max == 0)cout << "NONE" << endl;
		else cout << max << endl;
		max = 0;
	}


	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 a[1001];
        for(int i=0;i<n;i++)
            cin >> a[i];

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

        if(dp)
            cout << dp << endl;
        else
            cout << "NONE" << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define rep(i, n) for(int i = 0;i < n;i++)
#define reprb(i, n) for(int i = n;i >= 0;i--)
#define reps(i, m, n) for(int i = m;i < n;i++)
#define repsb(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(int argc,char const *argv[]) {
	int n,m,a,b;
	cin>>n>>m;

	while(n!=0&&m!=0)
	{
		vector<int>v;
		rep(i,n){
			cin>>a;
			v.pb(a);
			a=0;
		}
		rep(i,n){
			rep(j,n){
				if(i!=j){
					a=max(a,v[i]+v[j]);
				}
			}
		}
		cout<<a<<endl;
		cin>>n>>m;
	}

	return 0;
}

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

int main(){
	int n, m, i, j, k, tmp;
	int result = 0;
	scanf("%d%d\n", &n, &m);
	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>
using namespace std;

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];
        int maximum=0;
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(goods[i]+goods[j] <= m)
                    if(goods[i]+goods[j] > maximum)
                        maximum = goods[i]+goods[j];
            }
        }
        if(maximum==0)cout<<"NONE";
        else cout<<maximum;
        cout<<endl;
    }
}