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>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

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

}

C++: #include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<utility>
#include<algorithm>
using namespace std;

typedef long long ll;
int a[1010];

int main()
{
	ios::sync_with_stdio(false);
	int n, m;
	while (scanf("%d%d", &n, &m) == 2 && n&&m)
	{
		for (int i = 1; i <= n; i++)
			scanf("%d", &a[i]);
		int sum = -1;
		for (int i = 1; i <= n; i++)
			for (int j = i + 1; j <= n; j++)
				if (a[i] + a[j] <= m) sum = max(sum, a[i] + a[j]);
		if (sum == -1) printf("NONE\n");
		else printf("%d\n", sum);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int n,m,a[1000];

map<int,int> c;

int main() {
    while(true) {
        cin >> n >> m;
        if(n == 0)break;
        rep(i,n){
            cin >> a[i];
            c[a[i]] = 0;
        }
        rep(i,n) {
            c[a[i]]++;
        }
        sort(a,a+n);

        int ans = -1;
        rep(i,n) {
            auto itr = upper_bound(a,a+n,m - a[i]);
            if(itr - a == 0) {
                continue;
            }
            itr--;
            if(*itr == a[i] && c[a[i]] < 2) {
                auto itr2 = lower_bound(a,a+n,a[i]);
                if(itr2 - a == 0) {
                    continue;
                }
                ans = max(ans,*(itr2 - 1) + a[i]);
                continue;
            }
            ans = max(ans,*itr + a[i]);
        }
        if(ans == -1)cout << "NONE" << endl;
        else cout << ans << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<stack>
using namespace std;
int main(){
    while(1){
        int n,m,i,j,ans=0;
        cin >> n >> m;
        vector<int> p(n);
        if(n==0&&m==0)  break;
        for(i=0;i<n;i++){
            cin >> p[i];
        }
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(p[i]+p[j]<=m&&ans<p[i]+p[j])   ans = p[i]+p[j];
            }
        }
        if(ans==0)  cout << "NONE"<< endl;
        else cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>


int main(void){
  int n,m,tmp,cnt,max;
  std::cin>>n;
  std::cin>>m;
  int a[n];
  while(n!=0 && m!=0){
    a[n]={0};
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    max=a[0]+a[1];
    cnt=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	tmp=a[i]+a[j];
	if(tmp<=m && tmp>=max){
	  max=tmp;
	  cnt=1;
	}
      }
    }
    if(cnt==0 && max>>m){
      std::cout<<"NONE\n";
    }else{
      std::cout<<max<<"\n";
    }
    std::cin>>n;
    std::cin>>m;    
  }
  std::cout<<("終わり\n");
  return 0;
}

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

using namespace std;

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

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

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

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

int main(){
 int n, m;

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

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

 for(int h=0; h<n-1; h++){
  for(int i=h+1; i<n; i++){
   if(a[h]+a[i]<=m && a[h]+a[i]>=max){
    max = a[h]+a[i];
   }
  }
 }

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