Program: 157745
Project: 157745
Buggy source:
/** 
 * @param manaType the mana type that should be paid
 * @param ability
 * @param filter
 * @param game
 * @param costToPay complete costs to pay (needed to check conditional mana)
 * @param usedManaToPay the information about what mana was paid
 * @return
 */
public boolean pay(ManaType manaType,Ability ability,Filter filter,Game game,Cost costToPay,Mana usedManaToPay){
  if (!autoPayment && manaType != unlockedManaType) {
    return false;
  }
  if (autoPayment && autoPaymentRestricted && !wasManaAddedBeyondStock()&& manaType != unlockedManaType) {
    return false;
  }
  if (getConditional(manaType,ability,filter,game,costToPay) > 0) {
    removeConditional(manaType,ability,game,costToPay,usedManaToPay);
    lockManaType();
    return true;
  }
  for (  ManaPoolItem mana : manaItems) {
    if (filter != null) {
      if (!filter.match(mana.getSourceObject(),game)) {
        if (!(mana.getSourceObject() instanceof Spell) || ability.getSourceId().equals(mana.getSourceId())) {
          continue;
        }
      }
    }
    if (manaType != unlockedManaType && autoPayment && autoPaymentRestricted && mana.count() == mana.getStock()) {
      continue;
    }
    ManaType usableManaType=game.getContinuousEffects().asThoughMana(manaType,mana,ability.getSourceId(),ability,ability.getControllerId(),game);
    if (usableManaType == null) {
      continue;
    }
    if (mana.get(usableManaType) > 0) {
      GameEvent event=new GameEvent(GameEvent.EventType.MANA_PAID,ability.getId(),mana.getSourceId(),ability.getControllerId(),0,mana.getFlag());
      event.setData(mana.getOriginalId().toString());
      game.fireEvent(event);
      usedManaToPay.increase(mana.getFirstAvailable());
      mana.remove(usableManaType);
      if (mana.count() == 0) {
        manaItems.remove(mana);
      }
      lockManaType();
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @param manaType the mana type that should be paid
 * @param ability
 * @param filter
 * @param game
 * @param costToPay complete costs to pay (needed to check conditional mana)
 * @param usedManaToPay the information about what mana was paid
 * @return
 */
public boolean pay(ManaType manaType,Ability ability,Filter filter,Game game,Cost costToPay,Mana usedManaToPay){
  if (!autoPayment && manaType != unlockedManaType) {
    return false;
  }
  ManaType possibleAsThoughtPoolManaType=null;
  if (autoPayment && autoPaymentRestricted && !wasManaAddedBeyondStock()&& manaType != unlockedManaType) {
    if (unlockedManaType != null) {
      ManaPoolItem checkItem=new ManaPoolItem();
      checkItem.add(unlockedManaType,1);
      possibleAsThoughtPoolManaType=game.getContinuousEffects().asThoughMana(manaType,checkItem,ability.getSourceId(),ability,ability.getControllerId(),game);
    }
    if (possibleAsThoughtPoolManaType == null || possibleAsThoughtPoolManaType != unlockedManaType) {
      return false;
    }
  }
  if (getConditional(manaType,ability,filter,game,costToPay) > 0) {
    removeConditional(manaType,ability,game,costToPay,usedManaToPay);
    lockManaType();
    return true;
  }
  for (  ManaPoolItem mana : manaItems) {
    if (filter != null) {
      if (!filter.match(mana.getSourceObject(),game)) {
        if (!(mana.getSourceObject() instanceof Spell) || ability.getSourceId().equals(mana.getSourceId())) {
          continue;
        }
      }
    }
    if (possibleAsThoughtPoolManaType == null && manaType != unlockedManaType && autoPayment && autoPaymentRestricted && mana.count() == mana.getStock()) {
      continue;
    }
    ManaType usableManaType=game.getContinuousEffects().asThoughMana(manaType,mana,ability.getSourceId(),ability,ability.getControllerId(),game);
    if (usableManaType == null) {
      continue;
    }
    if (mana.get(usableManaType) > 0) {
      GameEvent event=new GameEvent(GameEvent.EventType.MANA_PAID,ability.getId(),mana.getSourceId(),ability.getControllerId(),0,mana.getFlag());
      event.setData(mana.getOriginalId().toString());
      game.fireEvent(event);
      usedManaToPay.increase(mana.getFirstAvailable());
      mana.remove(usableManaType);
      if (mana.count() == 0) {
        manaItems.remove(mana);
      }
      lockManaType();
      return true;
    }
  }
  return false;
}