滑动数组的方法,从0位开始遍历,子串末尾是"G"or"C",则计数+1;
子串数组滑动到下一位之前,如果子串首位是"G"or"C",则计数-1
while True:
try:
s = input()
L = int(input())
# sub = deque([], L)
sub = [] # len = L
GC_i, tmp, res = 0, 0, -1
for i in range(len(s)):
sub.append(s[i])
if sub[-1] == 'G' or sub[-1] == 'C':
tmp += 1
if len(sub) == L:
if tmp > res:
res = tmp
GC_i = i - L + 1
if sub[0] == 'G' or sub[0] == 'C':
tmp -= 1
sub.pop(0)
print(s[GC_i: GC_i+L])
except:
break