How about first transforming the row vectors into variables.  Once you have the x 
and y row vectors as variables, I believe the following should work:
clear
input y x
2 3 
4 4	
8 5
12 7
1 0
end
l
gen x_old = x
qui {
local max = .
local min = .
count
local num = r(N)
forv i = 1/`num' {
sum y if y < `max'
local max = r(max)
sum x if x < `max'
local min = r(min)
replace x = `max' if `max' > `min' & x == `min'
}
}
l y x_old x
Scott
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/