nus-yam/ex-repair huggingface dataset:
Program: 158058
Project: 158058
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent targetCreature=game.getPermanent(getTargetPointer().getFirst(game,source));
  if (targetCreature != null) {
    Effect effect=new RemoveCounterTargetEffect(CounterType.M1M1.createInstance(1));
    effect.setTargetPointer(targetPointer);
    effect.apply(game,source);
  }
  targetCreature=game.getPermanent(source.getTargets().get(1).getFirstTarget());
  if (targetCreature != null) {
    Effect effect=new AddCountersTargetEffect(CounterType.M1M1.createInstance(1));
    effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget()));
    effect.apply(game,source);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent targetCreature=game.getPermanent(getTargetPointer().getFirst(game,source));
  if (targetCreature != null && targetCreature.getCounters(game).containsKey(CounterType.M1M1)) {
    Effect effect=new RemoveCounterTargetEffect(CounterType.M1M1.createInstance(1));
    effect.setTargetPointer(targetPointer);
    effect.apply(game,source);
  }
  targetCreature=game.getPermanent(source.getTargets().get(1).getFirstTarget());
  if (targetCreature != null) {
    Effect effect=new AddCountersTargetEffect(CounterType.M1M1.createInstance(1));
    effect.setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget()));
    effect.apply(game,source);
  }
  return true;
}
Program: 158059
Project: 158059
Buggy source:
@Override public void adjustTargets(Ability ability,Game game){
  if (ability.getOriginalId().equals(originalId)) {
    ability.getTargets().clear();
    ability.addTarget(new TargetControlledCreaturePermanent());
    FilterCreaturePermanent filter=new FilterCreaturePermanent("String_Node_Str");
    UUID defenderId=game.getCombat().getDefenderId(ability.getSourceId());
    filter.add(new ControllerIdPredicate(defenderId));
    TargetCreaturePermanent target=new TargetCreaturePermanent(filter);
    ability.addTarget(target);
  }
}

Fixed version (ground truth):
@Override public void adjustTargets(Ability ability,Game game){
  if (ability.getOriginalId().equals(originalId)) {
    ability.getTargets().clear();
    ability.addTarget(new TargetControlledCreaturePermanent());
    FilterCreaturePermanent filter=new FilterCreaturePermanent("String_Node_Str");
    UUID defenderId=game.getCombat().getDefenderId(ability.getSourceId());
    filter.add(new ControllerIdPredicate(defenderId));
    TargetCreaturePermanent target=new TargetCreaturePermanent(0,1,filter,false);
    ability.addTarget(target);
  }
}
Program: 158060
Project: 158060
Buggy source:
public GlyphKeeperAbility(final GlyphKeeperAbility ability){
  super(ability);
  turnUsed=ability.turnUsed;
}

Fixed version (ground truth):
public GlyphKeeperAbility(final GlyphKeeperAbility ability){
  super(ability);
}
Program: 158061
Project: 158061
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getTargetId().equals(this.getSourceId()) && game.getTurnNum() > turnUsed) {
    this.getTargets().clear();
    TargetStackObject target=new TargetStackObject();
    target.add(event.getSourceId(),game);
    this.addTarget(target);
    turnUsed=game.getTurnNum();
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getTargetId().equals(this.getSourceId())) {
    Permanent permanent=game.getPermanent(event.getTargetId());
    if (permanent != null && permanent.isCreature()) {
      NumberOfTimesPermanentTargetedATurnWatcher watcher=(NumberOfTimesPermanentTargetedATurnWatcher)game.getState().getWatchers().get(NumberOfTimesPermanentTargetedATurnWatcher.class.getName());
      if (watcher != null && watcher.notMoreThanOnceTargetedThisTurn(permanent,game)) {
        for (        Effect effect : getEffects()) {
          effect.setTargetPointer(new FixedTarget(event.getSourceId()));
        }
        return true;
      }
    }
  }
  return false;
}
Program: 158062
Project: 158062
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getTargetId().equals(this.getSourceId())) {
    Permanent permanent=game.getPermanent(event.getTargetId());
    if (permanent != null && permanent.isCreature()) {
      KiraGreatGlassSpinnerWatcher watcher=(KiraGreatGlassSpinnerWatcher)game.getState().getWatchers().get(KiraGreatGlassSpinnerWatcher.class.getName());
      if (watcher != null && watcher.notMoreThanOnceTargetedThisTurn(permanent,game)) {
        for (        Effect effect : getEffects()) {
          effect.setTargetPointer(new FixedTarget(event.getSourceId()));
        }
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getTargetId().equals(this.getSourceId())) {
    Permanent permanent=game.getPermanent(event.getTargetId());
    if (permanent != null && permanent.isCreature()) {
      NumberOfTimesPermanentTargetedATurnWatcher watcher=(NumberOfTimesPermanentTargetedATurnWatcher)game.getState().getWatchers().get(NumberOfTimesPermanentTargetedATurnWatcher.class.getName());
      if (watcher != null && watcher.notMoreThanOnceTargetedThisTurn(permanent,game)) {
        for (        Effect effect : getEffects()) {
          effect.setTargetPointer(new FixedTarget(event.getSourceId()));
        }
        return true;
      }
    }
  }
  return false;
}
Program: 158063
Project: 158063
Buggy source:
@Override public KiraGreatGlassSpinnerWatcher copy(){
  return new KiraGreatGlassSpinnerWatcher(this);
}

Fixed version (ground truth):
@Override public KiraGreatGlassSpinnerAbility copy(){
  return new KiraGreatGlassSpinnerAbility(this);
}
Program: 158064
Project: 158064
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player cursedPlayer=game.getPlayer(targetPointer.getFirst(game,source));
  Player controller=game.getPlayer(source.getControllerId());
  if (cursedPlayer != null && controller != null) {
    if (cursedPlayer.chooseUse(outcome,"String_Node_Str",source,game)) {
      FilterControlledPermanent filter=new FilterControlledPermanent();
      filter.add(Predicates.or(new CardTypePredicate(CardType.CREATURE),new CardTypePredicate(CardType.PLANESWALKER)));
      TargetPermanent target=new TargetPermanent(filter);
      if (cursedPlayer.choose(outcome,target,source.getId(),game)) {
        Permanent objectToBeSacrificed=game.getPermanent(target.getFirstTarget());
        if (objectToBeSacrificed != null) {
          if (objectToBeSacrificed.sacrifice(source.getId(),game)) {
            return true;
          }
        }
      }
    }
    cursedPlayer.loseLife(5,game,false);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player cursedPlayer=game.getPlayer(targetPointer.getFirst(game,source));
  Player controller=game.getPlayer(source.getControllerId());
  if (cursedPlayer != null && controller != null) {
    FilterControlledPermanent filter=new FilterControlledPermanent("String_Node_Str");
    filter.add(Predicates.or(new CardTypePredicate(CardType.CREATURE),new CardTypePredicate(CardType.PLANESWALKER)));
    TargetPermanent target=new TargetPermanent(filter);
    if (cursedPlayer.choose(Outcome.Sacrifice,target,source.getId(),game)) {
      Permanent objectToBeSacrificed=game.getPermanent(target.getFirstTarget());
      if (objectToBeSacrificed != null) {
        if (objectToBeSacrificed.sacrifice(source.getId(),game)) {
          return true;
        }
      }
    }
    cursedPlayer.loseLife(5,game,false);
  }
  return false;
}
Program: 158065
Project: 158065
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Spell spell=game.getStack().getSpell(source.getSourceId());
  if (controller != null && spell != null) {
    ApproachOfTheSecondSunWatcher watcher=(ApproachOfTheSecondSunWatcher)game.getState().getWatchers().get(ApproachOfTheSecondSunWatcher.class.getName());
    if (watcher != null && watcher.getApproachesCast(controller.getId()) > 1 && spell.getFromZone() == Zone.HAND) {
      controller.won(game);
    }
 else {
      controller.gainLife(7,game);
      Card spellCard=game.getStack().getSpell(source.getSourceId()).getCard();
      if (spellCard != null) {
        List<Card> top6=new ArrayList<>();
        for (int i=0; i < 6 && controller.getLibrary().hasCards(); ++i) {
          top6.add(controller.getLibrary().removeFromTop(game));
        }
        boolean isOnBottom=!controller.getLibrary().hasCards();
        spellCard.moveToZone(Zone.LIBRARY,source.getSourceId(),game,true);
        for (int i=top6.size() - 1; i >= 0; --i) {
          controller.getLibrary().putOnTop(top6.get(i),game);
        }
        if (isOnBottom) {
          game.informPlayers(controller.getLogName() + "String_Node_Str" + spell.getLogName()+ "String_Node_Str");
        }
 else {
          game.informPlayers(controller.getLogName() + "String_Node_Str" + spell.getLogName()+ "String_Node_Str");
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  Spell spell=game.getStack().getSpell(source.getSourceId());
  if (controller != null && spell != null) {
    ApproachOfTheSecondSunWatcher watcher=(ApproachOfTheSecondSunWatcher)game.getState().getWatchers().get(ApproachOfTheSecondSunWatcher.class.getName());
    if (watcher != null && watcher.getApproachesCast(controller.getId()) > 1 && spell.getFromZone() == Zone.HAND) {
      controller.won(game);
    }
 else {
      controller.gainLife(7,game);
      Card spellCard=game.getStack().getSpell(source.getSourceId()).getCard();
      if (spellCard != null) {
        List<Card> top6=new ArrayList<>();
        for (int i=0; i < 6 && controller.getLibrary().hasCards(); ++i) {
          top6.add(controller.getLibrary().removeFromTop(game));
        }
        boolean isOnBottom=controller.getLibrary().size() < 6;
        spellCard.moveToZone(Zone.LIBRARY,source.getSourceId(),game,true);
        for (int i=top6.size() - 1; i >= 0; --i) {
          controller.getLibrary().putOnTop(top6.get(i),game);
        }
        if (isOnBottom) {
          game.informPlayers(controller.getLogName() + "String_Node_Str" + spell.getLogName()+ "String_Node_Str");
        }
 else {
          game.informPlayers(controller.getLogName() + "String_Node_Str" + spell.getLogName()+ "String_Node_Str");
        }
      }
    }
    return true;
  }
  return false;
}
Program: 158066
Project: 158066
Buggy source:
/** 
 * Returns a predicate that evaluates to   {@code true} if either of its components evaluates to {@code true}. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a true predicate is found.
 * @param < T >
 * @param first
 * @param second
 * @return 
 */
public static <T>Predicate<T> or(Predicate<? super T> first,Predicate<? super T> second){
  return new OrPredicate<>(Predicates.<T>asList(first,second));
}

Fixed version (ground truth):
/** 
 * Returns a predicate that evaluates to   {@code true} if either of its components evaluates to {@code true}. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a true predicate is found.
 * @param < T >
 * @param first
 * @param second
 * @return 
 */
public static <T>Predicate<T> or(Predicate<? super T> first,Predicate<? super T> second){
  return new OrPredicate<T>(Predicates.<T>asList(first,second));
}
Program: 158067
Project: 158067
Buggy source:
static <T>List<T> defensiveCopy(Iterable<T> iterable){
  ArrayList<T> list=new ArrayList<>();
  for (  T element : iterable) {
    list.add(checkNotNull(element));
  }
  return list;
}

Fixed version (ground truth):
static <T>List<T> defensiveCopy(Iterable<T> iterable){
  ArrayList<T> list=new ArrayList<T>();
  for (  T element : iterable) {
    list.add(checkNotNull(element));
  }
  return list;
}
Program: 158068
Project: 158068
Buggy source:
/** 
 * Returns a predicate that evaluates to   {@code true} if the given predicate evaluates to {@code false}.
 * @param < T >
 * @param predicate
 * @return 
 */
public static <T>Predicate<T> not(Predicate<T> predicate){
  return new NotPredicate<>(predicate);
}

Fixed version (ground truth):
/** 
 * Returns a predicate that evaluates to   {@code true} if the given predicate evaluates to {@code false}.
 * @param < T >
 * @param predicate
 * @return 
 */
public static <T>Predicate<T> not(Predicate<T> predicate){
  return new NotPredicate<T>(predicate);
}
Program: 158069
Project: 158069
Buggy source:
/** 
 * Returns a predicate that evaluates to   {@code true} if both of its components evaluate to {@code true}. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is found.
 * @param < T >
 * @param first
 * @param second
 * @return 
 */
public static <T>Predicate<T> and(Predicate<? super T> first,Predicate<? super T> second){
  return new AndPredicate<>(Predicates.<T>asList(checkNotNull(first),checkNotNull(second)));
}

Fixed version (ground truth):
/** 
 * Returns a predicate that evaluates to   {@code true} if both of its components evaluate to {@code true}. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is found.
 * @param < T >
 * @param first
 * @param second
 * @return 
 */
public static <T>Predicate<T> and(Predicate<? super T> first,Predicate<? super T> second){
  return new AndPredicate<T>(Predicates.<T>asList(checkNotNull(first),checkNotNull(second)));
}
Program: 158070
Project: 158070
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  boolean weControlSource=game.getControllerId(event.getSourceId()).equals(source.getControllerId());
  boolean isNoncombatDamage=!((DamageCreatureEvent)event).isCombatDamage();
  return weControlSource && isNoncombatDamage;
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  UUID sourceControllerId=game.getControllerId(event.getSourceId());
  UUID targetControllerId=game.getControllerId(event.getTargetId());
  UUID controllerId=source.getControllerId();
  boolean weControlSource=controllerId == sourceControllerId;
  boolean opponentControlsTarget=game.getOpponents(sourceControllerId).contains(targetControllerId);
  boolean isNoncombatDamage=!((DamageCreatureEvent)event).isCombatDamage();
  return weControlSource && isNoncombatDamage && opponentControlsTarget;
}
Program: 158072
Project: 158072
Buggy source:
public void ask(final String question,final Map<String,Serializable> options){
  if (!killed) {
    UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_TARGET,game.getId(),new GameClientMessage(getGameView(),question,options))));
  }
}

Fixed version (ground truth):
public void ask(final String question,final Map<String,Serializable> options){
  if (!killed) {
    UserManager.instance.getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.GAME_ASK,game.getId(),new GameClientMessage(getGameView(),question,options))));
  }
}
Program: 158073
Project: 158073
Buggy source:
public final EnumSet<SuperType> getSupertypes(){
  EnumSet<SuperType> list=EnumSet.noneOf(SuperType.class);
  for (  String type : this.types.split(SEPARATOR)) {
    try {
      list.add(SuperType.valueOf(type));
    }
 catch (    IllegalArgumentException e) {
    }
  }
  return list;
}

Fixed version (ground truth):
public final EnumSet<SuperType> getSupertypes(){
  EnumSet<SuperType> list=EnumSet.noneOf(SuperType.class);
  for (  String type : this.supertypes.split(SEPARATOR)) {
    try {
      list.add(SuperType.valueOf(type));
    }
 catch (    IllegalArgumentException e) {
    }
  }
  return list;
}
Program: 158074
Project: 158074
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getData().equals(CounterType.M1M1.getName())) {
    Permanent permanent=game.getPermanentOrLKIBattlefield(event.getTargetId());
    if (permanent == null) {
      permanent=game.getPermanentEntering(event.getTargetId());
    }
    return (permanent != null && permanent.isCreature());
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (event.getData().equals(CounterType.M1M1.getName()) && controllerId.equals(game.getControllerId(event.getSourceId()))) {
    Permanent permanent=game.getPermanentOrLKIBattlefield(event.getTargetId());
    if (permanent == null) {
      permanent=game.getPermanentEntering(event.getTargetId());
    }
    return (permanent != null && permanent.isCreature());
  }
  return false;
}
Program: 158075
Project: 158075
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=game.getLastKnownInformation(source.getSourceId(),Zone.BATTLEFIELD);
  if (controller != null) {
    for (    UUID opponentId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player opponent=game.getPlayer(opponentId);
      if (opponent != null && opponent != controller) {
        TargetCard target=new TargetCardInYourGraveyard(2,2,new FilterCard());
        target.setNotTarget(true);
        Cards cardsInGraveyard=opponent.getGraveyard();
        opponent.choose(outcome,cardsInGraveyard,target,game);
        if (!cardsInGraveyard.isEmpty()) {
          for (          Card cardInGraveyard : cardsInGraveyard.getCards(game)) {
            if (!target.getTargets().contains(cardInGraveyard.getId())) {
              opponent.moveCardToExileWithInfo(cardInGraveyard,CardUtil.getCardExileZoneId(game,source.getId()),sourceObject.getLogName(),source.getId(),game,Zone.GRAVEYARD,true);
            }
          }
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=game.getLastKnownInformation(source.getSourceId(),Zone.BATTLEFIELD);
  if (controller != null) {
    for (    UUID opponentId : game.getState().getPlayersInRange(controller.getId(),game)) {
      Player opponent=game.getPlayer(opponentId);
      if (opponent != null && opponent != controller) {
        TargetCard target=new TargetCardInYourGraveyard(2,2,new FilterCard());
        target.setNotTarget(true);
        Cards cardsInGraveyard=opponent.getGraveyard();
        if (cardsInGraveyard.size() > 2) {
          opponent.choose(outcome,cardsInGraveyard,target,game);
          for (          Card cardInGraveyard : cardsInGraveyard.getCards(game)) {
            if (!target.getTargets().contains(cardInGraveyard.getId())) {
              opponent.moveCardToExileWithInfo(cardInGraveyard,CardUtil.getCardExileZoneId(game,source.getId()),sourceObject.getLogName(),source.getId(),game,Zone.GRAVEYARD,true);
            }
          }
        }
      }
    }
    return true;
  }
  return false;
}
Program: 158076
Project: 158076
Buggy source:
private void startMatch(TournamentPairing pair,MatchOptions matchOptions){
  try {
    TableManager tableManager=TableManager.instance;
    Table table=tableManager.createTable(GamesRoomManager.instance.getMainRoomId(),matchOptions);
    table.setTournamentSubTable(true);
    table.setTournament(tournament);
    table.setState(TableState.WAITING);
    TournamentPlayer player1=pair.getPlayer1();
    TournamentPlayer player2=pair.getPlayer2();
    Optional<UUID> user1Id=getPlayerUserId(player1.getPlayer().getId());
    Optional<UUID> user2Id=getPlayerUserId(player2.getPlayer().getId());
    if (user1Id.isPresent() && user2Id.isPresent()) {
      tableManager.addPlayer(getPlayerUserId(player1.getPlayer().getId()).get(),table.getId(),player1);
      tableManager.addPlayer(getPlayerUserId(player2.getPlayer().getId()).get(),table.getId(),player2);
      table.setState(TableState.STARTING);
      tableManager.startTournamentSubMatch(null,table.getId());
      tableManager.getMatch(table.getId()).ifPresent(match -> {
        match.setTableId(tableId);
        pair.setMatch(match);
        pair.setTableId(table.getId());
        player1.setState(TournamentPlayerState.DUELING);
        player2.setState(TournamentPlayerState.DUELING);
      }
);
    }
  }
 catch (  GameException ex) {
    logger.fatal("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
private void startMatch(TournamentPairing pair,MatchOptions matchOptions){
  try {
    TableManager tableManager=TableManager.instance;
    Table table=tableManager.createTable(GamesRoomManager.instance.getMainRoomId(),matchOptions);
    table.setTournamentSubTable(true);
    table.setTournament(tournament);
    table.setState(TableState.WAITING);
    TournamentPlayer player1=pair.getPlayer1();
    TournamentPlayer player2=pair.getPlayer2();
    UUID user1Uuid=null;
    UUID user2Uuid=null;
    if (player1.getPlayerType() == PlayerType.HUMAN) {
      Optional<UUID> user1Id=getPlayerUserId(player1.getPlayer().getId());
      if (!user1Id.isPresent()) {
        logger.fatal("String_Node_Str");
      }
 else {
        user1Uuid=user1Id.get();
      }
    }
    if (player2.getPlayerType() == PlayerType.HUMAN) {
      Optional<UUID> user2Id=getPlayerUserId(player2.getPlayer().getId());
      if (!user2Id.isPresent()) {
        logger.fatal("String_Node_Str");
      }
 else {
        user2Uuid=user2Id.get();
      }
    }
    tableManager.addPlayer(user1Uuid,table.getId(),player1);
    tableManager.addPlayer(user2Uuid,table.getId(),player2);
    table.setState(TableState.STARTING);
    tableManager.startTournamentSubMatch(null,table.getId());
    tableManager.getMatch(table.getId()).ifPresent(match -> {
      match.setTableId(tableId);
      pair.setMatch(match);
      pair.setTableId(table.getId());
      player1.setState(TournamentPlayerState.DUELING);
      player2.setState(TournamentPlayerState.DUELING);
    }
);
  }
 catch (  GameException ex) {
    logger.fatal("String_Node_Str",ex);
  }
}
Program: 158078
Project: 158078
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  int inputValue=game.getBattlefield().countAll(filter,getControllerId(),game);
  return ComparisonType.compare(value,type,inputValue);
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  int inputValue=game.getBattlefield().countAll(filter,getControllerId(),game);
  return ComparisonType.compare(inputValue,type,value);
}
Program: 158079
Project: 158079
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  int count=1 + new CountersSourceCount(CounterType.LOYALTY).calculate(game,source,this);
  FilterPermanentCard filter=new FilterPermanentCard();
  filter.add(Predicates.or(new CardTypePredicate(CardType.CREATURE),new CardTypePredicate(CardType.LAND)));
  filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan,count));
  Card card=player.getLibrary().getFromTop(game);
  if (card != null) {
    Cards cards=new CardsImpl();
    cards.add(card);
    player.lookAtCards("String_Node_Str",cards,game);
    if (filter.match(card,game)) {
      String message="String_Node_Str" + card.getName() + "String_Node_Str";
      if (player.chooseUse(outcome,message,source,game)) {
        return card.putOntoBattlefield(game,Zone.LIBRARY,source.getSourceId(),source.getControllerId(),false);
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  int count=1 + new CountersSourceCount(CounterType.LOYALTY).calculate(game,source,this);
  FilterPermanentCard filter=new FilterPermanentCard();
  filter.add(Predicates.or(new CardTypePredicate(CardType.CREATURE),new CardTypePredicate(CardType.LAND)));
  filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN,count));
  Card card=player.getLibrary().getFromTop(game);
  if (card != null) {
    Cards cards=new CardsImpl();
    cards.add(card);
    player.lookAtCards("String_Node_Str",cards,game);
    if (filter.match(card,game)) {
      String message="String_Node_Str" + card.getName() + "String_Node_Str";
      if (player.chooseUse(outcome,message,source,game)) {
        return card.putOntoBattlefield(game,Zone.LIBRARY,source.getSourceId(),source.getControllerId(),false);
      }
    }
  }
  return true;
}
Program: 158080
Project: 158080
Buggy source:
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  FilterControlledCreaturePermanent filter=new FilterControlledCreaturePermanent();
  filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan,3));
  filter.add(new AnotherPredicate());
  if (permanent.getId().equals(source.getSourceId())) {
    Player controller=game.getPlayer(source.getControllerId());
    if (controller != null) {
      int permanentsOnBattlefield=game.getBattlefield().count(filter,source.getSourceId(),source.getControllerId(),game);
      return (CountType.compare(permanentsOnBattlefield,CountType.FEWER_THAN,1));
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  FilterControlledCreaturePermanent filter=new FilterControlledCreaturePermanent();
  filter.add(new PowerPredicate(ComparisonType.MORE_THAN,3));
  filter.add(new AnotherPredicate());
  if (permanent.getId().equals(source.getSourceId())) {
    Player controller=game.getPlayer(source.getControllerId());
    if (controller != null) {
      int permanentsOnBattlefield=game.getBattlefield().count(filter,source.getSourceId(),source.getControllerId(),game);
      return permanentsOnBattlefield < 1;
    }
    return true;
  }
  return false;
}
Program: 158081
Project: 158081
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  int count=1 + new CountersSourceCount(CounterType.LOYALTY).calculate(game,source,this);
  FilterPermanentCard filter=new FilterPermanentCard();
  filter.add(Predicates.or(new CardTypePredicate(CardType.CREATURE),new CardTypePredicate(CardType.LAND)));
  filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan,count));
  Card card=player.getLibrary().getFromTop(game);
  if (card != null) {
    Cards cards=new CardsImpl();
    cards.add(card);
    player.lookAtCards("String_Node_Str",cards,game);
    if (filter.match(card,game)) {
      String message="String_Node_Str" + card.getName() + "String_Node_Str";
      if (player.chooseUse(outcome,message,source,game)) {
        return card.putOntoBattlefield(game,Zone.LIBRARY,source.getSourceId(),source.getControllerId(),false);
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player player=game.getPlayer(source.getControllerId());
  if (player == null) {
    return false;
  }
  int count=1 + new CountersSourceCount(CounterType.LOYALTY).calculate(game,source,this);
  FilterPermanentCard filter=new FilterPermanentCard();
  filter.add(Predicates.or(new CardTypePredicate(CardType.CREATURE),new CardTypePredicate(CardType.LAND)));
  filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN,count));
  Card card=player.getLibrary().getFromTop(game);
  if (card != null) {
    Cards cards=new CardsImpl();
    cards.add(card);
    player.lookAtCards("String_Node_Str",cards,game);
    if (filter.match(card,game)) {
      String message="String_Node_Str" + card.getName() + "String_Node_Str";
      if (player.chooseUse(outcome,message,source,game)) {
        return card.putOntoBattlefield(game,Zone.LIBRARY,source.getSourceId(),source.getControllerId(),false);
      }
    }
  }
  return true;
}
Program: 158082
Project: 158082
Buggy source:
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  FilterControlledCreaturePermanent filter=new FilterControlledCreaturePermanent();
  filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan,3));
  filter.add(new AnotherPredicate());
  if (permanent.getId().equals(source.getSourceId())) {
    Player controller=game.getPlayer(source.getControllerId());
    if (controller != null) {
      int permanentsOnBattlefield=game.getBattlefield().count(filter,source.getSourceId(),source.getControllerId(),game);
      return (CountType.compare(permanentsOnBattlefield,CountType.FEWER_THAN,1));
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean applies(Permanent permanent,Ability source,Game game){
  FilterControlledCreaturePermanent filter=new FilterControlledCreaturePermanent();
  filter.add(new PowerPredicate(ComparisonType.MORE_THAN,3));
  filter.add(new AnotherPredicate());
  if (permanent.getId().equals(source.getSourceId())) {
    Player controller=game.getPlayer(source.getControllerId());
    if (controller != null) {
      int permanentsOnBattlefield=game.getBattlefield().count(filter,source.getSourceId(),source.getControllerId(),game);
      return permanentsOnBattlefield < 1;
    }
    return true;
  }
  return false;
}
Program: 158083
Project: 158083
Buggy source:
public void installComponents(){
  jLayeredPane.setOpaque(false);
  jLayeredPane.add(abilityPicker);
  jLayeredPane.add(DialogManager.getManager(gameId),JLayeredPane.MODAL_LAYER,0);
  abilityPicker.setVisible(false);
}

Fixed version (ground truth):
public void installComponents(){
  jLayeredPane.setOpaque(false);
  jLayeredPane.add(abilityPicker,JLayeredPane.MODAL_LAYER);
  jLayeredPane.add(DialogManager.getManager(gameId),JLayeredPane.MODAL_LAYER,0);
  abilityPicker.setVisible(false);
}
Program: 158084
Project: 158084
Buggy source:
@Override public void init(Game game,boolean testMode){
  this.abort=false;
  if (!testMode) {
    this.hand.clear();
    this.graveyard.clear();
  }
  this.library.reset();
  this.abilities.clear();
  this.counters.clear();
  this.wins=false;
  this.loses=false;
  this.left=false;
  this.quit=false;
  this.timerTimeout=false;
  this.idleTimeout=false;
  this.turns=0;
  this.isGameUnderControl=true;
  this.turnController=this.getId();
  this.playersUnderYourControl.clear();
  this.passed=false;
  this.passedTurn=false;
  this.passedTurnSkipStack=false;
  this.passedUntilEndOfTurn=false;
  this.passedUntilNextMain=false;
  this.skippedAtLeastOnce=false;
  this.passedUntilStackResolved=false;
  this.passedUntilEndStepBeforeMyTurn=false;
  this.passedAllTurns=false;
  this.justActivatedType=null;
  this.canGainLife=true;
  this.canLoseLife=true;
  this.topCardRevealed=false;
  this.payManaMode=false;
  this.setLife(game.getLife(),game);
  this.setReachedNextTurnAfterLeaving(false);
  this.castSourceIdWithAlternateMana=null;
  this.castSourceIdManaCosts=null;
  this.castSourceIdCosts=null;
}

Fixed version (ground truth):
@Override public void init(Game game,boolean testMode){
  this.abort=false;
  if (!testMode) {
    this.hand.clear();
    this.graveyard.clear();
  }
  this.library.reset();
  this.abilities.clear();
  this.counters.clear();
  this.wins=false;
  this.loses=false;
  this.left=false;
  this.quit=false;
  this.timerTimeout=false;
  this.idleTimeout=false;
  this.turns=0;
  this.isGameUnderControl=true;
  this.turnController=this.getId();
  this.playersUnderYourControl.clear();
  this.passed=false;
  this.passedTurn=false;
  this.passedTurnSkipStack=false;
  this.passedUntilEndOfTurn=false;
  this.passedUntilNextMain=false;
  this.skippedAtLeastOnce=false;
  this.passedUntilStackResolved=false;
  this.passedUntilEndStepBeforeMyTurn=false;
  this.passedAllTurns=false;
  this.justActivatedType=null;
  this.canGainLife=true;
  this.canLoseLife=true;
  this.topCardRevealed=false;
  this.payManaMode=false;
  this.setLife(game.getLife(),game);
  this.setReachedNextTurnAfterLeaving(false);
  this.castSourceIdWithAlternateMana=null;
  this.castSourceIdManaCosts=null;
  this.castSourceIdCosts=null;
  this.getManaPool().init();
}
Program: 158085
Project: 158085
Buggy source:
@Override public boolean apply(Game game,Ability source,UUID originalId,Cost costToPay){
  if (!(source instanceof SpellAbility)) {
    Permanent object=game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (object != null && object.getColor(game).isColorless()) {
      return true;
    }
  }
  if (costToPay instanceof ManaCost) {
    return ((ManaCost)costToPay).getText().contains("String_Node_Str");
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source,UUID originalId,Cost costToPay){
  if (!(source instanceof Spell)) {
    Permanent permanent=game.getPermanentOrLKIBattlefield(source.getSourceId());
    return permanent != null;
  }
  return false;
}
Program: 158086
Project: 158086
Buggy source:
@Test public void testConflagrateFlashback(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",2);
  addCard(Zone.HAND,playerA,"String_Node_Str",1);
  addCard(Zone.GRAVEYARD,playerB,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",2);
  addCard(Zone.HAND,playerB,"String_Node_Str",1);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  setChoice(playerA,"String_Node_Str");
  activateAbility(2,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str");
  setChoice(playerB,"String_Node_Str");
  addTarget(playerB,playerA);
  setStopAt(2,PhaseStep.BEGIN_COMBAT);
  execute();
  assertLife(playerA,19);
  assertLife(playerB,20);
  assertExileCount(playerB,"String_Node_Str",1);
}

Fixed version (ground truth):
@Test public void testConflagrateFlashback(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",2);
  addCard(Zone.HAND,playerA,"String_Node_Str",1);
  addCard(Zone.GRAVEYARD,playerB,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",2);
  addCard(Zone.HAND,playerB,"String_Node_Str",1);
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  setChoice(playerA,"String_Node_Str");
  activateAbility(2,PhaseStep.PRECOMBAT_MAIN,playerB,"String_Node_Str");
  setChoice(playerB,"String_Node_Str");
  addTarget(playerB,playerA);
  setStopAt(2,PhaseStep.BEGIN_COMBAT);
  execute();
  assertExileCount(playerB,"String_Node_Str",1);
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertLife(playerA,19);
  assertLife(playerB,20);
}
Program: 158087
Project: 158087
Buggy source:
/** 
 * Handles the setting of non mana X costs
 * @param controller
 * @param game
 * @return announce message
 */
protected String handleOtherXCosts(Game game,Player controller){
  StringBuilder announceString=new StringBuilder();
  for (  VariableCost variableCost : this.costs.getVariableCosts()) {
    if (!(variableCost instanceof VariableManaCost)) {
      int xValue=variableCost.announceXValue(this,game);
      Cost fixedCost=variableCost.getFixedCostsFromAnnouncedValue(xValue);
      if (fixedCost != null) {
        costs.add(fixedCost);
      }
      variableCost.setAmount(xValue);
      ((Cost)variableCost).setPaid();
      String message=controller.getLogName() + "String_Node_Str" + xValue+ "String_Node_Str"+ variableCost.getActionText()+ ')';
      announceString.append(message);
    }
  }
  return announceString.toString();
}

Fixed version (ground truth):
/** 
 * Handles the setting of non mana X costs
 * @param controller
 * @param game
 * @return announce message
 */
protected String handleOtherXCosts(Game game,Player controller){
  StringBuilder announceString=new StringBuilder();
  for (  VariableCost variableCost : this.costs.getVariableCosts()) {
    if (!(variableCost instanceof VariableManaCost) && !((Cost)variableCost).isPaid()) {
      int xValue=variableCost.announceXValue(this,game);
      Cost fixedCost=variableCost.getFixedCostsFromAnnouncedValue(xValue);
      if (fixedCost != null) {
        costs.add(fixedCost);
      }
      variableCost.setAmount(xValue);
      ((Cost)variableCost).setPaid();
      String message=controller.getLogName() + "String_Node_Str" + xValue+ "String_Node_Str"+ variableCost.getActionText()+ ')';
      announceString.append(message);
    }
  }
  return announceString.toString();
}
Program: 158088
Project: 158088
Buggy source:
@Override public int announceXValue(Ability source,Game game){
  int xValue=0;
  Player controller=game.getPlayer(source.getControllerId());
  StackObject stackObject=game.getStack().getStackObject(source.getId());
  if (controller != null && stackObject != null) {
    xValue=controller.announceXCost(getMinValue(source,game),getMaxValue(source,game),"String_Node_Str" + actionText,game,source,this);
  }
  return xValue;
}

Fixed version (ground truth):
@Override public int announceXValue(Ability source,Game game){
  int xValue=0;
  Player controller=game.getPlayer(source.getControllerId());
  StackObject stackObject=game.getStack().getStackObject(source.getId());
  if (controller != null && (source instanceof FlashbackAbility || stackObject != null)) {
    xValue=controller.announceXCost(getMinValue(source,game),getMaxValue(source,game),"String_Node_Str" + actionText,game,source,this);
  }
  return xValue;
}
Program: 158089
Project: 158089
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  if (creature != null) {
    creature.addCounters(CounterType.P1P1.createInstance(),source,game);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  if (creature != null) {
    creature.addCounters(CounterType.P1P1.createInstance(),source,game,event.getAppliedEffects());
  }
  return false;
}
Program: 158090
Project: 158090
Buggy source:
@Override public boolean apply(Game game,Ability source){
  int maxPower=0;
  for (  Permanent perm : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(),source.getControllerId(),game)) {
    if (perm.getPower().getValue() > maxPower) {
      maxPower=perm.getPower().getValue();
    }
  }
  ContinuousEffect effect=new GainAbilityControlledEffect(TrampleAbility.getInstance(),Duration.EndOfStep,new FilterCreaturePermanent());
  game.addEffect(effect,source);
  if (maxPower != 0) {
    effect=new BoostControlledEffect(maxPower,maxPower,Duration.EndOfTurn);
    game.addEffect(effect,source);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  int maxPower=0;
  for (  Permanent perm : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(),source.getControllerId(),game)) {
    if (perm.getPower().getValue() > maxPower) {
      maxPower=perm.getPower().getValue();
    }
  }
  ContinuousEffect effect=new GainAbilityControlledEffect(TrampleAbility.getInstance(),Duration.EndOfTurn,new FilterCreaturePermanent());
  game.addEffect(effect,source);
  if (maxPower != 0) {
    effect=new BoostControlledEffect(maxPower,maxPower,Duration.EndOfTurn);
    game.addEffect(effect,source);
  }
  return true;
}
Program: 158091
Project: 158091
Buggy source:
@Override public int calculate(Game game,Ability sourceAbility,Effect effect){
  for (  Cost cost : sourceAbility.getCosts()) {
    if (cost instanceof DiscardTargetCost) {
      return ((DiscardTargetCost)cost).getCards().size();
    }
  }
  return sourceAbility.getManaCostsToPay().getX();
}

Fixed version (ground truth):
@Override public int calculate(Game game,Ability sourceAbility,Effect effect){
  int xValue=sourceAbility.getManaCostsToPay().getX();
  for (  Cost cost : sourceAbility.getCosts()) {
    if (cost instanceof DiscardTargetCost) {
      xValue=((DiscardTargetCost)cost).getCards().size();
    }
  }
  return xValue;
}
Program: 158092
Project: 158092
Buggy source:
@Override public int announceXValue(Ability source,Game game){
  int xValue=0;
  Player controller=game.getPlayer(source.getControllerId());
  if (controller != null) {
    xValue=controller.announceXCost(getMinValue(source,game),getMaxValue(source,game),"String_Node_Str" + actionText,game,source,this);
  }
  return xValue;
}

Fixed version (ground truth):
@Override public int announceXValue(Ability source,Game game){
  int xValue=0;
  Player controller=game.getPlayer(source.getControllerId());
  Spell spell=game.getStack().getSpell(source.getId());
  if (controller != null && spell != null) {
    xValue=controller.announceXCost(getMinValue(source,game),getMaxValue(source,game),"String_Node_Str" + actionText,game,source,this);
  }
  return xValue;
}
Program: 158093
Project: 158093
Buggy source:
@Override public int announceXValue(Ability source,Game game){
  int xValue=0;
  Player controller=game.getPlayer(source.getControllerId());
  Spell spell=game.getStack().getSpell(source.getId());
  if (controller != null && spell != null) {
    xValue=controller.announceXCost(getMinValue(source,game),getMaxValue(source,game),"String_Node_Str" + actionText,game,source,this);
  }
  return xValue;
}

Fixed version (ground truth):
@Override public int announceXValue(Ability source,Game game){
  int xValue=0;
  Player controller=game.getPlayer(source.getControllerId());
  StackObject stackObject=game.getStack().getStackObject(source.getId());
  if (controller != null && stackObject != null) {
    xValue=controller.announceXCost(getMinValue(source,game),getMaxValue(source,game),"String_Node_Str" + actionText,game,source,this);
  }
  return xValue;
}
Program: 158094
Project: 158094
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  Permanent arsenalThresher=game.getPermanentEntering(source.getSourceId());
  FilterArtifactCard filter=new FilterArtifactCard();
  filter.add(new AnotherCardPredicate());
  if (controller.chooseUse(Outcome.Benefit,"String_Node_Str",source,game)) {
    Cards cards=new CardsImpl();
    if (controller.getHand().count(filter,source.getSourceId(),source.getControllerId(),game) > 0) {
      TargetCardInHand target=new TargetCardInHand(0,Integer.MAX_VALUE,filter);
      if (controller.choose(Outcome.Benefit,target,source.getSourceId(),game)) {
        for (        UUID uuid : target.getTargets()) {
          cards.add(controller.getHand().get(uuid,game));
        }
        if (arsenalThresher != null) {
          controller.revealCards(arsenalThresher.getIdName(),cards,game);
          arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()),source,game);
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  if (controller == null) {
    return false;
  }
  Permanent arsenalThresher=game.getPermanentEntering(source.getSourceId());
  FilterArtifactCard filter=new FilterArtifactCard();
  filter.add(new AnotherCardPredicate());
  if (controller.chooseUse(Outcome.Benefit,"String_Node_Str",source,game)) {
    Cards cards=new CardsImpl();
    if (controller.getHand().count(filter,source.getSourceId(),source.getControllerId(),game) > 0) {
      TargetCardInHand target=new TargetCardInHand(0,Integer.MAX_VALUE,filter);
      if (controller.choose(Outcome.Benefit,target,source.getSourceId(),game)) {
        for (        UUID uuid : target.getTargets()) {
          cards.add(controller.getHand().get(uuid,game));
        }
        if (arsenalThresher != null) {
          controller.revealCards(arsenalThresher.getIdName(),cards,game);
          ArrayList<UUID> appliedEffects=(ArrayList<UUID>)this.getValue("String_Node_Str");
          arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()),source,game,appliedEffects);
        }
      }
    }
    return true;
  }
  return false;
}
Program: 158095
Project: 158095
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  if (creature != null) {
    creature.addCounters(CounterType.P1P1.createInstance(),source,game);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  if (creature != null) {
    creature.addCounters(CounterType.P1P1.createInstance(),source,game,event.getAppliedEffects());
  }
  return false;
}
Program: 158096
Project: 158096
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  Map<String,Integer> spellX=(Map<String,Integer>)game.getState().getValue("String_Node_Str" + source.getSourceId());
  MageObject sourceObject=source.getSourceObject(game);
  if (sourceObject != null && creature != null && spellX != null) {
    String key=event.getSourceId().toString() + (game.getState().getZoneChangeCounter(event.getSourceId()) - 1);
    int xValue=spellX.get(key);
    if (xValue > 0) {
      creature.addCounters(CounterType.P1P1.createInstance(xValue),source,game);
      game.informPlayers(sourceObject.getLogName() + "String_Node_Str" + creature.getLogName()+ "String_Node_Str"+ xValue+ "String_Node_Str"+ (xValue > 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
    }
    spellX.remove(key);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent creature=((EntersTheBattlefieldEvent)event).getTarget();
  Map<String,Integer> spellX=(Map<String,Integer>)game.getState().getValue("String_Node_Str" + source.getSourceId());
  MageObject sourceObject=source.getSourceObject(game);
  if (sourceObject != null && creature != null && spellX != null) {
    String key=event.getSourceId().toString() + (game.getState().getZoneChangeCounter(event.getSourceId()) - 1);
    int xValue=spellX.get(key);
    if (xValue > 0) {
      creature.addCounters(CounterType.P1P1.createInstance(xValue),source,game,event.getAppliedEffects());
      game.informPlayers(sourceObject.getLogName() + "String_Node_Str" + creature.getLogName()+ "String_Node_Str"+ xValue+ "String_Node_Str"+ (xValue > 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
    }
    spellX.remove(key);
  }
  return false;
}
Program: 158097
Project: 158097
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent target=((EntersTheBattlefieldEvent)event).getTarget();
  if (target != null) {
    target.addCounters(CounterType.P1P1.createInstance(),source,game);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent target=((EntersTheBattlefieldEvent)event).getTarget();
  if (target != null) {
    target.addCounters(CounterType.P1P1.createInstance(),source,game,event.getAppliedEffects());
  }
  return false;
}
Program: 158098
Project: 158098
Buggy source:
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent permanent=((EntersTheBattlefieldEvent)event).getTarget();
  if (permanent != null) {
    permanent.addCounters(CounterType.P1P1.createInstance(),source,game);
    discard();
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean replaceEvent(GameEvent event,Ability source,Game game){
  Permanent permanent=((EntersTheBattlefieldEvent)event).getTarget();
  if (permanent != null) {
    permanent.addCounters(CounterType.P1P1.createInstance(),source,game,event.getAppliedEffects());
    discard();
  }
  return false;
}
Program: 158099
Project: 158099
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent permanent=game.getPermanent(source.getFirstTarget());
  if (permanent != null) {
    permanent.addCounters(CounterType.P1P1.createInstance(2),source,game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  return false;
}