lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.7
/**
 * @notice Fetch the latest medianPrice and whether it is null or not
 **/
function getResultWithValidity() public view returns (uint256 value, bool valid) {
        (uint256 targetValue, bool targetValid) = targetFeed.getResultWithValidity();
        (uint256 denominationValue, bool denominationValid) = denominationFeed.getResultWithValidity();
        value = multiply(targetValue, denominationValue) / converterFeedScalingFactor;
        valid = both(
            both(targetValid, denominationValid),
            both(validityFlag == 1, value > 0)
        );
    }
// Solidity 0.5.11
// ------------------------------------------------------------------------
// internal function applies Deductions upon transfer function
// ------------------------------------------------------------------------
function _transferAndBurn(address from, address to, uint tokens) internal {
        // calculate 1% of the tokens
        uint256 onePercentofTokens = _onePercent(tokens);
        
        // burn 1% of tokens
        _burn(from, onePercentofTokens);
        
        // transfer 1% to donation wallet
        _transfer(from, donation, onePercentofTokens);
        
        // distribute 1% to token holders
        _transfer(from, distribution, onePercentofTokens);

        // distribute 97% to recipient
		_transfer(from, to, tokens.sub(onePercentofTokens.mul(3)));
    }
// Solidity 0.6.2
/// @notice Set or reaffirm the approved address for an NFT
/// @dev The zero address indicates there is no approved address.
/// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
///  operator of the current owner.
/// @param _approved The new approved NFT controller
/// @param _tokenId The NFT to approve
function approve(address _approved, uint256 _tokenId)  external{
        address owner = ownerOf(_tokenId);
        uint innerId = tokenId_to_innerId(_tokenId);

        require( owner == msg.sender                    //Require Sender Owns Token
        || AUTHORISED[owner][msg.sender]                //  or is approved for all.
        ,"permission");
        for(uint  i = 0 ; i < 10; i++){
            emit Approval(owner, _approved, innerId*10 + i);
        }

        ALLOWANCE[innerId] = _approved;
    }
// Solidity 0.6.2
/// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
///  TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
///  THEY MAY BE PERMANENTLY LOST
/// @dev Throws unless `msg.sender` is the current owner, an authorized
///  operator, or the approved address for this NFT. Throws if `_from` is
///  not the current owner. Throws if `_to` is the zero address. Throws if
///  `_tokenId` is not a valid NFT.
/// @param _from The current owner of the NFT
/// @param _to The new owner
/// @param _tokenId The NFT to transfer
function transferFrom(address _from, address _to, uint256 _tokenId) public {

        uint innerId = tokenId_to_innerId(_tokenId);

        //Check Transferable
        //There is a token validity check in ownerOf
        address owner = ownerOf(_tokenId);

        require ( owner == msg.sender             //Require sender owns token
        //Doing the two below manually instead of referring to the external methods saves gas
        || ALLOWANCE[innerId] == msg.sender      //or is approved for this token
        || AUTHORISED[owner][msg.sender]          //or is approved for all
        ,"permission");
        require(owner == _from,"owner");
        require(_to != address(0),"zero");


        for(uint  i = 0 ; i < 10; i++){
            emit Transfer(_from, _to, innerId*10 + i);
        }

        OWNERS[innerId] =_to;

        BALANCES[_from] -= 10;
        BALANCES[_to] += 10;

        spread();

        //Reset approved if there is one
        if(ALLOWANCE[innerId] != address(0)){
            delete ALLOWANCE[innerId];
        }

    }
// Solidity 0.5.16
/**
 * @notice Returns the current per-block supply interest rate for this aToken
 * @return The supply interest rate per block, scaled by 1e18
 */
function supplyRatePerBlock() external view returns (uint) {
        /* We calculate the supply rate:
         *  underlying = totalSupply × exchangeRate
         *  borrowsPer = totalBorrows ÷ underlying
         *  supplyRate = borrowRate × (1-reserveFactor) × borrowsPer
         */
        uint exchangeRateMantissa = exchangeRateStored();

        (uint e0, uint borrowRateMantissa) = interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves);
        require(e0 == 0, "supplyRatePerBlock: calculating borrowRate failed"); // semi-opaque

        (MathError e1, Exp memory underlying) = mulScalar(Exp({mantissa: exchangeRateMantissa}), totalSupply);
        require(e1 == MathError.NO_ERROR, "supplyRatePerBlock: calculating underlying failed");

        (MathError e2, Exp memory borrowsPer) = divScalarByExp(totalBorrows, underlying);
        require(e2 == MathError.NO_ERROR, "supplyRatePerBlock: calculating borrowsPer failed");

        (MathError e3, Exp memory oneMinusReserveFactor) = subExp(Exp({mantissa: mantissaOne}), Exp({mantissa: reserveFactorMantissa}));
        require(e3 == MathError.NO_ERROR, "supplyRatePerBlock: calculating oneMinusReserveFactor failed");

        (MathError e4, Exp memory supplyRate) = mulExp3(Exp({mantissa: borrowRateMantissa}), oneMinusReserveFactor, borrowsPer);
        require(e4 == MathError.NO_ERROR, "supplyRatePerBlock: calculating supplyRate failed");

        return supplyRate.mantissa;
    }
// Solidity 0.5.16
/**
 * @notice Sender redeems aTokens in exchange for a specified amount of underlying asset
 * @dev Accrues interest whether or not the operation succeeds, unless reverted
 * @param redeemAmount The amount of underlying to redeem
 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
 */
function redeemUnderlyingInternal(uint redeemAmount) internal nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed
            return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED);
        }
        // redeemFresh emits redeem-specific logs on errors, so we don't need to
        return redeemFresh(msg.sender, 0, redeemAmount);
    }
// Solidity 0.5.16
/**
 * @notice Sender repays their own borrow
 * @param repayAmount The amount to repay
 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
 */
function repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed
            return fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED);
        }
        // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to
        return repayBorrowFresh(msg.sender, msg.sender, repayAmount);
    }
// Solidity 0.5.16
/**
 * @notice The sender liquidates the borrowers collateral.
 *  The collateral seized is transferred to the liquidator.
 * @param borrower The borrower of this aToken to be liquidated
 * @param aTokenCollateral The market in which to seize collateral from the borrower
 * @param repayAmount The amount of the underlying borrowed asset to repay
 * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
 */
function liquidateBorrowInternal(address borrower, uint repayAmount, AToken aTokenCollateral) internal nonReentrant returns (uint) {
        uint error = accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed
            return fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED);
        }

        error = aTokenCollateral.accrueInterest();
        if (error != uint(Error.NO_ERROR)) {
            // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed
            return fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED);
        }

        // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to
        return liquidateBorrowFresh(msg.sender, borrower, repayAmount, aTokenCollateral);
    }
// Solidity 0.8.7
// public mint
function mint(uint256 _mintAmount) public payable {
    require(!paused, "the mint is paused");
    uint256 supply = totalSupply();
    //require(_mintAmount > 0, "need to mint at least 1 NFT");
    require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");

    if (msg.sender != owner()) {
        require(addressMintedBalance[msg.sender] + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded");
        require(msg.value >= cost * _mintAmount, "insufficient funds");
    }
    
    for (uint256 i = 1; i <= _mintAmount; i++) {
      addressMintedBalance[msg.sender]++;
      _safeMint(msg.sender, supply + i);
    }
  }
// Solidity 0.4.25
/**
 * @dev emergency buy uses last stored affiliate ID
 */
function()
        isActivated()
        isHuman()
        isWithinLimits(msg.value)
        isGameStart()
        payable
        external
    {
        // determine if sniper is new or not
        determineSID();
            
        // fetch sniper id
        uint256 _sID = sIDxAddr_[msg.sender];
        
        // buy core 
        buyCore(_sID, spr_[_sID].laff);
    }
// Solidity 0.4.25
/**
 * @dev withdraws all of your earnings.
 * -functionhash- 
 */
function withdraw()
        public
        isActivated()
        isHuman()
    {
        // grab time
        uint256 _now = now;
        
        // fetch player ID
        uint256 _sID = sIDxAddr_[msg.sender];
        

        // get their earnings
       uint256 _eth = withdrawEarnings(_sID);
        
        // gib moni
        if (_eth > 0)
            spr_[_sID].addr.transfer(_eth);
        
        // fire withdraw event
        emit SPBevents.onWithdraw(_sID, msg.sender, _eth, _now);
        
    }
// Solidity 0.4.25
/**
 * @dev logic runs whenever a buy order is executed.
 */
function buyCore(uint256 _sID, uint256 _affID)
        private
    {
        uint256 _rID = rID_;
 
        //If the sniper does not enter the game through the affiliate, then 10% is paid to the team, 
        //otherwise, paid to the affiliate.

        if(_affID == 0 && spr_[_sID].laff == 0) {
            emit onAffiliatePayout(4, _rID, _sID, msg.value, now);
            core(_rID, _sID, msg.value, 4);
        }else{
            emit onAffiliatePayout(_affID, _rID, _sID, msg.value, now);
            core(_rID, _sID, msg.value, _affID);
        }

    }
// Solidity 0.4.25
/**
 * @dev this is the core logic for any buy that happens.
 */
function core(uint256 _rID, uint256 _sID, uint256 _eth, uint256 _affID)
        private
    {
        uint256 _now = block.timestamp;

        uint256 _value = _eth;
        uint256 _laffRearwd = _value / 10;
        
        //affiliate sniper
        spr_[_affID].aff = spr_[_affID].aff.add(_laffRearwd);
        
        //set sniper last affiliate id;
        spr_[_sID].laff = _affID;
        spr_[_sID].lplyt = _now;

        _value = _value.sub(_laffRearwd);

        uint256 _rndFireNum = generateRandom();
        
        emit onEndTx(_sID, _eth, _rndFireNum, _affID, _now);
        
        round_[_rID].ltime = _now;

        bool _isBingoLp = false;
        bool _isBingoKp = false;

        if(globalArr_.length != 0){
            if(globalArr_.length == 1)
            {
                globalArrEqualOne(_rID, _sID, _value, _rndFireNum);
            }else{
                globalArrNotEqualOne(_rID, _sID, _value, _rndFireNum);
            }
        }else{

            globalArrEqualZero(_rID, _sID, _value, _rndFireNum);
            
        }
        _isBingoLp = calcBingoLuckyPot(_rndFireNum);
        
        //bingo luckypot
        if(_isBingoLp){
            spr_[_sID].win = spr_[_sID].win.add(round_[_rID].lpot);
            round_[_rID].lpot = 0;
            emit onCheckLuckypot(_rndFireNum, _rID, spr_[_sID].addr, block.timestamp);
        }

        //bingo kingpot
        if(_eth >= 500000000000000000){
            _isBingoKp = calcBingoAirdropPot(_rndFireNum);
            
            if(_isBingoKp){
                spr_[_sID].win = spr_[_sID].win.add(round_[_rID].apot);
                round_[_rID].apot = 0;
                emit onCheckKingpot(_rndFireNum, spr_[_sID].addr, _rID, block.timestamp);
            }
        }
        
        //win mainpot
        checkWinMainPot(_rID, _sID, _rndFireNum);
        
        //surprise mother fuck
        autoDrawWithOEZDay();
    }
// Solidity 0.4.25
/**
 * @dev gets existing or registers new sID.  use this when a sniper may be new
 * @return sID 
 */
function determineSID()
        private
    {
        uint256 _sID = sIDxAddr_[msg.sender];
        // if sniper is new to this version of H1M
        if (_sID == 0)
        {
            // grab their sniper ID, name and last aff ID, from sniper names contract 
            _sID = SniperBook.getSniperID(msg.sender);
            lastSID_ = _sID;
            bytes32 _name = SniperBook.getSniperName(_sID);
            uint256 _laff = SniperBook.getSniperLAff(_sID);
            
            // set up sniper account 
            sIDxAddr_[msg.sender] = _sID;
            spr_[_sID].addr = msg.sender;
            
            if (_name != "")
            {
                sIDxName_[_name] = _sID;
                spr_[_sID].name = _name;
                sprNames_[_sID][_name] = true;
            }
            
            if (_laff != 0 && _laff != _sID)
                spr_[_sID].laff = _laff;
            
        }
    }
// Solidity 0.4.25
/// @dev Sum vector
/// @param self Storage array containing uint256 type variables
/// @return sum The sum of all elements, does not check for overflow
function sumElements(uint256[] storage self) public view returns(uint256 sum) {
    assembly {
      mstore(0x60,self_slot)

      for { let i := 0 } lt(i, sload(self_slot)) { i := add(i, 1) } {
        sum := add(sload(add(sha3(0x60,0x20),i)),sum)
      }
    }
  }
// Solidity 0.4.25
/// @dev Returns the max value in an array.
/// @param self Storage array containing uint256 type variables
/// @return maxValue The highest value in the array
function getMax(uint256[] storage self) public view returns(uint256 maxValue) {
    assembly {
      mstore(0x60,self_slot)
      maxValue := sload(sha3(0x60,0x20))

      for { let i := 0 } lt(i, sload(self_slot)) { i := add(i, 1) } {
        switch gt(sload(add(sha3(0x60,0x20),i)), maxValue)
        case 1 {
          maxValue := sload(add(sha3(0x60,0x20),i))
        }
      }
    }
  }
// Solidity 0.4.25
/// @dev Returns the minimum value in an array.
/// @param self Storage array containing uint256 type variables
/// @return minValue The highest value in the array
function getMin(uint256[] storage self) public view returns(uint256 minValue) {
    assembly {
      mstore(0x60,self_slot)
      minValue := sload(sha3(0x60,0x20))

      for { let i := 0 } lt(i, sload(self_slot)) { i := add(i, 1) } {
        switch gt(sload(add(sha3(0x60,0x20),i)), minValue)
        case 0 {
          minValue := sload(add(sha3(0x60,0x20),i))
        }
      }
    }
  }
// Solidity 0.4.25
/// @dev Finds the index of a given value in an array
/// @param self Storage array containing uint256 type variables
/// @param value The value to search for
/// @param isSorted True if the array is sorted, false otherwise
/// @return found True if the value was found, false otherwise
/// @return index The index of the given value, returns 0 if found is false
function indexOf(uint256[] storage self, uint256 value, bool isSorted)
           public
           view
           returns(bool found, uint256 index) {
    assembly{
      mstore(0x60,self_slot)
      switch isSorted
      case 1 {
        let high := sub(sload(self_slot),1)
        let mid := 0
        let low := 0
        for { } iszero(gt(low, high)) { } {
          mid := div(add(low,high),2)

          switch lt(sload(add(sha3(0x60,0x20),mid)),value)
          case 1 {
             low := add(mid,1)
          }
          case 0 {
            switch gt(sload(add(sha3(0x60,0x20),mid)),value)
            case 1 {
              high := sub(mid,1)
            }
            case 0 {
              found := 1
              index := mid
              low := add(high,1)
            }
          }
        }
      }
      case 0 {
        for { let low := 0 } lt(low, sload(self_slot)) { low := add(low, 1) } {
          switch eq(sload(add(sha3(0x60,0x20),low)), value)
          case 1 {
            found := 1
            index := low
            low := sload(self_slot)
          }
        }
      }
    }
  }
// Solidity 0.4.25
/// @dev Removes duplicates from a given array.
/// @param self Storage array containing uint256 type variables
function uniq(uint256[] storage self) public returns (uint256 length) {
    bool contains;
    uint256 index;

    for (uint256 i = 0; i < self.length; i++) {
      (contains, index) = indexOf(self, self[i], false);

      if (i > index) {
        for (uint256 j = i; j < self.length - 1; j++){
          self[j] = self[j + 1];
        }

        delete self[self.length - 1];
        self.length--;
        i--;
      }
    }

    length = self.length;
  }
// Solidity 0.8.6
/// @notice Creates an edition by deploying a new proxy.
function createEdition(
        AllocatedEditionsStorage.NFTMetadata memory metadata,
        AllocatedEditionsStorage.EditionData memory editionData,
        AllocatedEditionsStorage.AdminData memory adminData
    ) external returns (address allocatedEditionsProxy) {
        require(
            adminData.feePercentage >= minFeePercentage,
            "fee is too low"
        );

        require(editionData.allocation < editionData.quantity, "allocation must be less than quantity");

        parameters = Parameters({
            // NFT Metadata
            nftMetaData: abi.encode(
                metadata.name,
                metadata.symbol,
                baseURI,
                metadata.contentHash
            ),
            // Edition Data
            allocation: editionData.allocation,
            quantity: editionData.quantity,
            price: editionData.price,
            // Admin Data
            adminData: abi.encode(
                adminData.operator,
                adminData.tributary,
                adminData.fundingRecipient,
                adminData.feePercentage,
                treasuryConfig
            )
        });

        // deploys proxy
        allocatedEditionsProxy = address(
            new AllocatedEditionsProxy{
                salt: keccak256(abi.encode(metadata.symbol, adminData.operator))
            }(adminData.operator, proxyRegistry)
        );

        delete parameters;

        emit AllocatedEditionDeployed(
            allocatedEditionsProxy,
            metadata.name,
            metadata.symbol,
            adminData.operator
        );

        ITributaryRegistry(tributaryRegistry).registerTributary(
            allocatedEditionsProxy,
            adminData.tributary
        );
    }
// Solidity 0.8.4
/**
 * @dev Exclude `account` from receiving 1-2% transaction fee redistribution via auto-staking.
 *
 * Can be used to exclude technical addresses, such as exchange hot wallets.
 * Can be called by the contract owner.
 */
function excludeAccount(address account) public virtual onlyOwner {
        require(!_isExcluded[account], "Account is already excluded");

        uint256 eBalance = _balances[account] / _rate;
        _excludedBalances[account] += eBalance;
        _balances[account] = 0;
        _isExcluded[account] = true;
        _emissionExcluded += eBalance;
        _emissionIncluded -= eBalance;
    }
// Solidity 0.8.4
/**
 * @dev Includes `accounts` back for receiving 1-2% transaction fee redistribution via auto-staking.
 *
 * Can be called by the contract owner.
 */
function includeAccount(address account) public virtual onlyOwner {
        require(_isExcluded[account], "Account is already included");

        uint256 eBalance = _excludedBalances[account];
        _excludedBalances[account] = 0;
        _balances[account] = eBalance * _rate;
        _isExcluded[account] = false;
        _emissionExcluded -= eBalance;
        _emissionIncluded += eBalance;
    }
// Solidity 0.6.12
/**
 * @param _referral referral.
 */
function stake(address _referral) external payable {
        require(msg.value > 0, "amount cannot be 0");
    
        if (pool[msg.sender].amount > 0) {
            pool[msg.sender].reward = getTotalReward(msg.sender);
        } else {
            _addStaker(msg.sender);
        }

        pool[msg.sender].startDate = now;
        pool[msg.sender].amount = pool[msg.sender].amount.add(msg.value);

        totalStaked = totalStaked.add(msg.value);

        if (referrals[msg.sender] == address(0)) {
            referrals[msg.sender] = _referral;
        }

        emit Staked(msg.sender, msg.value, pool[msg.sender].amount);
    }
// Solidity 0.6.12
/**
 * @dev eth and tokens withdrawing
 */
function withdraw() external {
        require(pool[msg.sender].amount > 0, "insufficient funds");

        uint256 ethAmount = pool[msg.sender].amount;
        uint256 reward = getTotalReward(msg.sender);

        water.mint(address(this), reward.add(reward.div(referralPercentage)));

        totalStaked = totalStaked.sub(ethAmount);
        pool[msg.sender].amount = 0;
        pool[msg.sender].startDate = 0;
        pool[msg.sender].reward = 0;

        uint256 fees = ethAmount.div(feePercentage);
        msg.sender.transfer(ethAmount.sub(fees));
        beneficiary.transfer(fees);

        water.transfer(msg.sender, reward);
        if (referrals[msg.sender] != msg.sender) {
            water.transfer(referrals[msg.sender], reward.div(referralPercentage));
        }

        _deactivateUser(msg.sender);

        emit Withdrawn(msg.sender, ethAmount, reward);
    }
// Solidity 0.6.12
/**
 * @dev activate next staking Phase
 */
function activateNextPhase() public onlyOwner {
        for (uint256 i = 0; i < phases.length; i++) {
            if (phases[i].isActive) {
                phases[i].isActive = false;

                if (i < phases.length - 1) {
                    phases[i + 1].isActive = true;
                    phases[i + 1].startDate = now;

                    emit PhaseActivated(getCurrentPhaseStartDate(), getCurrentPhaseRate());
                    break;
                } else {
                    stakingFinishDate = now;
                }
            }
        }
    }