Copyright regulations for and sharing implementations of previously published computer code
When you create code based on an existing implementation, this is referred to as porting, and the code is considered a derivative work covered by the "derivative works" clause in the software license of the original.  For the code written in an executable language, that is generally the copyright you need worry about, not the copyright of the publication (which is also "borrowing" the code from its original source).  If the code has not been published elsewhere, such that there is no stated code license, then it's probably a short and algorithmic enough segment to think about it like pseudocode.

Pseudocode is a more iffy subject, where people disagree about whether it is copyrightable or not, since mathematical equations and recipes cannot generally be copyrighted but software can be.  Personally, I would take the position that pseudocode used to express an algorithm in a scientific paper should be considered non-copyrighted, since the communication is explicitly intended to enable reproduction of the scientific results.