Problem :

https://www.hackerrank.com/challenges/append-and-delete/problem


My Solution :

#!/usr/bin/env python3

def appendAndDelete(s, t, k):
    i = 0
    while i < min(len(s), len(t)):
        if s[i] != t[i]:
            break
        i += 1
    move = len(s) + len(t) - 2*i
    remain = k - move
    if remain < 0 or (remain%2 == 1 and remain < 2*i):
        return False
    return True


s = input()
t = input()
k = int(input())
print('Yes') if appendAndDelete(s, t, k) else print('No')