<s> """<STR_LIT>""" <EOL> import sys <EOL> __author__ = '<STR_LIT>' <EOL> class Solution : <EOL> def minCost ( self , costs ) : <EOL> """<STR_LIT>""" <EOL> if not costs : <EOL> return <NUM_LIT:0> <EOL> n = len ( costs ) <EOL> m = len ( costs [ <NUM_LIT:0> ] ) <EOL> F = [ [ <NUM_LIT:0> for _ in xrange ( m ) ] for _ in xrange ( n + <NUM_LIT:1> ) ] <EOL> for k in xrange ( <NUM_LIT:1> , n + <NUM_LIT:1> ) : <EOL> for i in xrange ( m ) : <EOL> F [ k ] [ i ] = sys . maxint <EOL> for j in xrange ( m ) : <EOL> if i != j : <EOL> F [ k ] [ i ] = min ( F [ k ] [ i ] , F [ k - <NUM_LIT:1> ] [ j ] + costs [ k - <NUM_LIT:1> ] [ i ] ) <EOL> return min ( F [ n ] [ i ] for i in xrange ( m ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> costs = [ [ <NUM_LIT:7> , <NUM_LIT:6> , <NUM_LIT:2> ] ] <EOL> assert Solution ( ) . minCost ( costs ) == <NUM_LIT:2> </s>
