Problem:


Score : 100 points

Problem Statement

There are S sheep and W wolves.

If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.

If the wolves will attack the sheep, print unsafe; otherwise, print safe.

Constraints

1 \leq S \leq 100

1 \leq W \leq 100

Input

Input is given from Standard Input in the following format:

S W

Output

If the wolves will attack the sheep, print unsafe; otherwise, print safe.

Sample Input 1

4 5

Sample Output 1

unsafe

There are four sheep and five wolves. The number of wolves is not less than that of sheep, so they will attack them.

Sample Input 2

100 2

Sample Output 2

safe

Many a sheep drive away two wolves.

Sample Input 3

10 10

Sample Output 3

unsafe



Sample input:
4 5


Sample output:
unsafe

Submission status: Runtime Error

Solution code:
import collections

S = input()
N = len(S)
l = []
for i in range(N):
    l.append(int(''.join(S[i:N]))%2019)

c = collections.Counter(l)

values, counts = zip(*c.most_common())
counts = list(counts)

try:
    ans = counts.pop(list(values).index(0))
except:
    ans = 0

for i in range(len(counts)):
    if counts[i] != 1:
        ans += counts[i] * (counts[i]-1) // 2

print(ans)

Submission status: Runtime Error

Solution code:
s, w = list(map(int, input().split(" ")))
if s >= w:
  print("unsafe")
else:
  print("safe)

Submission status: Runtime Error

Solution code:
 w = list(map(int, input().split(" ")))
if s >= w:
  print("unsafe")
else:
  print("safe")

Submission status: Runtime Error

Solution code:
def judge(s,w):
  print("羊の数を入力してください：")
  s = input()
  int_s = int(s)
  if s < 0 or s > 100:
    print("1から100の間でお願いします")
    continue
  else:
    break
  print("次に狼の数を入力してください：")
  w = input()
  int_w = int(w)
  if w < 0 or w > 1000:
    print("1から1000の間でお願いします")
    continue
  else:
    break

if int_s > int_w:
  print("safe")
else:
  print("unsafe")
  
judge()

Submission status: Runtime Error

Solution code:
def judge(s,w):
  print("羊の数を入力してください：")
  s = input()
  int_s = int(s)
  if s < 0 or s > 100:
    print("1から100の間でお願いします")
    continue
  else:
    break
  print("次に狼の数を入力してください：")
  w = input()
  int_w = int(w)
  if w < 0 or w > 1000:
    print("1から1000の間でお願いします")
    continue
  else:
    break

if int_s > int_w:
  print("safe")
else:
  print("unsafe")
  
print(judge())

Submission status: Runtime Error

Solution code:
a,b,c,d = map(int,input().split())
ta = 0
aok = 0
while True:
    ta = c-b
    c = ta
    if c <=0:
        print("Yes")
        break
    aok = a - d
    a = aok
    if a <=0:
        print("No")
        break

Submission status: Runtime Error

Solution code:
n = str(input())
count = 0
for j in range(len(n) - 4):
  for i in range(len(n) - 3 - j):
    if(int(n[i:4 + i + j]) % 2019 == 0):
       count += 1

print(count)

Submission status: Runtime Error

Solution code:
def judge(s,w):
  print("羊の数を入力してください：")
  s = input()
  int_s = int(s)
  if s < 0 or s > 100:
    print("1から100の間でお願いします")
    continue
  else:
    break
  print("次に狼の数を入力してください：")
  w = input()
  int_w = int(w)
  if w < 0 or w > 1000:
    print("1から1000の間でお願いします")
    continue
  else:
    break

if int_s > int_w:
  print("safe")
else:
  print("unsafe")
print(judge)

Submission status: Runtime Error

Solution code:
n=int(input())
s,l=[],[]
s=[input() for i in range(n)]
for i in s:
  if i not in l:
      l.append(i)
print(len(l))

Submission status: Runtime Error

Solution code:
s=input()
lens=len(s)
count=0
for i in range(lens):
    for k in range(i,lens):
        num=s[i:k]
        if(len(num)>=4):
            if(int(num)%2019==0):
                count=count+1
print(count)

Submission status: Runtime Error

Solution code:
s,w=input().split()
if s<=w:
  print(unsafe)
if s>w:
  print(safe)

Submission status: Runtime Error

Solution code:
N = int(input())
S = list()
for i in range(N):
  x = input()
  S.append(x)
  
A = set(S)
print(len(A))

Submission status: Runtime Error

Solution code:
s,w=input().split()
if s<=w:
  print(unsafe)
else:
  print(safe)

Submission status: Runtime Error

Solution code:
s = input()
cnt = 0
ans = []
for i in range(0, len(s) - 3):
    j = i
    num = ''
    while j < len(s):
        juhuku = 0
        num += s[j]
        if int(num) % 2019 == 0 and num != '0':
            #print(i, j)
            if j not in ans:
                ans.append(j)
            juhuku = ans.count(i - 1)
            cnt += 1 + juhuku
        j += 1
print(ans)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
	S = input()
	LEN = len(S)
	r = LEN
	l = LEN-1
	count = 0
	lst = []
	amari = 0
	while(l >= 0):
		amari = (amari + int(S[l])*10**(l-1)%2019)%2019
		
		if amari in lst:
			count += 1
		elif amari == 0:
			count += 1
			lst.append(count)
		else:
			lst.append(amari)
		l -= 1

	print(count)

Submission status: Runtime Error

Solution code:
s = input()
cnt = 0
ans = []
for i in range(0, len(s) - 3):
    j = i
    num = ''
    while j < len(s):
        juhuku = 0
        num += s[j]
        if int(num) % 2019 == 0 and num != '0':
            print(i, j)
            if j not in ans:
                ans.append(j)
            juhuku = ans.count(i - 1)
            cnt += 1 + juhuku
        j += 1
cnt, ans

Submission status: Runtime Error

Solution code:
S=int(input("羊は何匹？"))
W=int(input("オオカミは何匹？"))
if W>S:
    print("unsafe")
else:
    print("safe")

Submission status: Runtime Error

Solution code:
import sys

S = input()

s = []
for i in S:
    s.append(int(i))
count = 0

if (len(s) < 4 ):
    print(0)
    sys.exit()

for i in range(len(s)):
    j = i
    target = s[i]
    for k in range(len(s)-i):
        j += 1
        if(j >= len(s)):
            break
        target = target*10
        target += s[j]
        if ( target%2019 == 0):
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
takahashi_h, takahashi_a, aoki_h, aoki_a = map(int, input().split())

if takahashi_h // aoki_a < aoki_h // takahashi_a:
    print("Yes")
elif takahashi_h // aoki_a > aoki_h // takahashi_a:
    print("No")
else:
    takahashi_h = takahashi_h - (aoki_a * (takahashi_h // aoki_a))
    aoki_h = aoki_h - (takahashi_a * (aoki_h // takahashi_a))
    
    if aoki_h > 0 and takahashi_h == 0:
        print("No")
    else:
        print("Yes")

Submission status: Runtime Error

Solution code:
s,w = map(int,input().split())
　if　s =>　w：
　　　print('safe')
else：  
print('unsafe')

Submission status: Runtime Error

Solution code:
s = input()
for v in range(6,101):
    ans += s.count(str(v*2019))
print(str(ans))

Submission status: Runtime Error

Solution code:
S,W=input().split()
if S<=W:
  print(unsafe)
else:
  print(safe)

Submission status: Runtime Error

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

ans1 = 0
while a>=0:
    a -= d
    ans1 += 1

ans2 = 0
while c >= 0:
    c -= b
    ans2 += 1

if ans1 >= ans2:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
s = input()
cnt = 0
ans = []
for i in range(0, len(s) - 3):
    j = i
    num = ''
    while j < len(s):
        juhuku = 0
        num += s[j]
        if int(num) % 2019 == 0 and num != '0':
            #print(i, j)
            if j not in ans:
                ans.append(j)
            juhuku = ans.count(i - 1)
            cnt += 1 + juhuku
        j += 1
print(cnt)

Submission status: Runtime Error

Solution code:
S = input()
N = len(S)
l = []
temp = 0
index = 0
for i in range(N):
    l.append(int(''.join(S[i:N])))

ans = 0
for i in range(N-1):
    for j in range(i,N):
        if (l[i] - l[j])/(10**(N-j)) % 2019 == 0 and l[i]-l[j] != 0:
            ans += 1

if ans == 0:
    print(0)
else:
    print(ans+1)

Submission status: Runtime Error

Solution code:
N = int(input())
S = []
ans = N


for i in range(N):
    s = input()
    if i == 0:
        S.append(s)
    else:
        flg = 0
        j  = 0
        while(flg == 0 and j < len(S)):
            if S[j] == s:
                ans = ans - 1
                flg = 1
            j = j+1
        if flg == 0:
            S.append(s)
        
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    inputs = input()

    roop_num = len(inputs)

    cnt = 0
    flag = False
    for start in range(roop_num-3):
        roop_num_end = roop_num - start
        ans_list = []
        ans_list = [int(inputs[start:end+start+4]) for end in range(roop_num_end-3) if int(inputs[start:end+start+4]) % 2019 == 0]
        cnt += len(ans_list)

    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import itertools
s = input()
s_li = list(s)
lee = len(s_li)

count = 0
keta = list(itertools.combinations([i for i in range(lee)], 2))
for k in keta:
    lk = list(k)
    #print(s_li[lk[0]:lk[1]+1])
    if int(''.join(s_li[lk[0]:lk[1]+1]))%2019 == 0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
def main():
    inputs = input()

    roop_num = len(inputs)

    cnt = 0
    flag = False
    for start in range(roop_num-3):
        roop_num_end = roop_num - start
        ans_list = []
        ans_list = [int(inputs[start:end+start+4]) for end in range(roop_num_end-3) if int(inputs[start:end+start+4]) % 2019 == 0]

        cnt += len(ans_list)

    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
s=list(input())
from itertools import product, permutations,combinations


#l = len(s) +1
#A = [i for i in range(len(s)+1)]

cnt = 0
ans = []

for i in combinations([i for i in range(len(s)+1)],2):
    
    ans = s[i[0]:i[1]]
    if int("".join(map(str, ans)))%2019==0:
            cnt +=1
    
        
print(cnt)

Submission status: Runtime Error

Solution code:
S = input()
count = 0
for i in range(len(S)):
    for j in range(i + 5, i + 6):
        if int(S[i:j]) % 2019 == 0:
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
a, b, c, d = map(int, input().split())
if c//b + 1 > a//d:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
S = input()

count = 0

for i in len(S):
    for j in range(i, len(S)):
        if int(S[i:j]) % 2019 == 0:
            count += 1
      
      
print(count)

Submission status: Runtime Error

Solution code:
input a("")
input b("")
if a>b:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
def main():
    inputs = input()

    roop_num = len(inputs)
    if roop_num >= 100000:
        cnt = 0

    else:
        cnt = 0
        flag = False
        for start in range(roop_num-3):
            roop_num_end = roop_num - start
            ans_list = []
            ans_list = [int(inputs[start:end+start+4]) for end in range(roop_num_end-3) if int(inputs[start:end+start+4]) % 2019 == 0]

            cnt += len(ans_list)

    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
s = input()
len_s = len(s)
ans = 0
for i in range(len_s):
    for j in range(i + 3 , len_s + 1):
        if int(s[i:j]) % 2019 == 0:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = input()

m = len(n)

l = list()

c = 0

for i in range(m):
    for j in range(m-i):
        l.append(i)
        l.append(i+j+2)

for k in range(len(l)//2):
    s = n[l[2*k]:l[2*k+1]]
    s = int(s)
    
    if s % 2019 == 0:
        c += 1

print(c)

Submission status: Runtime Error

Solution code:
def main():
    inputs = input()

    roop_num = len(inputs)
    if roop_num >= 90000:
        cnt = 0

    else:
        cnt = 0
        flag = False
        for start in range(roop_num-3):
            roop_num_end = roop_num - start
            ans_list = []
            ans_list = [int(inputs[start:end+start+4]) for end in range(roop_num_end-3) if int(inputs[start:end+start+4]) % 2019 == 0]

            cnt += len(ans_list)

    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
s = input()
len_s = len(s)
ans = 0
for i in range(len_s):
    for j in range(i + 4 , len_s + 1):
        if int(s[i:j]) % 2019 == 0:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    inputs = input()

    roop_num = len(inputs)
    if roop_num >= 80000:
        cnt = 0

    else:
        cnt = 0
        flag = False
        for start in range(roop_num-3):
            roop_num_end = roop_num - start
            ans_list = []
            ans_list = [int(inputs[start:end+start+4]) for end in range(roop_num_end-3) if int(inputs[start:end+start+4]) % 2019 == 0]

            cnt += len(ans_list)

    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import itertools
S = input()
anskouho_set = set()
mod3 =[]
for x in S:
    mod3.append(int(x)%3)
mod3_accumulate = [x%3 for x in list(itertools.accumulate(mod3))]
ans = 0
for i in range(3):
    temp = []
    if i==0:
        temp.append(0)
    for j,x in enumerate(mod3_accumulate):
        if x==i:
            temp.append(j)
    for k in range(len(temp)):
        for l in range(k+1,len(temp)):
            if temp[l]-temp[k]>=4:
                anskouho_set.add((temp[k],temp[l]))
            if temp[l]+1-temp[k]>=4:
                anskouho_set.add((temp[k]+1,temp[l]))
for x in anskouho_set:
    if int(S[x[0]:x[1]+1])%2019==0:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
s = input()
len_s = len(s)
ans = 0
for i in range(len_s - 3):
    for j in range(i + 4 , len_s + 1):
        if int(s[i:j]) % 2019 == 0:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
S= int(input())
W= int(input())
if(W>=S):
  print("unsafe")
else:
  print("safe")

Submission status: Runtime Error

Solution code:
int s,w


print("羊の数を入力してください：")
s = input()
  S = int(s)
print("次に狼の数を入力してください：")
w = input()
  W = int(s)

if S > W:
  print("safe")
else:
  print("unsafe")

Submission status: Runtime Error

Solution code:
s = input()
if len(s) < 4:
  print('0')
else:
  cnt = 0
  for i in range(len(s)-3):
    if int(s[i:i+2]) %2 != 0:
      continue
    if i+4 > len(s):
      break
    for j in range(i+4, len(s)):
      if int(s[i:j+1]) % 2019 == 0:
        cnt += 1
  print(cnt)

Submission status: Runtime Error

Solution code:
S = int(input("Number of S: "))
W = int(input("Number of w: "))
if((1<=S<=100) >= (1<=W<=100)):
  print("unsafe")
else:
  print("safe")

Submission status: Runtime Error

Solution code:
s = input()
len_s = len(s)
ans = 0
for i in range(len_s - 4):
    for j in range(i + 4 , len_s + 1):
        if int(s[i:j]) % 2019 == 0:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
s,w = map(int, input().strip())

if w >= s:
	print("unsafe")
else:
	print("safe")

Submission status: Runtime Error

Solution code:
s = input()
n = s.__len__()
c = 0
l = list()
for i in range(n):
    l.append(s[i])
len = l.__len__()
for i2 in range(len):
    start = s[i2]
    for i3 in range(len-i2-1):
        start += s[i3+i2+1]
        if int(start) % 2019 == 0:
            c = c + 1
print(c)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(20000*20000)

S = str(input())
ans = set()
check = set()

def dfs(i, j):
    if (i, j) in check:
        return
    else:
        check.add((i, j))
    if int(S[i:j+1])%2019 == 0:
        ans.add((i, j))
    if j == len(S)-1:
        return

    dfs(i+1, j+1)
    dfs(i, j+1)

if len(S) < 4:
    print(0)

else:
    dfs(0, 3)
    print(len(ans))

Submission status: Runtime Error

Solution code:
S,W =map(int, input().split())
if S<=W print 'unsafe' else 'safe'

Submission status: Runtime Error

Solution code:
s,w = map(int, input().strip())

if w >=s:
    print("unsafe")
else:
    print("safe")

Submission status: Runtime Error

Solution code:
def main():
    inputs = input()

    roop_num = len(inputs)
    if roop_num >= 1000000000
        cnt = 0

    else:
        cnt = 0
        flag = False
        for start in range(roop_num-3):
            roop_num_end = roop_num - start
            ans_list = []
            ans_list = [int(inputs[start:end+start+4]) for end in range(roop_num_end-3) if int(inputs[start:end+start+4]) % 2019 == 0]

            cnt += len(ans_list)

        print(cnt)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
s,w = map(inr, input().split())
 
if w <= s:
  print("unsafe")
else:
  print("safe")

Submission status: Runtime Error

Solution code:
s,w = map(inr, input().split())

if w >= s:
  print("unsafe")
else:
  print("safe")

Submission status: Runtime Error

Solution code:
takahashi_h, takahashi_a, aoki_h, aoki_a = map(int, input().split())

if takahashi_h // aoki_a > aoki_h // takahashi_a:
    print("Yes")
elif takahashi_h // aoki_a < aoki_h // takahashi_a:
    print("No")
else:
    takahashi_h = takahashi_h - (aoki_a * (takahashi_h // aoki_a))
    aoki_h = aoki_h - (takahashi_a * (aoki_h // takahashi_a))
    
    if aoki_h > 0 and takahashi_h == 0:
        print("No")
    else:
        print("Yes")

Submission status: Runtime Error

Solution code:
S = input()
import numpy as np
length = len(S)
arr = np.array([int(S[i:j]) for i in range(0,length-3) for j in range(i+4, length+1)])
arr2 = arr % 2019
print(len(arr2)- np.count_nonzero(arr2))

Submission status: Runtime Error

Solution code:
s=input()
ans=0
for i in range(len(s)-4):
    for j in range(i+4,len(s)):
        if int(s[i:j+1])%2019==0:
            ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
s, w = map(int, input().split())
if ( w >= s )
	print("unsafe")
else
	print("safe")

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


def main():
    S = input().strip()
    answer = []
    for i in range(1, len(S)+1):
        [answer.append(j) for j in range(i+4, len(S)+1)
         if int(S[i-1:j]) % 2019 == 0]
    print(len(answer))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
s = int(input())
w = int(input())
if ( w >= s ):
	print("unsafe")
else:
	print("safe")

Submission status: Runtime Error

Solution code:
s, w = (for i in input().split())
if s > w:
  print("safe")
if w >= s:
  print("unsafe")

Submission status: Runtime Error

Solution code:
S = str(input())
s = int(S)
n = len(S)
count = 0
for i in range(1,n+1):
    for j in range(i+4,n+1):
        si = s%10**(n-i+1)
        sij = si//10**(n-j)
        if sij % 2019 == 0:
            count+=1
            i+=4
            j+=4

print(count)

Submission status: Runtime Error

Solution code:
import sys
import math
import queue
import copy
import bisect#2分探索
from collections import deque #popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s): return sorted(range(len(s)), key=lambda k: s[k])

#mod = 10**9+7

S = int(input())
#N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [inputl() for i in range(H)]
#q = queue.Queue() #q.put(i) #q.get() 
#q = queue.LifoQueue() #q.put(i) #q.get() 

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b=copy.deepcopy(a)  #2次元配列はこうコピーする
#w.sort(key=lambda x:x[1],reverse=True)  #二個目の要素で降順並び替え

#素数リスト
# n = 100
# primes = set(range(2, n+1))
# for i in range(2, int(n**0.5+1)):
#     primes.difference_update(range(i*2, n+1, i))
# primes=list(primes)

#bisect.bisect_left(a, 4)#aはソート済みである必要あり。aの中から4未満の位置を返す。rightだと以下
#bisect.insort_left(a, 4)#挿入

ss=str(S)
# #print(ss)
ls=len(ss)
# l=[0]*(ls+1)

    #print(l[i])
#print(l)

import heapq #優先度付きqueue

kl=dict()
kl[0]=1
# a = [0]
# heapq.heapify(a)  # aを優先度付きキューに

for i in range(0,ls):
    tmp=(S%10**(i+1))%2019
    kl[tmp]=kl.get(tmp,0)+1
#print(a)


ans=0

for k in kl:
    val=kl[k]
    ans+=val*(val-1)//2

print(ans)
# cur=-1
# ans=0
# for i, li in enumerate(l):
#     if cur==-1:
#         cur=li
#         count=1
#     elif li==cur:
#         count+=1
#     else:
#         ans+=count*(count-1)//2
#         cur=li
#         count=1

# print(ans)

Submission status: Runtime Error

Solution code:
a, b, c, d = map(int, input().split())
while a > 0 and c > 0:
  c -= b
  if c > 0:
    a -= d
  else:
    print('Yes')
  if a <= 0
    print('No')

Submission status: Runtime Error

Solution code:
S,W = input()
if S<=W print 'unsafe' else 'safe'

Submission status: Runtime Error

Solution code:
s, w = int(input().split())
if s > w:
  print("safe")
if w > s:
  print("unsafe")
if s == w:
  print("unsafe")

Submission status: Runtime Error

Solution code:
s=input()
for i in map(int, s.split()):
    lis.append(i)
if lis[0]>lis[1]:
    print("safe")
else:
    print("unsafe")

Submission status: Runtime Error

Solution code:
s = int(input())
w = int(input())
if ( w >= s )
	print("unsafe")
else
	print("safe")

Submission status: Runtime Error

Solution code:
S = str(input())

S_list =list(S)


A = 0
for i in range(0,len(S_list)-1):
    for j in range(i+3,len(S_list)+1):
        P = 0
        S_list_P = S_list[i:j]
        for k in range(0,j-i):
            P += int(S_list_P[k])* 10 ** (j-i-k-1)

        if P % 2019== 0:
            A += 1



print(A)

Submission status: Runtime Error

Solution code:
s, w = int(input().split())
if s > w:
  print("Safe")
if w > s:
  print("Unsafe")

Submission status: Runtime Error

Solution code:
s,w = input()
if s<=w print 'unsafe' else 'safe'

Submission status: Runtime Error

Solution code:
s = int(input())
w = int(input())
if w > s
	print("unsafe")
else
	print("safe")

Submission status: Runtime Error

Solution code:
t,k,a,o = map(int,input().split())
taka=int(a//k)
aoki=int(t//o)
if taka<=aoki:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
str=input()
gap_len=4
flag=0
count=0
for gap_len in range(4,20000):
    for i in list(range(len(str)-gap_len+1)):
        sub_str=str[flag:flag+gap_len]

        num=int(sub_str)
        if(num%2019==0):
            count+=1
        flag+=1
    flag =0
print(count)

Submission status: Runtime Error

Solution code:
S = int(input())
total = 0
keta = len(str(S))
for i in range(keta):
  for j in range(i+3,keta):
    n = (S%10**(keta-i))//10**(keta-j-1)
    #print(n)
    if n % 2019 == 0:
      total += 1
print(total)

Submission status: Runtime Error

Solution code:
S=input()
S1=int(S)
#print(len(S))
S_count=len(S)
sum=0
sum1=0
ii=0
jj=4
SSSS=int(S_count)
for i in range(S_count):
  sum1+=i
#print(sum1)
for i in range(sum1):
  if ii==int(S_count-1):
    break
  SS=S[ii:jj]
  #print(SS)
  SSS=int(SS)
  if SSS%2019==0:
    sum+=1
  jj+=1
  if jj==int(S_count+1):
    ii+=1
    if ii>=4:
      jj=ii+1
    else:
      jj=4
  
print(sum)

Submission status: Runtime Error

Solution code:
a,b,c,d = map(int,input().split())
while a >= 0 or c >= 0:
    c =c - b
    a =a - d
if c <= 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S = input()
ans = 0

for n in range(3, len(S)):
    for i in range(len(S)-n):
        ans += 1 if int(S[i:i+n+1]) % 2019 == 0 else 0

print(ans)

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int,input().split())
a=a-d
c=c-b
if c>=a:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
S = int(input())
W = int(input())

if W >= S:
 print('unsafe')
else:
 print('safe')

Submission status: Runtime Error

Solution code:
numbers = input().split(" ")
healthOfT = int(numbers[0])
strengthOfT = int(numbers[1])
healthOfA = int(numbers[2])
strengthOfA = int(numbers[3])
for i in(0,1000):
	healthOfA=healthOfA-strengthOfT
	if healthOfA<=0:
		a=i
		break
for p in(0,1000):
	healthOfT=healthOfT-strengthOfA
	if healthOfT<=0:
		break
if p<i:
	print("No")
else:
	print("Yes")

Submission status: Runtime Error

Solution code:
A, B, C, D = map(int, input().split())
while (A>0 and C > 0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "No")

Submission status: Runtime Error

Solution code:
a = int(input())
lst = []
for i in range(a):
    b = input()
    if not(b in lst):
    	lst.append(b)
        
print(len(lst))

Submission status: Runtime Error

Solution code:
s = input()
cnt=0
for i in range(len(s)-3):
    for j in range(i+4,len(s)):
        if int(s[i:j+1]) % 2019 == 0:
            cnt+= 1
print(cnt)

Submission status: Runtime Error

Solution code:
S = input()
l = len(S)

count = 0
for i in range(l):
  for j in range(l):
    if i < j:
      new_s = int(S[i:j+1])
      if new_s % 2019 == 0:
        count += 1
      else:
        continue
    else:
      continue
print(count)

Submission status: Runtime Error

Solution code:
import sys
a = []
for l in sys.stdin:
    a.append(int(l))
p = input() .split()
s = set()
for i in range(1, len(p)):
    s.add(p[i])
print(len(set(s)))

Submission status: Runtime Error

Solution code:
S = input()

count = 0

for i in range(len(S)):
    for j in range(i + 3,len(S)):
       
        x = int(S[i:j+1])
        

        if x % 2019 == 0:
            count += 1

print(count)

Submission status: Runtime Error

Solution code:
S = int(input())
total = 0
S1 = str(S)
for i in range(0,S,2019):
  j = str(i)
  if j in S1:
    total+=1
print(total)

Submission status: Runtime Error

Solution code:
s = int(input())
w = int(input())
if w>=s:
  print("unsafe")
else:
  print("safe")

Submission status: Runtime Error

Solution code:
A =str(input())


N = int(len(A))

S = 0

for i in range(N):
  
  for j in range(N):
      
      if i >= j:
          continue
      
      x = (A[i:j+1])
      
      
      
      y = int(x)
      
      if y % 2019 == 0:
            S += 1

print(int(S))

Submission status: Runtime Error

Solution code:
S = input()
n = len(S)
count = 0
for i in range(0,n-3):
    s = S[i:i+4]
    for j in range(i+4,n):
        s = s + S[j]
        if int(s)%2019 == 0 : count += 1
print(count)

Submission status: Runtime Error

Solution code:
a,b,c,d = map(int,input().split())
while a <= 0 or c <= 0:
    c =c - b
    a =a - d
    if c <= 0:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
A =str(input())


N = int(len(A))

S = 0

for i in range(N):
  
  for j in range(N):
      
      if i >= j:
          continue
      
      x = (A[i:j+1])
      
      
      
      y = int(x)
      
      if y % 2019 == 0:
            S += 1

print(int(S))

Submission status: Runtime Error

Solution code:
s, w = input().split()
if int(w) >=  int(s):
  print('unsafe')
elif:
  print('safe')

Submission status: Runtime Error

Solution code:
def Sol(a,b,c,d):
    
    if a%d != 0:
        m_aoki = int(a/d) + 1
    else:
        m_aoki = int(a/d)

    if c%b != 0:
        m_taka = int(c/b) + 1
    else:
        m_taka = int(c/b)
        
    if m_taka >= m_aoki:
        print("YES")
    else:
        print("NO")

    return

    

#for t in range(int(input())):
n,k,c,d = map(int,input().split())
#n = int(input())
#arr = []
#for i in range(n):
#    arr.append(input())
#arr = list(map(int,input().split()))
#k = input()
#n = int(input())
Sol(n,k,c,d)

Submission status: Runtime Error

Solution code:
s, w = map(int, input().split())
if w >=  s:
  print('unsafe')
elif:
  print('safe')

Submission status: Runtime Error

Solution code:
while True:
    num1 = input()
    if int(num1) < 1 or int(num1) > 100:
        break
    num2 = input()
    if int(num2) < 1 or int(num2) > 100:
         break
    if int(num1) < int(num2):
         print("safe")
         break
    else:
         print('unsafe')
         break

Submission status: Runtime Error

Solution code:
a,b,c,d = map(int,input().split())
while a <= 0 or c <= 0:
    c =c - b
    a =a - d
if c <= 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
s, w = map(str, input().split())
if w >=  s:
  print('unsafe')
elif:
  print('safe')

Submission status: Runtime Error

Solution code:
s = input()

n = len(s)

k = 0

for i in range(n - 4):
    for j in range(i+4, n+1):
        if int(s[i:j]) % 2019 == 0:
            k = k+1
            
print(k)

Submission status: Runtime Error

Solution code:
s, w = map(str(), input().split())
if w >=  s:
  print('unsafe')
elif:
  print('safe')

Submission status: Runtime Error

Solution code:
S = int(input())
W = int(input())
if(S <== W):
    print(unsafe)
eles:
    print(safe)

Submission status: Runtime Error

Solution code:
def main():
  s = input()
  n = len(s)
  num = 2019
  ans = 0
  for i in range(n-4):
    for j in range(i+5,n+1):
      a = int(s[i:j])
      if a%num == 0:
        ans += 1
  print(ans)
main()

Submission status: Runtime Error

Solution code:
s=str(input())

ans=0
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if int(s[i:j])%2019==0:
            ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
S = input()
N = len(S)
count = 0
for i in range(0, N):
    for j in range(i+1, N+1):
        if int(S[i:j]) % 2019 == 0:
            count += 1

print(count)

Submission status: Runtime Error

Solution code:
S = input()
slen = len(S)
Sint = int(S)
count = 0
for i in range(slen-3):
    for j in range(i+3,slen):
        s4 = int(S[i:j+1])
        if s4 % 2019 == 0:
            count = count + 1
        
print(count)

Submission status: Runtime Error

Solution code:
lis =[]
abc =[]
count = 0

N = int(input())
lis =[lis.append(input()) for _ in range(N)]

for i in lis:
    if any(i == j for j in abc):
        pass
    else:
        abc.append(i)
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
w,s = list(map,int(input().split()))
if w >= s:
    print('unsafe')
else:
    print('safe')

Submission status: Runtime Error

Solution code:
S = input()
#S = str(1817181712114)
ans = 0
 
for a in range(len(S) - 3):
	for b in range(a+3, len(S)):
		if int(S[a:b+1]) % 2019 == 0:
			ans += 1        
print(ans)

Submission status: Runtime Error

Solution code:
s = input()
a = [int(c) for c in s]

b=""
count=0

for i in range(len(a)):
    for j in range(i,len(a)):
        for k in range(i,j+1):
            b += str(a[k])
        #print(b)
        if int(b)%2019 == 0:
            count+=1
        b=""

print(count)

Submission status: Runtime Error

Solution code:
s = input()
n = len(s)
if n < 4:
  quit()
l,r = 0,4
ans = [[[],[]] for _ in range(n+3)]
for i in range(4,8):
  l = 0
  while l+i <= n:
    if int(s[l:(l+i)])%2019 == 0:
      ans[l+1][0].append(l+i)
      ans[l+i+1][1].append(l+1)
    l += 1
final = 0
cnt = 1
for i in range(n+1):
  if ans[i][0] and ans[i][1]:
    cnt += 1
    final += cnt
  elif ans[i][0]:
    final += 1
    cnt = 1
print(final)

Submission status: Runtime Error

Solution code:
S = int(input())
W = int(input())
if S < W :
    print(unsafe)
    else :
    print(safe)

Submission status: Runtime Error

Solution code:
S=int(input())
W=int(input())
if S>W:
	print("safe")
else:
  	print('unsafe')

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
while (A>0 and C>0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "NO")

Submission status: Runtime Error

Solution code:
N=[int(x) for x in input().split()]
if not N[2]%N[1]==0:
   c=N[2]//N[1]+1
else:
    c=N[2]//N[1]
if not N[0]%N[3]==0:
   d=N[0]//N[3]+1
else:
    d=N[0]//N[3]
if d>=c:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
S = input()
#S = str(1817181712114)
ans = 0

for a in range(len(S) - 3):
	for b in range(a+1, len(S)):
		if int(S[a:b+1]) % 2019 == 0:
			ans += 1        
print(ans)