Subdomain definition based on input file

How about:

import meshio
import numpy as np
mesh = meshio.read("mesh.inp")
cells = mesh.get_cells_type("triangle")
cell_sets = mesh.cell_sets_dict
cell_data = np.zeros(len(cells))
for marker, set in cell_sets.items():
    for type, entities in set.items():
        if type == "triangle":
            # Create marker with int from integer from name of input
            cell_data[entities] = int(marker[-1])

out_mesh = meshio.Mesh(points=mesh.points, cells={
                       "triangle": cells}, cell_data={"name_to_read": [cell_data]})
meshio.write("mesh.xdmf", out_mesh)

It seems to me that you have not marked every cell in the mesh (look at the top right corner of the mesh), as well as the material parameters eems a bit oddly distributed.