def find_gsm8k_frr(input_string, mode):
    text = input_string.split('\n\nQ:')[0]
    if mode == 'train':
        return text.strip()
    elif mode == 'test':
        if '\n\nCode:' not in text:
            return text.strip()
        frr = text.split('\n\nCode:')[1]
        return frr.strip()

def find_aqua_frr(input_string, mode):
    text = input_string.split('\n\nQ:')[0]
    if mode == 'train':
        return text.strip()
    elif mode == 'test':
        if '\n\nCode:' not in text:
            return text.strip()
        frr = text.split('\n\nCode:')[1]
        return frr.strip()

def find_proofwriter_frr(input_string, mode):
    text = input_string.split('\n\nQ:')[0]
    if mode == 'train':
        return text.strip()
    elif mode == 'test':
        if 'Formalized Proof:' not in text:
            return text.strip()
        frr = text.split('\n\nFormalized Proof:')[1]
        return frr.strip()

def find_MBPP_frr(input_string, mode):
    text = input_string.split('\n\nText:')[0]
    if mode == 'train':
        return text.strip()
    elif mode == 'test':
        if '\n\nCode:' not in text:
            return text.strip()
        frr = text.split('\n\nCode:')[1]
        return frr.strip()