I'm a little uncertain on how capital gains tax applies to this scenario, will it be consider long term or short term gain?

 1. I bought 100 shares of XYZ for a few years ago
 2. The stock does does well in October so I sell 50 shares
 3. After a few weeks, the stock prices drops and I buy another 50 shares


Does this count as a long term gain because I'm only selling stocks I bought a while ago?


----------
What if I buy more stocks before a sell some?

 1. I bought 100 shares of XYZ for a few years ago
 2. The stock price drops so I buy 50 more shares
 3. The price goes up and I decide to sell 100 shares

If I sell no more than my original number of shares, does it still count as a long term gain?