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())

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

s = input()
s += '

def check(x,y):
    while x<y:
        if s[x+1]=='.':
            x += 1
        elif s[x+1]=='
            if s[x+2]=='
                return False
            x += 2
    if x==y:
        return True
    else:
        return False


def overtake(x,y):
    while x<n and y<n and x<y:
        if s[x+1] == '.' and y-x!=1:
            x += 1
        elif s[x+2] == '.' and y-x!=2:
            x += 2
        elif s[y+1] == '.':
            y += 1
        elif s[y+2] == '.':
            y += 2
        else:
            return None, None
    if y<x:
        return x,y
    else:
        return None,None
            
            
            

if c<d:
    if check(b,d) and check(a,c):
        print('Yes')
    else:
        print('No')
else:
    a, b = overtake(a,b)
    if a is None:
        print('No')
    elif check(b,d) and check(a,c):
        print('Yes')
    else:
        print('No')

Solution (Python):
n,a,b,c,d = map(int, input().split())
S = input()
if "
  print('No')
elif c > d and "..." not in S[b-2:min(c,d)+1]:
  print('No')
else:
  print("Yes")

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

if '
  ng=True
if (not ng) and (B<C and D<C):
  if '...' in S[B-1:D+1]: pass
  elif S[B-2:B+1]=='...' and A<=B-1: pass
  else: ng = True

if ng: print('No')
else: print('Yes')

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

if C < D:
    S_cut = S[A-1:D]
    num = S_cut.count("
    
    if num > 0:
        print("No")
    else:
        print("Yes")

else:
    S_cut1 = S[A-1:C]
    
    flg1 = (S_cut1.count("
    S_cut2 = S[max(0,B-2):D+1]
    
    
    flg2 = (S_cut2.count("...")>=1)
    if flg1 and flg2:
        print("Yes")
    else:
        print("No")

Solution (Python):
def q1():
    _, A, B, C, D = [int(x) - 1 for x in input().split(' ')]
    S = input()
    if "
        return False
    if C < D:
        return True
    for b in range(B, D + 1):
        if S[b] == '
            continue
        if (S[b - 1] != "
            return True
    return False

print('Yes' if q1() else 'No')

Solution (Python):
N, A, B, C, D = map(int, input().split())
 
S = input()
 
S = S + '
 
def continuous_rock_search(S, A, B, C, D):
    begin = min(A, B)
    target = max(C, D)
    for i in range(begin, target - 1):
        if S[i] == '
            return True
    return False
  
def validation_funuke_move(S, B, D):
    '''
    ふぬけ君が両隣に岩がなくなるまで移動したとき、Dより向こうにはイカないことを確認する。
    True/False and ふぬけの移動後の位置
    '''
    funuke_position = B
    while (B <= D):
        if (S[B-2] == '
            if S[B] == '.' :
                B = B + 1
            else:
                B = B + 2
        elif (S[B-2] == '.' and S[B] == '.'):
            return True, B
    
    return False, -1
  
def KenKenRace(S, A, B, C, D):
    if continuous_rock_search(S, A, B, C, D):
        return False
    
    if C < D:
        return True
    
    if D < C:
        valid , _ = validation_funuke_move(S, B, D)
        if valid:
            return True
        else:
            return False
          
if KenKenRace(S, A, B, C, D):
    print('Yes')
else:
    print('No')

Solution (Python):
N,A,B,C,D = map(int,input().split())
s = input()
State = "Yes"
for i in range(B-1,D-1):
    if s[i] == "
        State = "No"
        break
if C < D:
    for i in range(A-1,C-1):
        if s[i] == "
            State = "No"
            break
elif State == "Yes":
    State = "No"
    for i in range(B-2,D-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            State = "Yes"
            break
    for i in range(D-1,C-1):
        if s[i] == "
            State = "No"
            break
    for i in range(A-1,B-1):
        if s[i] == "
            State = "No"
            break
print(State)

Solution (Python):
N,A,B,C,D = map(int,input().split())
s = input()
if ('
    print('No')
else:
    if C > D:
        if '...' in s[B-2:D+1]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Solution (Python):
import sys

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

for i in range(B,D-2):
	if S[i]=="
		print("No")
		sys.exit()


for i in range(A,C-2):
	if S[i]=="
		print("No")
		sys.exit()

if D<C:
	for i in range(B-1,D):
		if S[i-1]=="." and S[i+1]=="." and S[i]==".":
			print("Yes")
			sys.exit()
	print("No")
else:
	print("Yes")

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


if c < d:
  
  if c < b:
    for i in range(a, c-1):
      if s[i+1] == '
        print("No")
        exit()
    for i in range(b, d-1):
      if s[i+1] == '
        print("No")
        exit()
  
  else:
    for i in range(b, d-1):
        if s[i+1] == '
            print("No")
            exit()
    for i in range(a, c-1):
        if s[i+1] == '
            print("No")
            exit()
  print("Yes")
  

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

Solution (Python):
n, a, b, c, d = [int(item) for item in input().strip().split(" ")]
s = input().strip()

def h(a,b,c,d,s):
    if "
        return False
    if "
        return False
    if c < d:
        return True
    if "..." in s[b-2:d+1]:
        return True
    return False

if h(a,b,c,d,s):
    print("Yes")
else:
    print("No")

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

a -= 1
b -= 1
c -= 1
d -= 1
is_arrive = True
for i in range(len(s)-1):
  if s[i]+s[i+1] == '
    if a < i < c-1:
      is_arrive = False
      break
    elif b < i < d-1:
      is_arrive = False
      break

if is_arrive:
  if (a < b and c < d) or (a > b and c > d):
    print('Yes')
  else:
    if c < d:
      while b < d:
        if s[b + 1] == '
          if b + 2 == a:
            if s[a + 1] == '
              a += 2
              b += 2
            else:
              a += 1
              b += 2
          else:
            b += 2
        elif s[b + 2] == '
          if b + 1 == a:
            a += 2
            b += 1
          else:
            b += 1
        elif b + 1 == a:
          if s[a + 1] == '
            a += 2
            b += 1
          else:
            b += 2
        else:
          b += 1
      if a > c:
        print('No')
      else:
        print('Yes')
    elif d < c:
      while a < c:
        if s[a + 1] == '
          if a + 2 == b:
            if s[b + 1] == '
              b += 2
              a += 2
            else:
              b += 1
              a += 2
          else:
            a += 2
        elif s[a + 2] == '
          if a + 1 == b:
            b += 2
            a += 1
          else:
            a += 1
        elif a + 1 == b:
          if s[b + 1] == '
            b += 2
            a += 1
          else:
            a += 2
        else:
          a += 1
      if b > d:
        print('No')
      else:
        print('Yes')
else:
  print('No')

Solution (Python):
import sys
from collections import defaultdict

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

s='_'+input()

ans=['Yes','No']



def CanGo(x,y):
    cnt=0
    root=s[x:y]
    for c in root:
        if c=='
            cnt+=1
        elif c=='.':
            if cnt>2:
                return False
            cnt=0
    return True


def CanPass(x,y):  
    root=s[x-1:y+2]
    '''
    q=s[x-1:x+2]
    print(root,q)
    print(root,len(root)-3+1)
    for i in range(len(root)-3+1):
        if q=='...':
            return True
        q=q[1:3]+s[x+3+i]
    '''
    if root.find('...')!=-1:
        return True
    return False
        


if c<d:
    if CanGo(b,d) and CanGo(a,c):
        ai=0
    else:
        ai=1
elif c>d:
    if CanGo(b,d) and CanGo(a,c) and CanPass(b,d):
        ai=0
    else:
        ai=1
    
    

print(ans[ai])

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

Sstr=input()


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

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

if "
  ans = "No"
elif C < D:
  ans = "Yes"
else:
  if "..." in S[B-2:D+1]:
    ans = "Yes"
  else:
    ans = "No"

print(ans)

Solution (Python):

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


jumpable = 1
for i in range(A, max(D, C)-1):
    if S[i]=="
        jumpable = 0
        break;


if(D<C):
    changable = 0
    for i in range(B-2, D-1):
        if S[i]=="." and S[i+1]=="." and S[i+2]==".":
            changable=1
            break
    if(changable==0):
        jumpable=0

if(jumpable==0):
    print("No")
else:
    print("Yes")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    if C < D:
        flag_d = False
        for i in range(A+1, D-1):
            if S[i:i+2] == '
                flag_d = True
                break

        if flag_d:
            print(NO)
        else:
            print(YES)


    elif D < C:
        flag_d = False
        for i in range(A+1, C-1):
            if S[i:i+2] == '
                flag_d = True
                break

        flag_c = False
        for i in range(B-2, D-2):
            if S[i:i+3] == '...':
                flag_c = True
                break

        if flag_d:
            print(NO)
        else:
            if flag_c:
                print(YES)
            elif S[D-2] != '
                print(YES)
            else:
                print(NO)


    else:
        raise NotImplementedError





    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    D = int(next(tokens))  
    S = next(tokens)  
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

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

flag = True
isSharp = False
for i in range(A, max(C, D)):
    if S[i] == '
        if isSharp is False:
            isSharp = True
        else:
            flag = False
            break
    else:
        isSharp = False

if D < C:
    cnt = 0
    isCons = False
    for i in range(B-2, D+1):
        if S[i] == '.':
            cnt += 1
            if cnt == 3:
                isCons = True
                break
        else:
            cnt = 0
    if isCons is False:
        flag = False

if flag is True:
    print("Yes")
else:
    print("No")

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

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

ref = 1

if C < D:
    for i in range(B+1, D-1):
        if S[i]=='
            ref = 0
            break
        else:
            continue

    for j in range(A+1, C-1):
        if S[j]=='
            ref = 0
            break
        else:
            continue

    if ref == 1:
        print('Yes')
    else:
        print('No')
        
else:
    ref = 0
    for i in range(B, D+1):
        if S[i-1]=='.' and S[i]=='.' and S[i+1]=='.' : 
            ref = 1
            break
        else:
            ref = 0
    for j in range(A+1, C-1):
        if S[j]=='
            ref = 0
            break
        else:
            continue
    if ref == 1:
        print('Yes')
    else:
        print('No')

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

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

Solution (Python):
import sys

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

lst = [0] * (n+1)
for i in range(1, n+1):
    if s[i-1] == '
        lst[i] = 1

if c < d:
    stone = 0
    for i in range(b+1, d+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    stone = 0
    for i in range(a+1, c+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    print('Yes')
else:
    brank = 0
    three = 0
    for i in range(b-1, c+1):
        if lst[i] == 0:
            brank += 1
            if brank == 3:
                if i-1 <= d:
                    three = 1
                    break
                else:
                    print('No')
                    sys.exit()
        else:
            brank = 0
    if three == 0:
        print('No')
        sys.exit()
    stone = 0
    for i in range(b+1, d+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    stone = 0
    for i in range(a+1, c+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    print('Yes')

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

if c<b:
  if s[a:c].find("
    print("Yes")
  else:
    print("No")
elif s[a:d].find("
  if c<d:
    print("Yes")
  else:
    if s[b-1:d+2].find("...")==-1:
      print("No")
    else:
      print("Yes")
else:
  print("No")

Solution (Python):

"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""


"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect


def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   

def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
    

"""
N, X = map(int, input().split())

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

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())


dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')


ABT = zip(A, B, totAB)
result = 0

sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)


(x >> i) & 1


dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break

add = 1 
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)


li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    


org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)




    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""



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

A = A-1
B = B-1
C = C-1
D = D-1
def main(): 
    if C < D:
        past = True
        now = True
        for i in range(B, D):
            if S[i] == ".":
                now = True
            else:
                now = False
            
            if now == False and past ==False:
                return print("No")
            else:
                pass
            past = now
            
        past = True
        now = True
        for i in range(A, C):
            if S[i] == ".":
                now = True
            else:
                now = False
            
            if now == False and past ==False:
                return print("No")
            else:
                pass
            past = now
        return print("Yes")
    else:
        past = True
        now = True
        for i in range(A, C):
            if S[i] == ".":
                now = True
            else:
                now = False
            
            if now == False and past ==False:
                return print("No")
            else:
                pass
            past = now
                
        past2 = False
        past1 = False
        now   = True
        flg   = False
        
        if S[B-1] == "." and S[B] == "." and S[B+1] ==".":
            flg = True
        
        for i in range(B, D+1):
            if S[i] == ".":
                now = True
            else:
                now = False
            if now == True and past1 ==True and past2 == True:
                flg = True
            else:
                pass
            past2 = past1
            past1 = now
        if S[D-1] == "." and S[D+1] == ".":
            flg = True
        if flg == True:
            return print("Yes")        
        else:
            return print("No")
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Solution (Python):
import sys


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

if C < D:
    cnt_x = 0
    for pos in range(B - 1, D):
        Si = S[pos]
        if Si == '
            cnt_x += 1
            if cnt_x > 1:
                print('No')
                sys.exit()
        else:
            cnt_x = 0
    else:
        S[pos] = '
    
    cnt_x = 0
    for pos in range(A - 1, C):
        Si = S[pos]
        if Si == '
            cnt_x += 1
            if cnt_x > 1:
                print('No')
                sys.exit()
        else:
            cnt_x = 0
else:
    cnt_o = cnt_x = 0
    for pos in range(A - 1, D):
        Si = S[pos]
        if Si == '
            cnt_o = 0
            cnt_x += 1
            if cnt_x > 1:
                print('No')
                sys.exit()
        else:
            cnt_x = 0
            cnt_o += 1
            if pos >= B and cnt_o > 2:
                pos_fnk = pos - 1
                break
    else:
        pos_fnk = pos
    
    S[pos_fnk] = '
    
    cnt_x = 0
    for pos in range(A - 1, C):
        Si = S[pos]
        if Si == '
            cnt_x += 1
            if cnt_x > 1:
                print('No')
                sys.exit()
        else:
            cnt_x = 0
    else:
        S[pos] == '
    S[pos_fnk] = '.'
    
    cnt_x = 0
    for pos in range(pos_fnk, D):
        Si = S[pos]
        if Si == '
            cnt_x += 1
            if cnt_x > 1:
                print('No')
                sys.exit()
        else:
            cnt_x = 0

print('Yes')

Solution (Python):

n, a, b, c, d = map(lambda x: int(x) - 1, input().split())
s = list(input())

if d < c:
    s[b] = 'b'
    while a < b:
        if a + 1 <= c and s[a + 1] == '.':
            a += 1
        elif a + 2 <= c and s[a + 2] == '.':
            a += 2
        elif b < d:
            if b + 1 <= d and s[b + 1] == '.':
                s[b] = '.'
                s[b + 1] = 'b'
                b += 1
            elif b + 2 <= d and s[b + 2] == '.':
                s[b] = '.'
                s[b + 2] = 'b'
                b += 2
            else:
                print('No')
                exit()
        else:
            print('No')
            exit()
    a, b = b, a
    c, d = d, c
while b < d:
    if b + 1 <= d and s[b + 1] == '.':
        b += 1
    elif b + 2 <= d and s[b + 2] == '.':
        b += 2
    else:
        print('No')
        exit()
while a < c:
    if a + 1 <= c and s[a + 1] == '.':
        a += 1
    elif a + 2 <= c and s[a + 2] == '.':
        a += 2
    else:
        print('No')
        exit()
print('Yes')

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

flag = True


s_bd = s[b:d-1]
for i in range(len(s_bd)-1):
    if s_bd[i:i+2] == "
        flag = False
        break
s_ac = s[a:c-1]
for i in range(len(s_ac)-1):
    if s_ac[i:i+2] == "
        flag = False
        break

if c > d:
    
    if s[d-2] == "
        s_bd = s[b-2:d]
        has_ddd = False
        for i in range(len(s_bd)-2):
            if s_bd[i:i+3] == "...":
                has_ddd = True
        if has_ddd == False:
            flag = False

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

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,a,b,c,d = na()
s = ns()

a-=1
b-=1
c-=1
d-=1
fla = 0
flb = 0
dou = True
tri = False if d < c else True

for i in range(a+1,max(c,d)+1):
    if c < i and i < b:
        continue
    if s[i] == '.':
        fla = 0
        flb += 1
    else:
        fla += 1
        flb = 0
    if fla >= 2:
        dou = False
    if flb >= 3 and i >= b+1 and i <= d+1:
        tri = True

if dou and tri:
    print('Yes')
else:
    print('No')

Solution (Python):
from sys import stdin

n, a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()





ans = "Yes"

rock = 0
for i in range(a, c):
    if '
        rock += 1
        if rock >= 2:
            ans = "No"
            break
    else:
        rock = 0

rock = 0
for i in range(b, d):
    if '
        rock += 1
        if rock >= 2:
            ans = "No"
            break
    else:
        rock = 0


space = 0
if d < c:
    ok = 0
    for i in range(b-1, d+1):
        if '.' == s[i-1]:
            space += 1
            if space >= 3:
                ok = 1
                break
        else:
            space = 0
    if '.' == s[d-1-1] and '.' == s[d+1-1]:
        ok = 1
    if '.' == s[d-1-1] and '.' == s[d-2-1]:
        ok = 1
    if '.' == s[b-1-1] and '.' == s[b+1-1]:
        ok = 1
    if '.' == s[b+1-1] and '.' == s[b+2-1]:
        ok = 1
    if 0 == ok:
        ans = "No"

print(ans)

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

import sys




if S[A:max(C,D)-1].count("
    print("No")
    sys.exit()
if C > D:
    if not S[B-2:D+1].count("..."):
        
        print("No")
        sys.exit()
print("Yes")

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n,a,b,c,d = readmi()

s = read()
s = deque(s)
s.appendleft('.')

flg = True 
if c > d:
    flg = False 
flg2 = False
aflg = False
bflg = False

while(1):
    t = 0
    if flg:
        if b + 1 <= n and s[b + 1] != '
            t = 1
        elif s[b + 2] != '
            t = 2
        else:
            bflg = True
            flg = False
            flg2 = True
        b += t
        if b == d:
            bflg = True
            flg = False
            flg2 = True
    else:
        if not(flg):
            if not(flg2):
                if b != d:
                    if b + 1 <= n and s[b - 1] == '.' and s[b + 1] == '.' and not(bflg) and not(aflg):
                        flg2 = True
                    else:
                        if b + 1 <= n and s[b + 1] != '
                            t = 1
                        elif b + 2 <= n and s[b + 2] != '
                            t = 2
                        else:
                            bflg = True
                            flg2 = True
                b += t
                if b == d:
                    bflg = True
                    flg2 = True
            else:
                if a != c:
                    if a + 1 <= n and s[a + 1] != '
                        t = 1
                    elif a + 2 <= n and s[a + 2] != '
                        t = 2
                    else:
                        aflg = True
                        flg2 = False
                a += t
                if a == c:
                    aflg = True
                    flg2 = False
    if aflg and bflg:
        if a == c and b == d:
            print('Yes')
        else:
            print('No')
        exit()

Solution (Python):
def main():
    inp = input()
    st = inp.split()
    n = int(st[0])
    a = int(st[1])
    b = int(st[2])
    c = int(st[3])
    d = int(st[4])
    inp = input()
    
    rock_count = 0
    for i in range(a, b):
        if inp[i] == '
            rock_count += 1
        elif inp[i] == '.':
            rock_count = 0
        if rock_count == 2:
            print("No")
            return
    if inp[b] == "
        print("No")
        return

    max_cd = c if c > d else d
    continuous_count = 0
    nothing_count = 0
    nothing_3 = False
    if inp[b-1] == '.':
        nothing_count += 1
    if inp[b-2] == '.':
        nothing_count += 1
    for i in range(b, max_cd):
        if inp[i] == '
            continuous_count += 1
            nothing_count = 0
        elif inp[i] == '.':
            continuous_count = 0
            nothing_count += 1
        if continuous_count == 2:
            print("No")
            return
        if nothing_count == 3 and i < d + 1:
            nothing_3 = True

    
    if c < d or nothing_3:
        print("Yes")
    else:
        if (inp[d-1] == '.' and inp[d-2] == '.') and (inp[d] == '.' or inp[d-3] == '.'):
            print("Yes")
        else:
            print("No")
    return


if __name__ == '__main__':
    main()

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

Solution (Python):
def valid_check(n, a, b, c, d, s):
    if not two_rocks(s[b:d]):
        return 0
    
    if c < d:
        return two_rocks(s[a:c])
    else:
        return three_spaces(s[b-1:d+2]) and two_rocks(s[a:c])


def three_spaces(s):
    for i in range(len(s)-2):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            return 1
    return 0











def two_rocks(s):
    for i in range(len(s)-1):
        if s[i]=='
            return 0
    return 1

n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = list(input())


if valid_check(n, a, b, c, d, s):
    print('Yes')
else:
    print('No')

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()
if "
	print("No")
	exit()
for i in range(B - 1, D):
	if S[i] == "." and S[i - 1] == ".":
		if D == N or C < D:
			print("Yes")
			exit()
		else:
			if S[i + 1] == ".":
				print("Yes")
				exit()
print("No")

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()
mx = max(C,D)
r_count = [len(s) for s in S[A-1:mx].split('.') if len(s) > 1]
if r_count != []:
    print('No')
    exit()
if C < D:
    print('Yes')
    exit()

count = [len(s) for s in S[B-2:D+1].split('
print('Yes' if len(count) > 0 else 'No')

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = list(input())
ans = 0
A = c
B = d
cntS = [0 for i in range(len(s))]
if s[0] == "
    cntS[0] = 1
for i in range(len(s)):
    if s[i] == "
        cntS[i] = cntS[i - 1] + 1

cnt = 0
ans = "Yes"
for i in range(b - 1, B):
    if cntS[i] >= 2:
        ans = "No"
        break

for i in range(a - 1, A):
    if cntS[i] >= 2:
        ans = "No"
        break

if s[A - 1] == "
    ans = "No"

if A < a or B < b:
    ans = "No"

if a < b < B < A:
    key = 1
    if (s[b - 2] == "
        for i in range(b, B):
            if s[i - 1] == "." and s[i + 1] == "." and s[i] == ".":
                s[i] = "
                cntS[i] = 1
                key = 0
        if key:
            ans = "No"

    if ans == "Yes":
        for i in range(a - 1, A):
            if cntS[i] >= 2:
                ans = "No"

print(ans)