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<algorithm>
using namespace std;
int main() {
	int n, m;
	while (cin >> n >> m, n, m) {
		int a[1100], ans = -1;
		for (int i = 0; i < n; i++)cin >> a[i];
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				if (a[i] + a[j] <= m) {
					if (ans < a[i] + a[j])ans = a[i] + a[j];
				}
			}
		}
		if (ans < 0)cout << "NONE\n";
		else cout << ans << endl;
	}
}

C++: #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
using namespace std;
int main(void){

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

  vector<long> a(n);
  for(int i = 0 ; i < n ; i++)    cin >> a[i];

  long ans = 0;
  for(int i = 1 ; i < n ; i++){
    for(int j = 0 ; j < i ; 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>
#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;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

set<int>ng={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};

signed main()
{
	IOS();
	vector<int>ans;
	while(1){
		int N,M;
		cin >> N >> M;
		if(N == 0 && M == 0)break;
		vector<int>a(N);
		rep(i,0,N)cin>>a[i];
		int ma = -1;
		rep(i,0,N){
			rep(j,i+1,N){
				if(a[i]+a[j]<=M){
					chmax(ma,a[i]+a[j]);
				}
			}
		}
		ans.push_back(ma);
	}
	for(auto e:ans){
		if(e!=-1)cout<<e<<endl;
		else cout<<"NONE"<<endl;
	}
}

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 main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	while(true) {
		int n,m,a[1000];
		int ans=-1;
		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>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

  int n=1,kakaku=1,min1,min2=1000000,a,b,c,i,j,k=0;
  vector<int> min3(50000);
 while(n!=0&&kakaku!=0){
   min2=1000000;
  cin>>n;
  vector<int> s(n);
  cin>>kakaku;

    for(i=0;i<n;i++){
      cin>>s.at(i);
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(i!=j){
	  a=s.at(i);
	  b=s.at(j);
	  c=a+b;
	  min1=kakaku-c;
	  if(min2>min1&&min1>=0){
	    min2=min1;
	    min3[k]=c;
	  }
	}
      }
    }
    k++;
 }
 for(i=0;i<k-1;i++){
   if(min3.at(i)==0){
      cout<<"NONE"<<endl;
    }else{
      cout<<min3.at(i)<<endl;
  }
 }
  return 0;
}

C++: #include<iostream>

using namespace std;

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

    int num[n];

    for(int i=0;i<n;i++)
      cin>>num[i];

    int max=0,temp=0,flagx=0,flagy=0;

    for(int i=0;i<n;i++){
      for(int j=1;j<n-i;j++){
        temp=num[i]+num[i+j];
        if(temp>m)
          flagx=1;
        else if(max<temp && temp<=m){
          max=temp;
          flagy=1;
        }
      }
    }

    if(flagx==1 && flagy==0)
      cout<<"NONE"<<endl;
    else
      cout<<max<<endl;
  }

  return 0;
}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

int main(){
  while(1){
    int n,m;
    int a[1000];
    int ans=0;
    scanf("%d%d",&n,&m);
    if(n==0&&m==0)break;
    for(int i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    int x;

    for(int i=0;i<n-1;i++){
      for(int t=i+1;t<n;t++){
        x = a[i]+a[t];
        if(x>ans && x<=m){
          ans=x;
        }
      }
    }
    if(ans==0){
      printf("NONE\n");
    }
    else{
      printf("%d\n",ans);
    }
  }

  return 0;
}