This phase II trial studies the side effects and how well fludarabine phosphate, cytarabine, filgrastim-sndz, gemtuzumab ozogamicin, and idarubicin hydrochloride work in treating patients with newly diagnosed acute myeloid leukemia or high-risk myelodysplastic syndrome. Drugs used in chemotherapy, such as fludarabine phosphate, cytarabine, and idarubicin hydrochloride, work in different ways to stop the growth of cancer cells, either by killing the cells or by stopping them from dividing. Immunotherapy with monoclonal antibodies, such as gemtuzumab ozogamicin, may help the body's immune system attack the cancer, and may interfere with the ability of tumor cells to grow and spread. Colony-stimulating factors, such as filgrastim-sndz, may increase the number of immune cells found in bone marrow or peripheral blood and may help the immune system recover from the side effects of chemotherapy. Giving fludarabine phosphate, cytarabine, filgrastim-sndz, gemtuzumab ozogamicin, and idarubicin hydrochloride may kill more cancer cells.