  In this paper we introduce the concept of weighted deficiency for abstract
and pro-$p$ groups and study groups of positive weighted deficiency which
generalize Golod-Shafarevich groups. In order to study weighted deficiency we
introduce weighted versions of the notions of rank for groups and index for
subgroups and establish weighted analogues of several classical results in
combinatorial group theory, including the Schreier index formula. Two main
applications of groups of positive weighted deficiency are given. First we
construct infinite finitely generated residually finite $p$-torsion groups in
which every finitely generated subgroup is either finite or of finite index --
these groups can be thought of as residually finite analogues of Tarski
monsters. Second we develop a new method for constructing just-infinite groups
(abstract or pro-$p$) with prescribed properties; in particular, we show that
graded group algebras of just-infinite groups can have exponential growth. We
also prove that every group of positive weighted deficiency has a hereditarily
just-infinite quotient. This disproves a conjecture of Boston on the structure
of quotients of certain Galois groups and solves Problem~15.18 from Kourovka
notebook.
