#!/usr/bin/env python

import sys

_, raw, tok, shortraw, shorttok = sys.argv

with open(raw) as f:
    with open(tok) as g:
        with open(shortraw, 'w') as h:
            with open(shorttok, 'w') as i:
                while True:
                    try:
                        rawline = next(f)
                        tokline = next(g)
                        if len(rawline) < 10000:
                            h.write(rawline)
                            i.write(tokline)
                    except StopIteration:
                        break
            
