lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.23
/* Initializes contract with initial supply tokens to the creator of the contract */
function KEKEcon(){
        balanceOf[msg.sender] = 100000000000000000; // Give the creator all initial tokens
        totalSupply = 100000000000000000;                        // Update total supply
        name = "KEKEcon";                                   // Set the name for display purposes
        symbol = "KEKEcon";                             // Set the symbol for display purposes
        decimals = 8;                            // Amount of decimals for display purposes
    }
// Solidity 0.4.23
/* Internal transfer, only can be called by this contract */
function _transfer(address _from, address _to, uint _value) internal {
        require (_to != 0x0);                               // Prevent transfer to 0x0 address. Use burn() instead
        require (balanceOf[_from] >= _value);                // Check if the sender has enough
        require (balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows
        balanceOf[_from] -= _value;                         // Subtract from the sender
        balanceOf[_to] += _value;                            // Add the same to the recipient
        Transfer(_from, _to, _value);
    }
// Solidity 0.4.23
/// @notice Remove `_value` tokens from the system irreversibly
/// @param _value the amount of money to burn
function burn(uint256 _value) returns (bool success) {
        require (balanceOf[msg.sender] >= _value);            // Check if the sender has enough
        balanceOf[msg.sender] -= _value;                      // Subtract from the sender
        totalSupply -= _value;                                // Updates totalSupply
        Burn(msg.sender, _value);
        return true;
    }
// Solidity 0.4.25
/**
 * @dev Distributes the rewards to the consumers. Returns the amount of customers that received tokens. Can only be called by Owner
 * @param dests Array of cosumer addresses
 * @param values Array of token amounts to distribute to each client
 */
function multisend(address[] dests, uint256[] values) public onlyOwner returns (uint256) {
        assert(dests.length == values.length);
        uint256 i = 0;
        while (i < dests.length) {
            assert(ERC20Basic(tokenAddress).transfer(dests[i], values[i]));
            emit RewardDistributed(dests[i], values[i]);
            dropAmount += values[i];
            i += 1;
        }
        numDrops += dests.length;
        return i;
    }
// Solidity 0.4.25
//human 0.1 standard. Just an arbitrary versioning scheme.
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token
function Breakbits(

        ) {

        balances[msg.sender] = 900000;               // Give the creator all initial tokens (100000 for example)

        totalSupply = 900000;                        // Update total supply (100000 for example)

        name = "Breakbits";                                   // Set the name for display purposes

        decimals = 0;                            // Amount of decimals for display purposes

        symbol = "BR20";                               // Set the symbol for display purposes

    }
// Solidity 0.4.25
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {

        allowed[msg.sender][_spender] = _value;

        Approval(msg.sender, _spender, _value);


        //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.

        //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)

        //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.

        if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }

        return true;

    }
// Solidity 0.4.24
/**
 * Constrctor function
 *
 * Setup the owner
 */
function Crowdsale( ) {
        beneficiary = 0xe579891b98a3f58e26c4b2edb54e22250899363c;
        rate = 80000; // 8.000.000 TORC/Ether 
        tokenDecimals=8;
        fundingGoal = 2500000000 * (10 ** tokenDecimals); 
        start = 1536537600; //      
        deadline = 1539129600; //    
        bonusEndDate =1537156800;
        tokenReward = token(0xBD64a0d7330bc16c30aA1AE34eD2C329F6DB49C9); //Token address. Modify by the current token address
    }
// Solidity 0.4.24
/*
 It calculates the amount of tokens to send to the investor 
 */
function getNumTokens(uint _value) internal returns(uint numTokens) {
        require(_value>=10000000000000000 * 1 wei); //Min amount to invest: 0.01 ETH
        numTokens = safeMul(_value,rate)/(10 ** tokenDecimals); //Number of tokens to give is equal to the amount received by the rate 
        
        if(now <= bonusEndDate){
            if(_value>= 1 ether && _value< 5 * 1 ether){ // +15% tokens
                numTokens += safeMul(numTokens,15)/100;
            }else if(_value>=5 * 1 ether){              // +35% tokens
                numTokens += safeMul(numTokens,35)/100;
            }
        }

        return numTokens;
    }
// Solidity 0.4.24
/**
 * Check if goal was reached
 *
 * Checks if the goal or time limit has been reached and ends the campaign and burn the tokens
 */
function checkGoalReached() afterDeadline {
        require(msg.sender == owner); //Checks if the one who executes the function is the owner of the contract
        if (tokensSold >=fundingGoal){
            GoalReached(beneficiary, amountRaised);
        }
        tokenReward.burn(tokenReward.balanceOf(this)); //Burns all the remaining tokens in the contract 
        crowdsaleClosed = true; //The crowdsale gets closed if it has expired
    }
// Solidity 0.4.20
// returns the current amount of wei that will be given for the purchase 
// at purchases[index]
function getEarnings(uint index) public constant returns (uint earnings, uint amount) {
        Purchase memory cpurchase;
        Purchase memory lpurchase;
        
        cpurchase = purchases[index];
        amount = cpurchase.amount;
        
        if (cpurchase.addr == address(0)) {
            return (0, amount);
        }
        
        earnings = (index == 0) ? acm : 0;
        lpurchase = purchases[purchases.length-1];
        earnings = earnings.add( lpurchase.sf.sub(cpurchase.sf) );
        earnings = earnings.mul(amount).div(acm);
        return (earnings, amount);
    }
// Solidity 0.4.20
// Cash out Ether and Tangent at for the purchase at index "index".
// All of the Ether and Tangent associated with with that purchase will
// be sent to recipient, and no future withdrawals can be made for the
// purchase.
function cashOut(uint index) public {
        require(0 <= index && index < purchases.length);
        require(purchases[index].addr == msg.sender);
        
        uint earnings;
        uint amount;
        uint tangles;
        
        (earnings, amount) = getEarnings(index);
        purchases[index].addr = address(0);
        require(earnings != 0 && amount != 0);
        netStakes = netStakes.sub(amount);
        
        tangles = earnings.mul(multiplier).div(divisor);
        CashOutEvent(index, msg.sender, earnings, tangles);
        NetStakesChange(netStakes);
        
        tokenContract.transfer(msg.sender, tangles);
        msg.sender.transfer(earnings);
        return;
    }
// Solidity 0.4.20
// The fallback function used to purchase stakes
// sf is the sum of the proportions of:
// (ether of current purchase / sum of ether prior to purchase)
// It is used to calculate earnings upon withdrawal.
function () public payable {
        require(msg.value != 0);
        
        uint index = purchases.length;
        uint sf;
        uint f;
        
        if (index == 0) {
            sf = 0;
        } else {
            f = msg.value.mul(acm).div(netStakes);
            sf = purchases[index-1].sf.add(f);
        }
        
        netStakes = netStakes.add(msg.value);
        purchases.push(Purchase(msg.sender, msg.value, sf));
        
        NetStakesChange(netStakes);
        PurchaseEvent(index, msg.sender, msg.value, sf);
        return;
    }
// Solidity 0.5.17
/**
 * @dev Map root token to child token
 * @param _rootToken Token address on the root chain
 * @param _childToken Token address on the child chain
 * @param _isERC721 Is the token being mapped ERC721
 */
function mapToken(
        address _rootToken,
        address _childToken,
        bool _isERC721
    ) external onlyGovernance {
        require(_rootToken != address(0x0) && _childToken != address(0x0), "INVALID_TOKEN_ADDRESS");
        rootToChildToken[_rootToken] = _childToken;
        childToRootToken[_childToken] = _rootToken;
        isERC721[_rootToken] = _isERC721;
        IWithdrawManager(contractMap[WITHDRAW_MANAGER]).createExitQueue(_rootToken);
        emit TokenMapped(_rootToken, _childToken);
    }
// Solidity 0.4.24
// ------------------------------------------------------------------------
// 10,000 TRT Tokens per 1 ETH
// ------------------------------------------------------------------------
function () public payable {
        require(now >= startDate && now <= endDate);
        uint tokens;
        if (now <= bonusEnds) {
            tokens = msg.value * 13000;
        } else {
            tokens = msg.value * 10000;
        }
        balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
        _totalSupply = safeAdd(_totalSupply, tokens);
        Transfer(address(0), msg.sender, tokens);
        owner.transfer(msg.value);
    }
// Solidity 0.4.19
/// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited amount.
/// @param _from Address to transfer from.
/// @param _to Address to transfer to.
/// @param _value Amount to transfer.
/// @return Success of transfer.
function transferFrom(address _from, address _to, uint _value)
        public
        returns (bool)
    {
        uint allowance = allowed[_from][msg.sender];
        if (balances[_from] >= _value
            && allowance >= _value
            && balances[_to] + _value >= balances[_to]
        ) {
            balances[_to] += _value;
            balances[_from] -= _value;
            if (allowance < MAX_UINT) {
                allowed[_from][msg.sender] -= _value;
            }
            Transfer(_from, _to, _value);
            return true;
        } else {
            return false;
        }
    }
// Solidity 0.4.21
/**
 * @dev transfer token for a specified address
 * @param _to The address to transfer to.
 * @param _value The amount to be transferred.
 * @param _data Optional metadata.
 */
function transfer(address _to, uint _value, bytes _data) public whenActivated returns (bool) {
        require(_to != address(0));
        require(_value <= balances[msg.sender]);
        require(!freezedList[msg.sender]);

        // SafeMath.sub will throw if there is not enough balance.
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);

        if (isContract(_to)) {
            TokenReciever receiver = TokenReciever(_to);
            receiver.tokenFallback(msg.sender, _value, _data);
        }

        Transfer(msg.sender, _to, _value);
        Transfer(msg.sender, _to, _value, _data);
        return true;
    }
// Solidity 0.4.21
/**
 * @dev Transfer tokens from one address to another
 * @param _from address The address which you want to send tokens from
 * @param _to address The address which you want to transfer to
 * @param _value uint the amount of tokens to be transferred
 * @param _data Optional metadata.
 */
function transferFrom(address _from, address _to, uint _value, bytes _data) public whenActivated returns (bool) {
        require(_to != address(0));
        require(_value <= balances[_from]);
        require(_value <= allowed[_from][msg.sender]);
        require(!freezedList[_from]);

        balances[_from] = balances[_from].sub(_value);
        balances[_to] = balances[_to].add(_value);
        allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);

        if (isContract(_to)) {
            TokenReciever receiver = TokenReciever(_to);
            receiver.tokenFallback(_from, _value, _data);
        }

        Transfer(_from, _to, _value);
        Transfer(_from, _to, _value, _data);
        return true;
    }
// Solidity 0.4.21
/**
 * @dev Decrease the amount of tokens that an owner allowed to a spender.
 *
 * approve should be called when allowed[_spender] == 0. To decrement
 * allowed value is better to use this function to avoid 2 calls (and wait until
 * the first transaction is mined)
 * From MonolithDAO Token.sol
 * @param _spender The address which will spend the funds.
 * @param _subtractedValue The amount of tokens to decrease the allowance by.
 */
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
        uint oldValue = allowed[msg.sender][_spender];
        if (_subtractedValue > oldValue) {
            allowed[msg.sender][_spender] = 0;
        } else {
            allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
        }
        Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
        return true;
    }
// Solidity 0.4.21
/**
 * @dev Function to mint tokens
 * @param _to The address that will receive the minted tokens.
 * @param _amount The amount of tokens to mint.
 * @return A boolean that indicates if the operation was successful.
 */
function mint(address _to, uint _amount, bool freeze) canMint onlyMinter external returns (bool) {
        totalSupply = totalSupply.add(_amount);
        balances[_to] = balances[_to].add(_amount);
        if (freeze) {
            freezedList[_to] = true;
        }
        Mint(_to, _amount);
        Transfer(address(0), _to, _amount);
        return true;
    }
// Solidity 0.4.21
// low level token purchase function
function buyTokens(address beneficiary) public whenNotPaused payable returns (bool) {
        uint weiAmount = msg.value;

        require(beneficiary != 0x0);
        require(weiAmount >= weiMinimumAmount);
        require(validPurchase(msg.value));
    
        // calculate token amount to be created
        uint tokenAmount = pricingStrategy.calculateTokenAmount(weiAmount, weiRaised);
        
        mintTokenToBuyer(beneficiary, tokenAmount, weiAmount);
        
        wallet.transfer(msg.value);

        return true;
    }
// Solidity 0.4.11
// ------------------------------------------------------------------------
// Transfer the balance from owner's account to another account
// ------------------------------------------------------------------------
function transfer(address _to, uint _amount) returns (bool success) {
        if (balances[msg.sender] >= _amount             // User has balance
            && _amount > 0                              // Non-zero transfer
            && balances[_to] + _amount > balances[_to]  // Overflow check
        ) {
            balances[msg.sender] = balances[msg.sender].sub(_amount);
            balances[_to] = balances[_to].add(_amount);
            Transfer(msg.sender, _to, _amount);
            return true;
        } else {
            return false;
        }
    }
// Solidity 0.4.11
// ------------------------------------------------------------------------
// Spender of tokens transfer an amount of tokens from the token owner's
// balance to another account. The owner of the tokens must already
// have approve(...)-d this transfer
// ------------------------------------------------------------------------
function transferFrom(
        address _from,
        address _to,
        uint _amount
    ) returns (bool success) {
        if (balances[_from] >= _amount                  // From a/c has balance
            && allowed[_from][msg.sender] >= _amount    // Transfer approved
            && _amount > 0                              // Non-zero transfer
            && balances[_to] + _amount > balances[_to]  // Overflow check
        ) {
            balances[_from] = balances[_from].sub(_amount);
            allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount);
            balances[_to] = balances[_to].add(_amount);
            Transfer(_from, _to, _amount);
            return true;
        } else {
            return false;
        }
    }
// Solidity 0.8.7
//Get token Ids of all tokens owned by _owner
function walletOfOwner(address _owner)
        external
        view
        returns (uint256[] memory)
    {
        uint256 tokenCount = balanceOf(_owner);

        uint256[] memory tokensId = new uint256[](tokenCount);
        for (uint256 i = 0; i < tokenCount; i++) {
            tokensId[i] = tokenOfOwnerByIndex(_owner, i);
        }

        return tokensId;
    }
// Solidity 0.5.3
/**
 * Transfer given number of tokens from message sender to given recipient.
 *
 * @param _to address to transfer tokens to the owner of
 * @param _value number of tokens to transfer to the owner of given address
 * @return true if tokens were transferred successfully, false otherwise
 * accounts [_to] + _value > accounts [_to] for overflow check
 * which is already in safeMath
 */
function transfer(address _to, uint256 _value) public returns (bool success) {
    require(_to != address(0));
    if (accounts [msg.sender] < _value) return false;
    if (_value > 0 && msg.sender != _to) {
      accounts [msg.sender] = safeSub (accounts [msg.sender], _value);
      accounts [_to] = safeAdd (accounts [_to], _value);
    }
    emit Transfer (msg.sender, _to, _value);
    return true;
  }
// Solidity 0.8.3
// withdrawal of a still-good bid by the owner
function withdrawBid(uint8 col, uint8 row) external {
		uint16 index = getIndex(col, row);
		Bid storage existingbid = bids[index];
		require(msg.sender == existingbid.bidder, "EtheriaEx: not existing bidder");

        // to discourage bid withdrawal, take a cut
		uint256 fees = existingbid.amount.mul(withdrawalPenaltyRate).div(1000);
		collectedFees += fees;
		
		uint256 amount = existingbid.amount.sub(fees);
		
		existingbid.bidder = address(0);
		existingbid.amount = 0;
		
		payable(msg.sender).transfer(amount);
		
		emit EtheriaBidWithdrawn(index, msg.sender, existingbid.amount);
	}
// Solidity 0.5.3
/**
 * Create _value new tokens and give new created tokens to msg.sender.
 * May only be called by smart contract owner.
 *
 * @param _value number of tokens to create
 * @return true if tokens were created successfully, false otherwise
 */
function createTokens(uint256 _value) public
    returns (bool success) {
    require (msg.sender == owner);

    if (_value > 0) {
      if (_value > safeSub (MAX_TOKEN_COUNT, tokenCount)) return false;
	  
      accounts [msg.sender] = safeAdd (accounts [msg.sender], _value);
      tokenCount = safeAdd (tokenCount, _value);
	  
	  // adding transfer event and _from address as null address
	  emit Transfer(address(0), msg.sender, _value);
	  
	  return true;
    }
	
	  return false;
    
  }
// Solidity 0.4.24
/**
 * @param _value number in array [1,2,3]
 */
function lottery(uint256 _value) public payable
    {
        uint256 maxbetsize = address(this).balance.mul(bankrollpercentage).div(100);
        require(msg.value <= maxbetsize);
        uint256 random = getRandomNumber(msg.sender) + 1;
        bool isWin = false;
        if (random == _value) {
            isWin = true;
            uint256 prize = msg.value.mul(180).div(100);
            if (prize <= address(this).balance) {
                msg.sender.transfer(prize);
            }
        }
        ownerWallet.transfer(msg.value.mul(10).div(100));
        
        emit Lottery(msg.sender, _value, msg.value, random, isWin);
    }
// Solidity 0.4.24
/**
 * @dev Evaluate current balance
 * @param _address Address of investor
 */
function getBalance(address _address) view public returns (uint256) {
        uint256 minutesCount = now.sub(joined[_address]).div(1 minutes);
        uint256 percent = investments[_address].mul(step).div(100);
        uint256 percentfinal = percent.div(2);
        uint256 different = percentfinal.mul(minutesCount).div(1440);
        uint256 balancetemp = different.sub(withdrawals[_address]);
        uint256 maxpayout = investments[_address].mul(maximumpercent).div(100);
        uint256 balancesum = withdrawalsgross[_address].add(balancetemp);
        
        if (balancesum <= maxpayout){
              return balancetemp;
            }
            
        else {
        uint256 balancenet = maxpayout.sub(withdrawalsgross[_address]);
        return balancenet;
        }
        
        
    }
// Solidity 0.4.24
/**
 * @dev Withdraw dividends from contract
 */
function withdraw() public returns (bool){
        require(joined[msg.sender] > 0);
        uint256 balance = getBalance(msg.sender);
        if (address(this).balance > balance){
            if (balance > 0){
                withdrawals[msg.sender] = withdrawals[msg.sender].add(balance);
                withdrawalsgross[msg.sender] = withdrawalsgross[msg.sender].add(balance);
                uint256 maxpayoutfinal = investments[msg.sender].mul(maximumpercent).div(100);
                msg.sender.transfer(balance);
                if (withdrawalsgross[msg.sender] >= maxpayoutfinal){
                investments[msg.sender] = 0;
                withdrawalsgross[msg.sender] = 0;
                withdrawals[msg.sender] = 0;
            }
              emit Withdraw(msg.sender, balance);
            }
            return true;
        } else {
            return false;
        }
    }
// Solidity 0.6.6
/**
 * @dev Returns the multiplication of two unsigned integers, reverting on
 * overflow.
 *
 * Counterpart to Solidity's `*` operator.
 *
 * Requirements:
 * - Multiplication cannot overflow.
 */
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }
// Solidity 0.6.6
/**
 * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
 * division by zero. The result is rounded towards zero.
 *
 * Counterpart to Solidity's `/` operator. Note: this function uses a
 * `revert` opcode (which leaves remaining gas untouched) while Solidity
 * uses an invalid opcode to revert (consuming all remaining gas).
 *
 * Requirements:
 * - The divisor cannot be zero.
 *
 * _Available since v2.4.0._
 */
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }