akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  i64 n, k;
  cin >> n >> k;
  i64 c = (n - 1) / k;
  i64 a = n - k * c;
  cout << min(a, k - a) << endl;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(int x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(int x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
#define SpaceNewLine(a) Rep(i,a.size())cout<<a[i]<<(i==a.size()-1?'\n':' ')
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {
    // setup {{{ 1
    cin.tie(0);
    ios::sync_with_stdio(false);
    // }}}

    int N;
    Scd(N);

    vl a(N,INF);

    Rep(i,N){
        Scll(a[i]);
    }

    bool OK = true;

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

    priority_queue<int> p;

    int A = a[0];
    int B = a[N/3];
    int AB = a[N/3*2];

    if( N % 3 ) OK = false;

    Rep(i,N/3){
        if( A != a[i] ) OK = false;
        if( B != a[N/3+i] ) OK = false;
        if( AB != a[N/3*2+i] ) OK = false;
    }

    if( (A xor B) != AB ) OK = false;

    ll tmp = 0;
    Rep(i,N) tmp += a[i];
    if( tmp == 0 ) OK = true;

    YesNo(OK);


    return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;

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

        int m = sc.nextInt();
        int d = sc.nextInt();

        int ans = 0;
        for (int i = 2; i <= m; i++) {
            for (int j = 22; j <= d; j++) {
                int d1 = j % 10;
                int d2 = j / 10;
                if (d1 == 1)
                    continue;
                if (d1 * d2 == i)
                    ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23636
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
template<class _T>
inline void _prfe(const char *_n, _T _c, bool _p = false){
    ITER(_c) _it=_c.begin();
    if(_p){ cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{ cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

int main(){
    int n;
    cin >> n;
    REP(i,n){
        int k = 0, o = 0, p = 0;
        while(1){
            string s;
            cin >> s;
            if(s == "HIT"){
                k = (k << 1) | 1;
                if(k&(1<<3)) p++;
                k &= 7;
            }
            if(s == "HOMERUN"){
                while(k){
                    if(k&1) p++;
                    k >>= 1;
                }
                p++;
            }
            if(s == "OUT"){
                o++;
                if(o == 3) break;
            }
        }
        cout << p << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep(i,l,r) for(ll (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
int main(){
    ll n,x,y;
    cin>>n>>x>>y;
    vector<ll> ans(n,0);
    rep(i,1,n){
        rep(j,i+1,n+1){
            int num=min(abs(i-j),min(abs(x-i)+abs(y-j)+1,abs(x-j)+abs(y-i)+1));
            ans[num-1]++;
        }
    }
   rep(i,0,n-1) cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    int K;
    string S;
    cin >> K >> S;
    if(K >= (int)S.size()) cout << S << endl;
    else{
        cout << S.substr(0, K) << "..." << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    ll n, cnt = 0, ans = 0; cin >> n;
    vector<ll> p(n);
    rep(i, n){
        cin >> p[i], p[i]--;
        if(p[i] == i) cnt++;
        else ans += (cnt+1)/2, cnt = 0;
    }
    if(cnt != 0) ans += (cnt+1)/2;
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using indx = size_t;

#define endl '\n'
#define get(type, args...) type args; read(args)
#define all(v) v.begin(), v.end()
#define debug(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...);
}
template <typename... T>
void read(T&... args) {
    ((cin >> args), ...);
}
template <typename T>
void read(vector<T>& v) {
    for (auto& x : v) cin >> x;
}
template <typename... T>
void write(T&&... args) {
    ((cout << args << " "), ...);
    cout << '\n';
}
template <typename T>
void write(vector<T>& v) {
    for (auto x : v) cout << x << " ";
    cout << '\n';
}

int main() {
    get(int, n, m);
    vector<ll> h(n);
    read(h);
    vector<bool> r(n, true);
    while (m--) {
        get(int, a, b);
        a--; b--;
        if (h[a] <= h[b])
            r[a] = false;
        if (h[b] <= h[a])
            r[b] = false;
    }
    ll ans = 0;
    for (auto x : r) {
        if (x) ans++;
    }
    write(ans);
}


Measured memory_bytes: 3988
#include <iostream>
#include <string>

using namespace std;

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

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

using namespace std;

int main(){
  int n,x; cin >> n >> x;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  int count=1;
  int d=0;
  for(int i=0;i<n;i++){
    d+=l[i];
    if(d<=x){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int h, w;
int blacks = 0;
vector<string> a;
vector<pair<int, int>> rec;
vector<pair<int, int>> st;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
void bfs(int y, int x)
{
    for (ll i = 0; i < 4; i++)
    {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (nx < 0 || ny < 0 || ny >= h || nx >= w || a[ny][nx] == '#')
            continue;
        else
        {
            a[ny][nx] = '#';
            blacks++;
            rec.emplace_back(make_pair(ny, nx));
            //st.insert(make_pair(ny, nx));
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        string c;
        cin >> c;
        a.emplace_back(c);
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (a[i][j] == '#')
            {
                blacks++;
                st.emplace_back(make_pair(i, j));
            }
        }
    }
    int cnt = 0;
    while (blacks != h * w)
    {
        rec.resize(0);
        for (auto v : st)
        {
            bfs(v.first, v.second);
        }
        cnt++;
        st.resize(0);
        for (int i = 0; i < rec.size(); i++)
            st.emplace_back(make_pair(rec[i].first, rec[i].second));
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 14700
let n, ds = Scanf.(scanf " %d %d" @@ fun n k -> n, Array.(to_list @@ init k @@ fun _ -> scanf " %d" (+) 0))
let rec f i n = if i = 0 then (Printf.printf "%d\n" n; exit 0) else if not @@ List.mem (i mod 10) ds then f (i / 10) n
let _ = for i = n to 10 * n do f i i done

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
vector<lint> A;

int main()
{
    cin >> N;
    A.resize(N);
    cin >> A;
    lint st = 0;
    int ans = 1;
    FOR(i, 1, N) if (A[i] - A[i - 1])
    {
        if (st * (A[i] - A[i - 1]) < 0)
        {
            ans++;
            st = 0;
        }
        else st = A[i] - A[i - 1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using vl = vector<ll>;

int main(){
    ll n;
    cin>>n;
    vl a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vl b(n);
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    ll sum =a[0];
    for(int i=0;i<n;i++){
        sum+=b[i];
    }
    ll ans = sum;
    for(int i=1;i<n;i++){
        ans = max(ans,sum+a[i] - b[i-1]);
        sum = sum + a[i] -b[i-1];
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

const ll MX = 1e18;

int main(){
    int N, a;
    cin >> N;
    a = (N%100)%10;
    if (a == 3)
    {
        cout << "bon" << endl;
    }
    else if (a == 0 || a == 1 || a == 6 || a == 8)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }

    
    
    return 0;
}

Measured memory_bytes: 3576
n = int(input())
A = list(map(int, input().split()))
B = [a - i for i, a in enumerate(A)]
B.sort()
def median(list):
    L = sorted(list)
    n = len(L)
    m = int(n/2)
    if n % 2 == 0:
        return (L[m - 1] + L[m]) / 2
    else:
        return L[(n - 1) // 2]
b = int(median(B))
print(sum(abs(x - b) for x in B))

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

using namespace std;

typedef pair<int, int> II;
typedef pair<long long, int> LLI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<II> VII;

#define For(i,a,b) for(int i = a;i <= b; i++)
#define Rep(i,a,b) for(int i = a;i >= b; i--)
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, f) for(auto i : f)
#define fi first
#define se second
#define pb push_back
#define sz(s) int(s.size())
#define reset(f, x) memset(f, x, sizeof(f))
#define all(x) x.begin(), x.end()
#define two(x) (1LL << x)
#define getbit(x, i) ((x >> (i-1)) & 1LL)
#define onbit(x, i) (x | (1LL << (i-1)))
#define offbit(x, i) (x & ~(1 << (i-1)))

const int N = 1e5+10;

int n, m, res;
vector<int> ke[N];
int pos[N], a[N];
int lab[N], cnt;

void dfs(int u) {
    lab[u] = cnt;
    FOR(v, ke[u]) if (!lab[v]) {
        dfs(v);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    //freopen("","w",stdout);
    cin >> n >> m;
    For(i, 1, n) {
        cin >> a[i];
        pos[a[i]] = i;
    }
    REP(i, m) {
        int u, v;
        cin >> u >> v;
        ke[u].pb(v); ke[v].pb(u);
    }
    For(i, 1, n) if (!lab[i]) {
        cnt++;
        dfs(i);
    }
    For(i, 1, n) if (lab[i] == lab[a[i]]) res++;
    cout << res;
}




Measured memory_bytes: 8960
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
using namespace std;

struct Node {
	int key;
	Node *left, *right, *parent;
};

//ポインタなので同じ容器
Node* root, * NIL;

void insert(int t) {
	Node* x, * y, * z;
	x = root;
	y = NIL;
	z = (Node*)malloc(sizeof(Node));
	z->key = t;
	z->left = NIL;
	z->right = NIL;
	//zの親を決める
	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void In(Node* s) {
	if (s == NIL) {
		return;
	}
	In(s->left);
	cout << " " << s->key;
	In(s->right);
}

void Pre(Node* d) {
	if (d == NIL) {
		return;
	}
	cout << " " << d->key;
	Pre(d->left);
	Pre(d->right);

}

int main() {
	string S;
	int num, n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S;
		if (S == "insert") {
			cin >> num;
			insert(num);
		}
		else if (S == "print") {
			In(root);
			cout << endl;
			Pre(root);
			cout << endl;
		}
	}
}


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

const int MAX_N = 60;
int N, P;
int A[MAX_N];
ll dp[MAX_N][MAX_N];

ll nCk(int n, int k)
{
    return dp[n][k];
}

void solve()
{
    dp[0][0]=1;
    for(int i=1;i<=N;++i) dp[0][i]=0;
    for(int i=1;i<=N;++i) dp[i][0]=1;
    for(int i=1;i<=N;++i)for(int j=1;j<=i;++j){
        dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
    }
	int oc = 0, ec = 0;
	for(int i=0;i<N;++i){
		if(A[i]%2) oc++;
		else ec++;
	}
	ll res = 0;
	if(P == 0){ // even 
		for(int i=0;i<=oc;i+=2){
			for(int j=0;j<=ec;++j){
				res += 1LL*nCk(oc, i)*nCk(ec, j);
			}
		}
	}else{ // odd
		for(int i=1;i<=oc;i+=2){
			for(int j=0;j<=ec;++j){
				res += 1LL*nCk(oc, i)*nCk(ec, j);
			}
		}
	}
	cout<<res<<'\n';
}

int main()
{
	cin >> N >> P;
	for(int i=0;i<N;++i) cin >> A[i];
	solve();
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 1000000007;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
struct Edge{
   ll to,id;
};
int n;
vector<vector<Edge>> G;
vector<int>ans;
void dfs(int v,int c=-1, int p=-1){
   int k=1;
   for(auto u:G[v]){
      if(u.to==p)continue;
      if(k==c)++k;
      ans[u.id]=k;++k;
      dfs(u.to,ans[u.id],v);
   }
}
int main(){
   cin>>n;
   G.resize(n);
   ans.resize(n-1);
   rep(i,n-1){
      ll a,b;cin>>a>>b;a--;b--;
      G[a].emplace_back((Edge){b,i});
      G[b].emplace_back((Edge){a,i});
   }
   dfs(0);
   int mx=0;
   rep(i,n)chmax(mx,sz(G[i]));
   cout<<mx<<endl;
   rep(i,n-1)cout<<ans[i]<<endl;
   return 0;
}

Measured memory_bytes: 12352
/*
Hokudai Practice Contest 2014
A - King's Inspection

テ「ツ可、テδ堙δ?つーテつーテδ淌「ツ?「テ「ツ按妥「ツ?「テッツャツづ「ツ?「テδづ「ツ?「テδ湘つーテつコテ「ツ?「テ「ツ按妥「ツ?「テδ?「ツ?「テδ?
テ篠ゥテδ津つァテつエテつァテδ湘つァテ「ツ按?つァテつァテつァテδ偲「ツ?「テδ偲つーテつコテ「ツ?「テδ偲つァテδ?篠ゥテδヲテつァテ「ツ按堙つァテ「ツ按?「ツ?ヲテつクテ「ツ按湘つオテつァテ渉?つァテδ偲つァテつソテつァテつアテつーテつ」
テ「ツ?「テδ偲つーテつコテ「ツ?「テδ偲つァテδ堙「ツ按ォテ「ツ按?「ツ按湘篠ゥテつァテ渉?つァテδ偲つァテδクテつァテつキテつァテδ?つァテ?禿「ツ?「テδ催「ツ?「テ渉?「ツ?「テつサテつァテ?津篠ゥテ「ツつャテつ・テ?津つァテ「ツ?ーテつ?「ツ按湘つェテ仰凖つァテ?津篠ゥテ「ツつャテつ・テ?津つァテδ堙「ツ按ォテ「ツ按?「ツ按湘篠ゥテつァテ渉?つァテδ偲「ツ?ヲテつィテδ陛「ツ猟甘つァテつィテつァテつ「テつァテδ偲つーテつ」
(M-1)+1 -> 0, 0-1 -> (M-1)テつーテつーテつァテつサテつァテつ?つァテδ偲つァテδ凝つァテつカテつァテδ?つァテ渉?つァテδ偲つァテδ?つァテ?禿つーテつ「テδヲテδ催δ陛δヲ(%)テつァテδ堙δ陛「ツ?氾つァテつァテつァテδ湘つァテ「ツ?禿つァテδ凝つァテつァテつーテつ」

テつェテ仰崚つ・テδキテ「ツ按妥「ツ猟甘つェテつェテ?津δεつーテδ欅(|s|)
テ「ツ按づ?アテつ・テδキテ「ツ按妥「ツ猟甘つェテつェテ?津δεつーテδ欅(n + |s|)
*/

#include<iostream>
#include<cctype>
using namespace std;

//a-zA-z -> テ篠ゥテδ?つサテδキ
int toInt(char a){
  if(islower(a))return a-'a';
  return a-'A'+26;
}

//テ篠ゥテδ?つサテδキ -> a-zA-Z
char toChar(int a){
  if(a<26)return 'a'+a;
  return 'A'+a-26;
}

//テつアテδソテδクテδ?
const int M = 52;

int main(){
  int n,k[100];
  string s;

  while(cin >> n,n){
    for(int i=0;i<n;i++)cin >> k[i];
    cin >> s;

    for(int i=0;i<(int)s.size();i++){
      //テ篠ゥテ「ツつャテつ・テ?津つァテδ堙「ツ?「テ「ツ按妥「ツ?「テッツャツづ「ツ?「テδづ「ツ?「テδ湘つーテつコテ「ツ?「テ「ツ按妥「ツ?「テδ?「ツ?「テδ崚つァテ渉?つァテδ偲つァテδ?つァテ?杜odテつァテδ堙つェテつサテつァテつョテつァテ「ツ?禿?津「ツ?ヲテつァテつァ
      int tmp = toInt(s[i]) - k[i%n];
      //テ「ツ?ヲテδ暗δクテδ凖つァテ「ツ?堙つァテつ「テつァテδ催「ツ按?つソテつァテδ偲δヲテδ湘渉?δ?つァテ?津「ツ按榲つャテつ。テつ・テつァテつ?odテつァテ?津つコテδ凝つァテδ催つ?仰敕つァテ??(x%mod) + mod)%mod
      tmp = ((tmp%M) + M) % M;
      cout << toChar(tmp);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1200
import numpy as np
N, K = map(int, input().split())
P = np.arange(N, dtype=np.int64) + 1
count = 0
total = 0
prev = 0
ans = 0
while True:
    now = (P >= K).sum()
    total += now - prev
    ans += (now - prev) / (1 << count)
    if total == N:
        break
    P <<= 1
    count += 1
    prev = now
print(ans / N)

Measured memory_bytes: 14024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[214514],b[214514];
int main(){
	ll n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		b[i]+=b[i-1];
	}
	ll now=m,ans=0;
	for(int i=0;i<=n;i++){
		for(int j=now;j>=0;j--){
				if(a[i]+b[j]<=k){
					now=j;
					ans=max(ans,i+now);
					break;
				}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6752
n = int(input())
s = input()
r = len([i for i in range(n) if s[i] == 'R'])
g = len([i for i in range(n) if s[i] == 'G'])
b = len([i for i in range(n) if s[i] == 'B'])
ans = r * g * b
sub = 0
for j in range(n):
    for i in range(j):
        if s[i] == s[j]:
            continue
        k = 2 * j - i
        if k >= n or ((s[i] == s[k]) or (s[j] == s[k])):
            continue
        sub += 1
print(ans - sub)

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

const int MX = 100005;

int main(){
    int N;
    cin >> N;
    vector<int> a(10000,0);

    int atai =0;

    for(int i=1; i<100;i++){
        for(int j=1; j<100;j++){
            for(int k=1; k<100;k++){
                atai = (i+j+k)*(i+j+k) -i*j -j*k -k*i;
                if((atai > 0)&(atai < 10001)){
                    a[atai-1]++;
                }
            }
        }
    }

    for(int i=0;i<N;i++){
        cout << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;

int inf = 4e18, mod = 1e9+7;
vector<vi> g;
vi res;
vector<ii> rng;
bool parity(int cur, int p,int f){
    if(res[cur] != inf && res[cur] % 2 != f) return false;
    bool ans = true;
    if(res[cur] != inf) rng[cur].first = rng[cur].second = res[cur];
    for(auto &v:g[cur]){
        if(v == p) continue;
        ans &= parity(v, cur, 1-f);
        rng[cur].first = max(rng[cur].first, rng[v].first - 1);
        rng[cur].second= min(rng[cur].second, rng[v].second + 1);
    }
    return ans && (rng[cur].x <= rng[cur].y);
}

void setValue(int cur, int p = -1){
    if(p != -1 && res[cur] == inf){
        if(res[p] + 1 <= rng[cur].y && res[p] + 1 >= rng[cur].x) res[cur] = res[p] + 1;
        else res[cur] = res[p] - 1;
    }
    for(auto &v:g[cur]){
        if(v == p) continue;
        setValue(v,cur);
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n; cin >> n;
    g.resize(n); res.resize(n, inf); rng.resize(n,{-inf,inf});
    for(int i=1,a,b;i<n;i++){
        cin >> a >> b; --a, --b;
        g[a].pb(b);
        g[b].pb(a);
    }
    int k,r; cin >> k;
    for(int i=0;i<k;i++){
        cin >> r; --r;
        cin >> res[r];
    }
    if(!parity(r,-1,res[r] % 2)) return cout <<"No"<<endl, 0;
    cout <<"Yes"<<endl;
    setValue(r);
    for(auto &v:res) cout <<v<<'\n';
    cout << endl;
    return 0;
}


Measured memory_bytes: 16640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	InputStream inputStream = System.in;
    	OutputStream outputStream = System.out;
    	Scanner sc = new Scanner(inputStream);
    	PrintWriter out = new PrintWriter(outputStream);
      	int N = Integer.parseInt(sc.next());
      	out.println((800 * N) - (N / 15 * 200));
    	out.close();
    }
}

Measured memory_bytes: 21972
import java.util.Scanner;
//ワーシャルフロイド法の練習
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int c[][] = new int[10][10];
		for(int i = 0; i < 10; i++) {
			for(int j = 0; j < 10; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		//[i][j]・・・iからjまでの最短経路
		for(int k = 0; k < 10; k++) {
			for(int i = 0; i < 10; i++) {
				for(int j = 0; j < 10; j++) {
					c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
				}
			}
		}
		int total = 0;
		for(int i = 0; i < h*w; i++) {
			int a = sc.nextInt();
			if(a == -1 || a == 1) {
				continue;
			}
			total = total += c[a][1];
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 45308
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

using namespace std;

int main(void){
	ll n, m; cin >> n >> m;
	ll a[SIZE] ={0};
	rep(i, m){
		ll tmp; cin >> tmp;
		a[tmp] = -1;
	}
	a[0] = 1;
	rep(i, n){
		if(a[i] == -1) continue;
		if(a[i+1] != -1){
			a[i+1] += a[i];
			a[i+1] %= MOD;
		}
		if(a[i+2] != -1){
			a[i+2] += a[i];
			a[i+2] %= MOD;
		}
	}

	cout << a[n] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

ll INF = 10000000000000;

int main(void){
    ll n, ma, mb;
    cin >> n >> ma >> mb;

    ll a[n], b[n], c[n];
    rep(i, 0, n){
        cin >> a[i] >> b[i] >> c[i];
    }

    ll d[n + 1][401][401];
    rep(i, 0, n + 1){
        rep(j, 0, 401){
            rep(k, 0, 401){
                d[i][j][k] = INF;
            }
        }
    }

    d[0][0][0] = 0;
    rep(i, 0, n + 1){
        rep(j, 0, 401){
            rep(k, 0, 401){
                if(i == 0){
                    continue;
                }else if(j - a[i - 1] < 0 || k - b[i - 1] < 0){
                    d[i][j][k] = d[i-1][j][k];
                }else{
                    d[i][j][k] = min(d[i-1][j][k], d[i-1][j - a[i - 1]][k - b[i - 1]] + c[i - 1]);
                }
            }
        }
    }

    ll ans = INF;
    rep(i, 1, 401){
        rep(j, 1, 401){
            if(ma * j == mb * i){
                ans = min(ans, d[n][i][j]);
            }
        }
    }
    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 51712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    int h,w;
    cin >> h >> w;
    string sur[h];
    bool first = 0,second = 0;

    for(int i = 0; i < h; i++) cin >> sur[i];

    pair<int,int> s = make_pair(0,0);
    pair<int,int> g = make_pair(h-1,w-1);
    map<pair<int,int>,int> depth;
    map<pair<int,int>,bool> seen;
    queue<pair<int,int>> que;
    const int n_select = 2;
    int dx[n_select] = {0,1};
    int dy[n_select] = {1,0};
    if(sur[s.first][s.second] == '#') first = 1;
    if(sur[g.first][g.second] == '#') second = 1;

    que.push(s);
    depth[s] = 0;
    seen[s] = true;

    while(!que.empty()){
        pair<int,int> now = que.front();
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        for(int i = 0; i < n_select; i++){
            if(0 <= y+dy[i] && y+dy[i] < h && 0 <= x+dx[i] && x+dx[i] < w){
                int nxy = y+dy[i];
                int nxx = x+dx[i];
                pair<int,int> nxt = make_pair(nxy,nxx);
                int d = 0;
                if(sur[nxy][nxx] != sur[y][x]) d = 1;
                if(!seen[nxt] || depth[nxt] > depth[now]+1){
                    seen[nxt] = true;
                    depth[nxt] = depth[now]+d;
                    que.push(nxt);
                }  
            }
        }
    }

    /*for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            pair<int,int> tmp = make_pair(i,j);
            cout << depth[tmp];
        }
        cout << endl;
    }*/

    cout << depth[g]/2+min(first+second,1) << endl;

    return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;
const int mod = 998244353;

int main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
    multiset<int> st;
    rep(i, x) st.insert(p[i]);
    rep(i, y) st.insert(q[i]);
    rep(i, c){
        if (*st.begin() > r[i]) break;
        st.erase(st.begin());
        st.insert(r[i]);
    }
    ll ans = 0;
    for (ll s : st) ans += s;
    cout << ans << endl;
}


Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    Int sum = 0;
    vector<Int> a(n), b(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (Int i = 0; i < n; i++) cin >> b[i];
    Int x, y;
    x = y = 0;
    for (Int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            x += (b[i] - a[i] + 1) / 2;
            if ((b[i] - a[i]) % 2 == 1) y++;
        }
        else if (a[i] > b[i]) {
            y += a[i] - b[i];
        }
    }
    dump(x >= y ? "Yes" : "No");
    return 0;  
}

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

using vi=vector<int>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
void cmax(int &lhs,int rhs){
    lhs=max(lhs,rhs);
}
const int INF=1e5;
int main(){
    int r,c;
    cin>>r>>c;
    
    vector<string> s(r+1);
    for(int i=0;i<r;i++) cin>>s[i+1];
    vvi dp(c+1,vi(1<<c,-INF));
    dp[0][0]=0;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            for(int bit=0;bit<(1<<c);bit++){
                int upperc=__builtin_popcount((((1<<(c-j))-1)&bit));
                int posu=(int)(s[i].size())-upperc;
                int posn=(int)(__builtin_popcount(bit))-upperc;
                if(posu<0 || posu>s[i].size() || posn<0 || posn>s[i+1].size()) continue;
                int nextbit=bit>>1;
                cmax(dp[j+1][nextbit],dp[j][bit]);
                if(posn<s[i+1].size()){
                    nextbit|=(1<<(c-1));
                    if((bit&1) && s[i][posu]==s[i+1][posn]){
                        cmax(dp[j+1][nextbit],dp[j][bit]+1);
                    }
                    else{
                        cmax(dp[j+1][nextbit],dp[j][bit]);
                    }
                }
            }
        }
        for(int bit=0;bit<(1<<c);bit++){
            if(__builtin_popcount(bit)!=s[i+1].size()) dp[c][bit]=-INF;
            else{
                int idx=0;
                for(int j=0;j<c;j++){
                    if(((bit>>j)&1) && ((bit>>(j+1))&1) && s[i+1][idx]==s[i+1][idx+1]){
                        dp[c][bit]++;
                    }                    
                    if((bit>>j)&1) idx++;
                }
            }
            dp[0][bit]=dp[c][bit];
        }
        for(int j=1;j<=c;j++){
            fill(dp[j].begin(),dp[j].end(),-INF);
        }
    }
    cout<<*max_element(dp[0].begin(),dp[0].end())*2<<endl;
    return 0;
}


Measured memory_bytes: 7632
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

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

   vector<ll> s(2);
   s[0] = 1; s[1] = -1;

  ll ans = INF;
  REP(i, 2) REP(j, 2){
    ll x, y;
    x = a * s[i]; y = b * s[j];
    if(x<=y && ans > y-x+i+j) ans = y-x+i+j; 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    
    if(K <= A + B) {
        if(K < A) {
            cout << K << endl;    
        }
        if(K >= A) {
            cout << A << endl;
        }
        
    }else {
        cout << A - (K-A-B) << endl;
    }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll x,a,b;
	cin>>x>>a>>b;
	if(b<=a)
	{
		cout<<"delicious\n";
	}
	else
	{
		if((b-a)<=x)
		{
			cout<<"safe\n";
		}
		else
		{
			cout<<"dangerous\n";
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <set>
#include <map>
using namespace std;

map<char, long long> ma;
int N;

/* next combination */
int next_combination(int sub) {
	int x = sub & -sub, y = sub + x;
	return (((sub & ~y) / x) >> 1) | y;
}

string march = "MARCH";

int main() {
	while (cin >> N) {
		ma.clear();
		for (int i = 0; i < N; ++i) {
			string str;
			cin >> str;
			ma[str[0]]++;
		}
		long long res = 0;
		int bit = (1 << 3) - 1;
		for (; bit < (1 << 5); bit = next_combination(bit)) {
			long long tmp = 1;
			for (int i = 0; i < 5; ++i) {
				if (!(bit &(1 << i))) continue;
				long long num = ma[march[i]];
				tmp *= num;
			}
			res += tmp;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, a, b;
	cin >> n >> a >> b;
	
	cout << min(n * a, b) << 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++)

int main()
{
    int a, b;
    cin >> a >> b;
    vector<string> vec(a);
    rep(i, a) cin >> vec[i];

    vector<int> yoko(a, 0);
    vector<int> tate(b, 0);

    rep(i, a)
    {
        rep(j, b)
        {
            if (vec[i][j] == '#')
            {
                yoko[i]++;
                tate[j]++;
            }
        }
    }

    rep(i, a)
    {
        if (yoko[i])
        {
            rep(j, b)
            {
                if (tate[j])
                {
                    cout << vec[i][j];
                }
            }
            cout << endl;
        }
    }

    return 0;
}


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

using namespace std;

int main()
{
	int ans = 0;
	int tosort[5];
	int k;
	int s = 0;
	bool can = true;

	for (int i = 0; i < 5; i++)
		cin >> tosort[i];
	cin >> k;

	for (int i = 0; i < 5; i++)
	{
		int tmp = 0;

		for (int j = 0; j < 5; j++)
		{
			if (tosort[i] > tosort[j])
			{
				tmp = tosort[i];
				tosort[i] = tosort[j];
				tosort[j] = tmp;
			}
		}
	}

	if (abs(tosort[0] - tosort[4]) > k)
		can = false;

	if (can)
		cout << "Yay!" << '\n';
	else
		cout << ":(" << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int num;
int main()
{
    long long int a,b;
    while(cin>>a>>b){
        vector<long long int> cost(a+1,0);
        vector<long long int> value(a+1,0);
        vector<vector<long long int>> dp(a+1,vector<long long int> (b+1,0));
        for(int i=0;i<a;i++){
            cin>>cost[i]>>value[i];
        }
        for(int i=0;i<a;i++){
            for(int j=0;j<=b;j++){
                if(j>=cost[i]){
                    dp[i+1][j]=max(dp[i][j],dp[i][j-cost[i]]+value[i]);
                }
                else{
                    dp[i+1][j]=dp[i][j];
                }
            }
        }
        cout<<dp[a][b]<<endl;
    }
}


Measured memory_bytes: 83228
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include <bitset>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<string>
typedef long long ll;
using namespace std;
string s;
int main() {
	cin >> s;
	int lenn=0, lene=0, lens=0, lenw=0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'N') {
			lenn=1;
		}
		else if (s[i] == 'W') {
			lenw=1;
		}
		else if (s[i] == 'E') {
			lene=1;
		}
		else {
			lens=1;
		}
	}
	if ((lenn^lens)||(lenw^lene)) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 3600
<?php
list($n, $k) = explode(" ", trim(fgets(STDIN)));

$a = explode(" ", trim(fgets(STDIN)));

$junjo = [];
$ajunjo = [];
$next = "1";
$to_cycle = 0;
$from_cycle = 0;
for($i=0; $i<$n; $i++){
  $junjo[$i] = $next;
  $ajunjo[$next] = $i;
  $next = $a[$next-1];
  // 同じのが出てきたら終了
  if(isset($ajunjo[$next])){
    $to_cycle = $i+1;
    $from_cycle = $ajunjo[$next];
    break;
  }
}

if($k <= $from_cycle){
  echo $junjo[$k];
  exit;
}else{
  $machi_index = ($k - $from_cycle) % ($to_cycle-$from_cycle);
  //ho $to_cycle." ".$from_cycle." ".$machi_index.PHP_EOL;
  //var_dump($junjo);
  echo $junjo[$machi_index+$from_cycle];
  exit;
}



Measured memory_bytes: 44084
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var H = NextInt();
		var W = NextInt();

		var a = new string[H];
		for (var i = 0; i < H; i++) {
			a[i] = ReadLine();
		}

		for (var j = W - 1; j >= 0; j--) {
			var flg = false;
			for (var i = 0; i < H; i++) {
				if (a[i][j] == '#') {
					flg = true;
				}
			}
			if (!flg) {
				for (var i = 0; i < H; i++) {
					a[i] = a[i].Substring(0, j) + a[i].Substring(j + 1);
				}
			}
		}

		for (var i = 0; i < H; i++) {
			if (a[i].Contains("#")) {
				WriteLine(a[i]);
			}
		}
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}

Measured memory_bytes: 13268
from collections import deque

H, W = map(int, input().split())
a = [input() for _ in range(H)]

bl = [[False] * W for _ in range(H)]
dq = deque()

for r in range(H):
    for c in range(W):
        if a[r][c] == '#':
            bl[r][c] = True
            dq.append((r, c, 0))


def in_range(r, c):
    return 0 <= r < H and 0 <= c < W


dr_s = (0, 0, -1, 1)
dc_s = (-1, 1, 0, 0)

while dq:
    r, c, d = dq.popleft()
    for dr, dc in zip(dr_s, dc_s):
        nr = r + dr
        nc = c + dc
        if not in_range(nr, nc): continue
        if bl[nr][nc]: continue
        bl[nr][nc] = True
        dq.append((nr, nc, d + 1))

print(d)


Measured memory_bytes: 135900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = null;
		int cup = 0;
		String[] rrr;
		int st = 0;
		Stack<Integer> stack = new Stack<Integer>();
		
		while(true){
			
			try {
				tmp = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			if(tmp == null){
				break;
			}
			if(tmp.equals("")){
				break;
			}
			
			st = Integer.parseInt(tmp);
			
			if(st != 0){
				stack.push(st);
			}else{
				System.out.println(stack.pop());
			}
			
			
		}
	}

}

Measured memory_bytes: 16872
var main = function main(input) {
  var args = input.split(' ')
  var product = args[0] * args[1]
  if (product % 2 === 0) {
  	console.log('Even')
   } else {
     console.log('Odd')
   }
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll x;
/******* define variable end *******/
int solve() {
	cin >> x;
	if(x >= 30){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;



int main(){
    ll mod = pow(10, 9) + 7;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)   cin >> a[i];

    ll b = n%2;
    rep(i, n){
        if(a[i]%2 == b){
            cout << 0 << endl;
            return 0;
        }
    }
    
    map<ll, int> m;
    rep(i, n){
        m[a[i]]++;
    }

    if(b == 0){
        rep(i, n){
            if(i%2 == 1){
                if(m[i] != 2){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
    }
    else{
        if(m[0] != 1){
            cout << 0 << endl;
            return 0;
        }
        else{
            rep(i, n){
                if(i == 0)  continue;
                if(i%2 == 0){
                    if(m[i] != 2){
                        cout << 0 << endl;
                        return 0;
                    }
                }
            }
        }
        n--;
    }

    ll res = 1;
    rep(i, n/2){
        res *= 2;
        res %= mod;
    }

    cout << res << endl;



    return 0;
}


Measured memory_bytes: 4096