<commit_before>#!/usr/bin/env python3

import sys

def doit(data):
    out = []
    i = 0
    while i < len(data):
        if out and data[i] != out[-1] and data[i].upper() == out[-1].upper():
            out.pop()
        else:
            out.append(data[i])
        i += 1

    return (len(out))

def main(data):
    data = [s.strip() for s in sys.stdin][0]

    lol = []
    for i in range(26):
        c = chr(ord('a') + i)
        n = list(data.replace(c, '').replace(c.upper(), ''))
        a = doit(n)
        # This print got me on the leaderboard early: about 60% of the way
        # through, one of the results was like 40% lower than the rest,
        # so I submitted it before the program finished and it was right.
        print(a)
        lol.append(a)
    print(min(lol))


if __name__ == '__main__':
    sys.exit(main(sys.argv))
<commit_msg>clean up the good day 5<commit_after>#!/usr/bin/env python3

import sys

def doit(data):
    out = []
    for c in data:
        if out and c != out[-1] and c.upper() == out[-1].upper():
            out.pop()
        else:
            out.append(c)

    return len(out)

def main(data):
    data = [s.strip() for s in sys.stdin][0]

    lol = []
    for i in range(26):
        c = chr(ord('a') + i)
        n = list(data.replace(c, '').replace(c.upper(), ''))
        a = doit(n)
        lol.append(a)
    print(min(lol))


if __name__ == '__main__':
    sys.exit(main(sys.argv))

{'fraction_non_alphanumeric': 0.16446911866759195, 'fraction_numerical': 0.0131852879944483, 'mean_word_length': 1.991701244813278, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '3544627', 'n_tokens_mistral': 528, 'n_tokens_neox': 514, 'n_words': 148}