akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int n, k;
	cin >> n >> k;
	cout << (n-k+1) << endl;
}


Measured memory_bytes: 256
from sys import stdin


def main():
    D = int(stdin.readline().rstrip())
    if D == 25:
        print('Christmas')
    elif D == 24:
        print('Christmas Eve')
    elif D == 23:
        print('Christmas Eve Eve')
    else:
        print('Christmas Eve Eve Eve')


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern
let (n, k) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n k -> (n, k)
let aa = Array.init k @@ fun _ -> ignore(read_line ()); read_line () |> split_string |> List.map int_of_string

let ans = Array.make_matrix n k false

let () =
  Array.iteri (fun k -> List.iter (fun i -> ans.(i - 1).(k) <- true)) aa;
  for i = 0 to n - 1 do
    for j = 1 to k - 1 do
      ans.(i).(j) <- ans.(i).(j) || ans.(i).(j - 1)
    done
  done;
  let sum = ref 0 in
  for i = 0 to n - 1 do
    if not ans.(i).(k - 1) then sum := !sum + 1
  done;
  Printf.printf "%d\n" !sum


Measured memory_bytes: 5536
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int[] round = new int[5];
        int tempMin = 9;
        int index = -1;
        for (int i = 0; i < 5; i++) {
            int num = sc.nextInt();
            round[i] = (int) (Math.ceil((float) num / 10) * 10);
            if ((num % 10) <= (tempMin % 10) && num % 10 > 0) {
                tempMin = num;
                index = i;
            }
        }
        int sum = 0;
        for (int i = 0; i < 5; i++) {
            if (i != index) {
                sum += round[i];
            }
        }
        if (index >= 0) {
            sum += tempMin;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23124
N = gets.to_i
btc_rate = 380000.0
sum = 0.0
N.times.each do
  price, currency = gets.chomp.split
  price = price.to_f
  if currency == "JPY"
    sum += price
  else # currency = "BTC"
    sum += price * btc_rate
  end
end
puts sum


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    sort(h.begin(), h.end());
    long s = 0;
    for (int i = 0; i < n - k; i++) s += h[i];
    cout << s << "\n";

    return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;

int main() {
    ll n,m,ans=0, sum=0;
    cin >> n >> m;
    vector<pair<ll,ll>> pair(n);
    rep(i,n) cin >> pair.at(i).first >> pair.at(i).second;
    sort(pair.begin(), pair.end());
    rep(i,n) {
        int di = m - sum;
        sum += pair.at(i).second;
        if(sum < m) {
            ans += pair.at(i).first * pair.at(i).second;
        } else {
            ans += di * pair.at(i).first;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	int out=1+(n-2)/(m-1);
	cout<<out<<endl;
}







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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int d;
  cin >> d;
  arrll(c,26);
  vecll2(s, d, 26);
  rep(i,d){
    rep(j,26){
      cin >> s[i][j];
    }
  }

  srand(time(NULL));

  rep(i,d){
    int r=rand()%26 + 1;
    prt(r);
  }
}


Measured memory_bytes: 3720
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)


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

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

	ll target = 0;  // (new a[0])^(new a[1]) must equal a[2]^...^a[n-1] for Takahashi to win the Nim game
	for (int i = 2; i < n; i++)
	{
		target ^= a[i];
	}

	// square-division
	// record all the results, presumably not so many, which satisfy (a[0]-k)^(a[1]+k)=target at the lower 20 bits (as 10^12 = 2^39.9)
	vector<ll> result_low20;
	for (ll k_low20 = 0; k_low20 < min((ll)1 << 20, a[0]); k_low20++)
	{
		ll post_move_check = (a[0] - k_low20) ^ (a[1] + k_low20) ^ target;
		if ((post_move_check & ((ll)1 << 20) - 1) == 0)
			result_low20.push_back(k_low20);
	}

	// higher 20 bits
	ll res = (ll)1 << 40;
	for (auto this_k : result_low20)
	{
		for (ll k = this_k; k < min(res, a[0]); k += (1 << 20))
		{
			ll post_move_check = (a[0] - k) ^ (a[1] + k) ^ target;
			if (post_move_check == 0)
				res = min(res, k);
		}
	}

	if (res == (ll)1 << 40)
		res = -1;
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

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

void solve()
{
	ll n;
	cin>>n;
	vector<ll> v;
	while(n!=0)
	{
		n--;
		v.push_back((n)%26);
		n /= 26;
	}
	for(int i = v.size()-1; i>=0; i--)
	{
		cout<<(char)('a'+v[i]);
	}
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3632
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int const maxn = 115;
char s[maxn][maxn];
int dp[maxn][maxn];

int main() {
//    freopen("in.txt","r", stdin);
//    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    for (auto& vec : dp)
        fill(begin(vec), end(vec), 100000000);

    int h,w;
    cin >> h >> w;

    for (int i = 1; i <= h; ++i)
        cin >> (s[i] + 1);


    dp[0][1] = 0; s[0][1] = '.';
    for (int i = 1; i <= h; ++i)
        for (int j = 1; j <= w; ++j)
            dp[i][j] = min(dp[i-1][j] + (s[i][j] != s[i-1][j] && s[i][j] == '#'), dp[i][j-1] + (s[i][j] != s[i][j-1] && s[i][j] == '#'));

    cout << dp[h][w] << endl;
}


Measured memory_bytes: 384
#include "stdio.h"

int main(void) {
    int x;

    scanf("%d",&x);

    switch (x/100) {
        case 4:
        case 5:
            printf("8\n");
            break;
        case 6:
        case 7:
            printf("7\n");
            break;
        case 8:
        case 9:
            printf("6\n");
            break;
        case 10:
        case 11:
            printf("5\n");
            break;
        case 12:
        case 13:
            printf("4\n");
            break;
        case 14:
        case 15:
            printf("3\n");
            break;
        case 16:
        case 17:
            printf("2\n");
            break;
        case 18:
        case 19:
            printf("1\n");
            break;

    }

    return 0;
}

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

int main()
{
    int fib[50] = {1, 1};
    int n;
    cin >> n;    
    
    for(int i = 2; i <= n; ++i){
        fib[i] = fib[i-1] + fib[i-2];
    }
    cout << fib[n] << endl;
}

Measured memory_bytes: 1164
using namespace std;
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
 
int main() {
    long long X,Y;
    cin >> X >> Y;
    if (X == 1 | Y == 1) {
        cout << 1 <<endl;
        return 0;
    }
    if (!X%2) {
        cout << (X*Y)/2 <<endl;
    } else {
        cout << (X*Y)/2 + (X*Y)%2 <<endl;
    }
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()

# 1の個数, 0の個数, 1の個数, ..., 1の個数
list10 = []
head = S[0]
cnt = 0

# 左端の1の数
if S[0] == "0":
    list10.append(0)

for i in range(N):
    if S[i] == head:
        cnt += 1
    else:
        list10.append(cnt)
        cnt = 1
        head = S[i]

    if i == N - 1:
        list10.append(cnt)

# 右端の1の数
if S[-1] == "0":
    list10.append(0)

# print(list10)

ans = 0

cumsum = [0]
for li in list10:
    cumsum.append(cumsum[-1] + li)
# print(cumsum)

for j in range(1, len(cumsum), 2):
    h = j
    t = min(j + 2 * K, len(cumsum) - 1)
    ans = max(ans, cumsum[t] - cumsum[max(h - 1, 0)])
print(ans)


Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;
    return 0;
}


Measured memory_bytes: 764
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            int odd = 0;
            int buf = 0;

            if(input > 99999)
            {
                input = 99999;
            }

            while(input >9999)
            {
                if (input > 19999)
                {
                    odd   += 10000;
                    input -= 10000;
                    continue;
                }
                buf = input - 9999;
                odd += buf;
                input -= buf;
            }

            if (input > 999)
            {
                input = 999;
            }

            while(input > 99)
            {
                if(input > 199)
                {
                    odd   += 100;
                    input -= 100;
                    continue;
                }
                buf = input - 99;
                odd += buf;
                input -= buf;
            }

            if(input > 9)
            {
                input = 9;
            }

            odd += input;

            Console.WriteLine(odd);


        }

      
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  if(S == "SUN"){
    cout << 7 << endl;
  }
  else if(S == "MON"){
    cout << 6 << endl;
  }
  else if(S == "TUE"){
    cout << 5 << endl;
  }
  else if(S == "WED"){
    cout << 4 << endl;
  }
  else if(S == "THU"){
    cout << 3 << endl;
  }
  else if(S == "FRI"){
    cout << 2 << endl;
  }
  else if(S == "SAT"){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int N, x[202020];
int cnt[202020];

void solve() {
    int fail = 0;
    FOR (N) {
        cnt[(fail + 1) / 2]++;
        if (i == 0)
            x[i] = 1;
        else {
            if (x[i] == x[i - 1] + 1) {
                fail++;
            } else {
                x[i] = x[i - 1] + 2;
            }
        }
    }
    int ans = 1;
    int tot = 0;
    FOR (N) {
        tot += cnt[i];
        (ans *= tot) %= MOD;
        tot--;
    }
    cout << ans << endl;
}

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

    cin >> N;
    FOR (N)
        cin >> x[i];

    solve();
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#define S 2000000000
#define Max 500000
void merge(int *A,int n,int left, int mid ,int right);
void mergesort(int *A,int n,int left ,int right);
int Left[Max/2+2];
int Right[Max+2];
int count;

int main(){
  int A[Max],num,i;
  count=0;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }
mergesort(A,num,0,num);
  for(i=0;i<num;i++){
    if(i)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}
void merge(int A[],int n,int left,int mid,int right){
  int A1=mid-left;
  int A2=right-mid;
  int i,j,m;
  for(i=0;i<A1;i++)Left[i] = A[left+i];
  for(i=0;i<A2;i++)Right[i]=A[mid+i];
  Left[A1]=S;
  Right[A2]=S;
  i=0;
  j=0;
  for(m=left;m<right;m++){
    count++;
    if(Left[i]<=Right[j]){
      A[m]=Left[i++];
    }else{
      A[m]=Right[j++];
    }
  }
}
void mergesort(int A[],int n,int left,int right){
  int mid;
  if(left+1 <right){
    mid = (left+right)/2;
    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

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

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)
#define dz(o) ((o)<0?(-(o)):(o))

using namespace std;
typedef long long ll;
const ll N=20;

ll D,ten[N],sx;

ll ask(ll ws,ll d)
{
	if(ws==0)return (d==0);
	else if(ws==1) return d?0:10;
	int r=(d%10)==0?0:d%10-10;
	ll k=((d%10)==0?10:d%10)-(ws==sx);
	return k*ask(ws-2,dz(d+r*ten[ws]-r)/10);
}

int main()
{
	cin>>D; ll K=D;
	int u,cs=0; ll ans=0;
	for(;K;K/=10)++cs;
	for(ten[1]=1,u=2;u<=(cs<<1);++u)ten[u]=ten[u-1]*10;
	fo(i,cs,cs<<1)sx=i,ans=ans+ask(i,D);
	cout<<ans;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from collections import Counter
from functools import reduce
from operator import xor

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=[INT() for i in range(N)]

mnbit=[0]*N
for i, a in enumerate(A):
    bina=format(a, 'b')
    mnbit[i]=len(bina)-bina.rfind('1')
C=Counter(mnbit)

res=reduce(xor, A, 0)
ln=len(format(res, 'b'))
cnt=0
for i in range(ln):
    idx=ln-i
    if res>>(idx-1)&1:
        if C[idx]:
            res^=(1<<idx)-1
            cnt+=1
        else:
            print(-1)
            exit()
print(cnt)


Measured memory_bytes: 8448
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 1000
jugh = 1000
for i in range(0, 150):
    if abs(x-i) < jugh and i not in p:
        jugh = abs(x-i)
        ans = i
    # print(ans)
print(ans)


Measured memory_bytes: 9140
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0023
public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N;
	static final double EPS = 1e-10;
	public static void main(String[] args) {
		N = sc.nextInt();
		double xa, ya, ra, xb, yb, rb;
		for (int i = 0; i < N; i++) {
			xa = sc.nextDouble();
			ya = sc.nextDouble();
			ra = sc.nextDouble();
			xb = sc.nextDouble();
			yb = sc.nextDouble();
			rb = sc.nextDouble();
			System.out.println(collision_detection(xa, ya, ra, xb, yb, rb));
		}
	}
	
	static int collision_detection(
			double x1, double y1, double r1,
			double x2, double y2, double r2) {
		double d = hypot(x1 - x2, y1 - y2);
		double lR = r1 + r2;
		double sR = abs(r1 - r2);
		if (d > lR) {
			return 0;
		} else if (d < lR && sR < d){
			return 1;
		} else if (sR > d) {
			return (r1 > r2) ? 2 : -2;
		} else {
			return 1;
		}
	}
}

Measured memory_bytes: 12000
#pragma region

#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int N, K;
  cin >> N >> K;
  vi p(N);
  cin >> p;

  vl psum(N + 1, 0);
  rep(i, N) psum[i + 1] = psum[i] + p[i];

  int ind;
  ll msum = 0;
  rep(i, N - K + 1) {
    ll sum = psum[K + i] - psum[i];
    if (chmax(msum, sum)) ind = i;
  }

  double ans = K;
  rep(i, K) {
    ans += p[ind + i];
  }

  out(ans / 2);
}


Measured memory_bytes: 2560
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws IOException {
		int N = readInt(), A = readInt();
		if(N%500 <= A) println("Yes"); else println("No");
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	public void close() throws IOException {
		if (din == null)
			return;
		din.close();
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


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

int main(){
string S;
  cin>>S;
  
string ans;  
  for(int i=0; i<S.size(); i++){
   if(S[i]!='B'){ans+=S[i];}
   else if(ans.size()!=0){ans.pop_back();} 
  }
  
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 999999999;

int main() {
    int N;
    string S;
    cin >> N >> S;

    vector<int> vW(N+1, 0), vE(N+1, 0);
    
    for (int i = 0; i < N; i++) {
        vW[i+1] += vW[i];
        if (S[i] == 'W')
            vW[i+1]++;
        vE[i+1] += vE[i];
        if (S[i] == 'E')
            vE[i+1]++;
    }
    int ans = INF;
    for (int i = 0; i < N; i++) {
        int now = vW[i] + (vE[N] - vE[i+1]);
        if (ans > now)
            ans = now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;
const int mod = 1e9 + 7;
LL n;
map<pii, int> M;
inline void upd(int &a, int b){a += b; if(a >= mod) a -= mod;}
inline int dfs(LL x, LL y){
	if(y < 0) return 0;
	if(!y) return 1;
	if(M.count(MP(x, y))) return M[MP(x, y)];
	int res = dfs(x >> 1, y >> 1);
	upd(res, dfs(x - 1 >> 1, y - 1 >> 1));
	if(y >= 2) upd(res, dfs(x >> 1, y - 2 >> 1));
	return M[MP(x, y)] = res;
}
int main(){
	scanf("%lld", &n);
	printf("%d", dfs(n, n));
}

Measured memory_bytes: 256
// Author : MohamedSameh
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<stack>
#include<deque>
#include <sstream>
#include <string.h>

typedef long long ll ;
// random in each run --> srand(time(NULL));

#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define IN(n) scanf("%d" , &n )
#define debug(x) cout<<#x<<" = { "<<x<<" }\n"
void fo (){fflush(stdout);}
using namespace std;
int n ;
vector <pair<int,int>> v ;
bool cmp (pair<int,int> &a, pair<int,int>&b)
{
  if (a.s != b.s )return a.s < b.s ;
  return a.f < b.f ;
}
int main ()
{
  scanf ("%d" ,&n );
  for (int i =0 ; i < n ;i++)
  {
    int a ,b ;
    scanf ("%d%d" , &a , &b );
    v.pb({a,b});
  }
  sort(all(v) , cmp );
  ll curtime =0 ;
  bool ok = 1;
  for (int i =0 ; i < n ;i++)
  {
    if (v[i].s < curtime + v[i].f )
    {
      ok = 0;break;
    }
    curtime+=v[i].f ;
  }
  if (ok)printf ("Yes\n");
  else
  printf ("No\n");
  return 0;
}


Measured memory_bytes: 2548
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int m = sc.nextInt();
        int[] A = new int[a];
        int[] B = new int[b];
        Map<String, Integer> map = new HashMap<>();
        int minA = Integer.MAX_VALUE;
        for (int i = 0; i < a; i++) {
            A[i] = sc.nextInt();
            minA = Math.min(minA, A[i]);
        }
        int minB = Integer.MAX_VALUE;
        for (int i = 0; i < b; i++) {
            B[i] = sc.nextInt();
            minB = Math.min(minB, B[i]);
        }
        int min = minA + minB;

        for (int i = 0; i < m; i++) {
            int val = A[sc.nextInt()-1] + B[sc.nextInt()-1];
            int discount = sc.nextInt();
            min = Math.min(min, val-discount);
        }
        
        System.out.println(min);
    }
}


Measured memory_bytes: 132460
#include <iostream>
#include <vector>

struct UnionFind
{
  std::vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x)
  {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }

  bool unite(int x, int y)
  {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) std::swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y)
  {
    return root(x) == root(y);
  }
  int size(int x)
  {
    return -d[root(x)];
  }
};



int main()
{
  int n, q;
  std::cin >> n >> q;
  UnionFind uf(n);

  while (static_cast<bool>(q--))
  {
    int com, a, b;
    std::cin >> com >> a >> b;
    if (com == 0)
    {
      uf.unite(a, b);
    }
    else if (com == 1)
    {
      if (uf.same(a, b))
      {
        std::cout << 1 << std::endl;
      }
      else
      {
        std::cout << 0 << std::endl;
      }
    }
  }

  return 0;
}



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

int main(int argc, const char * argv[]) {
    // insert code here...
    int A, B;
    cin >> A >> B;
    
    if (A <= 8 and B <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Range Set
//-------------------------------------------------
template<typename T>
class RangeSet
{
private:
    ::std::vector<int> v;
    ::std::map<T, int> Map;
    ::std::vector<::std::vector<T> > data;
    int kind;
public:
    RangeSet(const ::std::vector<T> &v_):v(v_.size()){
        int sz = v_.size(); kind = 0;
        for(int i=0;i<sz;i++){
            T t = v_[i];
            if (Map.count(t)){
                data[Map[t]].push_back(i);
            }else{
                Map[t] = kind++;
                data.push_back(::std::vector<T>());
                data.back().push_back(i);
            }
            v[i] = Map[t];
        }
    }
    int query(T x){
        if (!Map.count(x)) return 0;
        return data[Map[x]].size();
    }
    int query(int a, int b, T x){
        if (a>b) return 0;
        if (!Map.count(x)) return 0;
        int xi = Map[x];
        auto right = ::std::upper_bound(data[xi].begin(),data[xi].end(),b);
        auto left  = ::std::lower_bound(data[xi].begin(),data[xi].end(),a);
        return right-left;
    }
    void update(int k, T x){
        int ei = v[k];
        auto eitr = ::std::lower_bound(data[ei].begin(),data[ei].end(),k);
        data[ei].erase(eitr);
        v[k] = Map[x];
        if (Map.count(x)){
            int xi = Map[x];
            auto itr = ::std::lower_bound(data[xi].begin(),data[xi].end(),k);
            data[xi].insert(itr, k);
        }else{
            Map[x] = kind++;
            data.push_back(::std::vector<T>());
            data.back().push_back(k);
        }
    }
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vll a(n);
    rep(i,n){cin>>a[i]; a[i]--;}
    vll s(n+1);
    s[0] = 0;
    rep(i,n) s[i+1]=(s[i]+a[i])%k;
    RangeSet<ll> rs(s);
    ll ans=0;
    rep(i, n){
        ans+=rs.query(i+1, i+k-1, s[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 30764
import scala.util.control.Breaks

object Main extends App {
  val n = scala.io.StdIn.readInt()
  val lInput = scala.io.StdIn.readLine()
  val lArray = lInput.split(" ").map(_.toLong).toVector

  val lArraySorted = lArray.toSet.toVector.sorted
  val sortedLength = lArraySorted.length
  val groupedMap = lArray.groupBy(l => l)
  var result = 0

  def setTriangle(head: Long, tail: Vector[Long]): Unit = {
    tail.zipWithIndex.foreach { t =>
      if (head < t._1) {
        val second = (head, t._1)
        setThirdPosition(second, tail.drop(t._2 + 1))
      }
    }
  }

  def setThirdPosition(nihen: (Long, Long), tail: Vector[Long]): Unit = {
    val b = new Breaks
    b.breakable {
      tail.foreach { t =>
        if ((nihen._1 + nihen._2) > t && t > Math.abs((nihen._1 - nihen._2))) {
          val firstCount = groupedMap.get(nihen._1).get.size
          val secondCount = groupedMap.get(nihen._2).get.size
          val thirdCount = groupedMap.get(t).get.size
          result = result + (firstCount * secondCount * thirdCount)
        } else {
          b.break()
        }
      }
    }
  }

  if (sortedLength > 2) {
    var count = sortedLength
    var tempSortedArray = lArraySorted
    while (count > 2) {
      val head = tempSortedArray.head
      tempSortedArray = tempSortedArray.tail
      setTriangle(head, tempSortedArray)
      count = count - 1
    }
    println(result)
  } else {
    println(0)
  }

}

Measured memory_bytes: 57208
n, m, k = list(map(int, input().split(" ")))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

sa = [0]
for i in range(n):
	if (sa[-1] + a[i]) > k:
		break
	sa.append(sa[-1] + a[i])
sb = [0]
for i in range(m):
	if (sb[-1] + b[i]) > k:
		break
	sb.append(sb[-1] + b[i])

r = 0
j = 0
cur = sa[-1]

for i in range(len(sa)-1, -1, -1):
	while j < len(sb):
		if sa[i] + sb[j] > k:
			break
		j += 1
	r = max(r, i + j - 1)
print (r)



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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;
//式変形とGreedyな発想で片側を適当に決める
//doubleで判定するのはバグの元（自戒の念を込めて）
int main() {

    ll N = 0;
    cin >> N;

    for(ll h = 1; h <= 3500; h++){
        for(ll n = 1; n <= 3500; n++){
            ll bunshi = N * h * n;
            ll bunbo  = 4*h*n-N*n-N*h;

            //もし分母が負だと答えも負になるのでNG
            if(bunbo <= 0) continue;
            //もし分子/分母で余りが発生すると1/wにはなれないのでNG
            if(bunshi % bunbo > 0) continue;

            cout << h << " " << n << " " << bunshi / bunbo << endl;
            return 0; 
        }        
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N,A,B;
    cin>>N>>A>>B;
    cout<<min(N*A,B)<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
typedef pair<int,int> pii;

int main()
{
    string str;cin>>str;
    for(int i=1;i<3;i++){
        if(str[i]!=str[i-1]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n,l = map(int,input().split())
apple_sum = 0
eat_apple = float('inf')

for i in range(1,n+1):
	apple_sum += l + i - 1
	if abs(eat_apple) > abs(l+i-1):
		eat_apple = l+i-1

ans = apple_sum - eat_apple

print(ans)

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

int h, w, mat[15];

char a[15][15];

bool vis[15], v2[15];

void solve () {
	int M = 0;
	for(int i=1;i<=h;i++) v2[i] = false;
	for(int i=1;i<=h;i++) {
		if(v2[i]) continue;
		for(int j=i+1;j<=h;j++) {
			if(v2[j]) continue;
			int flag = false;
			for(int k=1;k<=w;k++) {
				if(a[i][k] != a[j][mat[k]]) {flag = true; break;}
			}
			if(!flag) {v2[i] = true; v2[j] = true; M++; break;}
		}
	}
	if(h%2) {
		for(int i=1;i<=h;i++) {
			if(v2[i]) continue;
			bool flag = false;
			for(int j=1;j<=w;j++) {
				if(a[i][j] != a[i][mat[j]]) {flag = true; break;}
			}
			if(!flag) {v2[i] = true; M++; break;}
		}
	}
	if(M == (h+1)/2) {puts("YES"); exit(0);}
}

void Try (int X, bool F) {
	if(X == (w+1)/2) {solve(); return;}
	int I = 1;
	for(;I<=w;I++) {
		if(!vis[I]) break;
	}
	vis[I] = true;
	if(!F && w%2==1) {mat[I] = I; Try(X+1, true);}
	for(int i=1;i<=w;i++) {
		if(!vis[i]) {
			mat[I] = i; mat[i] = I;
			vis[i] = true;
			Try(X+1, F);
			vis[i] = false;
		}
	}
	vis[I] = false;
}

int main()
{
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++) {
		scanf("%s",a[i]+1);
	}
	Try(0, false);
	puts("NO");
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
m=1
for i in range(2,n):m=m*i%mod
ans=0
x=m
for i in range(n):
  ans=(ans+x*(a[i]-a[i-1]))%mod
  x=(x+m*pow(i+1,mod-2,mod))%mod
print(ans)

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

int main(){
  int one_yen, price;
  cin >> price >> one_yen;
  
  1 <= price <= 10000;
  0 <= one_yen <= 1000;
  
  if (price % 500 <= one_yen){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define ll long long
ll n,a[100050];
signed main(){
	cin>>n;
	for(ll i=0;i<n;i++)cin>>a[i];
	for(ll i=0;i<n;i++){if(a[i]==0){cout<<0<<endl; return 0;
	}
	}
	long double ans=0;
	for(ll i=0;i<n;i++){
		ans+=log10(a[i]);
	}
	if(ans>18.1){cout<<-1<<endl; return 0;
	}
	ll res=1;
	for(ll i=0;i<n;i++){
		res*=a[i];
	} 
	if(res>1000000000000000000){cout<<-1<<endl; return 0;
	}
	cout<<res<<endl;
}

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

int main(){
    string s;
    cin >> s;

    int len = s.length();

    for(int i = 0; i < len; i++){
        if(s[i] == 'S' && s[i + 1] == 'T'){
            s.erase(i, 2);
            len -= 2;
            i -= 2;
        }
    }

    cout << s.length() << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   int x,a,b;cin>>x>>a>>b;
   if(a>=b)cout<<"delicious";
   else if(a<b && a+x>=b)cout<<"safe";
   else cout<<"dangerous";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll a, b, c;
  cin >> a >> b >> c;

  if(a+b==c || a+c == b || b+c == a){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    int N, K;
    cin >> N >> K;
    unordered_set<int> digits;
    for (int i = 0; i < K; i++) {
        int di;
        cin >> di;
        digits.insert(di);
    }
    while (true) {
        string N_str = to_string(N);
        bool bad = false;
        for (char c : N_str) {
            int c_int = stoi(&c);
            if (digits.find(c_int) != digits.end()) {
                bad = true;
            }
        }
        if (bad) {
            N++;
            continue;
        } else {
            cout << N << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 888
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
//#include<algorithm>
//#include<cmath>
//#include<string>
using namespace std;
int main() {
	int n, m, ans;
	while (cin >> n >> m, n, m) {
		ans = m - 1;
		while (ans < (m - 1)*n) ans = (m*ans) / (m - 1) + 1;
		ans = n*m - ans;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
# -*- coding: utf-8 -*-
n, k , q = map(int,input().split())
a = []
for i in range(q):
    a.append(int(input()))

ans = [k - q for _ in range(n)]
#print(ans)
for i in range(q):
    ans[a[i] - 1] += 1
#print(ans)
for i in range(n):
    if ans[i] > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#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 int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;

signed main(){
  int N, K; cin >> N >> K;
  string S; cin >> S;
  FOR1(x, N) {
    if (x == K) {
      printf("%c", S.at(x-1)+32);
    } else {
      printf("%c", S.at(x-1));
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
M = [int(input()) for i in range(5)]

lm = 10
at = 0
t = 0
count = 0
for j in range(5):
    t,l = divmod(M[j],10)
    if lm > l and l != 0:
        lm = l
        at += t * 10
        count += 1
    elif l == 0:
        at += t * 10
    else:
        at += t * 10
        count += 1

at += lm + (10 * (count - 1))
print(at)

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

int main() {
	int N, Q;
	cin >> N;
	vector<ll> A(100005);
	rep(i, N){
		int j;
		cin >> j;
		A[j] += 1;
	}
	ll ans = 0;
	rep(i, 100005) ans += A[i]*i;
	cin >> Q;
	rep(i, Q){
		int b, c;
		cin >> b >> c;
		ans += (c - b)*A[b];
		cout << ans << endl;
		A[c] += A[b];
		A[b] = 0;
	}
	return 0;
}


Measured memory_bytes: 4024
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define NMAX 100000

int K = 1;
int C[NMAX+1];//child
int S[NMAX+1];//sibling
int colors[NMAX+1];

void dfs(int p, int p_color){
	for(int color=1, c=C[p]; c; c=S[c], color++){
		K = max(K, colors[c] = color==p_color? ++color: color);
		dfs(c, color);
	}
}

int main(){
	int N; cin>>N;
	int Q[N];
	rp(i, 1, N){
		int p; scanf("%d%d",&p,Q+i);
		S[Q[i]] = C[p];
		C[p] = Q[i];
	}
	dfs(1, 0);
	printf("%d\n", K);
	rp(i, 1, N) printf("%d\n", colors[Q[i]]);
}

Measured memory_bytes: 3968
import queue
import sys
input = sys.stdin.readline

N = int(input())
E = {n: set() for n in range(N)}

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    E[a].add((b, c))
    E[b].add((a, c))

def m():
    Q, K = map(int, input().split())
    K -= 1
    dist = [-1] * N
    already = set()
    que = queue.Queue()
    dist[K] = 0
    que.put(K)
    while not que.empty():
        now = que.get()
        out = E[now]
        for n, c in out:
            if dist[n] != -1:
                continue
            dist[n] = dist[now] + c        
            que.put(n)
    
    res = ""
    for _ in range(Q):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        res += str(dist[x] + dist[y]) + "\n"
    
    print(res)

if __name__ == "__main__":
    m()


Measured memory_bytes: 67036
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  static int n, a;
  static int[] x;

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

    n = sc.nextInt(); a = sc.nextInt();
    x = new int[n];
    for(int i = 0; i < n; i++){
      x[i] = sc.nextInt();
    }

    long[][][] dp = new long[n + 1][n + 1][n * 50 + 1];
    dp[0][0][0] = 1;
    for(int i = 1; i <= n; i++){
      for(int j = 0; j <= n; j++){
        for(int k = 0; k < dp[i][j].length; k++){
          if(j - 1 >= 0 && k - x[i - 1] >= 0){
            dp[i][j][k] += dp[i - 1][j - 1][k - x[i - 1]];
          }
          dp[i][j][k] += dp[i - 1][j][k];
        }
      }
    }

    long count = 0;
    for(int i = 1; i <= n; i++){
      int tar = i * a;
      count += dp[n][i][tar];
    }

    System.out.println(count);
  }
}

Measured memory_bytes: 77500