input n,m
input "k=";k
dim a(n,m),b(n,m+1)
'zadanie massiva
s=0
for i=1 to n
s=0
for j=1 to m
input "a(",i,",",j,")=";a(i,j)
s=s+a(i,j)
b(i,j)=a(i,j)
next j
'zapis v pervii stolbec sr. arifm-go
b(i,1)=s/n
's4et4ik k
if s>l then k=k+1
next i
for i=1 to n
for j=2 to m
for k=j+1 to m+1
'sortirovka
if b(i,j)>b(i,k) then swap(b(i,j),b(i,k))
next k
next j
next i
print "k=";k
for i=1 to n
for j=1 to m+1
print b(i,j);
next j
print
next i
end