/* * Warmup Contest #1, September 1, 2010 Problem B * Solution by Tom Conerly * Originally from http://contest.felk.cvut.cz/07cerc/solved/train/b.pdf * CERC 2008 Practice Session Problem B * * The one weird cause is "BBUGUG" which should return "". */ import java.util.*; public class B { public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNextLine()){ String line = sc.nextLine(); while(line.indexOf("BUG") != -1){ int index = line.indexOf("BUG"); line= line.substring(0, index)+line.substring(index+3); } System.out.println(line); } } }