Here is the mashup link (the problems are from Codeforces' problem set).

#### A.Blended Colors

**Solution**

Here are two solutions.

Solution 1. Iterate through the string character by character. If $$$s_i=R$$$, then $$$t_i=R;$$$ otherwise, if $$$s_i=G$$$ or $$$B$$$, then $$$t_i=G$$$ or $$$B$$$. If the statement is false for any $$$i$$$, the answer is $$$NO$$$. Otherwise it is $$$YES$$$.

Solution 2. Replace all $$$B$$$ with $$$G$$$, since they are the same anyway. Then just check if the two strings are equal. In either case the complexity is $$$O(n)$$$ per testcase.

**Code**

```
t = int(input())
for _ in range(t):
n = int(input())
s = input()
t = input()
flag = True
for i in range(n):
if (s[i] == "R" and t[i] != "R") or (s[i] != "R" and t[i] == "R"):
flag = False
break
if flag:
print("YES")
else:
print("NO")
```

#### B. Flip It to Max It!

**Solution**

We can delete all zeros from the array, and it won't affect on answer. Maximum sum is $$$\sum_{i=1}^{n} (a_i)$$$. Minimum number of operations we should do is the number of subarrays with negative values of elements.

Total complexity: $$$O(n)$$$

**Code**

```
t = int(input())
for _ in range(t):
n = int(input())
nums = list(map(int, input().split()))
total_sum = 0
count = 0
neg_found = False
for num in nums:
total_sum += abs(num)
if num < 0 and not neg_found:
neg_found = True
count += 1
if num > 0:
neg_found = False
print(total_sum, count)
```

#### C.Letter Party

**Solution**

In a valid substring, all characters must be the same. The objective is to change every character in the substring to the one that appears most frequently, using at most K changes. If the required changes exceed K, the substring isn't valid. Utilizing a dynamic sliding window approach, we begin with two pointers: a right pointer that increments while staying within K changes and a left pointer that moves right when the substring becomes invalid. During this process, we change the character with the minimum frequency to the character with the maximum frequency with an operation that equals the minimum frequency. We keep track of the largest valid substring size encountered.

**Code**

n,k = list(map(int,input().split()))
s = input()
count = {"a":0,"b":0}
ans = 0
left = 0
for right in range(n):
count[s[right]]+=1
while min(count.values()) > k:
count[s[left]]-=1
left+=1
ans = max(ans,right - left + 1)
print(ans)

#### D. Chromatic Substring

**Hint**

Let's consider three offsets of string "RGB": "RGB", "GBR" and "BRG".

**Solution**

Let's compare our string $$$s$$$ with infinite concatenation of each offsets of "RGB". However, we don't need an infinite string to compare. $$$n$$$-sized string could be enough. We don't either need to create $$$n$$$-sized string. We can observe that in the concatenated string the first character of the offset will always be on an index which is a multiple of 3 (whose modulo 3 is 0), the second character will be on an index whose modulo 3 is 1, the third character will be on an index whose modulo 3 is 2.

We can use fixed sliding window and compare the character in that window. While comparing we will count the matches and keep track of the maximum matches in $$$k$$$-sized window. We can then find the minimum number of changes we need to make by subtracting the number of maximum matches from $$$k$$$.

**Code**

```
T = int(input())
for _ in range(T):
N, K = map(int, input().split())
s = input()
offsets = ["RGB", "GBR", "BRG"]
ans = float('inf')
for offset in offsets:
matches = 0
for right in range(K): # Calculate the matches for first K elements
if offset[right%3] == s[right]:
matches += 1
max_matches = matches
for right in range(K, N):
left = right - K
if offset[right%3] == s[right]:
matches += 1
if offset[left%3] == s[left]:
matches -= 1
max_matches = max(matches, max_matches)
ans = min(ans, K - max_matches)
print(ans)
```

#### E. Global Contest Hour

**Hint 1**

Calculate the total number of participants that can join the contest for hour 1.

**Hint 2**

Use the sliding window algorithm to calculate the rest.

**Solution**

For hour 1 at the first timezone, it will be hour 2 for the second, and so forth. participants from timezone $$$s$$$ to timezone $$$f - 1$$$ are eligible to join the contest. For the second hour, it becomes $$$s - 1 - f - 2$$$, and so forth. If we have the count of contestants participating in the first hour, we can use a sliding window technique to compute the rest. Our answer is updated only when we discover a larger sum.

$$$Note$$$ Since the array is circular and our pointer might be out of bound we have to use mod to correct it

**Code**

```
n = int(input())
arr = list(map(int , input().split()))
s , f = map(int , input().split())
ans = 1
# The window when time = 1 at first timezone
cur_total = sum(arr[s - 1:f - 1])
left = s - 1 # the leftmost element in our window
right = f - 2 # the rightmost element in our window
max_value = cur_total
for i in range(2 , n + 2):
cur_total -= arr[right]
right -= 1
left -= 1
# When left and right < 0 that means they start iterating from the back
cur_total += arr[left]
if cur_total > max_value:
ans = i
max_value = cur_total
print(ans if ans else n)
```