Problem:
 Score : 400 points    Problem Statement There are N squares arranged in a row, numbered 1, 2, ..., N from left to right.
You are given a string S of length N consisting of . and # . If the i -th character of S is # , Square i contains a rock; if the i -th character of S is . , Square i is empty.  In the beginning, Snuke stands on Square A , and Fnuke stands on Square B .  You can repeat the following operation any number of times:   Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.   You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D .  Determine whether this is possible.      Constraints  4 \leq N \leq 200\ 000  S is a string of length N consisting of . and # .  1 \leq A, B, C, D \leq N  Square A , B , C and D do not contain a rock.  A , B , C and D are all different.  A < B  A < C  B < D         Input Input is given from Standard Input in the following format:  N  A  B  C  D  S       Output Print Yes if the objective is achievable, and No if it is not.        Sample Input 1 7 1 3 6 7
.#..#..      Sample Output 1 Yes  The objective is achievable by, for example, moving the two persons as follows. ( A and B represent Snuke and Fnuke, respectively.)  A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB       Sample Input 2 7 1 3 7 6
.#..#..      Sample Output 2 No       Sample Input 3 15 1 3 15 13
...#.#...#.#...      Sample Output 3 Yes

Solution (Python):
N, A, B, C, D = map(int, input().split())
s = input()

ans = "Yes"

for i in range(A - 1, C):
    if i != 0 and s[i-1:i+1] == "
        ans = "No"
        break

for i in range(B - 1, D):
    if i != 0 and s[i-1:i+1] == "
        ans = "No"
        break


spaceFlg = False
for i in range(max(A, B) - 1, min(C, D)):
    if s[i-1:i+2] == "...":
        spaceFlg = True
        break

if (A - B) * (C - D) < 0 and not spaceFlg:
    ans = "No"

print(ans)

Solution (Python):

N,A,B,C,D = map(int,input().split())
S = input()
def isContinuous(S):
    for i in range(len(S)-1):
        if S[i:i+2] == "
            return True
    return False
def paint(S):
    P = [0] * len(S)
    for i in range(len(S)):
        if S[i] == "
            P[i] = 1
            if i != 0:
                P[i-1] = 1
            if i != (len(S)-1):
                P[i+1] = 1
    return P
if C < D:
    if (not isContinuous(S[A:C])) and (not isContinuous(S[B:D])):
        print ("Yes")
    else:
        print ("No")
else:
    P = paint(S)
    
    
    for i in P[B-1:D]:
        if i == 0:
            print ("Yes")
            exit()
    print ("No")

Solution (Python):
from collections import deque

n, start1, start2, end1, end2 = map(lambda x: int(x) - 1, input().split())
n += 1
if start2 < start1:
    start1, start2 = start2, start1
    end1, end2 = end2, end1
s = list(input())

def bfs(start, end, otherEnd, inBetween=False):
    visited = [False] * n
    visited[start] = True
    q = deque()
    q.append(start)
    while q:
        cur = q.popleft()
        if cur == end:
            s[cur] = '
            return cur
        if inBetween and cur != otherEnd and s[cur - 1] == s[cur + 1] == '.':
            s[cur] = '
            return cur
        for next in (cur + 1, cur + 2):
            if next < n and s[next] == '.' and not visited[next]:
                visited[next] = True
                q.append(next)
    return -1

secondPos = bfs(start2, end2, end1, inBetween=True)
if secondPos == -1:
    print('No')
    exit()
if bfs(start1, end1, end2) == -1:
    print('No')
    exit()
print('Yes' if bfs(secondPos, end2, end1) else 'No')

Solution (Python):

import sys;
import string;
sys.setrecursionlimit(20000) 

import copy
import itertools

from functools import lru_cache







n, a, b, c, d = map(int, input().split())









s = input()









a -= 1
b -= 1
c -= 1
d -= 1

def canswap(s, b, d):
  print("canswap", s, file=sys.stderr)
  for x in range(b, d + 1):
    
    prev = s[x - 1] != '
    curr = s[x] != '
    post = s[x + 1] != '
    print(prev, post, file=sys.stderr)
    if post and prev and curr:
      return True
  return False

def canmove(s, a, c):
  print(s, file=sys.stderr)
  if a + 1 == c:
    return s[a + 1] != '.'
  prev = s[a + 1] != '.'
  for x in range(a + 2, c):
    
    post = s[x] != '.'
    if post and prev:
      return False
    prev = post
      
  return True

def doit():  
  s2 = list(s)
  print(s2, file=sys.stderr)
  s2[a] = 'A'
  s2[b] = 'B'
  print('s2 ', s2, file=sys.stderr)

  res = list(s)
  res[c] = 'A'
  res[d] = 'B'
  print('res', res, file=sys.stderr)
  
  if c < d:
    if not canmove(s2, b, d):
      return False
    s2[b] = '.'
    s2[d] = 'B'
    return canmove(s2, a, c)
  else:
    if not canmove(s2, a, c):
      if not canswap(s2, b, d):
        return False
      else:
        s2[b] = '.'
        return canmove(s2, a, c)
    s2[a] = '.'
    s2[c] = 'A'
    return canmove(s2, b, d)



try:
  print('Yes' if doit() else 'No')
    
except Exception as e:
  print("e", e, file=sys.stderr)

Solution (Python):
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''

from collections import Counter
gi = lambda : list(map(int,input().strip().split()))
n, a, b, c, d = gi()
s = input()
if a > b:
	a, b = b, a
	c, d = d, c
a -= 1
b -= 1
c -= 1
d -= 1
if c <= d:
	temp = s[a:c]
	if "
		print("No")
		exit()
	temp = s[b:d]
	if "
		print("No")
		exit()
	print("Yes")
	exit()
temp = s[a:c]
temp2 = s[max(0, b - 1):d + 2]
if "
	print("No")
	exit()
print("Yes")

Solution (Python):
def spaceinput():
    return list(map(int, input().split(" ")))

def count3(S, l, r):
    for i in range(l, r+1):
        if S[i:i+3] == "...":
            return True
    return False

def is_twocontinusblock(S, l, r):
    for i in range(l,r+1):
        if S[i:i+2] == "
            return True
    return False


N, A, B, C, D = spaceinput()
S = input()
S="A"+S

def solve():
    if is_twocontinusblock(S, A, C-1) or is_twocontinusblock(S, B, D-1):
        return False
    if D < C:
        if count3(S, B-1, D-1):
            return True
        else:
            return False

    return True


if solve():
    print("Yes")
else:
    print("No")

Solution (Python):
N, A, B, C, D = map( int, input().split())
S = input()
check = "Yes"
for i in range(A-1, C-1):
    if S[i] == "
        check = "No"
        break
if check == "Yes":
    for i in range(B-1, D-1):
        if S[i] == "
            check = "No"
            break    
if check == "Yes":
    if C < D:
        pass
    else:
        check = "No"
        B -= 1
        D -= 1
        t = 0
        for i in range(B-1, D+2):
            if S[i] == ".":
                if t <= 1:
                    t += 1
                else:
                    check = "Yes"
                    break
            else:
                t = 0
print(check)

Solution (Python):
def available(start, end, S, step=None):
    if step is not None:    
        S = S[:step] + "
    for i in range(start, end):
        if S[i] == "
            return False, S
    return True, S
    
def overtake(start, end, S):
    for i in range(start, end+1):
        if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
            step = i
            return True, step
    return False, None

N, A, B, C, D = map(int, input().split())
S = "." + input() + "."

if D > C:   
    judge1, S = available(A, C, S)
    judge2, S = available(B, D, S)
    if judge1 and judge2:
        print("Yes")
    else:
        print("No")
else:   
    overtakable, step = overtake(B, D, S)
    if overtakable:   
        judge1, S = available(B, D, S)
        judge2, S = available(A, C, S, step=step)
        if judge1 and judge2:
            print("Yes")
        else:
            print("No")
    else:   
        print("No")

Solution (Python):
n,a,b,c,d = map(int,input().split())
s = input().rstrip()
renzoku_iwa = [0 for i in range(n)]
renzoku_blank = [0 for i in range(n)]
old1 = ""
old2 = ""
for i,tmp in enumerate(s):
	if old1 == tmp:
		if old1 == "." and old2 == ".":
			renzoku_blank[i] = 1
		elif old1 == "
			renzoku_iwa[i] = 1
	old2 = old1
	old1 = tmp

if sum(renzoku_iwa[a-1:c]) == 0 and sum(renzoku_iwa[b-1:d]) == 0:
	if c < d:
		print("Yes")
	else:
		if sum(renzoku_blank[b:min(d+1,len(renzoku_blank))])>=1:
			print("Yes")
		else:
			print("No")
else:
	print("No")

Solution (Python):
N,A,B,C,D = map(int, input().split())
S = input()
S1 = ''

if C < D:
    S1 = S[A-1:D-1]
else:
    S1 = S[A-1:C-1]

fd = S1.find('
if fd != -1:
    print('No')
    exit()

if C < D:
    print('Yes')
    exit()

else:

    S2 = S[B-2:D+1]
    fddot = S2.find('...')

    if fddot == -1:
        print('No')

    else:
        print('Yes')

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()
A -= 1
B -= 1
C -= 1
D -= 1
if A < B and B < D and A < C and S[A] == "." and S[B] == "." and S[C] == "." and S[D] == ".":
    ans = True
else:
    ans = False

if C < B:
    count_x = 0
    for i in range(A, C):
        if S[i] == "
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_x = 0
        for i in range(B, D):
            if S[i] == "
                count_x += 1
            else:
                count_x = 0
            if count_x > 1:
                ans = False
                break
elif C < D:
    count_x = 0
    for i in range(A, D):
        if S[i] == "
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
else:
    count_x = 0
    for i in range(A, C):
        if S[i] == "
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_o = 0
        ans = False
        for i in range(B-1, D+2):
            if S[i] == "
                count_o = 0
            else:
                count_o += 1
            if count_o > 2:
                ans = True
                break
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()
flag = 0
for i in range(A, max(C, D)):
    if S[i-1] == "
        print("No")
        flag = 1
    

if flag == 0:

    if A > B:
        ab = 1
    else:
        ab = 0
    if C > D:
        cd = 1
    else:
        cd = 0

    if ab != cd:
        for i in range(B - 1, min(C, D)):
            if S[i-1] == "." and S[i+1] == "." and S[i] == "." and flag == 0:
                print("Yes")
                flag = 1
            
        if flag == 0:
            print("No")

    else:
        print("Yes")

Solution (Python):
n,a,b,c,d=map(int,input().split())
s=input()
if (c<d):
	if not '
	else: print('No')
elif (d<c):
	if (not '
	else: print('No')

Solution (Python):
N, A, B, C, D = map(int,input().split())
S = input()

pres = 'x'          
cntx, cnty = 0, 0   
mxx, mxy = 1, 1     

for i in range(A-1, max(C, D)): 
    if S[i] == pres:
        if S[i] == '.':
            cntx += 1
            if i >= B and i < D+1:  
                mxx = max(cntx, mxx)
        elif S[i] == '
            cnty += 1
            if C > B or (i < C and i >= B-1):   
                mxy = max(cnty, mxy)
    else:
        pres = S[i]
        if S[i] == '.':
            cntx = 1
        elif S[i] == '
            cnty = 1

if C < D:
    if mxy < 2:
        print("Yes")
    else:
        print("No")
else:
    if mxy < 2 and mxx >= 3:
        print("Yes")
    else:
        print("No")

Solution (Python):
n, a, b, c, d = (int(i) for i in input().split())  
s = str(input())
n = len(s)

m = max([c, d])
if n>m:
    n = m
    s = s[:n]
    
if '
    print('No')
elif b>c:
    print('Yes')
else:
    if c>d:
        if '...' in s[b-2:d+1]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Solution (Python):
N,A,B,C,D = map(lambda x: int(x)-1,input().split())
S = input()

def obs(st,end):
  for i in range(st,end):
  	if S[i] is "
  return False

if obs(B,D) or obs(A,C):
  print("No")
elif C > D:
  b = False
  for i in range(B-1,min(D,N-2)):
    if S[i] is "." and S[i+1] is "." and S[i+2] is ".":
      b = True
      break
  if b:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")

Solution (Python):
from sys import stdin, exit

N, A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
for k in range(A - 1, max(D, C)):
    if S[k] == '
        print('No')
        exit()

if C < D:
    print('Yes')
else:
    cnt = 0
    for k in range(B - 2, D + 1):
        if S[k] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            exit()
    print('No')

Solution (Python):
N,A,B,C,D=map(int,input().split())
S=input()
check=1
def check_double(S,L,R):
    count=1
    for i in range(L-1,R-1):
        if S[i]=="
            count=0
    return count
def check_triple(S,L,R):
    count=0
    for i in range(L-1,R):
        if S[i-1]=="." and S[i]=="." and S[i+1]==".":
            count=1
    return count
if C>D:
    check=check*check_double(S,A,B)*check_triple(S,B,D)*check_double(S,D,C)
else:
    check=check*check_double(S,A,B)*check_double(S,B,D)
if check==1:
    print("Yes")
else:
    print("No")

Solution (Python):
N,A,B,C,D =list(map(int,input().split()))
s=input()

if "
  print("No")
  quit()
st,e=0,0

for spl in s.split("
  e += (len(spl)+2)
  if st <A<max(C,D)<=e:
    break
  st+= (len(spl)+2)

if "..." in s[B-2:min(C,D)+1] or B<C<D:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    n, a, b, c, d = map(int, raw_input().split())
    s = '
    f = 0
    for i in xrange(b, d):
        if s[i] == '
            print 'No'
            return
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            f = 1
    for i in xrange(a, c):
        if s[i] == '
            print 'No'
            return
    if c > d:
        if s[b-1] == '.' and s[b+1] == '.':
            f = 1
        if not f:
            print 'No'
            return
    print 'Yes'
main()

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = input()

if c < d:
    if ('
        print('No')
    else:
        print('Yes')

else:
    if '
        print('No')
    elif '...' in s[b-2:d+1]:
        print('Yes')
    else:
        print('No')

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()	

if "
	print("No")
elif "
	print("No")
elif D < C:	
	if not "..." in S[B-2:D+1]:
		print("No")
	else:
		print("Yes")
else:
	print("Yes")

Solution (Python):
N, A, B, C, D = map(int, input().split())
s = list(input())

sunuke = ""
hunuke = ""


if C > D:
    k = ''.join(s[B-2:D+1])
    result = "..." in k
    if result == 0:
        print("No")
        exit()

while B <= D:
    if s[B] == ".":
        B += 1
        if B == D:
            hunuke = "ok"
            break
    elif s[B+1] == ".":
        B += 2
        if B == D:
            hunuke = "ok"
            break
        elif B > D:
            print("No")
            exit()
    else:
        print("No")
        exit()

while A <= C:
    if s[A] == ".":
        A += 1
        if A == C:
            sunuke = "ok"
            break
    elif s[A+1] == ".":
        A += 2
        if A == C:
            sunuke = "ok"
            break
        elif A > C:
            print("No")
            exit()
    else:
        print("No")
        exit()

if sunuke == "ok" and hunuke == "ok":
    print("Yes")
else:
    print("No")

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()
if "
  print("No")

elif C < D:
  print("Yes")

else:
  if "..." in S[B-2:D+1]:
    print("Yes")
  else:
    print("No")

Solution (Python):
n,a,b,c,d = map(int,input().split())
path = list(input())
path = ['.']+path
path[a] = 'a'
path[b] = 'b'
while(a<c or b<d):
    walk = 0
    if c<d:
        if b != d:
            if b+2<=d and path[b+2]!='
                path[b]='.'
                path[b+2] ='b'
                b+=1
                walk = 1
            if path[b+1]!='
                path[b]='.'
                path[b+1] ='b'
                b+=1
                walk = 1
        if not walk:
            if a!=c:
                if path[a+1]!='
                    path[a]='.'
                    path[a+1] ='a'
                    a+=1
                    walk = 1
                if a+2<=c and path[a+2]!='
                        path[a]='.'
                        path[a+2] ='a'
                        a+=2
                        walk = 1
    else :
        if a + 2 <= c and path[a + 2] != '
            path[a] = '.'
            path[a + 2] = 'a'
            a += 2
            walk = 1
        if a!=c:
            if path[a+1]!='
                path[a]='.'
                path[a+1] ='a'
                a+=1
                walk = 1
        if not walk:
            if b != d:
                if path[b+1]!='
                    path[b]='.'
                    path[b+1] ='b'
                    b+=1
                    walk = 1
                elif b+2<=d and path[b+2]!='
                    path[b]='.'
                    path[b+2] ='b'
                    b+=2
                    walk = 1
    if walk==0:
        break
if a==c and b==d:
    print('Yes')
else:
    print('No')

Solution (Python):

import sys

[N, A, B, C, D] = [int(i) for i in input().split()]

S = input()


minimum = min([A, B])
maximum = max([C, D])
S_split = S[minimum-1:maximum].split('.')

max_length = 0
for s in S_split:
    if len(s) > max_length:
        max_length = len(s)

if max_length >= 2:
    print('No')
    sys.exit()




if C < D:
    print('Yes')
    sys.exit()


if S[D-2] == '
    
    if '...' in S[B-2:D]:
        print('Yes')
        sys.exit()
    elif A + 1 == B and S[B] == '.':
        print('Yes')
        sys.exit()
    print('No')
    sys.exit()

print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline

listA=list(map(int,input().split()))

kenken_map = input()

A_init = listA[1]-1
B_init = listA[2]-1
A_goal = listA[3]-1
B_goal = listA[4]-1

kenken_temp_b = kenken_map[B_init:B_goal+1]
kenken_temp_b_i = kenken_map[B_init-1:B_goal+1]
kenken_temp_b_goal = kenken_map[:B_goal] + '
kenken_temp = kenken_temp_b_goal[A_init:A_goal+1]


if '
    print('No')
elif not '
    print('Yes')
elif '...' in kenken_temp_b_i:
    print('Yes')
else:
    print('No')

Solution (Python):
def solve():
	if C<D:
		cnt = 0
		for i in range(A, D):
			if S[i:i+1]=='
				cnt += 1
				if cnt>=2:
					print('No')
					return
			else:
				cnt = 0
		print('Yes')
		return

	if C<B:
		cnt = 0
		for i in range(A, C):
			if S[i:i+1]=='
				cnt += 1
				if cnt>=2:
					print('No')
					return
			else:
				cnt = 0
		cnt = 0
		for i in range(B, D):
			if S[i:i+1]=='
				cnt += 1
				if cnt>=2:
					print('No')
					return
			else:
				cnt = 0
		print('Yes')
		return

	cnt = 0
	for i in range(A, C):
		if S[i:i+1]=='
			cnt += 1
			if cnt>=2:
				print('No')
				return
		else:
			cnt = 0
	cnt = 0
	for i in range(B-2, D+1):
		if S[i:i+1]=='.':
			cnt += 1
			if cnt>=3:
				print('Yes')
				return
		else:
			cnt = 0
	print('No')
	return

N, A, B, C, D = map(int, input().split())
S = input()
solve()

Solution (Python):
n,a,b,c,d = map(int, input().split())
s="a"
s+=input()

    
ans="Yes"
for i in range(a,max(c,d)-1):
  if s[i]=="
    ans="No"

if ans=="No":
  print(ans)
else:
  if c < d:
    print(ans)
  else:
    ans="No"
    for i in range(b-1,d):
      if s[i]=="." and s[i+1]=="." and s[i+2]==".":
        ans="Yes"
    print(ans)

Solution (Python):
n,a,b,c,d=map(int,input().split())
s=list(input())
if c<d:
  f=0
  for i in range(b,d-1):
    if s[i]=='
      f=1
      break
  if f==0:
    for i in range(a,c-1):
      if s[i]=='
        f=1
        break
  if f==1:print('No')
  else:print('Yes')
else:
  f=0
  for i in range(b,d-1):
    if s[i]=='
      f=1
      break
  if f==0:
    for i in range(a,c-1):
      if s[i]=='
        f=1
        break
  if f==0:
    if (s[d-2]=='
      ct=0
      for i in range(b-1,d-2):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
          ct+=1
          break
      if ct==0:
        f=1
  if f==1:print('No')
  else:print('Yes')

Solution (Python):
n,a,b,c,d=map(int,input().split())
s=input()
if "
  print("No")
else:
  if c<d:
    print("Yes")
  else:
    if "..." in s[b-2:d+1]:
      print("Yes")
    else:
      print("No")

Solution (Python):



import sys

N, A, B, C, D = map(int, input().rstrip().split())
S = [x for x in input()]

if A < B and B < D and D < C:
    chain_rock = 0
    if S[B-2] == '.':
        chain_empty = 1
    else:
        chain_empty = 0
    max_chain_empty = 0
    for i in range(B-1, D):
        if S[i] == '.':
            chain_empty += 1
            chain_rock = 0
        else:
            chain_empty = 0
            chain_rock += 1
            
        max_chain_empty = max(max_chain_empty, chain_empty)
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
    if max_chain_empty < 3:
        if not (S[D-2] == '.' and S[D] == '.'):
            print('No')
            sys.exit()
            
    chain_rock = 0
    for i in range(A, C):
        if S[i] == '
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
else:
    chain_rock = 0
    for i in range(A, C):
        if S[i] == '
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
    chain_rock = 0
    for i in range(B, D):
        if S[i] == '
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()

print('Yes')

Solution (Python):
N,A,B,C,D = map(int,input().split())
S = input()
sunuke = A
hunuke = B

def syori1(sunuke,hunuke):
    while hunuke<D:
        if hunuke+1 == N:
            return "Yes"
        if S[hunuke+1] == ".":
            hunuke += 2
        elif S[hunuke] == ".":
            hunuke += 1
        else:
            return "No"
    
    while sunuke<C:
        if sunuke + 1 == N:
            return "Yes"
        if S[sunuke+1] == ".":
            sunuke += 2
        elif S[sunuke] == ".":
            sunuke += 1
        else:
            return "No"
    
    return "Yes"

def canover():
    for i in range(B-2,D-1):
        if S[i] == "." and S[i+1] == "." and S[i+2]==".":
            return True
        else:
            pass
    return False
    
def tonari():
    if S[B]==".":
        return True
    else:
        return False

if C > D:
    if A+1 == B:
        if tonari():
            print(syori1(sunuke,hunuke))
            exit()
            
    if canover():
        print(syori1(sunuke,hunuke))
    else:
        print("No")
else:
    print(syori1(sunuke,hunuke))

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = input()
j = 0
flag = False
fflag = False

if '
  flag = True

for i, k in enumerate(s):
  if k == '.':
    j += 1
  else:
    if j >= 3 and i - j + 1 < d and b < i:
      flag = True
    if s[i-1] == '
      fflag = True
    j = 0

if j >= 3 and len(s) - j + 1 < d:
  flag = True
    
if fflag:
  print('No')
else:
  if c > d and flag:
    print('Yes')
  elif c < d:
    print('Yes')
  else:
    print('No')

Solution (Python):
N,A,B,C,D = map(int,input().split())
S = list(input())


if C < D:
    if ''.join(S[A:C]).find('
        print('Yes')
    else:
        print('No')
        

else:
    if ''.join(S[A:C]).find('
        print('Yes')
    else:
        print('No')

Solution (Python):
N, A, B, C, D = map(int,input().split())
S = list(input())

switch = 0

S_before_a = S.copy()
S_before_a[B-1] ='
A_list = S_before_a[A:C-1]
count1 = 0
for i in range (len(A_list)-1):
    if ''.join(A_list[i:i+2])=='
        count1+=1

S_after_a = S.copy()
S_after_a[C-1]='

count2 = 0
B_list = S_after_a[B:D-1]
for i in range (len(B_list)-1):
    if ''.join(B_list[i:i+2])=='
        count2+=1
    

S_before_b = S.copy()
S_before_b[A-1] ='
B_list = S_before_b[B:D-1]
count3 = 0
for i in range (len(B_list)-1):
    if ''.join(B_list[i:i+2])=='
        count3+=1

S_after_b = S.copy()
S_after_b[D-1]='

count4 = 0
A_list = S_after_b[A:C-1]
for i in range (len(A_list)-1):
    if ''.join(A_list[i:i+2])=='
        count4+=1
        
change_counter =0
changer = S[max(A,B)-1:min(C,D)]
for i in range(len(changer)-2):
    if ''.join(changer[i:i+3])=='...':
        change_counter+=1
        
if (count1+count2) == 0 or (count3+count4) ==0:
    print('Yes')
elif (count1 == 1 and change_counter>0 ) or (count2 == 1 and change_counter>0 ) or (count3 == 1 and change_counter>0 ) or (count4 == 1 and change_counter>0 ):
    print('Yes')
else:
    print('No')

Solution (Python):
n,A,B,C,D = map(int,input().split())
s = input()[A-1:max(C,D)]
flag = 1
a,b,c,d = 0,B-A,C-A,D-A
if s[a]=='
  flag = 0
if bool('
  flag = 0
if c > d:
  scut = s[b-1:d+2]
  if bool('...' in scut) == 0:
    flag = 0
if flag == 1:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys
input = sys.stdin.readline

N,A,B,C,D=map(int,input().split())
S=input().strip()
S+="

A-=1
B-=1
C-=1
D-=1

if C<D:
    while B!=D or  A!=C:
        
        if B!=D and S[B+1]==".":
            B+=1
        elif B!=D and S[B+2]==".":
            B+=2
        elif B!=D and S[B+1]=="
            print("No")
            sys.exit()


        if A!=C and S[A+1]==".":
            A+=1
        elif A!=C and S[A+2]==".":
            A+=2
        elif A!=C and S[A+1]=="
            print("No")
            sys.exit()

    print("Yes")

else:
    while A<B:
            
        if S[A+1]=="." and A+1!=B:
            A+=1
        elif S[A+2]=="." and A+2!=B:
            A+=2
        elif S[A+1]=="
            print("No")
            sys.exit()

        if A+1==B or (A+2==B and S[A+1]=="
            break

    while True:
        if A+1==B and S[B+1]==".":
            A+=2
            break

        if S[B+1]==".":
            B+=1
        elif S[B+2]==".":
            B+=2
        else:
            print("No")
            sys.exit()

        if S[A+1]==".":
            A+=1
        elif S[A+2]==".":
            A+=2

        if B>D:
            print("No")
            sys.exit()

    
    while B!=D or  A!=C:
        
        if A!=C and S[A+1]==".":
            A+=1
        elif A!=C and S[A+2]==".":
            A+=2
        elif A!=C and S[A+1]=="
            print("No")
            sys.exit()
            
        if B!=D and S[B+1]==".":
            B+=1
        elif B!=D and S[B+2]==".":
            B+=2
        elif B!=D and S[B+1]=="
            print("No")
            sys.exit()




    print("Yes")

Solution (Python):
n,a,b,c,d =map(int,input().split())
s=list(input())

i=0
j=0
gg=0
nnt=0
if c<d:
    i=a-1
    while i!=d:
        if s[i]=="
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break
        i=i+1

else:
    i=a-1
    nnt=1
    while i!=c-1:

        if s[i]==".":
            gg=gg+1
        else:
            gg=0
        if gg>=3:
            if i>=b:
                if i<=d:
                    nnt=0




        if s[i]=="
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break

        i=i+1
if nnt==0:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
NABCD = list(map(int,input().split()))
N = NABCD[0]
A = NABCD[1]
B = NABCD[2]
C = NABCD[3]
D = NABCD[4]
S = input()

output = "No"

cous = 0
maxs = 0
cour = 0
maxr = 0
maxi = np.array([])
maxir = np.array([])

for i in range(N):
    p = S[i]
    if p == "
        cour += 1
        cous = 0
    elif p == ".":
        cous += 1
        cour = 0
    if cour > maxr:
        maxr = cour
    if cous > maxs:
        maxs = cous
    if cous > 2:
        maxi = np.append(maxi,i+1)
    if cour >= 2:
        maxir = np.append(maxir,i+1)

keysum = sum((maxi-1>=B)*(maxi-1<=D))
outsumA = sum((A<maxir)*(maxir<C))
outsumB = sum((B<maxir)*(maxir<D))
outsum = outsumA + outsumB
if C > D:
    if (maxr < 2)and(maxs >2)and(keysum>0):
        output = "Yes"
    elif (maxr >= 2)and(outsum==0)and(maxs >2)and(keysum>0):
        output = "Yes"
elif D > C:
    if maxr < 2:
        output = "Yes"
    elif (maxr >= 2)and(outsum==0):
        output = "Yes"

print(output)

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = list(input())

ans = "Yes"
if any(map(lambda i: s[i] == s[i + 1] == '
    ans = "No"
if any(map(lambda i: s[i] == s[i + 1] == '
    ans = "No"
if d < c and not any(map(lambda i: b <= i + 1 <= d, list(filter(lambda i: s[i - 1] == s[i] == s[i + 1] == '.', range(1, n - 1))))):
    ans = "No"

print(ans)

Solution (Python):
import sys
import copy

def solve(n, a, b, c, d, s):
    if c < d:
        if b < c:
            width = [(a-1, d-1)]
        else:
            width = [(a-1, c-1), (b-1, d-1)]

        for left, right in width:
            for i in range(left, right):
                if s[i] == "
                    return "No"
        return "Yes"
    else:
        flag = False
        for i in range(a-1, c-1):
            if s[i] == "
                return "No"
            if b - 2 <= i <= d - 2 and s[i] == "." and s[i+1] == "." and  s[i+2] == "." :
                flag = True
        return "Yes" if flag else "No"


if __name__ == '__main__':

    n, a, b, c, d = map(int, sys.stdin.readline().strip().split(" "))
    s = sys.stdin.readline().strip()
    print solve(n, a, b, c, d, s)

Solution (Python):
import sys

def chk(p,q):
    if q==p+1: return 1
    else:
        for i in range(p,q-1):
            if s[i]+s[i+1]==2: return 0

        return 1


N,A,B,C,D=map(lambda x: int(x)-1,input().split())
N+=1
S=input()
s=[]
for i in range(N):
    if S[i]==".": s.append(0)
    else: s.append(1)

if chk(A,C)==0 or  chk(B,D)==0: print("No"),sys.exit()
if C<B or C<D: print("Yes"),sys.exit()



for i in range(B,D+1):
    if s[i-1]+s[i]+s[i+1]==0: print("Yes"),sys.exit()

print("No")

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()

S = S[min(A, B)-1:max(C, D)]
if "
    print("No")
else:
    if "..." in S:
        S_b = S[B-2:min(D+1, N)]
        if "..." in S_b:
            print("Yes")
        else:
            print("No")
    else:
        if C < D:
            print("Yes")
        else:
            print("No")

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()

if C < B:
    if S[A-1:C-1].find("
        print("Yes")
    else:
        print("No")
elif D > C :
    if S[A-1:D-1].find("
        print("Yes")
    else:
        print("No")
else:
    if S[A-1:C].find("
        print("Yes")
    else:
        print("No")

Solution (Python):

n, a, b, c, d = map(int, input().split())
s = input()
grid = []
for rock in s:
    grid.append(rock == '

if grid[c-1] or grid[d-1]:
    print('No')

max_rock_count = 0
rock_count = 0
if c < d:
    for i in range(a-1, d):
        if grid[i]:
            rock_count += 1
        else:
            rock_count = 0

        max_rock_count = max(max_rock_count, rock_count)

    if max_rock_count >= 2:
        print('No')
    else:
        print('Yes')
elif c > d:
    max_rock_count = 0
    rock_count = 0
    canSkip = False
    for i in range(a-1, c):
        if grid[i]:
            rock_count += 1
        else:
            if b - 1 <= i and i <= c - 2 and not grid[i-1] and not grid[i] and not grid[i+1]:
                if i-1 != d - 1:
                    canSkip = True
            rock_count = 0

        max_rock_count = max(max_rock_count, rock_count)

    if max_rock_count <= 1 and canSkip:
        print('Yes')
    else:
        print('No')