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

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define TRAV(a, x) for(const auto& a : x)
#define ALL(x) x.begin(), x.end()
#define NEXT_PERM(x) while(next_permutation(ALL(x))) // 순열 알고리즘(오름)
#define PREV_PERM(x) while(prev_permutation(ALL(x))) // 순열 알고리즘(내림)
#define PRINT(x) cout << x
#define PRINT_LN(x) cout << x << endl;
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

typedef long long int ll;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<char> vc;

void solve() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  bool winA = true;
  ll lifeA = a;
  ll lifeB = c;
  ll attack = b;
  while (true) {
    if(winA) {
      lifeB -= attack;
      if (lifeB <= 0) {
        PRINT("Yes");
        break;
      }
    } else {
      lifeA -=attack;
      if (lifeA <= 0)  {
        PRINT("No");
        break;
      }
    }
    if(winA) {
      winA = false;
      attack = d;
    }
    else {
      winA = true;
      attack = b;
    }
  }
}

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


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
LL dis1[1000009];
LL dis2[1000009];
int main()
{
    LL k,n;
    cin>>k>>n;
    LL a[n];
    for(LL i=0; i<n; i++)
        cin>>a[i];
    dis1[0]=a[0];
    for(LL i=1; i<n; i++)
        dis1[i]=a[i]-a[i-1]+dis1[i-1];
    dis2[n-1]=k-a[n-1];
    for(LL i=n-2; i>=0; i--)
    {
        dis2[i]=a[i+1]-a[i]+dis2[i+1];
    }
    LL mx=INF;
//    for(LL i=0;i<n;i++)cout<<dis1[i]<<" ";
//    cout<<endl;
//        for(LL i=0;i<n;i++)cout<<dis2[i]<<" ";
//    cout<<endl;
    for(LL i=0; i<n; i++)
    {
        mx=min(mx,dis1[i]+dis2[i+1]);
    }
    LL p=0;
    for(LL i=1;i<n;i++)
    {
        p+=a[i]-a[i-1];
    }
    mx=min(mx,p);
    p=0;
    for(LL i=n-2;i>=0;i--)
    {
        p+=a[i+1]-a[i];
    }
    mx=min(mx,p);
    cout<<mx;



}


Measured memory_bytes: 7424
import sys
n = int(input())
w =[input() for i in range(n)]
if len(w) > len(set(w)):
    print('No')
    sys.exit()
else:
    for i in range(n-1):
        if w[i][-1] != w[i+1][0]:
            print('No')
            sys.exit()
    print('Yes')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    string s;
    cin>>s;
    ll size=SIZE(s), count0=0;
    REP(i,size){
        if(s[i]=='0'){
            count0++;
        }
    }
    ll m=min(count0, size-count0);
    cout<<m*2;
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int k, q; cin >> k >> q;
    vector<ll> d(k);
    rep(i,k){
        cin >> d[i];
    }

    rep(a,q){
        int n, x, m; cin >> n  >> x >> m;
        vector<ll> e(k);
        ll ans = 0;
        ll sume = 0;

        rep(i,k){
            e[i] = d[i] % m;
            sume += e[i];

            if(e[i] == 0) ans ++;

        }

        ll y = x+ (n-1)/k *sume;
        ans *= (n-1)/k;

        rep(i,(n-1)%k){
            y += e[i];

            if(e[i] == 0) ans++;

        }

        ll ans2 = (y/m - x/m);

        dunk(n - ans - ans2 - 1);

    }
}

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


int main(){
    int x[4] = {-1,  0, 0, 1};
    int y[4] = {0, 1, -1, 0};
    
    int H, W;
    cin >> H >> W;

    string s[H];
    for(int i=0;i<H;i++){
        cin >> s[i];
    }

    int dx, dy, score;
    bool flag = true;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            dx = 0;
            dy = 0;
            score = 0;
            if(s[i][j] == '#'){
                for(int k=0;k<4;k++){
                    dx = i + x[k];
                    dy = j + y[k];
                    if(dx <0 || dy <0) continue;
                        if(s[dx][dy] == '#') score++;
                }
                if(score == 0){
                    flag = false;
                    break;
                }
            }
        }
    }
    if(flag == true) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    A = LI()

    # 互いに素なペアがあれば、1を作れる
    # 1があればmax(A)以下の数字を作れる
    gcd = A[0]
    for i in A:
        gcd = math.gcd(gcd, i)

    if K % gcd == 0 and K <= max(A):
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 21560
def resolve():
    H, W = [int(i) for i in input().split()]
    S = [list(input()) for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if S[y][x] == ".":
                S[y][x] = 0
            else:
                S[y][x] = 9
    for y in range(H):
        for x in range(W):
            if S[y][x] < 9:
                continue
            if x - 1 >= 0:
                if y - 1 >= 0:
                    S[y - 1][x - 1] += 1
                S[y][x - 1] += 1
                if y + 1 < H:
                    S[y + 1][x - 1] += 1
            if y - 1 >= 0:
                S[y - 1][x] += 1
            S[y][x] += 1
            if y + 1 < H:
                S[y + 1][x] += 1
            if x + 1 < W:
                if y - 1 >= 0:
                    S[y - 1][x + 1] += 1
                S[y][x + 1] += 1
                if y + 1 < H:
                    S[y + 1][x + 1] += 1
    for y in range(H):
        for x in range(W):
            if S[y][x] < 9:
                S[y][x] = str(S[y][x])
            else:
                S[y][x] = "#"
        print("".join(S[y]))


resolve()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n, m;
    cin >> n >> m;
    int start = 1, end;
    rep(i,n-1) start *= 10;
    end = start * 10;
    if (n == 1) {start = 0; end = 10;}

    

    vector<int> s(m), c(m);
    rep(i,m) cin >> s[i] >> c[i];

    bool ok;
    for (int i = start; i < end; ++i) {
        int div;
        ok = true;
        rep(j,m) {
            div = 1;
            rep(k,n-s[j]) div *= 10;
            int digit = ((i / div) % 10);
            if (digit != c[j]) ok = false;
        }
        if (ok) {cout << i << endl; return 0;}
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;
use Math::BigInt;

my ($n, $a, $b);
{
    my $in = <STDIN>;
    ($n, $a, $b) = split(" ", $in);
}
my $MOD = 10 ** 9 + 7;

sub combination
{
    my ($n, $k) = @_;
    my $a = 1;
    my $b = 1;
    for (my $i=0; $i<$k; $i++)
    {
        $a *= $n - $i;
        $a %= $MOD;
        $b *= $i + 1;
        $b %= $MOD;
    }
    $a * Math::BigInt->new($b)->bmodinv($MOD) % $MOD;
}
my $ans = Math::BigInt->new(2)->bmodpow($n, $MOD) - 1;
$ans += $MOD - combination($n, $a);
$ans += $MOD - combination($n, $b);
print ($ans % $MOD), "\n";

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


int main() {
    int n, k;
    cin >> n >> k;
    bool used[10];
    for (int i = 0; i < 10; i++) {
        used[i] = false;
    }
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        used[d] = true;
    }
    for (int i = n; ; i++) {
        string s = to_string(i);
        for (int j = 0; j < s.size(); j++) {
            if(used[s[j] - '0']) {
                break;
            }
            if (j == s.size() - 1) {
                cout << i << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  int main(void){

    int a,b,c;
    int y = 0;

    scanf("%d %d %d",&a,&b,&c);

    for (int x = a;x <= b;x++)
      {
      if (c % x == 0)
	{
	y++;
	}
      }
    printf("%d\n",y);

    return 0;
  }

Measured memory_bytes: 1024
import java.util.Scanner;

class Main
{
    public static void main(String args[])
    {
        Scanner s = new Scanner(System.in);
        String a = s.nextLine();
        String res="";
        if(a.charAt(a.length()-1)=='s')
        {
           res = a+"es";
        }
        else 
        {
            res = a+"s";
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 38492
#include<iostream>
#include<bitset>
#include<vector>
#include<numeric>
#include<algorithm>

using namespace std;

typedef vector<int> BS;

BS absbs;
BS is[3000];
vector<int> idx;
int a[32345],b[32345];
int N,M,K;

int rec(const BS &bs,int nth,int r){
  if(r<0)return r;
  if(bs.size()==M)return r;
  while(includes(begin(bs),end(bs),begin(is[idx[nth]]),end(is[idx[nth]]))){
    nth++;
  }
  BS n;
  set_difference(begin(is[idx[nth]]),end(is[idx[nth]]),begin(bs),end(bs),back_inserter(n));
  if(n.size()==1){
    BS nx;
    set_union(begin(bs),end(bs),begin(is[a[n[0]]^b[n[0]]^idx[nth]]),end(is[a[n[0]]^b[n[0]]^idx[nth]]),back_inserter(nx));
    return rec(nx,nth+1,r-1);
  }else{
    BS nx;
    set_union(begin(bs),end(bs),begin(is[idx[nth]]),end(is[idx[nth]]),back_inserter(nx));
    int rv=rec(nx,nth+1,r-1);
    BS o=bs;
    for(auto i:n){
      BS dst;
      set_union(begin(o),end(o),begin(is[a[i]^b[i]^idx[nth]]),end(is[a[i]^b[i]^idx[nth]]),back_inserter(dst));
      o.swap(dst);
    }
    return max(rv,rec(o,nth+1,r-n.size()));
  }
}

int main(){
  cin>>N>>M>>K;
  int pop[32345]={};
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
    pop[a[i]]++;
    pop[b[i]]++;
    is[a[i]].push_back(i);
    is[b[i]].push_back(i);
  }
  idx.resize(N);
  iota(begin(idx),end(idx),0);
  sort(begin(idx),end(idx),[pop](int a,int b){
      return pop[a]>pop[b];
    });
  int r=rec(BS(),0,K);
  if(r<0){
    cout<<"Impossible"<<endl;
  }else{
    cout<<K-r<<endl;
  }
}

Measured memory_bytes: 8448
import java.io.PrintWriter

val pw = PrintWriter(System.out)

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

fun func() {
    val (a, b, c, d) = listOfInt()
    println(when{
        a + b > c + d -> "Left"
        a + b < c + d -> "Right"
        else -> "Balanced"
    })
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)

using ll = long long;

int main() {
	int N, K; cin >> N >> K;
	ll ans = 0;
	for (int x = 1; x <= N; x++) {
		int y = K - x, z = K - x;
		if ((y + z) % K == 0) {
			y = (y % K + K) % K;
			if (y == 0) y += K;
			z = (z % K + K) % K;
			if (z == 0) z += K;
			ll a = (N - y) / K + 1;
			ll b = (N - z) / K + 1;
			ans += a * b;
		}
	}
	cout << ans << endl;
}


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

int main() {
  int K, N; cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int ig = 0;
  for (int i = 0; i < N-1; i++) {
    ig = max(ig, A.at(i+1) - A.at(i));
  }
  ig = max(ig, K - A.at(N-1) + A.at(0));
  cout << K - ig << endl;
}

Measured memory_bytes: 1152
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var S string

func main() {
	sc.Split(bufio.ScanWords)

	S = nextStr()
	N := len(S)
	target := "keyence"

	if S == target {
		fmt.Println("YES")
		return
	}

	for i := 0; i < N; i++ {
		for j := i; j < N; j++ {
			if target == S[:i]+S[j+1:] {
				fmt.Println("YES")
				return
			}
		}
	}

	fmt.Println("NO")
}


Measured memory_bytes: 2016
import sys
sys.setrecursionlimit(1000000000)
from fractions import gcd
from itertools import count
from functools import lru_cache
from collections import defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    N = ii()
    A = lmis()
    i = 1
    for a in A:
        if i == a:
            i += 1
    i -= 1
    if i == 0:
        print(-1)
    else:
        print(N - i)

main()


Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+7;
const int inf=0x3f3f3f3f;
int main()
{
   int x,a;
   while(cin>>x>>a)
   {
       if(x<a)
           cout<<"0"<<endl;
       else
           cout<<"10"<<endl;
   }
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int N;
    cin >> N;
    int ans = 0;
    if(N == 100000) {
        ans = 90000 + 900 + 9;
    } else if(N >= 10000) {
        ans = ((N % 100000) - 9999) + 900 + 9;
    } else if(N >= 1000) {
        ans = 900 + 9;
    }else if(N >= 100) {
        ans = ((N % 1000) - 99) + 9;
    } else if(N >= 10){
        ans = 9;
    } else {
        ans = N;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

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

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    string s;
    cin >> s;

    string t = s;
    reverse(t.begin(), t.end());

    ll count {};

    for (int i = 0, lastBB = -1; i < t.size(); ++i)
    {
        if(t[i] == 'B')
        {
            ++lastBB;
            count += i - lastBB;
        }
    }

    cout << count << endl;


    return 0;
}


Measured memory_bytes: 772
#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<ll, ll>;

//最大公約数
ll gcd(ll a, ll b){
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}

int main(){
    ll x;
    cin >> x;
    for(ll i = -1000; i <= 1000; i++){
        for(ll j = -1000; j <= 1000; j++){
            if(i * i * i * i * i - j * j * j * j * j == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, a, b;
    long long int time = 0;
    cin >> n;
    vector<pair<int ,int>> v;
    for(int i = 0; i < n; ++i) {
        cin >> a >> b;
        v.push_back(make_pair(b, a));
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; ++i) {
        time += v[i].second;
        if(time > v[i].first) {
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
}


Measured memory_bytes: 2420
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXNB=50;
const int MAXNA=2*MAXNB-1;
const int MOD=1000000007;

int na,nb;
int a[MAXNA];

int mem[MAXNB+1][MAXNA+1][MAXNA+1];

int go(int sufflen,int prefopt,int curidx) {
	int &ret=mem[sufflen][prefopt][curidx];
	if(ret==-1) {
		int oprefopt=prefopt,ocuridx=curidx;
		if(sufflen==nb) return ret=1;
		if(a[nb-sufflen-1]!=a[nb-sufflen]) ++prefopt,++curidx;
		if(a[nb+sufflen-1]!=a[nb+sufflen-2]) ++prefopt;
		ret=0;
		REP(i,prefopt) {
			int nprefopt=prefopt; if(i<curidx) nprefopt-=abs(curidx-1-i); if(i>curidx) nprefopt-=abs(i-curidx-1);
			ret=(ret+go(sufflen+1,nprefopt,i<=curidx?i:curidx+1))%MOD;
		}
		//REP(i,sufflen-1) printf(" "); printf("go(%d,%d,%d)=%d [%d,%d]\n",sufflen,oprefopt,ocuridx,ret,prefopt,curidx);
	}
	return ret;
}


void run() {
	scanf("%d",&nb); na=2*nb-1;
	REP(i,na) scanf("%d",&a[i]); sort(a,a+na);
	memset(mem,-1,sizeof(mem));
	int ret=go(1,1,0);
	printf("%d\n",ret);
}

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


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
const int maxn = 1e5 + 5;

int main()
{
    ios::sync_with_stdio(false);
    int a , b;  cin  >> a>> b;
    int ans = 0;
    while (a){
        a /= b;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const int SIZE=18;

const ll MOD=1e9+7;

void add(ll &lhs,ll rhs){
    lhs=(lhs+rhs)%MOD;
}
int main(){
    int n;
    cin>>n;
    int xyz[3];
    for(int i=0;i<3;i++) cin>>xyz[i];

    vector<vector<ll>> dp(n+1,vector<ll>(1<<SIZE));
    dp[0][(1<<SIZE)-1]=1;

    vector<int> isAccept(1<<SIZE);

    for(int bit=0;bit<(1<<SIZE);bit++){
        int st=0;
        int buf=0;
        for(int i=0;i<SIZE;i++){
            buf++;
            if(!((bit>>i)&1) && xyz[st]==buf){
                st++;
                buf=0;
                if(st==3){
                    isAccept[bit]=true;
                    break;
                }
            }
        }
    }

    vector<ll> pow10(n);
    pow10[0]=1;
    for(int i=0;i+1<n;i++) pow10[i+1]=pow10[i]*10%MOD;

    ll res=0;
    int mask=(1<<SIZE)-1;
    for(int i=0;i<n;i++){
        for(int bit=0;bit<(1<<SIZE);bit++){
            if(dp[i][bit]==0) continue;
            for(int v=1;v<=7;v++){
                int nex=(bit<<v)+(1<<(v-1))-1;
                nex&=mask;
                add(dp[i+1][nex],dp[i][bit]);
            }
            add(dp[i+1][mask],3*dp[i][bit]);
        }
        for(int bit=0;bit<(1<<SIZE);bit++){
            if(isAccept[bit]){
                ll r=pow10[n-1-i];
                res+=r*dp[i+1][bit];
                res%=MOD;   
                dp[i+1][bit]=0;
            }
        }
    }

    cout<<res<<endl;
    
    
    return 0;
}


Measured memory_bytes: 86400
object Main {

  val INF = Int.MinValue

  case class Edge(u: Int, v: Int, weight: Int)
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val V, E, P = sc.nextInt()

    // つまり, 辺を通る時, Pは損失されているので
    // 重みからPを引いておく.
    // -{w(u,v) - P} を重みとした単一始点最短路問題を解く
    // また, 正閉路が存在する場合, w(u,v) - P > 0の場合, 無限にコインを増やすことができる
    // そのため, 閉路判定を行う必要がある
    val edges = (0 until E).foldLeft(Nil: List[Edge])((lst, _) => {
      val u, v, c = sc.nextInt()
      Edge(u, v, c - P) :: lst
    })

    bellmanFordMax(V, edges, 1, V) match {
      case Some(score) => println(score)
      case None => println(-1)
    }
  }

  def bellmanFordMax(V: Int, edges: List[Edge], s: Int, t: Int): Option[Int] = {
    val d = Array.fill(V+1)(INF)

    d(s) = 0
    for {
      _ <- 0 until V - 1
      edge <- edges
    } if (d(edge.u) != INF && d(edge.v) < d(edge.u) + edge.weight) {
      d(edge.v) = d(edge.u) + edge.weight
    }
    val max = d(t)

    val negative = new Array[Boolean](V+1)
    for {
      _ <- 0 until V
      edge <- edges
    } if (d(edge.u) != INF && d(edge.v) < d(edge.u) + edge.weight) {
      d(edge.v) = d(edge.u) + edge.weight
      negative(edge.v) = true
    } else if (negative(edge.u)) {
      negative(edge.v) = true
    }

    if (!negative(V)) Some(max max 0)
    else None
  }

}


Measured memory_bytes: 38964
use std::io::*;
use std::str::FromStr;

fn func(n: i64, mut now: i64) -> i64 {
    if n < now {
        return 0;
    }
    now *= 10;
    let mut ans = 0;
    if check753(now) {
        ans += 1;
    }
    ans += func(n, now + 7);
    ans += func(n, now + 5);
    ans += func(n, now + 3);
    return ans;
}

fn check753(mut n: i64) -> bool {
    let mut ok = [false, false, false];
    while n > 0 {
        match n % 10 {
            3 => ok[0] = true,
            5 => ok[1] = true,
            7 => ok[2] = true,
            _ => {}
        }
        n /= 10;
    }
    return ok[0] && ok[1] && ok[2];
}

fn main() {
    let n: i64 = read();
    println!("{}", func(n, 0));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll n,m;
	cin >> n >> m;
	if(n==m){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

using namespace std;

string s;
int k;
vector<string> sub;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL);

    cin >> ws >> s;
    cin >> k;

    for(int i = 0; i < (int) s.size(); i++){
        string tp = "";
        for(int j = i; j < i + k && j < (int) s.size(); j++){
            tp += s[j];

            sub.emplace_back(tp);
        }
    }

    sort(sub.begin(), sub.end());
    sub.erase(unique(sub.begin(), sub.end()), sub.end());

    cout << sub[k - 1] << endl;
    
    return 0;
}

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

vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
  ll n; cin >> n;
  ll ans = 0;
  const auto &res = prime_factorize(n);
  for(auto p: res){
    ll e = p.second;
    ll tmp = 0, cur = 1;
    while(e >= cur) e -= cur++, ++tmp;
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3480
n = gets.chomp.to_i
a = gets.chomp
b = gets.chomp
c = gets.chomp

total = 0
(0...n).each do |i|
  cnt = if a[i] == b[i] && b[i] == c[i]
	    	0
	  	elsif a[i] != b[i] && b[i] != c[i] && c[i] != a[i]
	    	2
  		else
	    	1
  		end
	total += cnt
end

puts total


Measured memory_bytes: 1788
z=60,t;void p(){printf("%02d:%02d:%02d\n", t/z/z,t/z%z,t%z);}main(h,m,s){for(;scanf("%d%d%d",&h,&m,&s),~h;p(t),t*=3,p(t))t=7200-h*z*z-m*z-s;exit(0);}

Measured memory_bytes: 612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    static class Solve
    {
        public static void Answer()
        {
            var n = IO_ShortCut.ReadInt;
            var s = n.ToString();

            bool f = false;
            if (s[0] == '7' || s[1] == '7' || s[2] == '7')
                f = true;
            WriteLine(f ? "Yes" : "No");
        }
    }

    static class IO_ShortCut
    {
        #region Input
        public static string ReadString => ReadLine();
        public static int ReadInt => int.Parse(ReadLine());
        public static long ReadLong => long.Parse(ReadLine());
        public static double ReadDouble => double.Parse(ReadLine());

        public static List<string> ReadSplitString => ReadLine().Split().ToList();
        public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
        public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        #endregion
    }
}


Measured memory_bytes: 17648
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

void dfs(int n, const int num, const vector<vector<int>>& friends, vector<int>& people) {
	if (people[n] != 0) return;
	people[n] = num;
	for (int i = 0; i < (int)friends[n].size(); i++) {
		dfs(friends[n][i], num, friends, people);
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> friends(N);
	int A, B;
	for (int i = 0; i < M; i++) {
		cin >> A >> B;
		friends[A - 1].push_back(B - 1);
		friends[B - 1].push_back(A - 1);
	}
	vector<int> people(N);
	int count = 0;
	for (int i = 0; i < N; i++) {
		if (people[i] == 0) {
			count++;
			dfs(i, count, friends, people);
		}
	}
	vector<int> group(count + 1);
	for (int i = 0; i < N; i++) {
		group[people[i]]++;
	}
	int max_num = 0;
	for (int i = 0; i < count + 1; i++) {
		max_num = max(max_num, group[i]);
	}
	cout << max_num << endl;
}

Measured memory_bytes: 24272
import sys
from heapq import heappush, heappop

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X, Y, Z, K = map(int, readline().split())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    hq = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
    seen = set()
    ans = []
    while len(ans) < K:
        s, i, j, k = heappop(hq)
        ans.append(-s)
        if i < X - 1 and (i + 1, j, k) not in seen:
            heappush(hq, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
            seen.add((i + 1, j, k))
        if j < Y - 1 and (i, j + 1, k) not in seen:
            heappush(hq, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
            seen.add((i, j + 1, k))
        if k < Z - 1 and (i, j, k + 1) not in seen:
            heappush(hq, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
            seen.add((i, j, k + 1))

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 77780
#include <iostream>                                                                                            
#include <cstdlib>                                                                                             
#include <algorithm>                                                                                           
#include <cmath>                                                                                               
#include <vector>                                                                                              
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                        
                                                                                                               
using namespace std;                                                                                           
#define ll long long                                                                                           
                                                                                                               
int main(){                                                                                                    
  int A, B, C;                                                                                                 
  cin >> A >> B >> C;                                                                                          
  if(C >= A && C <= B)                                                                                         
    cout << "Yes" << endl;                                                                                     
  else                                                                                                         
    cout << "No" << endl;                                                                                      
  return 0;                                                                                                    
} 

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

bool isSatisfy(int n) {
  int t = n % 10;
  n /= 10;
  while (n > 0) {
    int s = n % 10;
    if (s + 1 != t) return false;

    n /= 10;
    t = s;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  
  int ans = -1;
  for (int i = 0; i + 1 < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int t = a[i] * a[j];
      if (isSatisfy(t) == false) t = -1;
      ans = max(ans, t);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3104
n=int(input())
W=[]
S=set([])
flag=0
for i in range(n):
  w=input()
  W.append(w)
  S.add(w)
for i in range(n-1):
  if W[i][-1]!=W[i+1][0]:
    flag=1
if len(S)==n and flag==0:
  print('Yes')
else:
  print('No')

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

int main(){
    int n,tem,count; count = 0;
    bool flag; flag = true;

    cin >> n;
    vector<int> list(n);
    for(int i = 0; i < n; i++){
        cin >> list.at(i);
    }

    while(flag){
        flag = false;
        for(int i = 0; i < n-1; i++){
            if(list.at(i) > list.at(i+1)){
                tem = list.at(i);
                list.at(i) = list.at(i+1);
                list.at(i+1) = tem;
                flag = true;
                count++;
            }
        }
    }
    for(int i = 0; n-1 > i; i++){
        cout << list.at(i) << ' ';
    }
    cout << list.at(n-1) <<endl;
  	cout << count << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

bool match(char c, string s)
{
	rep(i, 0, s.length()) if (s[i] == c) return true;
	return false;
}

map< pair<int, int>, set<int> > memo;

set<int> parse(string s, int left, int right)
{
	auto p = make_pair(left, right);
	if (memo.find(p) != memo.end()) return memo[p];

	{
		bool ok = true;
		rep(i, left, right + 1) if (!match(s[i], "0123456789")) ok = false;
		if (ok)
		{
			int ret = 0;
			rep(i, left, right + 1) ret = ret * 10 + s[i] - '0';
			set<int> ans;
			ans.insert(ret);
			return (memo[p] = ans);
		}
	}

	// ??¨?????¬??§??§????????°??????
	if (s[left] == '(')
	{
		int cnt = 1;
		bool ok = true;
		rep(i, left + 1, right)
		{
			if (s[i] == '(')
				cnt++;
			else if (s[i] == ')')
				cnt--;

			if (cnt == 0) ok = false;
		}

		if (ok)
		{
			set<int> ans = parse(s, left + 1, right - 1);
			return (memo[p] = ans);
		}
	}

	int cnt = 0;
	set<int> ans;
	rep(i, left, right+1)
	{
		if (s[i] == '(')
			cnt++;
		else if (s[i] == ')')
			cnt--;
		else if (match(s[i], "+-*/") && cnt == 0)
		{
			set<int> l = parse(s, left, i - 1);
			set<int> r = parse(s, i + 1, right);

			for (int ll : l) for (int rr : r)
			{
				switch (s[i])
				{
				case '+': ans.insert(ll + rr); break;
				case '-': ans.insert(ll - rr); break;
				case '*': ans.insert(ll * rr); break;
				case '/': if(rr != 0) ans.insert(ll / rr); break;
				}
			}
		}
	}

	return (memo[p] = ans);
}

int main()
{
	while (1)
	{
		memo.clear();
		string s; cin >> s;
		if (s[0] == '#') return 0;

		auto ans = parse(s, 0, s.length() - 1);
		cout << ans.size() << endl;

		//for (int i : ans) cout << i << endl;
		//cout << endl;
	}
}

Measured memory_bytes: 3272
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextInt64() int64 {
	sc.Scan()

	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}
func f(x int) int {
	if x == 1 {
		return 1
	}
	return f(x/2)*2 + 1
}

func main() {
	sc.Split(bufio.ScanWords)
	x1, y1, x2, y2 := nextInt(), nextInt(), nextInt(), nextInt()
	var x3, y3, x4, y4 int

	a, b := x2-x1, y2-y1

	x3 = x2 - b
	y3 = y2 + a
	x4 = x3 - a
	y4 = y3 - b

	fmt.Println(x3, y3, x4, y4)

}


Measured memory_bytes: 1772
def main():
    a, b = map(int, input().split())

    if a % 2 == 1 and b % 2 == 1:
        print("Yes")
    else:
        print("No")


def main2():
    a, b = map(int, input().split())
    if a * b % 2 == 1:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define en "\n"
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*

/*ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
*/

/*void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; (ll)i*i <= 10000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*i ; j <= 10000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}  */



// *#########################################################################################*

int main()
{
      fast
 
    
      string s;
      cin>>s;
      if(s=="ABC")
      {
            o("ARC")
      }
 else
 {
       o("ABC")
 }


re}

Measured memory_bytes: 3636
def ABC_83_B():
    N,A,B = map(int, input().split())
    k=0

    for i in range(N+1):
        s=0
        p=str(i)
        for j in range(len(p)):
            s+=int(p[j])
        if s>=A and s<=B:
            k+=i
    print(k)

if __name__ == '__main__':

    ABC_83_B()

Measured memory_bytes: 3064
function Main(input) {
    var R = input[0];
    var G = input[1];
    var B = input[2];

    var num = parseInt((R + G + B), 10);
    console.log(num % 4 === 0 ? 'YES' : 'NO');
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main()
{
    ll X, A, B;
    cin >> X >> A >> B;
    string ans;

    if (A - B >= 0)
    {
        ans = "delicious";
    } 
    else if (A - B < 0 && B - A <= X)
    {
        ans = "safe";
    }
    else 
    {
        ans = "dangerous";
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
def dfs(nodes, v):

    preorder.append(v)
    if nodes[v][0] != -1:
        dfs(nodes, nodes[v][0])

    inorder.append(v)

    if nodes[v][1] != -1:
        dfs(nodes, nodes[v][1])

    postorder.append(v)


def main():
    global preorder
    global inorder
    global postorder

    preorder = []
    inorder = []
    postorder = []

    n = int(input())
    in_num = [0] * n
    nodes = [[] for _ in range(n)]
    for i in range(n):
        tree = list(map(int, input().split()))
        node = tree[0]
        left = tree[1]
        right = tree[2]

        nodes[node].append(left)
        nodes[node].append(right)

        if left != -1:
            in_num[left] += 1
        if right != -1:
            in_num[right] += 1

    for i in range(len(in_num)):
        if in_num[i] == 0:
            root_node = i
            break

    dfs(nodes, root_node)
    print("Preorder")
    print("", *preorder)
    print("Inorder")
    print("", *inorder)
    print("Postorder")
    print("", *postorder)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5612
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int N;
char S[300100];
int loss[300100];
int min_loss;
int main(){
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>S[i];
    }

    int first_loss=0;
    for(int i=1;i<N;++i){
        if(S[i]=='E') ++first_loss;
    }
    loss[0]=first_loss;
    min_loss=first_loss;
    for(int i=1;i<N;++i){
        int next_loss=loss[i-1];
        if(S[i]=='E') --next_loss;
        if(S[i-1]=='W') ++next_loss;
        loss[i]=next_loss;
        min_loss=min(min_loss,next_loss);
    }
    cout<<min_loss<<endl;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int a,b,h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
h = Hash.new(0)
ans = 0
a.each do |len|
    h[len] += 1
end
h = h.select{|key, value| value >= 2}.sort{|a, b| a[0] <=> b[0]}
ans =  0
if h.size >= 2
    if h[-1][1] >= 4
        ans = h[-1][0] ** 2
    else
        ans = h[-1][0] * h[-2][0]
    end
end
puts ans

Measured memory_bytes: 17228
package main

import (
  "fmt"
)

func makeX(a, b, F int) map[int]int {
  ax := make(map[int]int)
  for i := 0; i <= F / a; i++ {
    for j := 0; j <= F / b; j++ {
      x := a * i + b * j
      if x > F {
        continue
      }
      if _, ok := ax[x]; !ok {
        ax[x] = 1
      }
    }
  }
  return ax
}

func main() {
  var A, B, C, D, E, F int
  fmt.Scan(&A, &B, &C, &D, &E, &F)
  ax := makeX(100 * A, 100 * B, F)
  ay := makeX(C, D, F)

  maxTotal := 0
  maxSugar := 0
  for x, _ := range ax {
    for y, _ := range ay {
      if x + y == 0 || x + y > F {
        continue
      }
      if 100 * y > E * x {
        continue
      }
      total := x + y
      if maxTotal == 0 {
        maxTotal = total
        maxSugar = y
        continue
      }
      if 100 * maxSugar * total < 100 * y * maxTotal {
        maxTotal = total
        maxSugar = y
      }
    }
  }
  fmt.Println(maxTotal, maxSugar)
}


Measured memory_bytes: 768
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int k;
  cin >> k;

  int a,b;
  a = k / 2;
  b = k / 2 + (k % 2 == 0 ? 0 : 1);

  cout << a * b;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256