For a positive integer n we introduce quadratic Lie algebras tr(n), qtr(n) and finitely discrete groups Tr-n, QTr(n) naturally associated with the classical and quantum Yang-Baxter equation, respectively. We prove that the universal enveloping algebras of the Lie algebras tr(n), qtr(n) are Koszul, and compute their Hilbert series. We also compute the cohomology rings for these Lie algebras (which by Koszulity are the quadratic duals of the enveloping algebras). Finally, we construct a basis of U(tr(n)). We construct cell complexes which are classifying spaces of the groups Tr-n and QTr(n), and show that the boundary maps in them are zero, which allows us to compute the integral cohomology of these groups. We show that the Lie algebras tr(n), qtr(n) map onto the associated graded algebras of the Malcev Lie algebras of the groups Tr-n, QTr(n), respectively. In the case of Tr-n, we use quantization theory of Lie bialgebras to show that this map is actually an isomorphism. At the same time, we show that the groups Tr-n and QTr(n) are not formal for n >= 4. (c) 2006 Elsevier Inc. All rights reserved.