<commit_before>import itertools

from dmoj.executors.C import Executor as CExecutor
from dmoj.error import CompileError


template = '''\
#include <stdio.h>

char array[16777216];

int main() {
    char *ptr = array;
    %s
}
'''

trans = {'>': '++ptr;', '<': '--ptr;',
         '+': '++*ptr;', '-': '--*ptr;',
         '.': 'putchar(*ptr);', ',': '*ptr=getchar();',
         '[': 'while(*ptr){', ']': '}'}


class Executor(CExecutor):
    name = 'BF'
    test_program = ',+[-.,+]'

    def __init__(self, problem_id, source_code, **kwargs):
        if source_code.count('[') != source_code.count(']'):
            raise CompileError('Unmatched brackets\n')
        code = template % (''.join(itertools.imap(trans.get, source_code, itertools.repeat(''))))
        super(Executor, self).__init__(problem_id, code, **kwargs)

    @classmethod
    def get_runtime_versions(cls):
        return ('bf', (1, 33, 7)),<commit_msg>No need to use imap<commit_after>import itertools

from dmoj.executors.C import Executor as CExecutor
from dmoj.error import CompileError


template = '''\
#include <stdio.h>

char array[16777216];

int main() {
    char *ptr = array;
    %s
}
'''

trans = {'>': '++ptr;', '<': '--ptr;',
         '+': '++*ptr;', '-': '--*ptr;',
         '.': 'putchar(*ptr);', ',': '*ptr=getchar();',
         '[': 'while(*ptr){', ']': '}'}


class Executor(CExecutor):
    name = 'BF'
    test_program = ',+[-.,+]'

    def __init__(self, problem_id, source_code, **kwargs):
        if source_code.count('[') != source_code.count(']'):
            raise CompileError('Unmatched brackets\n')
        code = template % (''.join(map(trans.get, source_code, itertools.repeat(''))))
        super(Executor, self).__init__(problem_id, code, **kwargs)

    @classmethod
    def get_runtime_versions(cls):
        return ('bf', (1, 33, 7)),
{'fraction_non_alphanumeric': 0.22131593257205004, 'fraction_numerical': 0.013050570962479609, 'mean_word_length': 3.23963133640553, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '727072', 'n_tokens_mistral': 678, 'n_tokens_neox': 648, 'n_words': 131}