import sequtils,strutils,algorithm proc `<`(x,y : seq[int]):bool = # seq[int]をsortするのに必要 for i in 0..min(x.len,y.len): if x[i] < y[i]: return true elif x[i] == y[i]: continue else: return false if x.len < y.len: return true else: return false type kumi = tuple[ku : seq[int],s : int] var N,S : int (N,S) = stdin.readline.split.map(parseInt) var P = newSeq[int](N) p : int ans = newSeq[kumi](0) for n in 0.. S: p += 1 elif Ka[i].s + Kb[p].s < S: break p -= p2 p2 = 0 ans = ans.sortedByIt(it.ku) for s in ans: echo s.ku.join(" ")