Problem p03017 (python)

Fixed submission:
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [0] + [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(A,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and A <= i <= (max(C,D)-1):
        flag = False
        break
for j in range(A,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3] and (B <= j + 2 <= D):
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and (j+2 <= D):
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and (j+2 <= D):
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and (j+2 <= D):
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if cumsum[i+2] - cumsum[i] == 2 and j+2 <= D:
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 

flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and (j+2 <= D):
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True

if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")
提出情報

Buggy submission (verdict: Runtime Error):
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 

flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if cumsum[i+2] - cumsum[i] == 2 and j+2 <= D:
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True

if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")