Resizing the variables
exp_c . resize ( k ) ; exp_c [ 0 ] = 1 ; for ( int i = 1 ; i < k ; i ++ ) { exp_c [ i ] = ( exp_c [ i - 1 ] * ( c + 1 ) ) ; } dp . resize ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { dp [ i ] . resize ( exp_c [ k - 1 ] * ( c + 1 ) , 0 ) ; } v . resize ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { v [ i ] . resize ( exp_c [ k - 1 ] * ( c + 1 ) , 0 ) ; }