We, a novel by Yevgeny Zamyatin 1921

See also link

The story is told by the protagonist, "D-503", in his diary, which details both his work as a mathematician and his misadventures with a resistance group called the Mephi, who take their name from Mephistopheles. D-503 lives in the One State,[3] an urban nation constructed almost entirely of glass, where everything is organized according to primitive mathematics. Sleep times are measured out for each day and each individual is given a certain number of other people to have intercourse with based on a system of pink coupons and scheduling. People move around according to special marches in-step with each other and wear special suits so there is hardly any way to differentiate between different people save by their given numbers. Males have odd numbers prefixed by consonants, females have even numbers prefixed by vowels. D-503 spends most of his time with O-90 and R-13, referring to their relationship as a “triangle.” He eventually falls in love with I-330 and the problems begin. He starts a diary as a testament to the happiness that the One State has discovered. He hopes to present it to the extraterrestrial civilizations he will visit, with the spaceship he designed and oversaw the building of, the Integral. This ends up being all a part of the Great Benefactor’s plan so he could collect as many Mephi followers as possible. As the novel progresses, D-503’s infatuation with I-330, a rebellious woman in league with Mephi, starts to take over his life. He starts to lose his initial dedication to the One State, and his ability to differentiate between reality and dreams starts to fade. He is permitted to take off work at one point to overcome his illness, but cannot seem to shake the strange and alien sensations he is experiencing. By the end of his story, he has almost been driven to madness by inner conflicts between himself and his society, or imagination and mathematic truths. In addition, other members of the One State have fallen prey to higher math and various forms of chaos begin to occur. The “Green Wall” that separates their world from the outside is destroyed, birds begin to populate the glass city, people start having intercourse with the blinds up without using coupons, and the Great Benefactor has to create a special field to keep out the Mephis and their followers. At the end, D-503 is arrested and brought in for the Great Operation (similar to a lobotomy[4]), where his imagination is removed and he no longer loves, falling back into his previous existence.