Problem:


Score : 100 points

Problem Statement

Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier.
He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.

Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.

Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it.

Write a program that outputs delicious if he found it delicious, safe if he did not found it delicious but did not get a stomachache either, and dangerous if he got a stomachache.

Constraints

1 ≤ X,A,B ≤ 10^9

Input

Input is given from Standard Input in the following format:

X A B

Output

Print delicious if Takahashi found the food delicious; print safe if he neither found it delicious nor got a stomachache; print dangerous if he got a stomachache.

Sample Input 1

4 3 6

Sample Output 1

safe

He ate the food three days after the "best-by" date. It was not delicious or harmful for him.

Sample Input 2

6 5 1

Sample Output 2

delicious

He ate the food by the "best-by" date. It was delicious for him.

Sample Input 3

3 7 12

Sample Output 3

dangerous

He ate the food five days after the "best-by" date. It was harmful for him.



Sample input:
4 3 6


Sample output:
safe

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

X, A, B = [int(x) for x in input().split()]

if A >= B:
    print("delicious")
elif (A + X) >= B:
    print("safe")
else:
    print("dangerous")

Submission status: Accepted

Solution code:
X, A, B = list(map(int, input().split()))

if A - B >= 0:
  print('delicious')
elif B - A <= X:
  print('safe')
else:
  print('dangerous')

Submission status: Accepted

Solution code:
data = input().split()
X = int(data[0])
A = int(data[1])
B = int(data[2])

if((A - B) >= 0):
	print("delicious")
else:
	if((B - A) <= X):
		print("safe")
	else:
		print("dangerous")

Submission status: Accepted

Solution code:
x, a, b = map(int, input().split())
if b <= a:
    print("delicious")
else:
    if (b - a) <= x:
        print("safe")
    else:
        print("dangerous")

Submission status: Accepted

Solution code:
#coding: utf-8
X,A,B = map(int, input().split())
if A+X < B:
    print('dangerous')
elif A < B:
    print('safe')
else:
    print('delicious')

Submission status: Accepted

Solution code:
def ini(): return int(input())
def inli(): return list(map(int, input().split()))
def inf(): return float(input())
def inlf(): return list(map(float, input().split()))
def inl(): return list(input())
def pli(): return "".join(list(map(str, ans)))

a=inli()

if a[1]-a[2] >= 0:
    print("delicious")
elif (a[0]+a[1])-a[2]>=0:
    print("safe")
else:
    print("dangerous")

Submission status: Accepted

Solution code:

X, A, B = (int(e) for e in input().split())

if B - A <= 0:
    print('delicious')
elif B - A > X:
    print('dangerous')
else:
    print('safe')

Submission status: Accepted

Solution code:
X,A,B=map(int,raw_input().split(' '))


if B-A<=0:
    print 'delicious'
elif B-A<=X:
    print 'safe'
else:
    print 'dangerous'

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
l = [int(i) for i in input().split()]
if l[2] > l[1]+l[0]:
  print("dangerous")
elif l[2] > l[1]:
  print("safe")
else:
  print("delicious")

Submission status: Accepted

Solution code:
X, A, B = list(map(int, input().split()))

if A - B >= 0:
    print("delicious")
elif B - A <= X:
    print("safe")
else:
    print("dangerous")

Submission status: Accepted

Solution code:
X, A, B = map(int, input().split())
if B-A>X:
    print("dangerous")
elif A>=B:
    print("delicious")
else:
    print("safe")

Submission status: Accepted

Solution code:
def main():
    X, A, B = map(int, input().split())

    if A >= B:
        ans = 'delicious'
    elif B - A <= X:
        ans = 'safe'
    else:
        ans = 'dangerous'

    print(ans)

main()

Submission status: Accepted

Solution code:

X,A,B = input().split(' ')
X = int(X)
A = int(A)
B = int(B)
if A + X < B:
    print('dangerous')
elif B <= A:
    print('delicious')
else:
    print('safe')

Submission status: Accepted

Solution code:
x,a,b = input().split()
x = int(x)
a=int(a)
b = int(b)

if a >=b:
    print("delicious")
elif a+x >= b:
    print("safe")
else:
    print("dangerous")

Submission status: Accepted

Solution code:
# 4 3 6

x, a, b = map(int, input().split())
y = (-a + b)

if y <= 0:
 print("delicious")
elif y <= x:
 print("safe")
else:
 print("dangerous")

Submission status: Accepted

Solution code:
x, a, b =map(int, input().split(" "))
if a >= b:
    print("delicious")
elif x + a >= b:
    print("safe")
else:
    print("dangerous")

Submission status: Accepted

Solution code:
X,A,B = map(int,input().split())
if B <= A:
  print('delicious')
elif B-A <= X:
  print('safe')
else:
  print('dangerous')

Submission status: Accepted

Solution code:
z =list(map(int,input().split(" ")))
d=z[2]-z[1]
if d<=0:
  print("delicious")
elif d<=z[0]:
  print("safe")
else:
  print("dangerous")

Submission status: Accepted

Solution code:
[x,a,b] = list(map(int,input().split()))
n = b - a
if n > x:
  print("dangerous")
elif n > 0:
  print("safe")
else:
  print("delicious")

Submission status: Accepted

Solution code:
X,A,B = map(int,raw_input().split())
if A-B >= 0:
    print "delicious"
elif B-A < X+1:
    print "safe"
else:
    print "dangerous"

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    X, A, B = list(map(int, input().split()))
    if B - A <= 0:
        print("delicious")
    elif B - A <= X:
        print("safe")
    else:
        print("dangerous")

Submission status: Accepted

Solution code:
X,A,B=map(int,input().split())

if B<=A:
    print("delicious")
elif B<=A+X:
    print("safe")
else:
    print("dangerous")

Submission status: Accepted

Solution code:
X, A, B = map(int, input().split())
if B - A <= 0:
	print('delicious')
elif B - A <= X:
	print('safe')
else:
	print('dangerous')

Submission status: Accepted

Solution code:
X, A, B = map(int, input().split())
if B <= A:
    print('delicious')
elif A + X >= B:
    print('safe')
else:
    print('dangerous')

Submission status: Accepted

Solution code:
x, a, b = map(int, raw_input().split())

if b - a <= 0:
	print "delicious"
elif b - a <= x:
	print "safe"
else:
	print "dangerous"

Submission status: Accepted

Solution code:
X, A, B = list(map(int, input().split()))
if B - A <= 0:
	print("delicious")
elif B - A >= X + 1:
	print("dangerous")
else:
	print("safe")

Submission status: Accepted

Solution code:
x, a, b = map(int, input().split())

if b-a <= 0:
    print("delicious")
elif b-a <= x:
    print("safe")
else:
    print("dangerous")

Submission status: Accepted

Solution code:
x, a, b = map(int, input().split())

if b <= a:
    print('delicious')
elif (b > a) and (b <= a + x):
    print('safe')
else:
    print('dangerous')

Submission status: Accepted

Solution code:
X,A,B = map(int,input().split())

if A-B>=0:
    print("delicious")
else:
    if X+A-B>=0:
        print("safe")
    else:
        print("dangerous")

Submission status: Accepted

Solution code:
x, a, b = map(int, input().split())

if -a + b <= x:
    if -a + b <= 0:
        print('delicious')
    else:
        print('safe')
else:
    print('dangerous')

Submission status: Accepted

Solution code:
x,a,b=map(int,input().split())
if b<=a:print('delicious')
elif b-a<=x:print('safe')
else :print('dangerous')

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import division, print_function
import sys


def main():
    x, a, b = map(int, sys.stdin.readline().strip().split(" "))
    if b - a <= 0:
        print("delicious")
    elif b - a <= x:
        print("safe")
    else:
        print("dangerous")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X, A, B = [int(x) for x in input().split()]
if A - B >= 0:
	print("delicious")
elif X + A - B >= 0:
	print("safe")
else:
	print("dangerous")

Submission status: Runtime Error

Solution code:
x,a,b = map(int,input().split())

if b < a:
  print('delicious')
elif b <= x:
  pritn('safe')
elif b > x:
  print('dangerous')

Submission status: Runtime Error

Solution code:
N = int(input())

l = []
for i in range(N):
  v = int(input())
  l.append(v)

v = l[0]
print(l)
print(v)
ans = 1
while v != 2 and v != -1:
  tmp = l[v-1]
  l[v-1] = -1
  v = tmp
  ans += 1

if v == 2:
  print(ans)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
n = int(input())
data = [input().split() for i in range(n)]
light = [0]*n
light[0] = 1
count = 1
bool = False
temp = int(data[0][0])
for i in range(n):
    temp = int(data[temp - 1][0])
    count += 1
    if temp == 2:
        print(count)
        exit()
print(-1)

Submission status: Runtime Error

Solution code:
a,b,c=list(map(int,input().split()))

if a-b>0=:
  print('delicious')
  
elif -b+c<=a:
  print('safe')
  
else:
  print('dangerous')

Submission status: Runtime Error

Solution code:
N = int(input())
A = [(i+1, int(input())) for i in range(N)]
cnt = 1
for i in range(N):
  if 2 not in A[i]:
    print(-1)
    exit()
  if A[i][0] == A[i][1]:
    if i != 2:
      print(-1)
      exit()
    
    
x = A[0]
while x[1] != 2:  
  if x[1] == 1:
    print(-1)
    exit()
  x = A[x[1]-1]
  cnt += 1
  
print(cnt)

Submission status: Runtime Error

Solution code:
a, b, c= map(int, input().split())
if b <= c:
  print("delicious")
elif c-b<= x:
  print("safe")
else:
  print("dengerous")

Submission status: Runtime Error

Solution code:
X,A,B=map(int,input().split())

if A>B:
  print('delicious')
else:
  if X>=B-A:
    print('safe')
  else:
    pint('dangerous')

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]
 
G = [1]
for i in range(N):
    G.append(A[G[-1]-1])
    
ans = 0
for i in G:
    if i==2:
        break
    ans += 1
else:
    ans = -1
    
print(ans)

Submission status: Runtime Error

Solution code:
x,a,b = map(str,input().split())
if a>b:
    print('delicious')
elif x>=b-a:
    print('safe')
else:
    print('dangerous')

Submission status: Runtime Error

Solution code:
4 3 6

Submission status: Runtime Error

Solution code:
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string[] input = Console.ReadLine().Split();
      int x = int.Parse(input[0]);
      int a = int.Parse(input[1]);
      int b = int.Parse(input[2]);
      
      int t = b - a;
      if (a>=b){
        Console.WriteLine("delicious");
      }
      else if (x>=t){
        Console.WriteLine("safe");
      }
      else{
        Console.WriteLine("dangerous");
      }
    }
}

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input())
n=a-b
if n >= 0:
  print("delicious")
elif x+n >=0:
  print("safe")
else:
  print("dangerous")

Submission status: Runtime Error

Solution code:
if b - a <= 0:
    print("delicious")
elif b - a <= x:
    print("safe")
else:
    print("dangerous")

Submission status: Runtime Error

Solution code:
x,a,b = map(int, input().split())
if b-a < 1:
    print("delicious")
elif b-a = 1:
    print("safe")
else:
    print("dangerous")

Submission status: Runtime Error

Solution code:
x,a,b = (int(x) for x in input().split())
if a < b:
  if b-a > c:
    print ('dengerous')
  else:
    print ('safe')
else:
  print ('delicious')

Submission status: Runtime Error

Solution code:
x, a, b = map(int, input().split())
if a <= b:
    print('delicious')
else:
    if b - a <= x:
    print('safe')
    else:
        print('dangerous')

Submission status: Runtime Error

Solution code:
n, m = map(int,input().split())

mod = 10**9 + 7

if abs(n-m) > 1:
    print(0)
    quit()

elif abs(n-m) == 1:
    a = max(n,m)
    b = min(n,m)
    ans = 1
    for i in range(1,a+1):
        ans *= (i%mod)
        ans %= mod
    for i in range(1,b+1):
        ans *= (i%mod)
        ans %= mod
    print(ans%mod)

else:
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print((2*ans)%mod)

Submission status: Runtime Error

Solution code:
x,a,b = map(int, input().spilit())
if(a>=b):
  print("delicious")
else:
  if(b-a >x):
    print("dangerous")
  else:
    print("safe")

Submission status: Runtime Error

Solution code:
n=int(input())
A=[int(input()) for _ in range(n)]
A=[0]+A
cnt=1
for i in range(1,n+1):
  cnt=A[cnt]
  if cnt==2:
    print(i)
    exit()
  
print(-1)

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[int(input()) for i in range(n)]
    light=0
    cnt=0
    while True:
        if l[light]==2:
            cnt+=1
            print(cnt)
            break
        else:
            if cnt>n:
                print(-1)
                break
            else:
                light=l[light]-1
                cnt+=1
            
resolve()

Submission status: Runtime Error

Solution code:
#最小全域木問題、プリム法
from heapq import *
def solve():
    N = int(input())
    A = [list(map(int, input().split()))+[i] for i in range(N)]
    edge = [[] for _ in range(N)]
    A.sort()
    for i in range(N-1):
        w = A[i+1][0]-A[i][0]
        edge[A[i][2]].append((w,A[i+1][2]))
        edge[A[i+1][2]].append((w,A[i][2]))
    A.sort(key=lambda x:x[1])
    for i in range(N-1):
        w = A[i+1][1]-A[i][1]
        edge[A[i][2]].append((w,A[i+1][2]))
        edge[A[i+1][2]].append((w,A[i][2]))
    bridges = []
    heapify(bridges)
    used = [False]*N
    used[0] = True
    ans = 0
    for w,v in edge[0]:
        heappush(bridges,(w,v))
    while len(bridges)>0:
        w,v = heappop(bridges)
        if used[v]==False:
            ans += w
            used[v] = True
            for w,u in edge[v]:
                if used[u]==False:
                    heappush(bridges,(w,u))
    return ans
print(solve())

Submission status: Runtime Error

Solution code:
import math
n, m = map(int, input().split())

N = math.factorial(n)
M = math.factorial(m)
INF = 10**9 + 7

if abs(n-m) > 1:
    print(0)
elif abs(n-m) == 1:
    print(N*M%INF)
else:
    print(2*N*M%INF)

Submission status: Runtime Error

Solution code:
x,y = tuple(map(int,input().split()))

for i in range(1,10*18):
  x<<=1
  if x>y:
    print(i)
    break

Submission status: Runtime Error

Solution code:
x,a,b = tuple(map(int,input().split()))

if b-a=<x:
  print("delicious")
else:
  print("dangerous")

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
if b-a>x:print("dangerous")
elif b-a<=0:print("delicious")
else:print("safe")

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
if b-a<x:
    print('delicious')
elif b-a=x:
    print('safe')
else:
    print('dangerous')

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
print("delicious")if a>b print("safe")elif x+a>b else print("dangerous")

Submission status: Runtime Error

Solution code:
x,a,b=map(nt,input().split())
print("delicious" if a-b>=0 else "safe" if b-a<=x else "dangerous")

Submission status: Runtime Error

Solution code:
x,a,b = map(int, input().split())
if b-a <= 0:
  print("delicious")
elif b-a =< x:
  print("safe")
else:
  print("dangerous")

Submission status: Runtime Error

Solution code:
from math import factorial

def resolve():
	n, m = map(int, input().split())
	mod = 10**9+7
	if abs(n - m) > 1:
		print(0)
		return
	a = factorial(m) % mod * factorial(n) % mod
	if (n + m) % 2 == 0:
		a = a * 2 % mod
	print(a)
resolve()

Submission status: Runtime Error

Solution code:
N = int(input())
S = [int(input()) for i in range(N)]
count=1
i=0
while True:
  if S[i]==2 or count==N:
    print(count)
    exit()
  else:
    count+=1
    i=S[i]-1
print(-1)

Submission status: Runtime Error

Solution code:
from sys import stdin
from collections import namedtuple
from heapq import heappush, heappop

input = stdin.readline


class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n + 1)]
    self.size = [1] * (n + 1)

  def is_same(self, a, b):
    return self.find(a) == self.find(b)

  def unite(self, a, b):
    a = self.find(a)
    b = self.find(b)  
    if self.size[a] < self.size[b]:
      a, b = b, a
    self.par[b] = a
    self.size[a] += self.size[b]

  def size_of(self, a):
    return self.size[self.find(a)]

  def find(self, a):
    if a == self.par[a]:
      return a
    self.par[a] = self.find(self.par[a])
    return self.par[a]

Edge = namedtuple('Edge', 'w s t')
X = namedtuple('X', 'x i')
Y = namedtuple('Y', 'y i')

N = int(input())

edges = []
xg = []
yg = []

for i in range(N):
  x, y = map(int, input().split())
  xg.append(X(x, i))
  yg.append(Y(y, i))

xg.sort()
yg.sort()

for i in range(N - 1):
  x1, a = xg[i]
  x2, b = xg[i + 1]
  heappush(edges, Edge(abs(x1 - x2), a, b))

for i in range(N - 1):
  y1, a = yg[i]
  y2, b = yg[i + 1]
  heappush(edges, Edge(abs(y1 - y2), a, b))

u = UnionFind(N)
cost = 0

while edges:
  if u.size_of(0) >= N:
    break

  w, s, t = heappop(edges)
  if u.is_same(s, t):
    continue
  u.unite(s, t)
  cost += w

print(cost)

Submission status: Runtime Error

Solution code:
X, A, B = map(int, input().split())
if B - A <= 0:
  print("delicious")
elif:
  0 < B - A and B - A <= X:
  print("safe")
else:
  print("dangerous")

Submission status: Runtime Error

Solution code:
X, A, B = map(int, input().split())
if B - A <= 0:
  print("delicious")
elif:
  0 < B - A < X:
  print("safe")
else:
  print("dangerous")

Submission status: Runtime Error

Solution code:
X,A,B=map(int, input().split())
if A>=B:
  print('delicious')
elif A+X>=N:
  print('safe')
else:
  print('dangerous')

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())

if b-a=<x and b-a<=0:
    print("delicious")
elif b-a<=x and b-a>0:
    print("safe")
else:
    print("dangerous")

Submission status: Runtime Error

Solution code:
N = 10**6
mod = 10**9 + 7
fact = [1]
for i in range(1, N+1):
    fact.append(fact[-1]*i%mod)

n, m = map(int, input().split())

if n - m > 1 or m - n > 1:
    ans = 0
elif n - m == 0:
    ans = 2 * fact[n] * fact[m] % mod
else:
    ans = fact[n] * fact[m] % mod
    
print(ans)

Submission status: Runtime Error

Solution code:
x,a,b=map(int, input().split())

if b<=a:
  print("delicious")
elif a+x>b:
  print("dangerous")
else:
  print("safe"

Submission status: Runtime Error

Solution code:
def test():
	mod = 10**9 + 7
	n, m = map(int, input().split())
	if abs(n-m) > 1:
		print(0)
		exit()
	i_n = n
	i_m = m
	np = 1
	mp = 1
	while True:
		np = (np%mod) * (i_n%mod)
		mp = (mp%mod) * (i_m%mod)
		i_n -= 1
		i_m -= 1
		if i_n < 1:
			i_n = 1
		if i_m < 1:
			i_m = 1
		if i_n == 1 and i_m == 1:
			break
	s = 2 if n == m else 1
	r = (mp*np*s) % (10**9 + 7)
	print(r)
test()

Submission status: Runtime Error

Solution code:
x,a,b = map(int,input().split())
kigen = b-a
if x>kigen:
  print('delicious')
elif x=kigen:
  print('safe')
else:
  print('dangerous')

Submission status: Runtime Error

Solution code:
x,a,b=int(input().split())
if a-b>=0:print('delicious')
elif a-b < 0 and a+x>=b:print('safe')
else:print('dangerous')

Submission status: Runtime Error

Solution code:
if A + X - B <  0:
    print('dangerous')
elif A - B >= 0 :
    print('delicious')
elif A + X + B >= 0:
    print('safe')

Submission status: Runtime Error

Solution code:

DL = A + X - B
if DL <  0:
  print('dangerous')
elif A - B >= 0 :
  print('delicious')
elif DL >= 0:
  print('safe')

Submission status: Runtime Error

Solution code:

DL = A + X - B
if DL <  0:
  print('dangerous')
elif A - B >= 0 :
  print('delicious')
elif DL > 0:
  print('safe')

Submission status: Runtime Error

Solution code:
x, buy, eat = int(input().split())

if buy > eat:
    print("delicious")
elif eat-buy < x:
    print("safe")
elif eat - buy > x:
    print("dangerous")

Submission status: Runtime Error

Solution code:
input_list = input().split(" ")
syoumi = int(input_list[0])
mae = int(input_list[1])
eat = int(input_list[2])
if eat < mae:
  print("delicious")
else if (eat - mae) < syoumi:
  print("safe")
else:
  print("dangerous")

Submission status: Runtime Error

Solution code:
#054_A
a,b=map(int,input().split())
print('Draw' if a==b else 'Alice' if (a-2)%13>(b-2)%13 else 'Bob')

Submission status: Runtime Error

Solution code:
X,A,B=map(int,input().split())
if A>=B:
	print("delicious")
elif A<B and B=<A+X:
	print("safe")
else:
	print("dangerous")

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
if(c-b>a): print("dangerous")
else if(c-b<=0): print("delicious")
else : print("safe")

Submission status: Runtime Error

Solution code:
X,A,B = map(int.input().split())

C = B - A

if C <= 0:
  print("delicious")
elif C > X:
  print("dangerous")
else:
  print("safe")

Submission status: Runtime Error

Solution code:


def main():
    N = int(input())
    a = [int(input()) for _ in range(N)]
    
    b = a[0]
    count = 1
    if b == 2:
        ans = 1
    else:
        while True:
            count += 1
            b = a[b - 1]
            if b == 2:
                ans = count
                break
        
            if count > N:
                ans = -1
                break
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
x,a,b = = map(int,input().split())
if b <= a: print("delicious")
elif b <= a + x: print("safe")
else: print("dangerous")

Submission status: Runtime Error

Solution code:
import math

n, m = map(int, input().split())
w = 10 ** 9 + 7
if n + 1 == m or m + 1 == n:
    print(math.factorial(min(n, m)) ** 2 * max(n, m) % w)
elif n == m:
    print(2 * math.factorial(n) ** 2 % w)
else:
    print(0)

Submission status: Runtime Error

Solution code:
X, A, B = map(int, input().split())
if A <= B:
    print("delicious")
if (B-A) <= X:
    pirint("safe")
if X < (B-A):
    print("dangerous")

Submission status: Runtime Error

Solution code:
X, A, B = map(int, input().split())
if A <= B:
    print("delicious")
if (B-A) <= X:
    pirnt("safe")
if X < (B-A):
    print("dangerous")

Submission status: Runtime Error

Solution code:
X, A, B = map(int, input().split())
if A <= B:
    print("delicious")
elif (B-A) <= X:
    pirnt("safe")
elif X < (B-A):
    print("dangerous")

Submission status: Runtime Error

Solution code:
X, A, B = map(int, input().split())
if A <= B:
    print("delicious")
elif (B-A) <= X:
    pirnt("safe")
else:
    print("dangerous")

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
print("delicious" if b=c else "safe" if c-b-1<=a else "dangerous")

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
if b-a<=0:
  print("delicious")
elif b-a=0 and x-(b-a)>=0:
  print("safe")
else:
  print("dangerous")

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
b = []
for i in range(n):
   a.append(int(input()))
   b.append(0)

# 1: now, -1: visited, 0: none
b[0] = 1
now = 0
count = 0
while (b[1] != 1 and count <= n):
   next = a[now] - 1

   if (b[next] == -1):
      print(-1)
      exit()

   b[now] = -1
   b[next] = 1

   now = next
   count += 1

if (b[1] == 1):
   print(count)
else:
   print(-1)

Submission status: Runtime Error

Solution code:
x,a,c=map(int,input().split())
if -1*a+b <= 0:
  print('delicious')
elif -1*a+b <= x:
  print('safe')
else:print('dangerous')

Submission status: Runtime Error

Solution code:
x, a, b = (int(i) for i in input().split())

if b-a <= 0: 
  print('delicious')
elif b-a <= X:
  print('safe')
else:
  print('dengerous')

Submission status: Runtime Error

Solution code:
x, a, b = map(int,input().split())
 
if x => abs(b - a):
  print("safe")
elif x <= abs(b - a):
  print("dangerous")
else:
  print("delicious")

Submission status: Runtime Error

Solution code:
x, a, b = map(int,input().split())
 
if x >= abs(b - a):
  print("safe")
elif x =< abs(b - a):
  print("dangerous")
else:
  print("delicious")

Submission status: Runtime Error

Solution code:
x, a, b  = map(lambda x: int(x),  input().split())

if b =< a:
  print('delicious')
elif x <= b - a:
  print('safe')
else:
  print('dangerous')

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
print('delicious' if b-a<=0 else 'safe' if b-a<x+1 else 'dangerous
')

Submission status: Runtime Error

Solution code:
n=int(input())
a = [int(input()) for _ in range(n)]
pos=0
for i in range(n):
  if a[pos] == 2:
    print(i+1)
    exit()
  pos = a[pos]-1
print(-1)

Submission status: Runtime Error

Solution code:
import math
a, b = map(int, input().split())
if abs(a - b) >= 2:
    print(0)
else:
    x = math.factorial(a)
    y = math.factorial(b)
    ans = x * y
    if a == b:
        print(ans * 2 % (10 ** 9 + 7))
    else:
        print(ans % (10 ** 9 + 7))

Submission status: Runtime Error

Solution code:
x,a,b = list(map(int,input().split()))
if b >= c:
  print("delicious")
elif a+b < c:
  print("dangerous")
else:
  print("safe")

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
if b in range(a):
  print('delicious')
elif bin range(a,x+a+1):
  print('safe')
else:
  print('dangerous')

Submission status: Runtime Error

Solution code:
if a >= b :
    print("delicious")
elif b - a <= x:
    print("safe")
else:
    print("dangerous")

Submission status: Runtime Error

Solution code:
import heapq
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [0] * n
    
    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]
 
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return
        
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            self.rank[x] += (self.rank[x] == self.rank[y])
 
def kruskal(n, edge):
    ans = 0
    uf = UnionFind(n)
    for i in range(len(edge)):
        d, v, u = heapq.heappop(edge)
        
        if uf.find(v) != uf.find(u):
            uf.union(v, u)
            n -= 1
            ans += d
    	if n < 1: return ans
    return ans
 
n = int(input())
x, y = [None]*n, [None]*n
dist = [[0] * n for _ in range(n)]
 
for i in range(n):
    a, b = map(int, input().split())
    x[i] = (a, i)
    y[i] = (b, i)
 
x.sort(key=lambda x:x[0])
y.sort(key=lambda y:y[0])
 
edge = []
for i in range(n-1):
    heapq.heappush(edge, (x[i+1][0]-x[i][0], x[i][1], x[i+1][1]))
    heapq.heappush(edge, (y[i+1][0]-y[i][0], y[i][1], y[i+1][1]))
 
del x, y
print(kruskal(n, edge))

Submission status: Runtime Error

Solution code:
def find(A,x) -> int:
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a

def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx
    
    def examD():
    N = I()
    x = [[] for _ in range(N)]; y = [[] for _ in range(N)]
    for i in range(N):
        a, b = LI()
        x[i] = (a-1,i)
        y[i] = (b-1,i)
    v = [ i for i in range(N)]
    x.sort(); y.sort()
    H = []
    heapify(H)
    for i in range(N - 1):
        x1, j1 = x[i]
        x2, j2 = x[i + 1]
        y1, k1 = y[i]
        y2, k2 = y[i + 1]
        heappush(H, (x2 - x1, j1, j2))
        heappush(H, (y2 - y1, k1, k2))
    ans = 0
#    print(H)
#    print(v)
    while H:
        w, s, t = heappop(H)
        if find(v, s) != find(v, t):
            union(v, s, t)
            ans += w
    print(ans)

import sys
import copy
import bisect
from heapq import *
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()

Submission status: Runtime Error

Solution code:
X,A,B = map(int,input().split())

if A >= B:
  print('delisious')
  elif X >= B - A:
    print('safe')
    else:
      print('dangerous')

Submission status: Runtime Error

Solution code:
#Expired?
X, A, B = map(int, input().split())
Count = -A+B
if Count <= 0:
    print("delicious")
elif Cunt <= X:
    print("safe")
else:
    print("dangerous")

Submission status: Runtime Error

Solution code:
x, a, b = map(int, input().split())
print('delicious' if a-b>=0 else 'safe' a+x-b>=0 else 'dangerous')

Submission status: Runtime Error

Solution code:
x, a, b = map(int, input().split())

if a>=b:
  print("delicious")
else:
  if x=<b:
    print("safe")
  if a+x+1 <= b:
    print("dangerous")

Submission status: Runtime Error

Solution code:
x, a, b = map(int, input().split())

if a-b > 0:
  print("delicious")

if b > x
  print("safe")

if b > x+1:
  print("dangerous")

Submission status: Runtime Error

Solution code:
x, a, b = map(int, input().split())
if x < b - a:
  print("dangerous")
elif x <= b - a and 0 < x - (a - b):
  primt("safe")
elif 0 >= b - a:
  print("delicious")

Submission status: Runtime Error

Solution code:
x, a, b = map(int, input().split())
if x < b - a:
  print("dangerous")
elif x == b - a:
  primt("safe")
elif x <= b - a and 0 <= a - b:
  print("delicious")

Submission status: Runtime Error

Solution code:
x, a, b = map(int, input().split())
if x < b - a:
  print("dangerous")
elif x == b - a:
  primt("safe")
elif x <= b - a:
  print("delicious")

Submission status: Runtime Error

Solution code:
x, a, b = map(int, input().split())
if x < b - a:
  print("dangerous")
elif x <= b - a:
  print("delicious")
else:
  primt("safe")

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
if b-a=<0:
  print('delicious')
elif b-a=<x and not b-a=<0:
  print('safe')
else:
  print('dangerous')

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
if -a+b=<0:
  print('delicious')
elif -a+b=<x and not -a+b=<0:
  print('safe')
else:
  print('dangerous')

Submission status: Runtime Error

Solution code:
x,a,b=map(int,input().split())
if q-b>=0:
  print("delicious")
elif -x<=a-b<0:
  print("safe")
else:
  print("dangerous")

Submission status: Runtime Error

Solution code:
x, a, b = map(int, input().split)
if a >= b:
    print('delicious')
elif x + a < b:
    print('dangerous')
else:
    print('safe')

Submission status: Runtime Error

Solution code:
x, a, b = map(int, input().split())
if a-b => 0 :
  print('delicious')
elif b-a <= x:
  print('safe')
else:
  print('dangerous')

Submission status: Runtime Error

Solution code:
X, A, B = map(int, input())
if A-B > X:
  print('dangerous')
  exit()
elif A-B <= 0:
  print('delicious')
  exit()
print('safe')

Submission status: Runtime Error

Solution code:
X,A,B = (int(i) for i in input().split())
Y = A - B
if Y >= 0:
    print('delicious')

elif (-1) * Y =< X :
    print('safe')
    
else:
    print('dangerous')

Submission status: Runtime Error

Solution code:
x, a, b =map(int, input().split())
if b - a > x
  print('dangerous')
elif b - a == x:
  print('safe')
else:
  print('delicious')

Submission status: Runtime Error

Solution code:
#include<iostream>
using namespace std;

int main(){
  int X, A, B;
  cin >> X >> A >> B;
  if((B - A) <= 0) cout << "delicious";
  else if((B - A) > 0 and (B - A) <= X) cout << "safe";
  else cout << "dangerous";
}

Submission status: Runtime Error

Solution code:
n = int(input())
an = [int(input()) for i in range(n)]
c, s = 1, an[0]
while s != 2 and c < n:
    c, s = c + 1, an[s - 1]
print(c if c < n else -1)