some function
TLE
optimize algo
spped up, but WA
TLE 9