n=gets.to_i (1..n).each do |a| (a..n).each do |b| if b<=n-a-b puts "#{a} #{b} #{n-a-b}" end end end