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

from __future__ import print_function

from collections import defaultdict, deque
import sys
import time
import math

DIRS = [(0, -1), (1, 0), (0, 1), (-1, 0)]

def add(v1, v2):
    return tuple(x + y for x, y in zip(v1, v2))


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

    board = defaultdict(lambda: " ")
    m = data

    for y in range(len(m)):
        for x in range(len(m[y])):
            board[x,y] = m[y][x]

    source = next(k for k, v in board.items() if v == "@")
    allkeys = {v for v in board.values() if v.islower()}

    if len(tuple(k for k, v in board.items() if v == "@")) == 1:
        sx, xy = source
        board[source] = '#'
        for dir in DIRS:
            board[add(source, dir)] = '#'
        for dx in (-1,1):
            for dy in (-1, 1):
                board[add(source, (dx, dy))] = '@'

    sources = tuple(sorted(k for k, v in board.items() if v == "@"))

#     sx, sy = min(sources)
#     sx += 1
#     sy += 1
#     print(sx, sy)

#     print(sources)
#     quadrants = [
#         (lambda x, y: x < sx and y < sy),
#         (lambda x, y: x > sx and y < sy),
#         (lambda x, y: x < sx and y > sy),
#         (lambda x, y: x > sx and y > sy),
#     ]
#     def which(x, y):
#         for i, q in enumerate(quadrants):
#             if q(x, y):
#                 return i

#     key_quads = [set() for _ in quadrants]
#     door_quads = [set() for _ in quadrants]
#     for k, v in board.items():
#         if v.isupper():
#             door_quads[which(*k)].add(v)
#         if v.islower():
#             key_quads[which(*k)].add(v)

#     rkey_quads = {v2: k for k, v in enumerate(key_quads)for v2 in v }
#     rdoor_quads = {v2: k for k, v in enumerate(door_quads)for v2 in v }

#     print(key_quads)
#     print(door_quads)

#     print(allkeys)

#     dependencies = {}

#     i = 0
#     for robot in range(4):
#         start = sources[robot]
#         q = deque([(0, (start, frozenset()))])
#         seen = {(start)}

#         while q:
#             i += 1
#             steps, (pos, doors) = q.popleft()
#             if i % 1000 == 0:
#                 print(i, steps, pos)

#             for dir in range(0, 4):
#                 nextpos = add(pos, DIRS[dir])

#                 # lol
#                 ndoors = doors
#                 if board[nextpos].isupper():
#                     ndoors = doors | frozenset([board[nextpos]])
#                 if (nextpos) in seen:
#                     continue

#                 seen.add((nextpos))

#                 tp = board[nextpos]
#                 if tp != "#":
#                     q.append((steps+1, (nextpos, ndoors)))
#                 if tp.islower():
#                     assert tp not in dependencies
#                     dependencies[tp] = set(ndoors)

#     print("DEPENDENCIES: ", dependencies)
#     print(dependencies['o'])


#     print("KEYQUADS", key_quads)
#     print("RKEYQUADS", rkey_quads)
#     open = {(k, rkey_quads[k]) for k, v in dependencies.items() if not v}
#     print(open)

#     crossdeps = {
# #        k: {x for x in v if rkey_quads[k] != rdoor_quads[x] or True}
#         k: {(x, rkey_quads[k], rdoor_quads[x]) for x in v}
#         for k,v in dependencies.items()
#     }
#     print('CROSSDEPS:', crossdeps)

#     cross = {
#         x  for x in rdoor_quads if rkey_quads[x.lower()] != rdoor_quads[x]
#     }
#     print("CROSS:", cross)

#     crossdeps2 = {k: dependencies[k.lower()] for k in cross if dependencies[k.lower()]}
#     print("CROSS2:", crossdeps2)


#     asdf = defaultdict(set, crossdeps2)
#     asdf['B'] = set()
#     asdf['F'] = set()
#     asdf['E'] = set()
#     sccs, ordering = kosaraju(asdf)
#     print(ordering)

    #### real one
    bigq = deque([(0, (sources, frozenset()))])<commit_msg>delete all the things that did not work<commit_after>#!/usr/bin/env python3

from __future__ import print_function

from collections import defaultdict, deque
import sys
import time
import math

DIRS = [(0, -1), (1, 0), (0, 1), (-1, 0)]

def add(v1, v2):
    return tuple(x + y for x, y in zip(v1, v2))


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

    board = defaultdict(lambda: " ")
    m = data

    for y in range(len(m)):
        for x in range(len(m[y])):
            board[x,y] = m[y][x]

    source = next(k for k, v in board.items() if v == "@")
    allkeys = {v for v in board.values() if v.islower()}

    if len(tuple(k for k, v in board.items() if v == "@")) == 1:
        sx, xy = source
        board[source] = '#'
        for dir in DIRS:
            board[add(source, dir)] = '#'
        for dx in (-1,1):
            for dy in (-1, 1):
                board[add(source, (dx, dy))] = '@'

    sources = tuple(sorted(k for k, v in board.items() if v == "@"))


    #### real one
    bigq = deque([(0, (sources, frozenset()))])
{'fraction_non_alphanumeric': 0.16577977896029472, 'fraction_numerical': 0.012279983626688497, 'mean_word_length': 1.891715976331361, 'pattern_counts': {'":': 1, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1111417', 'n_tokens_mistral': 1824, 'n_tokens_neox': 1754, 'n_words': 504}