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 -= 1
B -= 1
C -= 1
D -= 1
S = list(input())
if D < C:
    sl = [0]
    ml = [0]
    cnt = 0
    mcnt = 0
    for i in range(A+1,B-1):
        if [S[i],S[i+1]] == ['
            cnt += 1
        elif [S[i],S[i+1]] == ['
            sl.append(cnt)
            cnt = 0
        if i == B-2 :
            sl.append(cnt)
            cnt = 0
    for i in range(D+1,C):
        if [S[i],S[i+1]] == ['
            cnt += 1
        elif [S[i],S[i+1]] == ['
            sl.append(cnt)
            cnt = 0
        if i == C-1 :
            sl.append(cnt)
    for i in range(B-1,D+1):
        if [S[i],S[i+1]] == ['.','.']:
            mcnt += 1
        elif [S[i],S[i+1]] == ['.','
            ml.append(mcnt)
            mcnt = 0
        if i == D:
            ml.append(mcnt)
            mcnt = 0
    if max(sl) >= 1:
        print('No')
    elif max(ml) <= 1:
        print('No')
    else:
        print('Yes')
else:
    acnt = 0
    bcnt = 0
    al = [0]
    bl = [0]
    for i in range(A+1,C):
        if [S[i],S[i+1]] == ['
            acnt += 1
        elif [S[i],S[i+1]] == ['
            al.append(acnt)
            acnt = 0
        if i == C-1 :
            al.append(acnt)
            acnt = 0
    for i in range(B+1,D):
        if [S[i],S[i+1]] == ['
            bcnt += 1
        elif [S[i],S[i+1]] == ['
            bl.append(bcnt)
            bcnt = 0
        if i == C-1 :
            bl.append(bcnt)
            bcnt = 0
    if max(al) >= 1:
        print('No')
    elif max(bl) >= 1:
        print('No')
    else:
        print('Yes')

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

if c<d:
    m=d
else:
    m=c

for i in range(a, m-3):
        if s[i] == '
            ans=0

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

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

S = list(input().split()[0])

result = "Yes"
flag = False

for i in range(B, D - 1):
    if S[i] == "
        result = "No"
        print(result)
        flag = True
        break
if not flag:
    for i in range(A, C - 1):
        if S[i] == "
            result = "No"
            print(result)
            flag = True
            break

if not flag:    
    if A < B and B < D and D < C:
        for i in range(B - 2, D - 1):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                result = "Yes"
                print(result)
                flag = True
                break
            else:
                result = "No"
                flag = False
if not flag:
    print(result)

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    ret = YES
    for i in range(A - 1, C - 1):
        if S[i:i + 2] == '
            ret = NO
            print(ret)
            return
    for i in range(B - 1, D - 1):
        if S[i:i + 2] == '
            ret = NO
            print(ret)
            return
    if D < C:
        ret = NO
        for i in range(B - 2, D - 1):
            if S[i:i + 3] == '...':
                ret = YES
                break

    
    
    
    
    
    
    
    print(ret)
    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):
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint

import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def unite(x, y):
    
    x = root(x)
    y = root(y)
    if x == y:
        return
    
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  
        return x
    else:
        node[x] = root(node[x])  
        return node[x]
def dfs(v):
    
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  
            continue
        if visited[v2] == True:  
            continue
        dfs(v2)


n, a, b, c, d = MI()
s = [s for s in input()]
aki = []
for i in range(1, len(s)):
    if s[i] == '
        if a-1 < i < c-1 or b-1 < i < d-1:
            print('No')
            exit()

if c < d:
    print('Yes')
else:
    for i in range(2, len(s)):
        if s[i] == '.' and s[i-1] == '.' and s[i-2] == '.':
            aki.append(i)
    if s[d-2] == '
        for num in aki:
            if b-1 < num < d-2:
                print('Yes')
                exit()
        print('No')
        exit()
    elif s[d-2] == '
        for num in aki:
            if b-1 < num < d-2:
                print('Yes')
                exit()
        print('No')
        exit()
    elif s[d] == '
        for num in aki:
            if b-1 <= num < d:
                print('Yes')
                exit()
        print('No')
        exit()
    elif s[d-2] == '.' and s[d] == '.':
        print('Yes')
        exit()
    print('No')

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

S = input()

def AA(mojiretu):
    if '
     print("No")
    else:
     print("Yes")

Scp = S
if C < D:
      AA(Scp[A:D])
      
else:
    if "..." in Scp[B-2:D]:
      AA(Scp[A:C])
    else:
      Scp = Scp[:D-1]+"
      AA(Scp[A:C])

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

def check():
    if '
        return False
    if d < c and '...' not in s[b - 2:d + 1]:
        return False
    return True

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

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


flag1 = False
block = 0
for i in range(b, len(s)):
    if block == 2:
        flag1 = False
        break
    elif i == d-1:
        flag1 = True
        break
    elif s[i] == ".":
        block = 0
    elif s[i] == "
        block += 1

if flag1 == True:
    s2 = s[:d-1]+'
    flag1 = False
    block = 0
    for i in range(a, len(s)):
        if block == 2:
            flag1 = False
            break
        elif i == c-1:
            flag1 = True
            break
        elif s2[i] == ".":
            block = 0
        elif s2[i] == "
            block += 1


flag2 = False
flag3 = False
temp = 0
block = 0
for i in range(b-2,c-2):
    if temp == 3:
        flag2 = True
        temp = i-1
        break
    elif s[i] == "
        temp = 0
    elif s[i] == ".":
        temp += 1

if flag2 == True:
    flag3 = False
    block = 0
    s1 = s[:temp-1]+'
    for i in range(a, len(s)):
        if block == 2:
            flag3 = False
            break
        elif i == c-1:
            flag3 = True
            break
        elif s1[i] == ".":
            block = 0
        elif s1[i] == "
            block += 1

    if flag3 == True:
        s3 = s1[:c - 1] + '
        flag3 = False
        block = 0
        for i in range(temp, len(s)):
            if block == 2:
                flag3 = False
                break
            elif i == d-1:
                flag3 = True
                break
            elif s3[i] == ".":
                block = 0
            elif s3[i] == "
                block += 1

if flag1 or flag3:
    print("Yes")
else:
    print("No")

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

if C<D:
    if "
        print("No")
    else:
        print("Yes")
else:
    if (not ("
        print("Yes")
    else:
        print("No")

Solution (Python):
N,A,B,C,D = list(map(int, input().split()))
S = [0]+[0 if s=='.' else 1 for s in input()]
can_jump = [0] + [1-S[i]*S[i+1] for i in range(1,N-1)]
can_change = [0] + [(1-S[i])*(1-S[i+1])*(1-S[i+2]) for i in range(1,N-2)]

def Solution():
  if not all(can_jump[A:C]):
    return False
  if not all(can_jump[B:D]):
    return False
  
  if C<D:
    return True
  if C>D:
    if any(can_change[B-1:D]):
      return True
    else:
      return False

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

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

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


flag1 = False
block = 0
for i in range(b, len(s)):
    if block == 2:
        flag1 = False
        break
    elif i == d-1:
        flag1 = True
        break
    elif s[i] == ".":
        block = 0
    elif s[i] == "
        block += 1

if flag1 == True:
    s2 = s[:d-1]+'
    flag1 = False
    block = 0
    for i in range(a, len(s)):
        if block == 2:
            flag1 = False
            break
        elif i == c-1:
            flag1 = True
            break
        elif s2[i] == ".":
            block = 0
        elif s2[i] == "
            block += 1


flag2 = False
flag3 = False
temp = 0
block = 0
for i in range(b-2,c-2):
    if temp == 3:
        flag2 = True
        temp = i-1
        break
    elif s[i] == "
        temp = 0
    elif s[i] == ".":
        temp += 1

if flag2 == True:
    flag3 = False
    block = 0
    s1 = s[:temp-1]+'
    for i in range(a, len(s)):
        if block == 2:
            flag3 = False
            break
        elif i == c-1:
            flag3 = True
            break
        elif s1[i] == ".":
            block = 0
        elif s1[i] == "
            block += 1

    if flag3 == True:
        s3 = s1[:c - 1] + '
        flag3 = False
        block = 0
        for i in range(temp, len(s)):
            if block == 2:
                flag3 = False
                break
            elif i == d-1:
                flag3 = True
                break
            elif s3[i] == ".":
                block = 0
            elif s3[i] == "
                block += 1

if flag1 or flag3:
    print("Yes")
else:
    print("No")

Solution (Python):
line = input().split()
object_ = input()

N = int(line[0])
A = int(line[1])-1
B = int(line[2])-1
C = int(line[3])-1
D = int(line[4])-1

placing_objects = [True if s == '

def main():
    if (A < B and C < D) or (A > B and C > D):
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1] and i > A and i < max(C, D):
                print('No')
                return
        print('Yes')
        return
    else:
        possible_trans = False
        trans_index = []
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1] and i > A and i < max(C, D):
                print('No')
                return
            if i < N-2 and (not placing_objects[i]) and (not placing_objects[i+1]) and (not placing_objects[i+2]):
                possible_trans = True
                trans_index.append(i+1)
        if not possible_trans:
            if C < D:
                if placing_objects[C-1] or placing_objects[C+1]:
                    print('No')
                    return
            else:
                if placing_objects[D-1] or placing_objects[D+1]:
                    print('No')
                    return
        else:
            if A > B:
                if A > max(trans_index):
                    print('No')
                    return
            else:
                if B > max(trans_index) or D < min(trans_index):
                    print('No')
                    return
        print('Yes')
        
main()

Solution (Python):
from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)
 
N,A,B,C,D = map(int,input().split())
S = list(input())
SA = deepcopy(S)
SB = deepcopy(S)
SA[B-1] = "
SB[D-1]=  "
 
bool=False
for i in range(A,max(D,C)):
    if S[i]=="
        print("No")
        exit()
for i in range(B-1,D):
    if i >= N-1:
        break
    if S[i] == "." and S[i-1]=="." and S[i+1]==".":
        bool = True
        break
if bool:
    print("Yes")
else:
    bool1,bool2,bool3 = True,True,True
    
    for i in range(A,C):
        if SB[i-1]=="
            bool1 = False
            break
    
    for i in range(A,C):
        if SA[i-1]=="
            bool2 = False
            break
    SA[B-1]="."
    SA[C-1]="
    
    for i in range(B,D):
        if SA[i-1]=="
            bool3 = False
            break
    if bool1 or(bool2 and bool3):
        print("Yes")
    else:
        print("No")

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

def yn(a):
    print('Yes' if a else 'No')

if C < D:
    
    yn('
else:
    
    yn('

Solution (Python):
n,a,b,c,d = map(int,input().split())
S = input()
 
ans = 0
def aaa(s,g):
    global ans
    if S[s:g].count("
        ans += 1
    
def bbb(s,g):
    global ans
    if S[s:g].count("
        ans += 1
        return(1)
    else:
        return(0)

def ccc(s,g):
    global ans
    if S[s:g].count("
        return(1)
    else:
        return(0)
        
if c < d:
    aaa(b,d)
    aaa(a,c)
else:
    flag = bbb(b,d)
    flag2 = ccc(a,c)
 
    if flag == 1 and flag2 == 1:
        for i in range(b,d+1):
      
            if S[i-1:i] != "
                k = S[i-2:i-1] + "
      
                if k.count("
                    ans += 1
                    break


 
if ans == 2:
    print("Yes")
else:
    print("No")

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

def not_double_stone(way):
    already=False
    for i in way:
        if i=="
            return False
        elif i=="
            already=True
        else:
            already=False
    return True

def can_over(way):
    count=0
    for i in way:
        if i==".":
            count+=1
        else:
            count=0
        if count==3:
            return True
    return False

if c<d:
    if not_double_stone(way[b-1:d]) and not_double_stone(way[a-1:c]):
        answer='Yes'
    else:
        answer='No'
else:
    if can_over(way[b-2:d]):
        if not_double_stone(way[a-1:c]):
            answer='Yes'
        else:
            answer='No'
    else:
        if not_double_stone(way[a-1:c]) and way[d-2]!="
            answer='Yes'
        else:
            answer='No'

print(answer)

Solution (Python):


''' 
------------------------
author : iiou16
------------------------
'''

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

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


if __name__ == '__main__':
    main()

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

str_ac = str[A:C-1]
str_bd = str[B:D-1]



if C<D:
  if str_bd.find("
    print("No")
  else:
    print("Yes")
else:
  if str_bd.find("
    print("No")
  elif str_bd.find("...") != -1 and str_ac.find("
    print("Yes")
  elif str_bd.startswith("..") and str_ac.find("
    print("Yes")
  elif str_bd.endswith("..") and str_ac.find("
    print("Yes")
  else:
    str_b = str[:B-1] + "
    str_d = str[:D-1] + "
    str_b_ac = str_b[A:C-1]
    str_d_ac = str_d[A:C-1]
    
    
    if str_b_ac.find("
      print("Yes")
    else:
      print("No")

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

curval = "x"
cnt = 0
initidx = 0
ngarea = [-1]
triarea = [-1]

for idx,val in enumerate(S):
    if val == curval:
        cnt += 1
    else:
        if cnt >= 2 and curval == '
            ngarea.append(initidx + 1)
        elif cnt >= 3 and curval == '.':
            for i in range(3,cnt+1):
                triarea.append(initidx + 1 + i - 3)
        initidx = idx
        cnt = 1
    curval = val
else:
    if cnt >= 2 and curval == '
        ngarea.append(initidx + 1)
    elif cnt >= 3 and curval == '.':
        triarea.append(initidx + 1)

if C < D:
    isBflg = True
    isABflg = True
    for ngp in ngarea:
        if ngp > B and ngp < D:
            isBflg = False
        if ngp > A and ngp < B:
            isABflg = False
    if isBflg and isABflg:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
else:
    isChangeFlg = False
    
    for trp in triarea:
        if trp >= A and trp + 1 >= B:
            Changepoint = trp + 1
            isChangeFlg = True
            break
    if isChangeFlg == False or Changepoint >= C or Changepoint > D:
        print('No')
        exit()
    else:
        isBflg = True
        isABflg = True
        isChange2DFlg = True
        for ngp in ngarea:
            if ngp > B and ngp < Changepoint:
                isBflg = False
            if ngp > A and ngp < B:
                isABflg = False
            if ngp > Changepoint and ngp < D:
                isChange2DFlg = False
        if isBflg and isABflg and isChange2DFlg:
            print('Yes')
            exit()
        else:
            print('No')
            exit()

Solution (Python):


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

A -= 1
B -= 1
C -= 1
D -= 1
S[A] = 'a'
S[B] = 'b'

ans_D = False
ans_C = False

b = B
a = A

if C <= D:
    while True:
        if b == D:
            ans_D = True
            break
        else:
            if S[b+1] == '.':
                S[b] = '.'
                S[b+1] = 'b'
                b += 1
            else:
                if S[b+2] == '.':
                    S[b] = '.'
                    S[b+2] = 'b'
                    b += 2
                else:
                    break
    if ans_D:
        while True:
            if a == C:
                ans_C = True
                break
            else:
                if S[a+1] == '.':
                    S[a] = '.'
                    S[a+1] = 'a'
                    a += 1
                else:
                    if S[a+2] == '.':
                        S[a] = '.'
                        S[a+2] = 'a'
                        a += 2
                    else:
                        break
    if ans_C and ans_D:
        print('Yes')
    else:
        print('No')
else:
    swap_flag = False
    while b + 1 < N:
        if (S[b-1] == '.' and S[b+1] == '.') or (S[b-1] == 'a' and S[b+1] == '.'):
            swap_flag = True
            break
        else:
            if S[b+1] == '.':
                S[b] = '.'
                S[b+1] = 'b'
                b += 1
            else:
                if S[b+2] == '.':
                    S[b] = '.'
                    S[b+2] = 'b'
                    b += 2
                else:
                    break
    if swap_flag:
        while True:
            if a == C:
                ans_C = True
                break
            else:
                if S[a+1] == '.':
                    S[a] = '.'
                    S[a+1] = 'a'
                    a += 1
                else:
                    if S[a+2] == '.':
                        S[a] = '.'
                        S[a+2] = 'a'
                        a += 2
                    else:
                        break
        if ans_C:
            while True:
                if b == D:
                    ans_D = True
                    break
                else:
                    if S[b+1] == '.':
                        S[b] = '.'
                        S[b+1] = 'b'
                        b += 1
                    else:
                        if S[b+2] == '.':
                            S[b] = '.'
                            S[b+2] = 'b'
                            b += 2
                        else:
                            break
            if ans_C and ans_D:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')

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

def cd():
    two_block_flg = False
    for s in S[A:C+1]:
        if two_block_flg:
            if s=='
                return 'No'
            else:
                two_block_flg = False
        else:
            if s=='
                two_block_flg = True
    two_block_flg = False
    for s in S[B:D+1]:
        if two_block_flg:
            if s=='
                return 'No'
            else:
                two_block_flg = False
        else:
            if s=='
                two_block_flg = True
    return 'Yes'

def dc():
    two_block_flg = False
    for s in S[A:C+1]:
        if two_block_flg:
            if s=='
                return 'No'
            else:
                two_block_flg = False
        else:
            if s=='
                two_block_flg = True
    for i in range(B, D+1):
        if S[i-1]=='.' and S[i]=='.' and S[i+1]=='.':
            return 'Yes'
    return 'No'  


if C<D:
    print(cd())
else:
    print(dc())

Solution (Python):
n, a, b, c, d = map(int, input().split())
 
S = input()
x = [0]
 
for s in S:
    if s == '
        x.append(1)
    else:
        x.append(0)
 
flag = 0
 
for i in range(a, c):
    if x[i] + x[i+1] == 2:
        flag = 1
for i in range(b, d):
    if x[i] + x[i+1] == 2:
        flag = 1
 
flag2 = 1
 
if c > d:
    for i in range(b-1, d):
        if x[i] + x[i+1] + x[i+2] == 0:
            flag2 = 0
else:
    flag2 = 0
 
if flag + flag2 == 0:
    print('Yes')
else:
    print('No')

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

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


white = []
for i in range(N - 2):
    if S[i] == "." == S[i + 1] == S[i + 2]:
        white.append(i + 1)

if C > D:
    
    i = A - 1
    T = S.copy()
    T[B - 1] = "
    while C - 1 != i:
        if T[i + 1] == ".":
            i += 1
        elif T[i + 2] == ".":
            i += 2
        elif i + 1 == B - 1 or i + 2 == B - 1:
            es = False
            for w in white:
                if i < w:
                    if w <= D - 1:
                        es = True
            if es:
                i = B - 1
            else:
                break
        else:
            break
    if i == C - 1:
        print("Yes")
        exit()
else:
    i = B - 1
    T = S.copy()
    while D - 1 != i:
        if T[i + 1] == ".":
            i += 1
        elif T[i + 2] == ".":
            i += 2
        else:
            break
    if i == D - 1:
        T2 = S.copy()
        T2[D - 1] = "
        j = A - 1
        while C - 1 != j:
            if T[j + 1] == ".":
                j += 1
            elif T[j + 2] == ".":
                j += 2
            else:
                break
        if j == C - 1:
            print("Yes")
            exit()
print("No")

Solution (Python):
import sys
rr = lambda: sys.stdin.readline().strip()
rri = lambda: int(rr())
rrs = lambda: [int(_) for _ in rr().split()]

N, A_, B_, C_, D_ = rrs()
A, B, C, D = [i-1 for i in [A_, B_, C_, D_]]
S = rr()

for i in range(A, max(C, D)):
	if S[i] == '
		print('No')
		sys.exit()

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

if S[B-1] == '.' and S[B+1] == '.':
	print('Yes')
	sys.exit()

if S[B+1] == '.' and S[B+2] == '.':
	print('Yes')
	sys.exit()
	
for i in range(B, D-1):
	if S[i] == '
		if S[i+1] == '.' and S[i+2] == '.' and S[i+3] == '.':
			print('Yes')
			sys.exit()

print('No')
sys.exit()

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = input()
print("No" if s.find("

Solution (Python):
def solve4():
    N, A, B, C, D = [int(_) for _ in raw_input().split()]
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = raw_input()
    R2 = False
    E3 = False
    for i in range (A+1, max(C,D)-1):
        if S[i:(i+2)] == '
            R2 = True
            break
    if C == D or R2:
        return False
    elif C < D:
        return True
    elif C > D:
        for i in range (B - 1, D):
            if S[i:(i+3)] == '...':
                E3 = True
                break
        ret = E3
        return ret

if __name__ == '__main__':
    ret = solve4()
    if ret:
        print 'Yes'
    else:
        print 'No'

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

seq=0
tri=0
if c<d:
    seq=s[a-1:d-1].count("
    if seq==0:
        print("Yes")
    else:
        print("No")
else:
    seq=s[a-1:c-1].count("
    tri=s[b-2:d+1].count("...")
    if seq==0:
        if tri!=0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Solution (Python):



def main():
    N, A, B, C, D = map(int, input().split())
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    iwa = "
    S = input()
    ans = True
    canexchange = False

    for i in [A, B, C, D]:
        if S[i] == iwa:
            exit()

    exchagable_list = []
    for i in range(N-2):
        temps = S[i:i+3]
        if temps == "...":
            exchagable_list.append(i)

    if len(exchagable_list) > 0:
        for i in exchagable_list:
            if i+1 >= B and i+1 <= min(C, D):
                canexchange = True

    
    for i in range(N-1):
        if S[i] == iwa and S[i+1] == iwa:
            if C < B and (C < i and i+1 < B):
                pass
            elif not (i+1 < A or i > max(C, D)):
                ans = False

    if ans:
        if C < D:
            ans = True
        elif C > D and canexchange:
            ans = True
        elif C > D and not canexchange:
            if S[D-1] == iwa or S[D+1] == iwa:
                ans = False
            else:
                ans = True

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


if __name__ == "__main__":
    main()

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

def solve():
    ac, bd = S[A - 1:C], S[B - 1:D]
    if A < B < D < C:
        bd = S[B - 2:D + 1]
        return ("..." in bd and "
    else:
        return ("

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

Solution (Python):
def f(i, y, S):
    while i < y:
        if S[i + 2] == '.':
            i += 2
        elif S[i + 1] == '.':
            i += 1
        else:
            return False
    return True
def g(i, y, S):
    while i < y:
        if S[i + 2] == '.':
            i += 2
        elif S[i + 1] == '.':
            i += 1
        else:
            break
    return i
def dc(n, a, b, c, d, S):
    S = list(S)
    S[b] = 'B'
    while a < b:
        a = g(a, c, S)
        if b == d:
            return a >= c
        elif S[b + 1] == '.':
            S[b] = '.'
            b += 1
            S[b] = 'B'
        elif S[b + 2] == '.':
            S[b] = '.'
            b += 2
            S[b] = 'B'
        else:
            return a >= c
    return True
def solve():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    S = input() + "
    if c < d:
        S = list(S)
        return f(b, d, S) and f(a, c, S)
    else:
        return dc(n, a, b, c, d, S)
    return True
print("Yes" if solve() else "No")

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

S = input()
x = [0]

for s in S:
    if s == '
        x.append(1)
    else:
        x.append(0)

flag = 0

for i in range(a, c):
    if x[i] + x[i+1] == 2:
        flag = 1
for i in range(b, d):
    if x[i] + x[i+1] == 2:
        flag = 1

flag2 = 1

if c > d:
    for i in range(b-1, d):
        if x[i] + x[i+1] + x[i+2] == 0:
            flag2 = 0
else:
    flag2 = 0

if flag + flag2 == 0:
    print('Yes')
else:
    print('No')

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

def check(l, r):
  if (r-l) <= 1:
    return True
  for i in range(l, r):
    if s[i:i+2] == '
      return False
  return True

def check2(l, r):
  for i in range(l, r-1):
    if s[i:i+3] == '...':
      if check(b, i) and check(i+2, c-2):
        return (True, i+1)
  return (False, -1)

if c < d:
  flag = check(a, c-2) and check(b, d-2)
else:
  flag, idx = check2(b-2, d)
  if flag:
    s = s[:idx] + '
    flag = check(a, c-2)

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

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

if C > D:
    if '...' not in s[B-2:D+1]: ans = False
if ans:
    if '
    if '

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

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

Solution (Python):
N,A,B,C,D = [int(x) for x in input().split()]
S = input()
cross = False
minG = C
maxG = D

if C > D:
    minG = D
    maxG = C
    cross = True

S_wall = S[A-1:maxG]
S_even = S[B-1-1:minG+1]

wall = S_wall.find("
even = S_even.find("...")

if cross == False:
    if wall == -1:
        print("Yes")
    else:
        print("No")
else:
    if wall == -1:
        if even != -1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")