akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    string ans = "";
    ans += (char)(s1[0] + ('A' - 'a'));
    ans += (char)(s2[0] + ('A' - 'a'));
    ans += (char)(s3[0] + ('A' - 'a'));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *   author: sahushivam
 *   created: 12 January 2020 (Sunday)  16:50:15
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back	
#define MP make_pair
#define int long long

void solve(){
	int n,m; cin>>n>>m;
	vector<int> a(n,0),cor(n,0);
	int p; string s;
	int wrong=0;
	for(int i=0;i<m;i++)
	{
		cin>>p>>s;
		if(s=="AC"){
			cor[p-1]=1;
		}
		if(cor[p-1]==0 && s=="WA") a[p-1]++; 
	}
	int correct=0;
	for(int i=0;i<n;i++)
	{
		if(cor[i]) {correct++; wrong+=a[i];}
	}
	cout<<correct<<" "<<wrong<<endl;

}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main() {
	string S, T; cin >> S >> T;
	vector<int> start(26, -1), goal(26, -1);
	REP(i, S.size()){
		int a = S[i] - 'a';
		int b = T[i] - 'a';
		if(start[a] != -1 or goal[b] != -1){
			if(start[a] != b or goal[b] != a){
				cout << "No" << endl;
				return 0;
			}
		}else{
			start[a] = b;
			goal[b] = a;
		} 
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 776
# -*- coding: utf-8 -*-
import numpy as np

L, R = list(map(int, input().split()))

if R-L >= 2019:
    print(0)
else:
    tmp = []
    for i in range(L, R):
        for j in range(i+1, R+1):
            tmp.append((i * j) % 2019)
    print(min(tmp))


Measured memory_bytes: 84424
#include<stdio.h>
#include<stdlib.h>
 
 
int main()
{ 
	long long int n;
	scanf("%lld",&n);	
	long long int *a = NULL;
	a = (long long int *)malloc(sizeof(long long int)*n);
	long long int *b = NULL;
	b = (long long int *)malloc(sizeof(long long int)*n);
	

	long long int sum = 0;
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
		sum += a[i];
	 }
	long long int t = 0,m;
		 
	for (int i = 0; i<n;i++)
	{
		t += a[i];
		if (sum - 2 * t >= 0) 
			b[i] = sum - 2 * t;
		else b[i]=2*t-sum;
	}
	m = b[0];
	for (int i = 0; i < n-1; i++)
		if (b[i] < m)
			m = b[i];
 
	
	printf("%lld\n", m);
	free(a);
	free(b);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        int a;
        cin >> a;
        if (a & 1) continue;
        if(a % 3 == 0) continue;
        if(a % 5 == 0) continue;
        puts("DENIED");
        return 0;
    }
    puts("APPROVED");
    return 0;
}

Measured memory_bytes: 256
count = int(input())
numbers = input().split(' ')
check = 0

for number in numbers:
    int_number = int(number)
    if int_number % 2 == 0:
        if int_number % 3 == 0:
            continue
        if int_number % 5 == 0:
            continue
        else:
            check = 1
            break




if check == 0:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] post = new int[N+1];
        for(int i = 0; i <= N; i++) post[i] = -1;
        List<List<Integer>> room = new ArrayList<>();
        for(int i = 0; i <= N; i++) {
            List<Integer> path = new ArrayList<>();
            room.add(path);
        }
        for(int i = 0; i < M; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            room.get(a).add(b);
            room.get(b).add(a);
        }

        Deque<Integer> dq = new ArrayDeque<>();
        dq.addLast(1);
        dq.addLast(0);
        while(!dq.isEmpty()) {
            int q = dq.removeFirst();
            int pre = dq.removeFirst();
            if(post[q] == -1) {
                post[q] = pre;
                for(int i = 0; i < room.get(q).size(); i++) {
                    int x = room.get(q).get(i);
                    if(post[x] == -1) {
                        dq.addLast(x);
                        dq.addLast(q);
                    }
                }
            }
        }

        for(int i = 2; i <= N; i++) {
            if(post[i] == -1) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
        for(int i = 2; i <= N; i++) {
            System.out.println(post[i]);
        }
    }
}

Measured memory_bytes: 78452
import collections

N,M=map(int,input().split())
#if not(M==0):
s=[list(map(int,input().split())) for _ in range(M)]
flag=1
l=[[i+1,-1] for i in range(N)]
ns=""
#print(l)
"""
if M==0:
    for i in range(M):
        if i==0:
            l[i][1]=1
        else:
            l[i][1]=0
        ns="".join((ns,str(l[i][1])))
    print(ns)
"""
#else:
for i in range(M):
    #print(l)
    if l[s[i][0]-1][1]==-1:
        l[s[i][0]-1][1]=s[i][1]
    else:
        if not(l[s[i][0]-1][1]==s[i][1]):
            flag=0
if (not(N==1) and (l[0][1]==0)):
    flag=0
if flag==1:
    for i in range(N):
        if not(N==1):
            if (l[i][1]==-1):
                if i==0:
                    l[i][1]=1
                else:
                    l[i][1]=0
        else:
            if (l[i][1]==-1):
                l[i][1]=0
        ns="".join((ns,str(l[i][1])))
    print(ns)
else:
    print("-1")



Measured memory_bytes: 38384
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



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 Graph = vector<vector<int>>;



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int L,R; cin >> L >> R;
    int ans = INF;
    if(R-L > 3000) ans = 0;
    else{
        for (int i = L; i <= R; i++) {
            for (int j = L; j <= R; j++) {
                
                if(i==j) continue;
                if(i<j) continue;
                ans = min(ans, (i*j)%2019);
                
                
            }
        }
    }
    
    
    cout << ans << endl;
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

vvi adj;
vb vis;
vi dp;
int dfs(int v){
    // cout << v << " -> ";
    int tot = 0;
    vis[v] = true;
    for (auto u: adj[v]){
        ++tot;
        if (vis[u]) dp[v] = max(dp[v], dp[u] + 1);
        else dp[v] = max(dp[v], dfs(u) + 1);
    }
    if (tot == 0) dp[v] = 1;
    return dp[v];
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    adj = vvi(n + 1);
    vis = vb(n + 1, false);
    dp = vi(n + 1, 0);
    for (int i = 0; i < m; i++){
        int a, b;
        scanf("%d%d", &a, &b);
        adj[a].pb(b);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        if (!vis[i]) ans = max(ans, dfs(i));
        // cout << endl;
    }
    // for (int i = 0; i <= n; i++) printf("%d ", dp[i]);
    printf("%d", ans - 1);
    return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};
map<char,int> a;
string s;
int main(){
    ios::sync_with_stdio(false);
    cin >> s;
    REP(i,s.size()) {
        a[s[i]]=1;
    }
    if (a['N'] == a['S'] && a['E'] == a['W']) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int l, m, n, tmp, tmp2;
	
	while(1){
		cin >> l;
		if(l == 0){
			break;
		}
		tmp = tmp2 = 0;
		for(int i = 1, f = 0; i <= 12; i++){
			cin >> m >> n;
			tmp += (m-n);
			if(tmp >= l && f == 0){
				tmp2 = i;
				f = 1;
			} else if(tmp < l && f == 1){
				tmp2 = 0;
				f = 0;
			}
		}
		
		if(tmp2 == 0){
			cout << "NA" << endl;
		} else {
			cout << tmp2 << endl;
		}
	}
	
	return 0;
}

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

int main(){
  int five=0,seven=0;
  for(int i=0;i<3;i++){
    int a;
    cin>>a;
    if(a==5){five++;}
    else if(a==7){seven++;}
  }
  string ans="NO";
  if(five==2||seven==1){ans="YES";}
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int, raw_input().split())
mod = 10**9 + 7

def Split_Bule(N, K, i):
    #Split K Bule balls into i groups
    #ans =  np.prod(np.arange(1,K)) / np.prod(np.arange(1,i)) / np.prod(np.arange(1,K-i+1))
    if i == 1:
        return 1
    ans = com_mod(K-1, i-1, mod)
    return ans    

def com_mod(A, B, mod):
    c = 1
    for i in xrange(B+1, A+1):
        c = (c * i) % mod
    d = 1
    for i in xrange(1, A-B+1):
        d = (d * i) % mod
    ans = c * pow(d, mod-2, mod) % mod
    return ans


#foo = 1
#fac = [0]

#for i in xrange(1, N+1):
#    foo = (foo * i) % mod
#    fac.append(foo)

for i in xrange(1,K+1):
    M = Split_Bule(N, K, i)
    if i > N-K+1:
        print 0
#    elif N == K:
#        print 0
    else:
        print com_mod(N-K+1, i, mod) * M % mod

Measured memory_bytes: 10416
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int n, k;
    cin >> n >> k;

    vector<int> ints(n);
    rep(i, 0, n) cin >> ints[i];
    sort(ints.begin(), ints.end());

    if (ints[n - 1] < k)
    {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    while(true)
    {

        set<int> int_set;
        rep(i, 1, ints.size())
            int_set.insert(ints[i] % ints[0]);
        
        vector<int> new_ints;
        for (auto i : int_set)
        if (i > 0)
        new_ints.push_back(i);

        if (new_ints.size() == ints.size())
            break;
        else
        {
            ints = new_ints;
            sort(ints.begin(), ints.end());
        }
    }

    if (k % ints[0] == 0)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;


int main()
{
    ll H, W;
    cin >> H >> W;
    vector<vector<ll>> c(10, vector<ll>(10));
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    vector<ll> cnt(10, 0);
    ll x;
    rep(i,H)rep(j,W){
        cin >> x;
        if (x>-1)
            cnt[x]++;
    }
    rep(k, 10) rep(i, 10) rep(j, 10) c[i][j] =min(c[i][j], c[i][k] + c[k][j]);
    ll ans = 0;
    rep(i, 10) ans += cnt[i] * c[i][1];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, l;
	cin >> n >> l;

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

	vector<int> degree(n, 0);
	for(int i = 0; i < n - 1; ++i) {
		if(icicles[i] > icicles[i + 1])
			++degree[i + 1];
		else
			++degree[i];
	}

	queue<int> que;
	for(int i = 0; i < n; ++i)
		if(!degree[i])
			que.push(i);

	int ans = 0;
	vector<int> times(n);
	for(int i = 0; i < n; ++i)
		times[i] = l - icicles[i];

	while(!que.empty()) {
		int idx = que.front();
		que.pop();

		chmax(ans, times[idx]);

		if(idx > 0 && icicles[idx] > icicles[idx - 1]) {
			chmax(times[idx - 1], times[idx] + l - icicles[idx - 1]);
			if(!(--degree[idx - 1]))
				que.push(idx - 1);
		}

		if(idx < n - 1 && icicles[idx] > icicles[idx + 1]) {
			chmax(times[idx + 1], times[idx] + l - icicles[idx + 1]);
			if(!(--degree[idx + 1]))
				que.push(idx + 1);
		}
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const double PI = acos(-1);

int main(){
  cout<<setprecision(10)<<fixed;
  int a, b, x;
  cin>> a >> b >> x;
  double ans;
  if(x*2 <= a*a*b){
    double s = (double)x / a;
    double c = 2 * s / b;
    ans = atan(b/c) / PI * 180;
  }else{
    double s = (double)(a*a*b - x) / a;
    double c = 2 * s / a;
    ans = atan(c/a) / PI * 180;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4048
#include<iostream>
#include<vector>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> ii;

ll t;

char str[10];

int main()
{
//     cin>>t;
//     while(t--){
//
//     }
    cin>>str;
    (str[2]==str[3]&&str[4]==str[5])?cout<<"Yes\n":cout<<"No\n";
}


Measured memory_bytes: 256
N = int(input())
S =input()
r = S.count('R')
b = S.count('B')
g = S.count('G')
x = r*b*g

count = 0
for i in range(0,N,1):
    for j in range(i+1,N,1):
        if 2*j-i > len(S)-1:
            continue
        if S[i] != S[j] and S[j] != S[2*j-i] and S[i] != S[2*j-i]:
            count +=1

print(x-count)


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

int main()
{
    int x, y, z;
    int k, s, cnt = 0;
    cin >> k >> s;
    for (int i = 0; i <= k; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            if (s-(i+j)<=k && i+j<=s) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main()
{
	int n;
	std::cin >> n;
	int ans = 0;

	for (int i = 105; i <= n; i += 2)
	{
		int cnt = 0;
		for (int j = 1; j <= i; j++)
		{
			if (i % j == 0)
				cnt++;
			if (cnt > 8)
				break;
		}
		if (cnt == 8)
			ans++;
	}

	std::cout << ans << std::endl;
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X, A, B;
  IN(X,A,B);
  ll Y = B-A;

  if(Y<=0){
    OUT("delicious");
  }else if(Y<=X){
    OUT("safe");
  }else{
    OUT("dangerous");
  }

  return 0;
}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  for(int i=0; i<31; i++){
    if(A%2 == 1 || B%2 == 1 || C%2 == 1){
      cout << i << endl;
      return 0;
    }
    int a = B/2 + C/2;
    int b = A/2 + C/2;
    int c = A/2 + B/2;
    A = a;
    B = b;
    C = c;
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
 
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}
 
template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}
 
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;
}
 
__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
 
signed main() {
  int N;
  cin >> N;
  int NG = N;
  if (NG % 2 == 0)
    NG++;
 
  vector<int> a, b;
  rep(i, N) {
    repp(j, i + 1, N - 1) {
      if (i + j + 2 != NG) {
        a.pb(i + 1), b.pb(j + 1);
      }
    }
  }
 
  int M = len(a);
  cout << M << "\n";
  rep(i, M) {
    cout << a[i] << ' ' << b[i] << "\n";
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }


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

ll dp[101010][3];
ll a[101010][3];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    REP(i,n) REP(j,3) cin>>a[i][j];
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k) continue;
                chmax(dp[i+1][k],dp[i][j]+a[i][k]);
            }
        }
    }
    ll ans = 0;
    REP(i,3) chmax(ans,dp[n][i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,x[200005],y[200005],f[4005][4005],ans;
void add(int &x,int y){
    x+=y;
    if(x>=orz)x-=orz;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d%d",x+i,y+i),++f[2000-x[i]][2000-y[i]];
    for(int i=0;i<=4000;++i){
        for(int j=0;j<=4000;++j)add(f[i+1][j],f[i][j]),add(f[i][j+1],f[i][j]);
    }
    for(int i=1;i<=n;++i)add(ans,f[x[i]+2000][y[i]+2000]);
    memset(f,0,sizeof(f));
    f[0][0]=1;
    for(int i=0;i<=4000;++i){
        for(int j=0;j<=4000;++j)add(f[i+1][j],f[i][j]),add(f[i][j+1],f[i][j]);
    }
    for(int i=1;i<=n;++i)add(ans,orz-f[x[i]<<1][y[i]<<1]);
    if(ans&1)ans+=orz;
    ans>>=1;
    printf("%d\n",ans);
    //system("pause");
    return 0;
}


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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

int n,W,w[100005],v[100005];
ll dp[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>W;
    for(int i =0 ; i<n; ++i){
        cin>>w[i]>>v[i];
        for(int j=W; j>=0; j--){
            if(j>=w[i]){
                dp[j]  = max(dp[j],dp[j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[W]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
using namespace std;

int D[6];
class Dice{
  public:
    int p, q;
    
    Dice(int a, int b, int c, int d, int e, int f){
        D[0] = a;
        D[1] = b;
        D[2] = c;
        D[3] = d;
        D[4] = e;
        D[5] = f;
    }
    
    void move(char ord){
        if (ord == 'S'){
            p = D[4];
            D[4] = D[5];
            q = D[0];
            D[0] = p;
            p = D[1];
            D[1] = q;
            D[5] = p;
        }
        if (ord == 'E'){
            p = D[5];
            D[5] = D[2];
            q = D[3];
            D[3] = p;
            p = D[0];
            D[0] = q;
            D[2] = p;
        }
        if (ord == 'W'){
            p = D[5];
            D[5] = D[3];
            q = D[2];
            D[2] = p;
            p = D[0];
            D[0] = q;
            D[3] = p;
        }
        if (ord == 'N'){
            p = D[5];
            D[5] = D[4];
            q = D[1];
            D[1] = p;
            p = D[0];
            D[0] = q;
            D[4] = p;
        }
    }
    void R_rota(){
        p = D[1];
        D[1] = D[3];
        q = D[2];
        D[2] = p;
        p = D[4];
        D[4] = q;
        D[3] = p;
    }
    
    void L_rota(){
        p = D[1];
        D[1] = D[2];
        q = D[3];
        D[3] = p;
        p = D[4];
        D[4] = q;
        D[2] = p;
    }
};

int main(){
    
    int n;
    scanf("%d", &n);
    int list[n][6];
    for ( int i = 0; i < n; i++ ){
        scanf("%d %d %d %d %d %d", &list[i][0], &list[i][1], &list[i][2], &list[i][3], &list[i][4], &list[i][5]);
    }
    
    int flag = 0;
    for ( int i = 0; i < n; i++){
        for ( int j = 0; j < n; j++){
            
            if ( i == j ) continue;
            Dice sai2 (list[j][0], list[j][1], list[j][2], list[j][3], list[j][4],list[j][5]);
            
            for ( int l = 0; l < 6; l++ ){
                if ( list[i][0] == D[l] ){
                    if ( l == 1) sai2.move('N');
                    else if ( l == 2 ) sai2.move('W');
                    else if ( l == 3 ) sai2.move('E');
                    else if ( l == 4 ) sai2.move('S');
                    else if ( l == 5 ){
                        sai2.move('W');
                        sai2.move('W');
                    }
                }    
            }
        
            if ( list[i][1] == D[2] ) sai2.L_rota();
            else if ( list[i][1] == D[3] ) sai2.R_rota();
            else if ( list[i][1] == D[4] ){
                sai2.R_rota();
                sai2.R_rota();
            }
            
            for ( int k = 0; k < 6; k++){
                if ( list[i][k] == D[k]){
                    if ( k == 5 ){
                        flag = 1;
                        break;
                    }
                }
                else break;
            }
            if ( flag == 1 ) break;
        }
        if ( flag == 1 ) break;
    }
    
    if ( flag == 1 ) cout << "No" << endl;
    else cout << "Yes" <<endl;
    
    return 0;
}


Measured memory_bytes: 3228
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let b: Vec<usize> = sc.vec(n - 1);
    let mut result = b[0];
    for i in 1..n - 1 {
        result += std::cmp::min(b[i - 1], b[i]);
    }
    result += b[n - 2];
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        List<Integer> intList = new ArrayList<Integer>();
        intList.add(sc.nextInt());
        intList.add(sc.nextInt());
        intList.add(sc.nextInt());

        Collections.sort(intList);

        System.out.println(intList.get(0) + intList.get(1) + intList.get(2) * 10);
        sc.close();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

int main(){
    int a,b,t;
    cin >> a >> b >> t;
    int num=b*(int)((t+0.5)/a);
    cout << num << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(){
  int i,j,k;
  int n;
  scanf("%d",&n);
  int L[150];
  int ans = 0;
  for(i=0;i<n;++i){
    scanf("%d",&L[i]);
  }
  
  for(i=0;i<n;++i){
    for(j=0;j<n-1;j++){
      int a = L[j], b = L[j+1];
      if(a<b){
        L[j]=b;
        L[j+1]=a;
      }
    }
  }
  
  for(i=0;i<n;++i){
    for(j=i+1;j<n;++j){
      for(k=j+1;k<n;++k){
        if(L[i]>=L[j]+L[k])continue;
        if(L[i]==L[j])continue;
        if(L[j]==L[k])continue;
  		ans++;      
      }
    }
  }
  
  printf("%d\n",ans);
}

Measured memory_bytes: 1712
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())

result = []
for _ in range(n):
    result.append(input().strip())

from collections import Counter
c = Counter(result)

for r in ('AC', 'WA', 'TLE', 'RE'):
    print('{} x {}'.format(r, c[r]))


Measured memory_bytes: 74356
N,L = map(int,input().split())
a=[]
for i in range(N):
  a.append(L+i)
if 0 in a:
  print(sum(a))
else:
  if a[0]>0:
    print(sum(a)-a[0])
  else:
    print(sum(a)-a[N-1])

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#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,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int n;
	cin >> n;
	vector<P> p(n);
	REP(i, n) {
		cin >> p[i].second >> p[i].first;
	}
	sort(all(p));
	put(p[0].first + p[0].second);
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005][5],dp[200005][5],n;


ll dfs(ll x,ll c)
{
	if(x>n)
		return 0;
	if(dp[x][c]!=-1)
	{
		if(c==1)
			return max(dp[x][2],dp[x][3]);
		else if(c==2)
			return max(dp[x][1],dp[x][3]);
		else 
			return max(dp[x][2],dp[x][1]);
	}
	if(x==n)
	{
		if(c==1)
			return max(arr[n][2],arr[n][3]);
		else if(c==2)
			return max(arr[n][1],arr[n][3]);
		else 
			return max(arr[n][2],arr[n][1]);
	}
	dp[x][1]=arr[x][1]+dfs(x+1,1);
	dp[x][2]=arr[x][2]+dfs(x+1,2);
	dp[x][3]=arr[x][3]+dfs(x+1,3);
	if(c==1)
		return max(dp[x][2],dp[x][3]);
	else if(c==2)
		return max(dp[x][1],dp[x][3]);
	else 
		return max(dp[x][2],dp[x][1]);
}


int main()
{
  	boost
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(ll i=1;i<=n;i++)
		cin>>arr[i][1]>>arr[i][2]>>arr[i][3];
	dp[1][1]=arr[1][1]+dfs(2,1);
	dp[1][2]=arr[1][2]+dfs(2,2);
	dp[1][3]=arr[1][3]+dfs(2,3);
	cout<<max(dp[1][1],max(dp[1][2],dp[1][3]));
	return 0;
}


Measured memory_bytes: 17280
from heapq import heapify, heappush, heappop
from heapq import _heapify_max, _heappop_max
import heapq

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)

"""
method:
    heapify(x): ヒープに変換
    heappush(heap, item): itemをheapにpush
    heappop(heap): heapから最小値を取得 空の場合はIndexError
note:
    max heapにする場合は、prefix: _ とsuffix: _maxをつければ良い
"""
def main():
    n, m = map(int, input().split())
    h = [0] + list(map(int, input().split()))
    ans = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        _heappush_max(ans[a], h[b])
        _heappush_max(ans[b], h[a])
    out = 0
    for ai, hi in zip(ans[1:], h[1:]):
        if (not ai) or hi > _heappop_max(ai):
            out += 1
    print(out)

if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;

int main()
{
	long long l,r;
	while(~scanf("%lld %lld",&l,&r)){
		l--;
		
		ll ans=0,b=2,l1,r1,d1;
		for(ll i=0;i<=40;i++){
			l1=(b/2)*(l/b)+max(0LL,l%b-b/2+1);
			r1=(b/2)*(r/b)+max(0LL,r%b-b/2+1);
			d1=r1-l1;
			if(d1&1)ans+=b/2;
			b<<=1;	
		}
		
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Store{
	long long int A;
	long long int B;
};
bool cmp(const Store &a, const Store &b){
	return a.A < b.A;
}
int main(){
	int N, M; cin >> N >> M;
	vector<Store> st(N);
	for(int i = 0; i < N; i++) cin >> st[i].A >> st[i].B;
	sort(st.begin(), st.end(), cmp);
	long long int cost = 0, num = 0;
	for(int i = 0; i < N; i++){
		if(num + st[i].B >= M){
			cost += (st[i].A * (M - num));
			break;
		}
		else{
			cost += (st[i].A * st[i].B);
			num += st[i].B;
		}
	}
	cout << cost << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
ll inf = 1e18+7;
//LLONG_MIN

/*

*/

int main(void){
	ll x,y;
	cin>>x>>y;
	cout<<x+y/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n, k;
    cin >> n >> k;
    ll p[n], ans = 0;
    rep(i, n) {
        cin >> p[i];
        p[i]++;
    }
    int i = 0, j = 0;
    ll num = 0;
    while(i + k - 1 >= j)
        num += p[j++];
    ans = num;
    for(; j < n; i++, j++) {
        num -= p[i];
        num += p[j];
        chmax(ans, num);
    }
    printf("%.10f\n", (double)ans / 2.0);
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int n, k;
    cin >> k >> n;
    vector<int> a(n);
    for (auto &&i : a)
    {
        cin >> i;
    }

    sort(a.begin(), a.end());

    int maxdis = 0;
    for (int i = 0; i < n - 1; i++)
    {
        maxdis = max(a[i + 1] - a[i], maxdis);
    }

    maxdis = k - maxdis;

    int ans = a.back() - a.front();
    ans = min(ans, maxdis);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
N = int(input())
L = [i for i in map(int, input().split())]

L = sorted(L)[::-1] # descending order

def binary_search(descend_list, threshold):
    # 閾値を超えている要素の数を返す
    length = len(descend_list)
    
    # 最小の数が閾値を超えればリストの長さを返す
    if descend_list[-1] > threshold:
        return length
    
    # 最大の数が閾値を超えなければ0を返す
    if descend_list[0] <= threshold:
        return 0
    
    # 二分探索する 少なくとも一つはthresholdを超える要素があり、少なくとも一つはthresholdを超えない要素がある場合
    upper_bound = length
    lower_bound = 0
    index = (upper_bound - lower_bound) // 2
    
    while upper_bound > lower_bound + 1:
        if descend_list[index] > threshold:
            lower_bound = index
        else:
            upper_bound = index
        
        index = (upper_bound + lower_bound) // 2
    
    return lower_bound + 1

i = 0
ret = 0

while i < N - 2:
    edge1 = L[i]
    for j in range(i + 1, N-1):
        edge2 = L[j]
        _ret = binary_search(L[j+1:], edge1 - edge2)
        if _ret == 0:
            break
        else:
            ret += _ret
    
    i += 1

print(ret)


Measured memory_bytes: 54364
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef pair<int, pi> pii;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define fax(i, a) for (int i = 0; i < (a); i++)
#define f0x(i, a, b) for (int i = (a); i < (b); i++)
#define faxd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define f0xd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define memeset memset

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;
const ld PI = 4*atan((ld)1);

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

ll dp[MX][3][2]; char in[MX];
//dp[pos][curr][0] -> dp[pos+1][0][0], dp[pos+1][1][0], dp[pos+1][2][0];
//dp[pos][curr][1] -> dp[pos+1][0][0], if(in[pos+1] == 1) dp[pos+1][1][1], dp[pos+1][2][1];
//dp[0][0][0] = 1, if(in[0] == 1) dp[0][1][1] = 1, dp[0][2][1] = 1;


int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   string s; cin >> s; int n = sz(s);
   fax(i, sz(s)){
	   in[i] = s.at(i);
   }
   
   if(in[0] == '1'){
	dp[0][0][0] = 1; dp[0][1][1] = 1; dp[0][2][1] = 1;
   }
   else{
	   dp[0][0][1] = 1;
   }
   for(int pos = 0; pos < n-1; pos++){
	   for(int curr = 0; curr < 3; curr++){
		   dp[pos+1][0][0] += dp[pos][curr][0]; 
		   dp[pos+1][1][0] += dp[pos][curr][0];
		   dp[pos+1][2][0] += dp[pos][curr][0];
		   dp[pos+1][0][0] %= MOD;
		   dp[pos+1][1][0] %= MOD;
		   dp[pos+1][2][0] %= MOD;
		   if(in[pos+1] == '1'){
			   dp[pos+1][0][0] += dp[pos][curr][1]; 
			   dp[pos+1][1][1] += dp[pos][curr][1];
			   dp[pos+1][2][1] += dp[pos][curr][1];
			   dp[pos+1][0][0] %= MOD; dp[pos+1][1][1] %= MOD; dp[pos+1][2][1] %= MOD;
		   }
		   else{
			   dp[pos+1][0][1] += dp[pos][curr][1];
			   dp[pos+1][0][1] %= MOD;
		   }
	   }
   }
   ll ans = 0;
   fax(curr, 3){
	   fax(flag, 2){
		   ans += dp[n-1][curr][flag];
		   ans %= MOD;
	   }
   }
   cout << ans << "\n";
}


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

int main()
{
    int n;
    cin >> n;

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

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = n - 1; j > 0; j--) {
            if (a[j] < a[j - 1]) swap(a[j], a[j - 1]), cnt++;
        }
    }

    for (int i = 0; i < n; i++) cout << a[i] << (i == n - 1 ? "" : " ");
    cout << endl << cnt << endl;

    return 0;
}



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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int A, B;
  cin >> A >> B;
  cout << max(max(A + B, A - B), A * B) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long INF = 2e18;

void solve() {
	int n, W; cin >> n >> W;
	vector<int> w(n + 1), v(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	long long dp[n + 1][W + 1];
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i][j] = -INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= W; j++) {
			if (w[i] > j) dp[i][j] = dp[i - 1][j];
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			}
		}
	}
	long long ans = 0;
	for (int j = 0; j <= W; j++) {
		ans = max(ans, dp[n][j]);
	}
	cout << ans << endl;
}

void less_memory_solve() {
	int n, W; cin >> n >> W;
	vector<int> w(n + 1), v(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	long long dp[W + 1];
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= W; j++) {
			dp[j] = -INF;
		}
	}
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		vector<long long> new_dp(W + 1);
		for (int j = 0; j <= W; j++) {
			if (w[i] > j) new_dp[j] = dp[j];
			else {
				new_dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
			}
		}
		for (int j = 0; j <= W; j++) {
			dp[j] = new_dp[j];
		}
	}
	long long ans = 0;
	for (int j = 0; j <= W; j++) {
		ans = max(ans, dp[j]);
	}
	cout << ans << endl;
}

int main() {
	less_memory_solve();
	return 0;
}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a=0,b=0;
    int n;
    double x;
    string s;
    scanf("%d",&n);
    while(n--)
    {
        cin>>x>>s;
        if(s=="JPY") a+=x;
        else b+=x;
    }
    cout<<a+b*380000<<endl;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
#define MAX 2000000000
#define PI 3.1415926535897932
using ll = long long;
using Graph = vector<vector<int>>;
//二項係数を求める。

int main(){
  double a,b,x; cin>>a>>b>>x;
  if(x>a*a*b/2){
    x = a*a*b-x;
    double c = 2*x/(a*a);
    cout<<setprecision(20)<<atan(c/a)/PI*180<<endl;
  }else{
    double c = 2*x/(a*b);
    cout<<setprecision(20)<<atan(b/c)/PI*180<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = ~(1 << 31);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n;
    cin >> k;
    vi x(n);
    rep(i, n){ cin >> x[i]; }
    int ans = 0;

    rep(i, n){
        if(k - x[i] < x[i]){
            ans += (k - x[i]) * 2;
        }else{
            ans += x[i] * 2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256