using System;
class Program
{
// Function to compare two strings, s1 and s2
static void Check(string s1, string s2)
{
int n = s1.Length;
int[,] dp = new int[n + 1, 2]; // Create a 2D array to store dynamic programming values
for (int i = 0; i < n; i++)
{
// Check each character of the strings and update the dp array based on the character comparison
if (s1[i] == '0' && s2[i] == '0')
{
dp[i + 1, 0] = dp[i, 0]; // If both characters are '0', update dp values accordingly
dp[i + 1, 1] = dp[i, 1] + 1;
}
else if (s1[i] == '1' && s2[i] == '1')
{
dp[i + 1, 0] = dp[i, 0] + 1; // If both characters are '1', update dp values accordingly
dp[i + 1, 1] = dp[i, 1];
}
else if (s1[i] == '0' && s2[i] == '1')
{
dp[i + 1, 0] = dp[i, 1]; // If s1 is '0' and s2 is '1', update dp values accordingly
dp[i + 1, 1] = dp[i, 0] + 1;
}
else
{
dp[i + 1, 0] = dp[i, 0] + 1; // If s1 is '1' and s2 is '0', update dp values accordingly
dp[i + 1, 1] = dp[i, 1];
}
}
// Compare the final values in dp array to determine the result
if (dp[n, 0] >= dp[n, 1])
{
Console.WriteLine("YES"); // If the first category has equal or more '1's, print "YES"
}
else
{
Console.WriteLine("NO"); // If the second category has more '1's, print "NO"
}
}
static void Main()
{
string s1 = "100111";
string s2 = "111010";
Check(s1, s2);
s1 = "110100";
s2 = "010101";
Check(s1, s2);
}
}