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>
 
using namespace std;
 
int main(void){
  while(1){
    int n , m;
    cin >> n;
    cin >> m;
    if(n == 0 && m == 0){
      return 0;
    }
 
    int a[n];
    for(int i = 0 ; i < n ; i ++){
      cin >> a[i];
    }
 
    int sum[n][n];
 
    for(int i = 0 ; i < n ; i ++){
      for(int j = 0 ; j < n ; j++){
        if(i != j){ sum[i][j] = a[i] + a[j]; }
        else{ sum[i][j] = -1000; }
      }
    }
 
    int max = -1000;
 
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
        if( sum[i][j] > max && sum[i][j] <= m ){
          max = sum[i][j];
        }
      }
    }
 
    if(max == -1000){
      cout << "NONE" << endl;
    }else{
      cout << max << endl;
    }
  }
 
}

C++: #include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;

int main(){
 while(1){ 
 ll n,m,t,s,ans=-1; cin>>n>>m;
   if(n==0&&m==0) break;
 vector<ll>a; rep(i,n){cin>>t; if(t>=m) continue; a.push_back(t);}
   
   sort(a.begin(),a.end());
   if(a.size()<=1){ cout<<"NONE"<<endl; continue;}
   
   rep(i,a.size()-1){
   for(int k=i+1;k<a.size();k++){
     s=a.at(i)+a.at(k);
     if(s<=m&&m-s<m-ans) ans=s;
     else if(s>m) break;
   }
   }
   
   if(ans<0) cout<<"NONE"<<endl;
   else cout<<ans<<endl;
   
 }
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
	int n,m,tmp,max;
	while(1){
		cin >> n >> m;
		
		if(n == 0 && m == 0)break;
		
		vector<int> s(n),v(n*(n-1)/2);
		
		for(int i=0;i<n;i++){
			cin >> s[i];
		}
		
		tmp = 0;
		max = -1;
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				v[tmp] = s[i]+s[j];
				tmp++;
			}
		}
		
		for(int i=0;i<tmp;i++){
			if(v[i] > max && m >= v[i] ) max = v[i];
		}
		
		if(max < 0)cout << "NONE" << endl;
		else cout << max << endl;
	}
	
	
	return 0;
}

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;
	while (true) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		vector<int> a(n);
		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 <iostream>
#include <vector>

int main(){

    int n,m,price,sum,temp_sum;
    sum=0;
    std::vector<int> prices;

    n=m=1;

    while(n!=0&&m!=0){

    std::cin>>n>>m;

    for(int i=0;i<n;i++){
        std::cin>>price;
        prices.push_back(price);
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            temp_sum = prices[i]+prices[j];
            if(sum<temp_sum&&temp_sum<m) sum=temp_sum;
        }
    }

    if(sum==0){
        std::cout<<"NONE"<<std::endl;
    }
    else{
        std::cout<<sum<<std::endl;
    }

}

    return 0;

}

C++: #include <iostream>
using namespace std;
int main(void){
    int n= 1,m=1,i,j,sum=0;
    int a[1001];
    
    while(n > 0){
    for(i=1;i<1001;i++){
        a[i] = 0;
    }
    cin >> n >> m;
    
    if(n == 0 || m == 0) break;
    
    for(i = 1;i<n+1;i++){
        cin >> a[i];
    }
    
    sum = 0;
    
    for(i=1;i<n;i++){
        for(j=i+1;j<n+1;j++){
            if(a[i] + a[j] > sum  && a[i] + a[j] <= m ) {
                sum = a[i] + a[j];    
            }
        }
    }
    
    if( sum == 0) cout << "NONE" << endl;
    else cout << sum << endl;
    }
}

C++: /*Problem sennobushige 16D8104015E 18.5.16*/
#include <iostream>
#define N 1000000

int main(){
  int n=1,max;
  int A[50000],k=0;


  while(n!=0){
    int p=0,tmp;
    std::cin>>n;
    int a[n]={0};
    std::cin>>max;
    if(n==0)break;
    for(int i=0;i<n;i++){
      std::cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	tmp=a[i]+a[j];
	if(tmp>=A[k]&&tmp<=max){
	  A[k]=tmp;
	  p++; 
	}
      }
    }
    if(p==0) A[k]=0;

      k++;
    //if(p!=0) std::cout<<sum<<"\n";
    //else std::cout<<"NONE\n";
  }
  for(int i=0;i<k;i++){
    if(A[i]!=0){
      std::cout<<A[i]<<"\n";
    }else{
      std::cout<<"NONE\n";
    }
   
  }



}

C++: #include "stdafx.h"
#include <iostream>
using namespace std;

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

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

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

		for (i = 0; i<n - 1; i++) {
			for (j = i + 1; j<n; j++) {
				sum = price[i] + price[j];
				if (max<sum&&sum <= m) {
					max = sum;
				}
			}
		}

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

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

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

    while(cin >> n >> m){
        if(n == 0 && m == 0) break;
        if(max != 0) cout << "\n";
        max = 0;
        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(a[i]+a[j] >= max){
                        max = a[i] + a[j];
                    }
                }
            }
        }
        if(max == 0){
            cout << "NONE";
        }else{
            cout << max;
        }
    }
}