OK 200 shares became 600, so if for example you paid $1,000 for the original 200 shares your basis is $1,000 in the 600 shares now.
Then you sold 300 so $500 basis remains in the 300 shares you have left.
Then you bought 300 more so this cost plus the $500 above in my example and now have 600 shares.
Don't worry about the number of shares purchase worry about the cost and allocate to the amount you sold and the amount you have left.
Use my example only with the actual amount paid for the shares.