akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    cout << max(0, c - (a-b)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  ll n; cin >> n;
  vector<ll> p(n);
  for(ll i=0; i<n; ++i) cin >> p[i];
  
  ll min = n, res = 0;
  for(ll i=0; i<n; ++i){
    if(min >= p[i]){
      min = p[i];
      ++res;
    }
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#ifndef LIB_REPEAT_HPP
#define LIB_REPEAT_HPP
#define repeat(i,n) for (int i = 0; i < (n); ++i)
#define repeat_from(i,m,n) for (int i = (m); i < (n); ++i)
#define repeat_one(i,n) for (int i = 1; i <= (n); ++i)
#define repeat_rev(i,n) for (int i = (n)-1; 0 <= i; --i)
#define foreach(it, cont) for (decltype(cont.begin()) it = cont.begin(); it != cont.end(); ++it)
#endif
#include <vector>

struct union_find {
    std::vector<int> tree;
    union_find(size_t n) : tree(n, -1) {}
    bool is_root(int a) { return tree[a] < 0; }
    int find_root(int a) { return is_root(a) ? a : (tree[a] = find_root(tree[a])); }
    int tree_size(int a) { return - tree[find_root(a)]; }
    void union_tree(int a, int b) {
        a = find_root(a); b = find_root(b);
        if (a != b) {
            if (not (tree_size(a) < tree_size(b))) std::swap(a,b);
            tree[b] += tree[a];
            tree[a] = b;
        }
    }
    bool is_connected(int a, int b) { return find_root(a) == find_root(b); }
};
#ifndef LIB_TYPEDEF_LL_HPP
#define LIB_TYPEDEF_LL_HPP
typedef long long ll;
typedef unsigned long long ull;
#endif
using namespace std;
struct edge { int a, b; ll c; };
bool operator < (const edge & x, const edge & y) { return x.c > y.c; } // reversed
int main() {
    ios_base::sync_with_stdio(false);
    int N; cin >> N;
    priority_queue<edge> que;
    repeat (i,N-1) {
        int a, b; ll c; cin >> a >> b >> c;
        que.push((edge){ a,b,c });
    }
    ll result = 0;
    union_find uft(N);
    while (not que.empty()) {
        const edge e = que.top(); que.pop();
        result += (ll)uft.tree_size(e.a) * (ll)uft.tree_size(e.b) * e.c;
        uft.union_tree(e.a, e.b);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 6752
#include<bits/stdc++.h>

int main()
{
    std::string s;
    std::cin>>s;
    int n = s.size();
    std::vector<std::pair<int,int>> arr(n-1); //first : n(R) / second : n(L)
    std::pair<int,int> p = {0,0};
    int k = 0; //一個前の衝突点からの距離
    for(int i=0;i<n;i++){
        k++;
        if(s[i]=='R' && k%2 == 1)p.first++;
        if(s[i]=='R' && k%2 == 0)p.second++;
        if(s[i]=='R' && s[i+1]=='L'){
            k = 0;
            int j = i+1;
            for(;s[j] =='L';j++){
                k++;
                if(k%2 == 1)p.second++;
                else p.first++;
            }
            arr[i] = {p.first,p.second};
            i = j-1;
            p = {0,0};
            k = 0;
        }
    }
    std::vector<int> ans(n);
    for(int i = 0;i < n-1; i++){
        if(arr[i].first != 0){
            ans[i] = arr[i].first;
            ans[i+1] = arr[i].second;
        }
    }
    for(int i=0;i<n;i++)std::cout<<ans[i]<<" ";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    // your code goes here
    ll a,b,n,i,ans=0,c,d;
    cin >> n >> a >> b;
    if((b-a)%2==0){
        cout << (b-a)/2 << endl;
    } else {
        c = a; d = b;
        d -= c;
        ans = c + d/2;
        c = n-b+1; d = n-a+1;
        d -= c;
        ans = min(ans,c + d/2);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  pb push_back
#define  pf push_front
#define  S second
#define  F first
#define ra ragham
#define ll long long
#define ld long double
#define I(c) (int(c)-'a')
#define lc (x*2)
#define rc (x*2+1)
#define md (i+j)/2
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace std;
//using namespace __gnu_pbds;
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll,ll> pii ;
typedef pair<long double,ll> pldi ;
typedef pair<long double,pii> pldii ;
typedef pair<int,char> cii ;
typedef pair<pii,ll> piii ;
//setprecision(8)
//ios_base:sync_with_stdio(false);
//ifstream fin ("in.txt");
//ofstream fout ("out.txt");
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout;
//123456m
string s ;
ll ans ;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ans = 10000 ;
    cin>>s;
    for(ll y= 0 ; y < s.size()-2 ; y++)
        ans = min(ans,abs(753LL-((s[y]-'0')*100+(s[y+1]-'0')*10+(s[y+2]-'0'))));
    cout<<ans;

}


Measured memory_bytes: 256
from itertools import product
n = list(input())
L = (1,0)
ss = ""
li = []
for v in product(L,repeat =len(n)-1):
    v = list(v)+[0]
    for i in range(len(n)):
        ss += str(n[i])
        
        if v[i] == 1:
            ss += "+"
    li.append(eval(ss))
    ss = ""
print(sum(li))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long a;
	scanf("%lld",&a);
	long long b;
	scanf("%lld",&b);
	long long c;
	scanf("%lld",&c);

	if ((a >= c || b >= c) && (a + b >= c) && (a >= c - b || b >= c - a))
	{
		cout << "No" << endl;
	}
	else
	{
		cout << (4 * a * b - (a + b) * (a + b) < c * c - 2 * c * (a + b) ? "Yes" : "No") << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(200000);
  for(int i=1;i<N+1;i++){
    cin >> a.at(i);
  }
  int b=1;
  for(int j=0;j<N;j++){
    b=a.at(b);
    if(b==2){
      cout << j+1 << endl;
      goto as;
    }
  }
  cout << -1 << endl;
  as:
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    set<pair<string, char> > cur;
    cur.emplace("a", 'a');
    REP(i, 1, n) {
        set<pair<string, char>> nxt;
        for(auto&& p: cur) {
            auto& s = p.fi;
            auto& c = p.se;
            for(char d = 'a'; d <= c+1; ++d) {
                nxt.emplace(s+d, max(c, d));
            }
        } 
        swap(cur, nxt);
    }
    for(auto&& p: cur) {
        cout << p.fi << endl;
    }
    return 0;
}

Measured memory_bytes: 16896
#include<stdio.h>
#define TRUE 1
#define FALSE 0
int solve(int *,int,int,int);
int main(){
  int i,n,A[20],q,S[200],flag;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&S[i]);
  }

  for(i=0;i<q;i++){
    flag=solve(A,0,n,S[i]);
    if(flag==1){
      printf("yes\n");
    }
    else if(flag==0){
      printf("no\n");
    }
  }
  return 0;
}

int solve(int *A,int i,int n,int key){
  int res;
  if(key==0){
      return TRUE;
    }
  if(i>=n){
    return FALSE;
      }
  res=solve(A,i+1,n,key-A[i]) || solve(A,i+1,n,key);                                  
   return res;
}



Measured memory_bytes: 2108
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		int w = sc.nextInt();
		
		for (int i = 0; i < S.length(); i++) {
			if (i == 0 || i % w == 0) {
				System.out.print(S.charAt(i));
			}
		}

	}
}

Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] k = line.split(" ");
		int[] v = new int[2];
		v[0] = Integer.parseInt(k[0]);
		v[1] = Integer.parseInt(k[1]);
		int[] tatesum = new int[v[1] + 1];
		for (int i = 0; i < v[0]; i++) {
			String linek = sc.nextLine();
			String[] suuzi = linek.split(" ");
			int[] kazu = new int[v[1]];
			for (int j = 0; j < kazu.length; j++) {
				kazu[j] = Integer.parseInt(suuzi[j]);
			}
			int sum = 0;
			for (int j = 0; j < kazu.length; j++) {
				sum += kazu[j];
			}
			for (int j = 0; j < kazu.length; j++) {
				tatesum[j] += kazu[j];
			}
			System.out.println(linek + " " + sum);
			tatesum[v[1] ] += sum;
		}
		for (int i = 0; i < tatesum.length - 1; i++) {
			System.out.print(tatesum[i] + " ");
		}
		System.out.println(tatesum[v[1] ]);

	}
}

Measured memory_bytes: 30100
n,a,b=map(int,input().split())

mod=10**9+7

ans = pow(2,n,mod)-1

x=1
for i in range(n-a+1,n+1):
  x *= i
  x %= mod

for i in range(1,a+1):
  x *= pow(i,mod-2,mod)
  x %= mod
  
y=1
for i in range(n-b+1,n+1):
  y *= i
  y %= mod

for i in range(1,b+1):
  y *= pow(i,mod-2,mod)
  y %= mod

ans = ans - x - y
ans %= mod

print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>

using namespace std;
int main() {
  long long N, D;
  cin >> N >> D; 
  long long range = D * 2 + 1; 
  if (N % range > 0){
    cout << (N/range) + 1; 
  } else {
    cout << (N/range); 
}
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>

using namespace std;

int main(void){

	double xa,ya,ra,xb,yb,rb;
	double xs,ys,rw;
	int n;

	cin>>n;

	for(int i=0;i<n;i++){
		cin>>xa>>ya>>ra>>xb>>yb>>rb;
		xs=xa-xb;
		ys=ya-yb;
		rw=ra+rb;
		if(xs*xs+ys*ys>rw*rw) cout<<"0"<<endl;
		else if(sqrt(xs*xs+ys*ys)+rb<ra) cout<<"2"<<endl;
		else if(sqrt(xs*xs+ys*ys)+ra<rb) cout<<"-2"<<endl;
		else cout<<"1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<int> p,j;
		p.resize(n);
		j.resize(n-1);

		ll ans = 0;
	    ll size = n;
		rep(i,n) 
		{
			cin >> p[i];
			ans += p[i];
		}
		rep(i,n-1) cin >> j[i];

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

		rep(i,n-1)
		{
		    ll ret = ans * size;
			ll ret2 = (ans +  j[i]) * (size - 1);

			if(ret2 > ret)
			{
				ans += j[i];
				size--;
			}
			else break;
		}

		cout << ans*size << endl;
	}
}

Measured memory_bytes: 1532
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> p(N);
  REP(i, N) cin >> p[i];

  int ans = 0;
  REP(i, N) {
    if (p[i] == i + 1) {
      swap(p[i], p[i + 1]);
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
using namespace std;

char table[6][5] = {
	{'a','b','c','d','e'},
	{'f','g','h','i','j'},
	{'k','l','m','n','o'},
	{'p','q','r','s','t'},
	{'u','v','w','x','y'},
	{'z','.','?','!',' '}
};

int main(){
	string s;
	while( cin >> s ){
		string ans;
		if( s.size()%2 ){
			cout << "NA" << endl;
		}else{
			bool flag = false;
			for(int i=1 ; i < s.size() ; i+=2 ){
				int y = s[i-1]-'0'-1;
				int x = s[i]-'0'-1;
				if( y < 0 || x < 0 || y >= 6 || x >= 5 ){
					flag = true;
					break;
				}
				ans += table[y][x];
			}
			if( flag )
				cout << "NA" << endl;
			else
				cout << ans << endl;
		}
	}
}

Measured memory_bytes: 1188
num = int(input())
line = []
for i in range(num):
  line.append(input().split())

ans = "No"

for i in range(num - 2):
  if line[i][0] == line[i][1] and line[i+1][0] == line[i+1][1]and line[i+2][0] == line[i+2][1]:
    ans = "Yes"
    break
    
print(ans)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////



int main(){
    
    ll n;cin>>n;
    if(n==25){
        cout<<"Christmas"<<endl;
    }else if(n==24){
        cout<<"Christmas Eve"<<endl;
    }else if(n==23){
        cout<<"Christmas Eve Eve"<<endl;
    }else{
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int,input().split()))

if N == 2:
    print(B[0]*2)
    exit()
l = [B[0]]

for i in range(N-2):
    # print(l)
    # print("i=====",i)
    # print("B[i]",B[i])
    if B[i] > B[i+1]:
        l.append(B[i+1])
    else:
        l.append(B[i])
l.append(B[N-2])
# print(l)
print(sum(l))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n,m,a[52][52],op=-10;
char c;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            cin>>c;
            if(c=='#')
            {
                a[i][j]=op;
                a[i-1][j-1]++;
                a[i-1][j]++;
                a[i-1][j+1]++;
                a[i][j-1]++;
                a[i][j+1]++;
                a[i+1][j-1]++;
                a[i+1][j]++;
                a[i+1][j+1]++;
            }
        }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            if(a[i][j]<0)cout<<"#";
            else cout<<a[i][j];
        cout<<endl;
    }   
}

Measured memory_bytes: 256
#!/usr/bin/env python3
"""
Simple Version
Python TLE https://atcoder.jp/contests/dp/submissions/14906600
PyPy TLE https://atcoder.jp/contests/dp/submissions/14906630
"""
from collections import defaultdict
import sys

sys.setrecursionlimit(10**6)


def solve(N, M, edges):
    longest = [-1] * (N + 1)
    for i in range(N + 1):
        if not edges[i]:
            longest[i] = 0

    def get_longest(start):
        next = edges[start]
        for v in next:
            if longest[v] == -1:
                longest[v] = get_longest(v)

        ret = max(longest[v] for v in next) + 1
        return ret

    for i in range(N + 1):
        if longest[i] == -1:
            longest[i] = get_longest(i)

    return max(longest[v] for v in edges)


def main():
    N, M = map(int, input().split())
    edges = defaultdict(set)
    for i in range(M):
        v1, v2 = map(int, input().split())
        edges[v1].add(v2)

    print(solve(N, M, edges))


main()


Measured memory_bytes: 179268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	int n, m, k;
	scanf("%d%d%d",&n,&m,&k);
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			int ans = (m*i + n*j) - 2 * i*j;
			if (ans == k) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;

int n ,x ;
pair<int,int> arr[N] ;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",&x);
        arr[i] = {x,i+1};
    }
    sort(arr,arr+n);
    for(int i=0;i<n;++i)printf("%d ",arr[i].second);
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

class UnionFindTree {
   public:
    vector<int> parent;
    vector<int> siz;

    UnionFindTree(int n) {
        siz.resize(n, 1);
        parent.resize(n);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
        }
    }

    int root(int x) {
        if (parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    void unite(int x, int y) {
        int rx = root(x); int ry = root(y);
        if (rx == ry) return;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        parent[ry] = rx;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return siz[root(x)];
    }
};

int main() {
    int N, M; cin >> N >> M;
    vector<int> P(N), idx(N);
    REP(i, 0, N) {
        int p; cin >> p; p--;
        P[i] = p;
        idx[p] = i;
    }

    UnionFindTree uft(N);
    REP(i, 0, M) {
        int a, b; cin >> a >> b;
        uft.unite(--a, --b);
    }

    int ans = 0;
    REP(i, 0, N) {
        if (P[i] == i || uft.same(i, idx[i])) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
 int a;
 int b;
 int c;
 

	scanf("%d %d %d\n", &a,&b,&c);
	
	if (c > a && c > b && b > a)	
	printf("Yes\n");
	
	else 
	printf("No\n");
	

   return 0;
   
}

Measured memory_bytes: 2684
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (W, H, N) = nextIntList()
    var xl = 0
    var xr = W
    var yb = 0
    var yt = H
    repeat(N) {
        val (x, y, a) = nextIntList()
        when (a) {
            1 -> if (xl < x) xl = x
            2 -> if (xr > x) xr = x
            3 -> if (yb < y) yb = y
            else -> if (yt > y) yt = y
        }
    }
    if (xl < xr && yb < yt) {
        println((xr - xl) * (yt - yb))
    } else {
        println(0)
    }
}

Measured memory_bytes: 37880
n = int(input())
a = [int(i) for i in input().split()]
b = [-1 for i in range(n)]
if n%2==1:#odd
  left = n//2+1
  right = left - 2
  center = left - 1
  b[center] = a[0]
  
  for i in range(1,n):
    if i%2==1:#odd is left
      b[left]=a[i]
      left+=1
    else:#even is right
      b[right]=a[i]
      right-=1
          
else:#even
  left = n//2
  right = left-1
  for i in range(n):
    if i%2==1:
      b[right]=a[i]
      right-=1
    else:
      b[left]=a[i]
      left+=1
    
ans=""
for i in range(n):
  ans+=str(b[i])+" "
print(ans)
  




Measured memory_bytes: 25744
t_score = 0
h_score = 0

for i in range(int(input())):
  card1, card2 = input().split(' ')

  if card1 < card2:
    h_score += 3
  elif card1 > card2:
    t_score += 3
  else:
    h_score += 1
    t_score += 1

print(t_score, h_score)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    string s; cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
		if(s[i]=='2'){
			ans++;
		}
	}
	cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    int A[2][N];
    rep(i,2){
        rep(j,N){
            cin >> A[i][j];
        }
    }

    int ans=0;
    int sum=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=i;j++){
            sum+=A[0][j];
        }

        for(int k=N-1;k>=i;k--){
            sum+=A[1][k];
        }
        ans=max(ans,sum);
        sum=0;
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
long long a,b,c;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	if(c-a-b<0){printf("No\n");return 0;}
	if(4*a*b<(c-a-b)*(c-a-b))printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;

int64_t n, a, b;
int h[100001];

bool f (int64_t x) {
    int64_t cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (h[i] > x * b)
            cnt += (h[i] - x * b + (a - b - 1)) / (a - b);
    }
    return cnt <= x;
}

signed main () {
    cin >> n >> a >> b;
    for (int i = 1; i <= n; ++i)
        cin >> h[i];
    int64_t l = 1, r = 1000000000;
    while (r - l > 1) {
        int64_t m = (l + r) / 2;
        if (f(m))
            r = m;
        else
            l = m;
    }
    if (f(l))
        cout << l << '\n';
    else
        cout << r << '\n';
}


Measured memory_bytes: 640
#include<cstdio>
using namespace std;
int main(){
    int k,a,maxa,t;
    scanf("%d %d",&k,&t);
    for(int i=0;i<t;i++){
        scanf("%d",&a);
        if(maxa<a){
            maxa=a;
        }
    }
    if(maxa<=(k+1)/2){
        printf("0\n");
    }
    else{
        printf("%d\n",maxa-(k-maxa)-1);
    }
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	
	/*
	 * default function
	 * */	
	int ni() {
		return cin.nextInt();
	}
	
	long nl() {
		return cin.nextLong();
	}
	
	String line() {
		return cin.nextLine();
	}
	
	void println(String str) {	
		System.out.println(str);
	}
	
	void print(String str) {
		System.out.print(str);
	}
	
	/*
	 * default variable
	 */
	
	static final int MOD = 1000000007;
	
	Scanner cin = new Scanner(System.in);	
	String  output;
	
	public static void main(String[] args) {			
		new Main().run();						
	}
	
	/* default above */		
	public void run() {
			
		input();
		/* 
		 * start
		 */	
		
		
		
		solve();
		
		/*
		 * finish
		 */
		
		output = cnt+"";
		println(output);
			
	}
	/* 
	 * define variable
	 */
	
	
	int N;
	int[] nums;
	long cnt;
	
	void input() {
		
		cnt = 0;
		
		N = ni();
		nums = new int[N];
		
		for (int i = 0; i < N; i ++) {
			nums[i] = ni();
		}
	}
	
	void solve() {
		
		long sum1 = 0, sum2 = 0;
		long cnt1 = 0, cnt2 = 0;
		
		if (nums[0] > 0) {
			
			sum1 = nums[0];
			cnt2 += nums[0] + 1;
			sum2 = -1;
		} else if (nums[0] == 0) {
			
			sum1 = 1;
			cnt1 += 1;
			sum2 = -1;
			cnt2 += 1;
		} else {
			
			sum1 = nums[0];
			cnt2 = Math.abs(nums[0]) + 1;
			sum2 = 1;
		}
		
		//1th iteration
		for (int i = 1; i < N; i ++) {
			
			if (sum1 > 0) {
				
				if (sum1 + nums[i] >= 0) {
					cnt1 += sum1 + nums[i] + 1;
					sum1 = -1;					
				} else {
					sum1 = sum1 + nums[i];
				}
			} else{
				
				if (sum1 + nums[i] <= 0) {
					cnt1 += Math.abs(sum1 + nums[i]) + 1;
					sum1 = 1;
				} else {
					sum1 = sum1 + nums[i];
				}
			}
		}
		if (sum1 == 0) {
			cnt1 += 1;
		}
		
		
		//2nd iteration
		for (int i = 1; i < N; i ++) {

			if (sum2 > 0) {
				
				if (sum2 + nums[i] >= 0) {
					cnt2 += sum2 + nums[i] + 1;
					sum2 = -1;					
				} else {
					sum2 = sum2 + nums[i];
				}
			} else{
				
				if (sum2 + nums[i] <= 0) {
					cnt2 += Math.abs(sum2 + nums[i]) + 1;
					sum2 = 1;
				} else {
					sum2 = sum2 + nums[i];
				}
			}
		}
		
		if (sum2 == 0) {
			cnt2 += 1;
		}
		
		
		cnt = Math.min(cnt1, cnt2);
	}
}


Measured memory_bytes: 52560
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [ for i in 1..n -> stream.ReadLine().ToCharArray() ]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let myceil n = if n % 10 = 0 then n else n - (n % 10) + 10

let xs = util.ScanVecV 5 int
let tot = Array.sumBy myceil xs
let last = xs |> Array.sortBy (fun x -> if x%10 = 0 then 10 else x%10) |> Array.head
let delta = last - (myceil last)

printfn "%d" <| tot + delta


Measured memory_bytes: 14940
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void a() {
		int r = sc.nextInt();
		System.out.println(3 * r  * r);
	}
	
	void b() {
		int n = sc.nextInt(),d = sc.nextInt();
		int range = d * 2 + 1;
		if(n % range == 0) System.out.println(n / range);
		else System.out.println(n / range + 1);
	}

	public static void main(String[] args) {
		new Main().b();
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <math.h>
#include <stdio.h>

typedef long long ll;

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int t = c - a - b;
  if (t > 0 && (ll)4 * a * b < (ll)t * t) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
//#define endl '\n'

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

ll modpow(ll x, ll y){
    ll r = 1, a = x % MOD;
    while(y > 0){
        if((y&1) == 1) r = (r*a) % MOD;
        a = (a*a) % MOD;
        y /= 2;
    }
    return r;
}


template<int N, int MOD>
struct Comb{
    ll fact[N+1], inv[N+1];
    Comb(){
        fact[0] = inv[0] = inv[1] = 1;
        for(int i=2;i<=N;i++) inv[i] = (MOD+((ll)-inv[MOD%i]*(MOD/i))%MOD)%MOD;
        REPS(i, N){
            fact[i] = fact[i-1]*i%MOD;
            inv[i] = inv[i]*inv[i-1]%MOD;
        }
    }
    ll operator()(int n, int r){
        if(n < 0 || r < 0 || r > n) return 0;
        ll res = inv[r]*inv[n-r];
        if(res >= MOD) res%= MOD;
        res *= fact[n];
        if(res >= MOD) res%= MOD;
        return res;
    }
};
Comb<2000000, MOD> C;

int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    while(cin >> m) {
        string s;
        cin >> s;
        n = s.size();
        ll sum = 0;
        for (ll i = n; i <= n + m; i ++) {
            sum += modpow(25, i - n) * modpow(26, n + m - i) % MOD * C(i - 1, n - 1) % MOD;
        }
        cout << sum % MOD << endl;
    }
}


Measured memory_bytes: 35512
from collections import defaultdict

works = defaultdict(int)
n = int(input())
for i in range(n):
    time, limit = map(int, input().split())
    works[limit] += time

now = max(works)
for limit in sorted(works.keys(), reverse=True):
    if limit < now:
        now = limit
    now -= works[limit]

if now >= 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 31692
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000


int main(){

	string S;
	cin>>S;
	
	vector<int> v(26,0);
	
	for(int i=0;i<S.size();i++){
		v[S[i]-'a']++;
	}
	
	for(int i=0;i<26;i++){
		if(v[i]==0){
			cout<<(char)('a'+i)<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	
    return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
int main (void)
{
    
    int A,B,N;
    int i,j,s=0;
    int q,w,e,r,t;
    scanf("%d",&N);
    scanf("%d",&A);
    scanf("%d",&B);
  for(i=1;i<=N;i++)
    {
        q=i/10000;
        w=i/1000-10*q;
        e=i/100-100*q-10*w;
        r=i/10-1000*q-100*w-10*e;
        t=i%10;
    j=q+w+e+r+t;
       if(j<=B&&j>=A)
       {
           s=s+i;
       }
    }
    printf("%d\n",s);
    }



Measured memory_bytes: 128
#include <bits/stdc++.h>

using namespace std;

#define lint long long
#define P pair<lint, lint>

struct edge {
    lint from, to, cost;
};

const int V_MAX = 100000;

class Graph{
public:
    vector<vector<edge>> es;
    int E; //edgeの数
    int V; //頂点の数
    const lint INF = 1E14;
    lint d[V_MAX]; //ある頂点からの最短距離の配列
    
    
public:
    void BellmanFord(int s); //頂点sから各頂点への最小距離を求める O(EV)
    void dijkstra(int s); //頂点sから各頂点への最小距離を求める O(E lnV)
    void add(lint from, lint to, lint cost); //edgeをグラフに追加する操作。
    
};

void Graph::add(lint from, lint to, lint cost){
    edge e = {from, to, cost};
    es[from].push_back(e);
}

void Graph::dijkstra(int s){
    bool used[V];
    fill(d, d + V, INF);
    fill(used, used + V, false);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(make_pair(0, s));
    
    while(!que.empty()){
        P p = que.top(); que.pop();
        
        if(used[p.second]){
            continue;
        }
        d[p.second] = p.first;
        used[p.second] = true;
        
        for(auto e : es[p.second]){
            if(!used[e.to]){
                que.push(make_pair(d[e.from] + e.cost, e.to));
            }
        }
    }
    return ;
}

int main(){
    int N, M, R;
    cin >> N >> M >> R;

    vector<lint> r(R);
    Graph G;
    G.V = N + 1;
    G.es.resize(V_MAX);

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

    for(int i = 0; i < M; ++i){
        lint a, b, c;
        cin >> a >> b >> c;

        G.add(a, b, c);
        G.add(b, a, c);
    }

    int d[R][R];

    for(int i = 0; i < R; ++i){
        G.dijkstra(r[i]);
        
        for(int j = 0; j < R; ++j){
            d[i][j] = G.d[r[j]];
        }

        for(int j = 0; j < N + 1; ++j){
            G.d[j] = G.INF;
        }
    }

    int ans = 1E9;
    vector<int> num(R);

    for(int i = 0; i < R; ++i){
        num[i] = i;
    }


    do{
        int tmp = 0;
        for(int i = 0; i < R - 1; ++i){
            tmp += d[num[i]][num[i + 1]];
        }
        ans = min(ans, tmp);
    } while(next_permutation(num.begin(), num.end()));
    
    cout << ans << endl;

}

Measured memory_bytes: 4760
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const int N=300010;
int n;
int a[N],b[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int sum=0;
	for(int i=1;i<=n;i++)
		if(a[i]==i)
		{
			b[i]=1;
			sum++;
		}
	if(sum==n)
	{
		printf("Yes\n");
		return 0;
	}
	int l=1,r=n;
	while(b[l])
		l++;
	while(b[r])
		r--;
	for(int i=l;i<=r;)
	{
		if(i==r||!b[i+1])
		{
			printf("No\n");
			return 0;
		}
		while(b[i])
			i++;
		int j=i+1;
		for(;j<=r&&b[j];j+=2)
		{
			if(b[j+1])
				break;
		}
		j-=2;
		int s1=0,s2=0;
		for(int k=i;k<=j+1;k+=2)
			if(a[k]>k)
			{
				if(a[k]<s1)
				{
					printf("No\n");
					return 0;
				}
				s1=a[k];
			}
			else
			{
				if(a[k]<s2)
				{
					printf("No\n");
					return 0;
				}
				s2=a[k];
			}
		sort(a+i,a+j+2);
		i=j+2;
	}
	for(int i=1;i<=n;i++)
		if(a[i]!=i)
		{
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <cmath>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);

	double ave = 0;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		ave += A.at(i);
	}

	ave /= N;
	int num = 0;
	double diff = abs(A[0] - ave);
	for (int i = 1; i < N; i++) {
		if (diff > abs(A[i] - ave)) {
			num = i;
			diff = abs(A[i] - ave);
		}
	}
	
	cout << num << endl;

	return 0;
}

Measured memory_bytes: 256
def dfs(i,f):
    if i==n-1:
        return sum(list(map(int,f.split("+"))))

    return dfs(i+1,f+s[i+1])+dfs(i+1,f+"+"+s[i+1])

s=input()
n=len(s)

print(dfs(0,s[0]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli n;
    cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    lli x[n];
    lli y[n];
    REP(i, 0, n) {
        lli xi, yi;
        cin >> xi >> yi;
        x[i] = xi;
        y[i] = yi;
    }
    map<P, lli> m;
    REP(i, 0, n) {
        REP(j, 0, n) {
            if (i == j)
                continue;
            // この(p, q)の組み合わせでのコストを出す。
            lli p = x[j] - x[i];
            lli q = y[j] - y[i];

            m[P(p, q)]++;
        }
    }
    lli ans = 0;
    REPIT(it, m) {
        ans = max(ans, it->second);
    }
    cout << n - ans << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int main(){
    int h,n,i,j,dp[10010]={},a,b;
    scanf("%d %d",&h,&n);
    for(i=1; i<10010; i++){
        dp[i]=123456789;
    }
    for(i=0; i<n; i++){
        scanf("%d %d",&a,&b);
        for(j=1; j<=h; j++){
            dp[j]=min(dp[j],dp[max(j-a,0)]+b);
        }
    }
    printf("%d",dp[h]);
    return 0;
}

Measured memory_bytes: 1772
import sys
input = sys.stdin.readline

def main():
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 10**6

    for i in range(M):
        x, y, c = map(int, input().split())
        ans = min(ans, a[x - 1] + b[y - 1] - c)

    ans = min(ans, min(a) + min(b))

    print(ans)

main()

Measured memory_bytes: 64800
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	while (cin >> n >> m, n) {
		vi v(n);
		REP(i, n)cin >> v[i];
		int ans = -INF;
		REP(i, n)FOR(j, i + 1, n) {
			if (v[i] + v[j] <= m)ans = max(ans, v[i] + v[j]);
		}
		if (ans != -INF)cout << ans << endl;
		else cout << "NONE" << endl;
	}
}


Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 42;
bool A[N][N];
ll dp[N][N][N];
int n;
char s[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	
	scanf("%d", &n);
	n *= 2;
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		for (int j = 0; j < n; j++)
			A[i][j] = (s[j] == '1');
	}
	
/*
	n = 40;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			A[i][j] = 1;
*/
	for (int i = 0; i < n; i++)
		dp[i][i + 1][i] = 1;
	for (int len = 3; len < n; len += 2) {
		for (int l = 0; l + len <= n; l++) {
			int r = l + len;
			for (int m1 = l + 1; m1 < r; m1 += 2)
				for (int m2 = m1 + 1; m2 < r; m2 += 2) {
					ll w = 0;
					for (int i = l; i < m1; i++)
						for (int j = m2; j < r; j++) {
							if (!A[i][j]) continue;
							w += dp[l][m1][i] * dp[m2][r][j];
						}
					for (int i = m1; i < m2; i++)
						dp[l][r][i] += w * dp[m1][m2][i];
				}
		}
	}

	ll ans = 0;
	for (int i = 1; i < n; i++)
		if (A[0][i])
			ans += dp[1][n][i];
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
int main(){
  ll n,k,r,S,p;
  cin>>n>>k>>r>>S>>p;
  string s;
  cin>>s;
  vstr ss(k);
  rep(i,sz(s)){
    ss[i%k].pb(s[i]);
  }
  ll ans=0;
  rep(i,k){
    vll f(sz(ss[i]));
    for(int j=0;j<sz(ss[i]);j++){
      if(j==0){
        if(ss[i][j]=='r'){
          ans+=p;
          f[j]=p;
        }
        else if(ss[i][j]=='s'){
          ans+=r;
          f[j]=r;
        }
        else {
          ans+=S;
          f[j]=S;
        }
      }
      else if(ss[i][j-1]==ss[i][j]&&f[j-1]==0){
        if(ss[i][j]=='p'){
          ans+=S;
          f[j]=S;
        }
        else if(ss[i][j]=='s'){
          ans+=r;
          f[j]=r;
        }
        else {
          ans+=p;
          f[j]=p;
        }
      }
      else if(ss[i][j-1]!=ss[i][j]){
         if(ss[i][j]=='p'){
          ans+=S;
          f[j]=S;
        }
        else if(ss[i][j]=='s'){
          ans+=r;
          f[j]=r;
        }
        else {
          ans+=p;
          f[j]=p;
        }
      }
    }
  }
  COUT(ans);
}


Measured memory_bytes: 5120
//#include<bits/stdc++.h>
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#define ll long long
#define maxn 0x3f3f3f3f
using namespace std;

int a[100005];
int main()
{
    int m,n;
    ll ans=0;
    cin>>m>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
        ans+=a[i];
        if(ans>=m)
        {
            cout<<"Yes"<<endl;
            return 0;
        }

    }
    cout<<"No"<<endl;
    return 0;
}
























Measured memory_bytes: 640
import sys
input = sys.stdin.readline

T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())

DA=(T1*A1,T2*A2)
DB=(T1*B1,T2*B2)

if sum(DA)==sum(DB):
    print("infinity")
    sys.exit()

if DA[0]>DB[0]:
    DA,DB=DB,DA

if sum(DA)<sum(DB):
    print(0)
    sys.exit()

rep=(DB[0]-DA[0])//(sum(DA)-sum(DB))
minus=0
if (DB[0]-DA[0])%(sum(DA)-sum(DB))==0:
    minus=1
print(rep*2+1-minus)

Measured memory_bytes: 3064
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [k,t] <- getIntList
    as <- getIntList
    let ans | m <= l = 0
            | even k = (m-l-1)*2 + 1
            | odd k = (m-l)*2
            where l = (k+1) `div` 2
                  m = maximum as
    print ans

Measured memory_bytes: 508
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> String -> Maybe String
solve n s = foldr op Nothing (map (tryF n s) ["SS", "SW", "WS", "WW"])
  where
  op (Just p) _ = Just p
  op Nothing q = q

tryF n s [p_start, q_start] | res2 == [p_start, q_start] = Just (res2 ++ res1)
                            | otherwise                  = Nothing
  where
  (_, results) = mapAccumL f (p_start, q_start) (tail s ++ [head s])
    where f (p,q) u = ((q, newP), newP)
            where newP = nxt p q u
  (res1, res2) = splitAt (n-2) results

nxt p1 p2 u = nxt'' u (nxt' p1 p2)
  where
    nxt' 'S' = id
    nxt' 'W' = rev_SW
    nxt'' 'o' = id
    nxt'' 'x' = rev_SW

rev_SW 'S' = 'W'
rev_SW 'W' = 'S'



readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Maybe String
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      [bs_s]:remLines2 = remLines1
      s = B.unpack bs_s
  in solve n s

outAnswer :: Maybe String -> IO ()
outAnswer (Just s) = putStrLn s
outAnswer Nothing  = putStrLn "-1"

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "6\nooxoox\n"
inp2 = "3\noox\n"
inp3 = "10\noxooxoxoox\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
test1 = tv1 == Just "SSSWWS"
test2 = tv2 == Nothing
test3 = tv3 == Just "SSWWSSSWWS"
alltest = test1 && test2 && test3



Measured memory_bytes: 43388
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

using Graph = std::vector<std::vector<int64_t>>;

std::vector<bool> seen;
void dfs(const Graph &G, int64_t v, int64_t &cnt) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        cnt++;
        dfs(G, next_v, cnt);
    }
}

void solve()
{
    int64_t N, M;
    std::cin >> N >> M;
    Graph G(N);
    for (int64_t i = 0; i < M; i++)
    {
        int64_t a, b;
        std::cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int64_t ans = 0;
    seen.assign(N, false);
    for (int v = 0; v < N; v++) {
        if (seen[v]) continue;
        int64_t cnt = 0;
        dfs(G, v, cnt);
        ans = std::max(ans, cnt);
    }

    std::cout << ans + 1 << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 23484