nus-yam/ex-repair huggingface dataset:
Program: 101036
Project: 101036
Buggy source:
public void load(InputStream is) throws IOException {
  DataInputStream dis=new DataInputStream(is);
  size=dis.readInt();
  size0=dis.readInt();
  node1pos=dis.readInt();
  node2pos=dis.readInt();
  node3pos=dis.readInt();
  int vectorSize=size / 8 + 1;
  vector=new byte[vectorSize];
  dis.read(vector,0,vectorSize);
  int blockSize=CACHE_WIDTH / 8;
  int size=vectorSize / blockSize + (((vectorSize % blockSize) != 0) ? 1 : 0);
  countCache0=new int[size];
  for (int i=0; i < size; i++) {
    countCache0[i]=dis.readInt();
  }
  indexCache0=new int[size + 1];
  for (int i=0; i < size + 1; i++) {
    indexCache0[i]=dis.readInt();
  }
}

Fixed version (ground truth):
public void load(InputStream is) throws IOException {
  DataInputStream dis=new DataInputStream(is);
  size=dis.readInt();
  size0=dis.readInt();
  node1pos=dis.readInt();
  node2pos=dis.readInt();
  node3pos=dis.readInt();
  int vectorSize=dis.readInt();
  vector=new byte[vectorSize];
  dis.read(vector,0,vectorSize);
  int size=dis.readInt();
  countCache0=new int[size];
  for (int i=0; i < size; i++) {
    countCache0[i]=dis.readInt();
  }
  size=dis.readInt();
  indexCache0=new int[size];
  for (int i=0; i < size; i++) {
    indexCache0[i]=dis.readInt();
  }
}
Program: 101037
Project: 101037
Buggy source:
@Test public void test() throws Exception {
  Trie trie=createFirstTrie();
  System.out.println("String_Node_Str" + trie.getClass().getName());
  int c=0, chars=0;
  long b=0;
  LapTimer t=new LapTimer();
  for (  String word : new WikipediaTitles(wikipediaFilename)) {
    t.lap();
    trie.insert(word);
    b+=t.lap();
    ;
    c++;
    chars+=word.length();
  }
  System.out.println(String.format("String_Node_Str",(b / 1000000),c,chars));
  Trie second=trie;
  try {
    getClass().getMethod("String_Node_Str",Trie.class);
    System.out.print("String_Node_Str");
    t.lap();
    second=buildSecondTrie(trie);
    System.out.println(second.getClass().getName());
    System.out.println("String_Node_Str" + (t.lap() / 1000000) + "String_Node_Str");
  }
 catch (  NoSuchMethodException e) {
  }
  System.out.println("String_Node_Str");
  long sum=0;
  c=0;
  for (  String word : new WikipediaTitles(wikipediaFilename)) {
    t.lap();
    boolean found=second.contains(word);
    sum+=t.lap();
    c++;
    if (!found) {
      System.out.println(String.format("String_Node_Str",c,word));
      break;
    }
  }
  System.out.println("String_Node_Str" + (sum / 1000000) + "String_Node_Str"+ c+ "String_Node_Str");
}

Fixed version (ground truth):
@Test public void test() throws Exception {
  Trie trie=createFirstTrie();
  System.out.println("String_Node_Str" + trie.getClass().getName());
  int c=0, chars=0;
  long b=0;
  LapTimer t=new LapTimer();
  for (  String word : new WikipediaTitles(wikipediaFilename)) {
    t.lap();
    trie.insert(word);
    b+=t.lap();
    ;
    c++;
    chars+=word.length();
  }
  System.out.println(String.format("String_Node_Str",(b / 1000000),c,chars));
  Trie second=trie;
  try {
    getClass().getDeclaredMethod("String_Node_Str",Trie.class);
    System.out.print("String_Node_Str");
    t.lap();
    second=buildSecondTrie(trie);
    System.out.println(second.getClass().getName());
    System.out.println("String_Node_Str" + (t.lap() / 1000000) + "String_Node_Str");
  }
 catch (  NoSuchMethodException e) {
  }
  System.out.println("String_Node_Str");
  long sum=0;
  c=0;
  for (  String word : new WikipediaTitles(wikipediaFilename)) {
    t.lap();
    boolean found=second.contains(word);
    sum+=t.lap();
    c++;
    if (!found) {
      System.out.println(String.format("String_Node_Str",c,word));
      break;
    }
  }
  System.out.println("String_Node_Str" + (sum / 1000000) + "String_Node_Str"+ c+ "String_Node_Str");
  afterVerification(second);
}
Program: 101038
Project: 101038
Buggy source:
public void save(OutputStream os) throws IOException {
  BufferedOutputStream bos=new BufferedOutputStream(os);
  DataOutputStream dos=new DataOutputStream(bos);
  dos.writeInt(base.length);
  for (  int v : base) {
    dos.writeInt(v);
  }
  for (  int v : check) {
    dos.writeShort(v);
  }
  for (  int v : tail) {
    dos.writeInt(v);
  }
  dos.flush();
  ObjectOutputStream oos=new ObjectOutputStream(bos);
  oos.writeObject(term);
  oos.flush();
  dos.writeInt(firstEmptyCheck);
  dos.writeInt(tails.length());
  dos.writeChars(tails.toString());
  dos.writeInt(charCodes.size());
  for (  Map.Entry<Character,Integer> e : charCodes.entrySet()) {
    dos.writeChar(e.getKey());
    dos.writeInt(e.getValue());
  }
  dos.flush();
  bos.flush();
}

Fixed version (ground truth):
public void save(OutputStream os) throws IOException {
  BufferedOutputStream bos=new BufferedOutputStream(os);
  DataOutputStream dos=new DataOutputStream(bos);
  dos.writeInt(base.length);
  for (  int v : base) {
    dos.writeInt(v);
  }
  for (  int v : check) {
    dos.writeShort(v);
  }
  for (  int v : tail) {
    dos.writeInt(v);
  }
  dos.flush();
  ObjectOutputStream oos=new ObjectOutputStream(bos);
  oos.writeObject(term);
  oos.flush();
  dos.writeInt(tails.length());
  dos.writeChars(tails.toString());
  dos.writeInt(charCodes.size());
  for (  Map.Entry<Character,Integer> e : charCodes.entrySet()) {
    dos.writeChar(e.getKey());
    dos.writeInt(e.getValue());
  }
  dos.flush();
  bos.flush();
}
Program: 101039
Project: 101039
Buggy source:
private void setCheck(int index,short value){
  if (firstEmptyCheck == index) {
    firstEmptyCheck=findNextEmptyCheck(firstEmptyCheck);
  }
  check[index]=value;
  last=Math.max(last,index);
}

Fixed version (ground truth):
private void setCheck(int index,short value){
  check[index]=value;
  last=Math.max(last,index);
  if (base[index] == BASE_EMPTY)   base[index]--;
}
Program: 101040
Project: 101040
Buggy source:
public OptimizedTailDoubleArray(Trie trie,int arraySize,TailBuilder tb){
  base=new int[arraySize];
  Arrays.fill(base,BASE_EMPTY);
  check=new short[arraySize];
  Arrays.fill(check,(short)-1);
  tail=new int[arraySize];
  Arrays.fill(tail,-1);
  term=new BitSet(65536);
  int nodeIndex=0;
  base[0]=nodeIndex;
  Node root=trie.getRoot();
  if (root == null)   return;
  if (root.getLetters() != null) {
    if (root.getLetters().length == 0) {
      if (root.isTerminate())       term.set(0);
    }
 else {
      int c=getCharId(root.getLetters()[0]);
      check[c]=(short)c;
      nodeIndex=c;
      firstEmptyCheck=1;
    }
  }
  build(root,nodeIndex,tb);
  tails=tb.getTails();
}

Fixed version (ground truth):
public OptimizedTailDoubleArray(Trie trie,int arraySize,TailBuilder tb){
  base=new int[arraySize];
  Arrays.fill(base,BASE_EMPTY);
  check=new short[arraySize];
  Arrays.fill(check,(short)-1);
  tail=new int[arraySize];
  Arrays.fill(tail,-1);
  term=new BitSet(65536);
  int nodeIndex=0;
  base[0]=nodeIndex;
  Node root=trie.getRoot();
  if (root == null)   return;
  if (root.getLetters() != null) {
    if (root.getLetters().length == 0) {
      if (root.isTerminate())       term.set(0);
    }
 else {
      int c=getCharId(root.getLetters()[0]);
      check[c]=(short)c;
      nodeIndex=c;
    }
  }
  build(root,nodeIndex,tb);
  tails=tb.getTails();
}
Program: 101041
Project: 101041
Buggy source:
public void load(InputStream is) throws IOException {
  BufferedInputStream bis=new BufferedInputStream(is);
  DataInputStream dis=new DataInputStream(bis);
  int len=dis.readInt();
  base=new int[len];
  for (int i=0; i < len; i++) {
    base[i]=dis.readInt();
  }
  check=new short[len];
  for (int i=0; i < len; i++) {
    check[i]=dis.readShort();
  }
  tail=new int[len];
  for (int i=0; i < len; i++) {
    tail[i]=dis.readInt();
  }
  ObjectInputStream ois=new ObjectInputStream(bis);
  try {
    term=(BitSet)ois.readObject();
  }
 catch (  ClassNotFoundException e) {
    throw new IOException(e);
  }
  firstEmptyCheck=dis.readInt();
  int n=dis.readInt();
  StringBuilder b=new StringBuilder(n);
  for (int i=0; i < n; i++) {
    b.append(dis.readChar());
  }
  tails=b;
  n=dis.readInt();
  for (int i=0; i < n; i++) {
    char c=dis.readChar();
    int v=dis.readInt();
    charCodes.put(c,v);
  }
}

Fixed version (ground truth):
public void load(InputStream is) throws IOException {
  BufferedInputStream bis=new BufferedInputStream(is);
  DataInputStream dis=new DataInputStream(bis);
  int len=dis.readInt();
  base=new int[len];
  for (int i=0; i < len; i++) {
    base[i]=dis.readInt();
  }
  check=new short[len];
  for (int i=0; i < len; i++) {
    check[i]=dis.readShort();
  }
  tail=new int[len];
  for (int i=0; i < len; i++) {
    tail[i]=dis.readInt();
  }
  ObjectInputStream ois=new ObjectInputStream(bis);
  try {
    term=(BitSet)ois.readObject();
  }
 catch (  ClassNotFoundException e) {
    throw new IOException(e);
  }
  int n=dis.readInt();
  StringBuilder b=new StringBuilder(n);
  for (int i=0; i < n; i++) {
    b.append(dis.readChar());
  }
  tails=b;
  n=dis.readInt();
  for (int i=0; i < n; i++) {
    char c=dis.readChar();
    int v=dis.readInt();
    charCodes.put(c,v);
  }
}
Program: 101042
Project: 101042
Buggy source:
@Override public Iterable<String> commonPrefixSearch(String query){
  List<String> ret=new ArrayList<String>();
  char[] chars=query.toCharArray();
  int ci=0;
  int ni=0;
  if (tail[0] != -1) {
    TailCharIterator it=new TailCharIterator(tails,tail[0]);
    while (it.hasNext()) {
      ci++;
      if (ci >= chars.length)       return ret;
      if (it.next() != chars[ci])       return ret;
    }
    if (term.get(0))     ret.add(new String(chars,0,ci + 1));
  }
  TailCharIterator it=new TailCharIterator(tails,-1);
  for (; ci < chars.length; ci++) {
    int cid=findCharId(chars[ci]);
    if (cid == -1)     return ret;
    int b=base[ni];
    if (b == BASE_EMPTY)     return ret;
    int next=b + cid;
    if (check.length <= next || (next + check[next]) != ni)     return ret;
    ni=next;
    if (tail[ni] != -1) {
      it.setIndex(tail[ni]);
      while (it.hasNext()) {
        ci++;
        if (ci >= chars.length)         return ret;
        if (it.next() != chars[ci])         return ret;
      }
    }
    if (term.get(ni))     ret.add(new String(chars,0,ci + 1));
  }
  return ret;
}

Fixed version (ground truth):
@Override public Iterable<String> commonPrefixSearch(String query){
  List<String> ret=new ArrayList<String>();
  char[] chars=query.toCharArray();
  int ci=0;
  int ni=0;
  if (tail[0] != -1) {
    TailCharIterator it=new TailCharIterator(tails,tail[0]);
    while (it.hasNext()) {
      ci++;
      if (ci >= chars.length)       return ret;
      if (it.next() != chars[ci])       return ret;
    }
    if (term.get(0))     ret.add(new String(chars,0,ci + 1));
  }
  TailCharIterator it=new TailCharIterator(tails,-1);
  for (; ci < chars.length; ci++) {
    int cid=findCharId(chars[ci]);
    if (cid == -1)     return ret;
    int b=base[ni];
    if (b == BASE_EMPTY)     return ret;
    if (b == (BASE_EMPTY - 1))     return ret;
    int next=b + cid;
    if (check.length <= next || (next + check[next]) != ni)     return ret;
    ni=next;
    if (tail[ni] != -1) {
      it.setIndex(tail[ni]);
      while (it.hasNext()) {
        ci++;
        if (ci >= chars.length)         return ret;
        if (it.next() != chars[ci])         return ret;
      }
    }
    if (term.get(ni))     ret.add(new String(chars,0,ci + 1));
  }
  return ret;
}
Program: 101046
Project: 101046
Buggy source:
private int findNextEmptyCheck(int i){
  int d=check[i] * -1;
  if (d <= 0) {
    throw new RuntimeException();
  }
  int prev=i;
  i+=d;
  if (check.length <= i) {
    extend(i);
    return i;
  }
  if (check[i] < 0) {
    return i;
  }
  for (i++; i < check.length; i++) {
    if (check[i] < 0) {
      int v=prev - i;
      if (v < Short.MIN_VALUE) {
        throw new RuntimeException("String_Node_Str");
      }
      check[prev]=(short)v;
      return i;
    }
  }
  extend(i);
  int v=prev - i;
  if (v < Short.MIN_VALUE) {
    throw new RuntimeException("String_Node_Str");
  }
  check[prev]=(short)v;
  return i;
}

Fixed version (ground truth):
private int findNextEmptyCheck(int baseNodeIndex,int i){
  int d=check[i] * -1;
  if (d <= 0) {
    throw new RuntimeException();
  }
  int prev=i;
  i+=d;
  if (check.length <= i) {
    extend(i);
    return i;
  }
  if (check[i] < 0) {
    return i;
  }
  for (i++; i < check.length; i++) {
    if (check[i] < 0 && base[i] == BASE_EMPTY) {
      int v=baseNodeIndex - i;
      if (v < Short.MIN_VALUE) {
        throw new RuntimeException("String_Node_Str");
      }
      check[prev]=(short)v;
      return i;
    }
  }
  extend(i);
  int v=prev - i;
  if (v < Short.MIN_VALUE) {
    throw new RuntimeException("String_Node_Str");
  }
  check[prev]=(short)v;
  return i;
}
Program: 101047
Project: 101047
Buggy source:
private int findFirstEmptyCheck(){
  int i=firstEmptyCheck;
  while (check[i] >= 0 || base[i] != BASE_EMPTY) {
    i++;
  }
  firstEmptyCheck=i;
  return i;
}

Fixed version (ground truth):
private int findFirstEmptyCheck(int baseNodeIndex){
  int i=Math.max(baseNodeIndex - Short.MAX_VALUE,0);
  while (check[i] >= 0 || base[i] != BASE_EMPTY) {
    i++;
  }
  return i;
}
Program: 101048
Project: 101048
Buggy source:
public boolean contains(String text){
  char[] chars=text.toCharArray();
  int charsIndex=0;
  int nodeIndex=0;
  TailCharIterator it=new TailCharIterator(tails,-1);
  while (charsIndex < chars.length) {
    int tailIndex=tail[nodeIndex];
    if (tailIndex != -1) {
      it.setIndex(tailIndex);
      while (it.hasNext()) {
        if (chars.length <= charsIndex)         return false;
        if (chars[charsIndex] != it.next())         return false;
        charsIndex++;
      }
      if (chars.length == charsIndex) {
        if (!it.hasNext())         return term.get(nodeIndex);
 else         return false;
      }
    }
    int cid=findCharId(chars[charsIndex]);
    if (cid == -1)     return false;
    int i=cid + base[nodeIndex];
    if (i < 0 || check.length <= i || check[i] != cid)     return false;
    charsIndex++;
    nodeIndex=i;
  }
  return term.get(nodeIndex);
}

Fixed version (ground truth):
public boolean contains(String text){
  char[] chars=text.toCharArray();
  int charsIndex=0;
  int nodeIndex=0;
  TailCharIterator it=new TailCharIterator(tails,-1);
  while (charsIndex < chars.length) {
    int tailIndex=tail[nodeIndex];
    if (tailIndex != -1) {
      it.setIndex(tailIndex);
      while (it.hasNext()) {
        if (chars.length <= charsIndex)         return false;
        if (chars[charsIndex] != it.next())         return false;
        charsIndex++;
      }
      if (chars.length == charsIndex) {
        if (!it.hasNext())         return term.get(nodeIndex);
 else         return false;
      }
    }
    int cid=findCharId(chars[charsIndex]);
    if (cid == -1)     return false;
    int i=cid + base[nodeIndex];
    if (i < 0 || check.length <= i || (i + check[i]) != nodeIndex)     return false;
    charsIndex++;
    nodeIndex=i;
  }
  return term.get(nodeIndex);
}
Program: 101049
Project: 101049
Buggy source:
@Override public Iterable<String> commonPrefixSearch(String query){
  List<String> ret=new ArrayList<String>();
  char[] chars=query.toCharArray();
  int ci=0;
  int ni=0;
  if (tail[0] != -1) {
    TailCharIterator it=new TailCharIterator(tails,tail[0]);
    while (it.hasNext()) {
      ci++;
      if (ci >= chars.length)       return ret;
      if (it.next() != chars[ci])       return ret;
    }
    if (term.get(0))     ret.add(new String(chars,0,ci + 1));
  }
  for (; ci < chars.length; ci++) {
    int cid=findCharId(chars[ci]);
    if (cid == -1)     return ret;
    int b=base[ni];
    if (b == BASE_EMPTY)     return ret;
    int next=b + cid;
    if (check.length <= next || check[next] != cid)     return ret;
    ni=next;
    if (tail[ni] != -1) {
      TailCharIterator it=new TailCharIterator(tails,tail[ni]);
      while (it.hasNext()) {
        ci++;
        if (ci >= chars.length)         return ret;
        if (it.next() != chars[ci])         return ret;
      }
    }
    if (term.get(ni))     ret.add(new String(chars,0,ci + 1));
  }
  return ret;
}

Fixed version (ground truth):
@Override public Iterable<String> commonPrefixSearch(String query){
  List<String> ret=new ArrayList<String>();
  char[] chars=query.toCharArray();
  int ci=0;
  int ni=0;
  if (tail[0] != -1) {
    TailCharIterator it=new TailCharIterator(tails,tail[0]);
    while (it.hasNext()) {
      ci++;
      if (ci >= chars.length)       return ret;
      if (it.next() != chars[ci])       return ret;
    }
    if (term.get(0))     ret.add(new String(chars,0,ci + 1));
  }
  TailCharIterator it=new TailCharIterator(tails,-1);
  for (; ci < chars.length; ci++) {
    int cid=findCharId(chars[ci]);
    if (cid == -1)     return ret;
    int b=base[ni];
    if (b == BASE_EMPTY)     return ret;
    int next=b + cid;
    if (check.length <= next || (next + check[next]) != ni)     return ret;
    ni=next;
    if (tail[ni] != -1) {
      it.setIndex(tail[ni]);
      while (it.hasNext()) {
        ci++;
        if (ci >= chars.length)         return ret;
        if (it.next() != chars[ci])         return ret;
      }
    }
    if (term.get(ni))     ret.add(new String(chars,0,ci + 1));
  }
  return ret;
}
Program: 101053
Project: 101053
Buggy source:
@Override public Iterable<String> predictiveSearch(String query){
  List<String> ret=new ArrayList<String>();
  char[] chars=query.toCharArray();
  int charsLen=chars.length;
  int nodeId=0;
  TailCharIterator tci=new TailCharIterator(tails,-1);
  String pfx=null;
  for (int charsIndex=0; charsIndex < charsLen; charsIndex++) {
    int child=getChildNode(nodeId,chars[charsIndex]);
    if (child == -1)     return ret;
    int ti=tail[child];
    if (ti != -1) {
      tci.setIndex(ti);
      int charsIndexBack=charsIndex;
      while (tci.hasNext()) {
        charsIndex++;
        if (charsIndex >= charsLen) {
          pfx=new String(chars,0,charsIndexBack);
          break;
        }
        if (chars[charsIndex] != tci.next())         return ret;
      }
    }
    nodeId=child;
  }
  if (pfx == null)   pfx=query;
  Deque<Pair<Integer,String>> queue=new LinkedList<Pair<Integer,String>>();
  queue.offerLast(Pair.create(nodeId,pfx));
  while (queue.size() > 0) {
    Pair<Integer,String> element=queue.pollFirst();
    int nid=element.getFirst();
    StringBuilder b=new StringBuilder(element.getSecond());
    b.append(labels[nid]);
    int ti=tail[nid];
    if (ti != -1) {
      tci.setIndex(ti);
      while (tci.hasNext())       b.append(tci.next());
    }
    String letter=b.toString();
    if (term.get(nid))     ret.add(letter);
    int s=bv.select0(nid) + 1;
    int e=bv.next0(s);
    int lastNodeId=bv.rank1(s) + e - s - 1;
    for (int i=(e - 1); i >= s; i--) {
      queue.offerFirst(Pair.create(lastNodeId--,letter));
    }
  }
  return ret;
}

Fixed version (ground truth):
@Override public Iterable<String> predictiveSearch(String query){
  List<String> ret=new ArrayList<String>();
  char[] chars=query.toCharArray();
  int charsLen=chars.length;
  int nodeId=0;
  TailCharIterator tci=new TailCharIterator(tails,-1);
  String pfx=null;
  int charsIndexBack=0;
  for (int charsIndex=0; charsIndex < charsLen; charsIndex++) {
    charsIndexBack=charsIndex;
    int child=getChildNode(nodeId,chars[charsIndex]);
    if (child == -1)     return ret;
    int ti=tail[child];
    if (ti != -1) {
      tci.setIndex(ti);
      while (tci.hasNext()) {
        charsIndex++;
        if (charsIndex >= charsLen)         break;
        if (chars[charsIndex] != tci.next())         return ret;
      }
    }
    nodeId=child;
  }
  pfx=new String(chars,0,charsIndexBack);
  Deque<Pair<Integer,String>> queue=new LinkedList<Pair<Integer,String>>();
  queue.offerLast(Pair.create(nodeId,pfx));
  while (queue.size() > 0) {
    Pair<Integer,String> element=queue.pollFirst();
    int nid=element.getFirst();
    StringBuilder b=new StringBuilder(element.getSecond());
    b.append(labels[nid]);
    int ti=tail[nid];
    if (ti != -1) {
      tci.setIndex(ti);
      while (tci.hasNext())       b.append(tci.next());
    }
    String letter=b.toString();
    if (term.get(nid))     ret.add(letter);
    int s=bv.select0(nid) + 1;
    int e=bv.next0(s);
    int lastNodeId=bv.rank1(s) + e - s - 1;
    for (int i=(e - 1); i >= s; i--) {
      queue.offerFirst(Pair.create(lastNodeId--,letter));
    }
  }
  return ret;
}
Program: 101054
Project: 101054
Buggy source:
public boolean contains(String word){
  char[] chars=word.toCharArray();
  int charsIndex=0;
  int nodeId=1;
  int start=0;
  while (true) {
    start=bv.select0(nodeId) + 1;
    int end=bv.next0(start);
    int baseNodeId=bv.rank1(start) - start;
    while (start != end) {
      int i=(start + end) / 2;
      int index=baseNodeId + i;
      int d=chars[charsIndex] - labels[index];
      if (d < 0) {
        end=i;
      }
 else       if (d > 0) {
        if (start == i)         return false;
 else         start=i;
      }
 else {
        charsIndex++;
        int ti=tail[index];
        if (charsIndex == chars.length) {
          return (ti == -1) && term.get(index);
        }
        if (ti != -1) {
          TailCharIterator tci=new TailCharIterator(tails,ti);
          while (tci.hasNext()) {
            if (charsIndex == chars.length)             return false;
            if (tci.next() != chars[charsIndex])             return false;
            charsIndex++;
          }
          if (charsIndex == chars.length)           return term.get(index);
        }
        nodeId=baseNodeId + i;
        break;
      }
    }
    if (start == end)     return false;
  }
}

Fixed version (ground truth):
public boolean contains(String word){
  char[] chars=word.toCharArray();
  int charsIndex=0;
  int nodeId=1;
  TailCharIterator tci=new TailCharIterator(tails,-1);
  while (true) {
    int start=bv.select0(nodeId) + 1;
    int end=bv.next0(start);
    if (end == -1)     end=start + 1;
    int baseNodeId=bv.rank1(start) - start;
    do {
      int i=(start + end) / 2;
      int index=baseNodeId + i;
      int d=chars[charsIndex] - labels[index];
      if (d < 0) {
        end=i;
      }
 else       if (d > 0) {
        if (start == i)         return false;
 else         start=i;
      }
 else {
        charsIndex++;
        int ti=tail[index];
        if (charsIndex == chars.length) {
          return (ti == -1) && term.get(index);
        }
        if (ti != -1) {
          tci.setIndex(ti);
          while (tci.hasNext()) {
            if (charsIndex == chars.length)             return false;
            if (tci.next() != chars[charsIndex])             return false;
            charsIndex++;
          }
          if (charsIndex == chars.length)           return term.get(index);
        }
        nodeId=baseNodeId + i;
        break;
      }
    }
 while (start != end);
    if (start == end)     return false;
  }
}
Program: 101056
Project: 101056
Buggy source:
@Override public void dump(){
  System.out.println("String_Node_Str" + getClass().getName() + "String_Node_Str");
  final AtomicInteger c=new AtomicInteger();
  visit(new TrieVisitor(){
    @Override public void accept(    Node node,    int nest){
      int cur=c.get();
      if (cur > 100)       return;
      for (int i=0; i < nest; i++) {
        System.out.print("String_Node_Str");
      }
      if (cur == 100) {
        System.out.println("String_Node_Str");
        return;
      }
      c.incrementAndGet();
      char[] letters=node.getLetters();
      if (letters != null && letters.length > 0) {
        System.out.print(letters);
      }
 else       if (node instanceof LabelTrieNode) {
        LabelNode ln=((LabelTrieNode)node).getLettersNode();
        if (ln != null) {
          do {
            System.out.print("String_Node_Str");
            char[] l=ln.getLetters();
            for (int i=0; i < l.length; i++) {
              System.out.print(l[l.length - i - 1]);
            }
            ln=ln.getParent();
          }
 while (ln != null);
        }
 else {
          System.out.print("String_Node_Str");
        }
      }
      if (node.isTerminate()) {
        System.out.print("String_Node_Str");
      }
      System.out.println();
    }
  }
);
}

Fixed version (ground truth):
@Override public void dump(){
  System.out.println("String_Node_Str" + getClass().getName() + "String_Node_Str");
  Algorithms.dump(getRoot());
}
Program: 101057
Project: 101057
Buggy source:
public boolean contains(String word){
  char[] chars=word.toCharArray();
  int charsIndex=0;
  int nodeId=1;
  TailCharIterator tci=new TailCharIterator(tails,-1);
  while (true) {
    int start=bv.select0(nodeId) + 1;
    int end=bv.next0(start);
    if (end == -1)     end=start + 1;
    int baseNodeId=bv.rank1(start) - start;
    do {
      int i=(start + end) / 2;
      int index=baseNodeId + i;
      int d=chars[charsIndex] - labels[index];
      if (d < 0) {
        end=i;
      }
 else       if (d > 0) {
        if (start == i)         return false;
 else         start=i;
      }
 else {
        charsIndex++;
        int ti=tail[index];
        if (charsIndex == chars.length) {
          return (ti == -1) && term.get(index);
        }
        if (ti != -1) {
          tci.setIndex(ti);
          while (tci.hasNext()) {
            if (charsIndex == chars.length)             return false;
            if (tci.next() != chars[charsIndex])             return false;
            charsIndex++;
          }
          if (charsIndex == chars.length)           return term.get(index);
        }
        nodeId=baseNodeId + i;
        break;
      }
    }
 while (start != end);
    if (start == end)     return false;
  }
}

Fixed version (ground truth):
@Override public boolean contains(String word){
  char[] chars=word.toCharArray();
  int charsIndex=0;
  int nodeId=0;
  TailCharIterator tci=new TailCharIterator(tails,-1);
  while (true) {
    int start=bv.select0(nodeId) + 1;
    int end=bv.next0(start);
    if (end == -1)     return false;
    int baseNodeId=bv.rank1(start) - start;
    do {
      int i=(start + end) / 2;
      int index=baseNodeId + i;
      int d=chars[charsIndex] - labels[index];
      if (d < 0) {
        end=i;
      }
 else       if (d > 0) {
        if (start == i)         return false;
 else         start=i;
      }
 else {
        charsIndex++;
        int ti=tail[index];
        if (charsIndex == chars.length) {
          return (ti == -1) && term.get(index);
        }
        if (ti != -1) {
          tci.setIndex(ti);
          while (tci.hasNext()) {
            if (charsIndex == chars.length)             return false;
            if (tci.next() != chars[charsIndex])             return false;
            charsIndex++;
          }
          if (charsIndex == chars.length)           return term.get(index);
        }
        nodeId=baseNodeId + i;
        break;
      }
    }
 while (start != end);
    if (start == end)     return false;
  }
}
Program: 101058
Project: 101058
Buggy source:
public LOUDSTrie(Trie orig){
  int sz=2000;
  bv=new SuccinctBitVector(sz);
  labels=new char[sz];
  tail=new int[sz];
  term=new BitSet(sz);
  LinkedList<Node> queue=new LinkedList<Node>();
  int count=0;
  bv.append(true);
  bv.append(false);
  labels[0]=0xffff;
  tail[0]=-1;
  count++;
  TailBuilder tb=new SuffixTrieTailBuilder();
  if (orig.getRoot() != null)   queue.add(orig.getRoot());
  while (!queue.isEmpty()) {
    Node node=queue.pollFirst();
    int index=count++;
    if (index >= labels.length) {
      extend();
    }
    if (node.isTerminate()) {
      term.set(index);
    }
    Node[] children=node.getChildren();
    if (children != null) {
      for (      Node c : children) {
        bv.append(true);
        queue.offerLast(c);
      }
    }
    bv.append(false);
    char[] letters=node.getLetters();
    if (letters.length == 0) {
      labels[index]=0xffff;
      tail[index]=-1;
    }
 else {
      labels[index]=letters[0];
      if (letters.length >= 2) {
        tail[index]=tb.insert(letters,1,letters.length - 1);
      }
 else {
        tail[index]=-1;
      }
    }
  }
  size=count;
  tails=tb.getTails();
}

Fixed version (ground truth):
public LOUDSTrie(Trie orig){
  int sz=2000;
  bv=new SuccinctBitVector(sz);
  labels=new char[sz];
  tail=new int[sz];
  term=new BitSet(sz);
  LinkedList<Node> queue=new LinkedList<Node>();
  int count=0;
  TailBuilder tb=new SuffixTrieTailBuilder();
  if (orig.getRoot() != null)   queue.add(orig.getRoot());
  while (!queue.isEmpty()) {
    Node node=queue.pollFirst();
    int index=count++;
    if (index >= labels.length) {
      extend();
    }
    if (node.isTerminate()) {
      term.set(index);
    }
    Node[] children=node.getChildren();
    if (children != null) {
      for (      Node c : children) {
        bv.append(true);
        queue.offerLast(c);
      }
    }
    bv.append(false);
    char[] letters=node.getLetters();
    if (letters.length == 0) {
      labels[index]=0xffff;
      tail[index]=-1;
    }
 else {
      labels[index]=letters[0];
      if (letters.length >= 2) {
        tail[index]=tb.insert(letters,1,letters.length - 1);
      }
 else {
        tail[index]=-1;
      }
    }
  }
  size=count;
  tails=tb.getTails();
}
Program: 101059
Project: 101059
Buggy source:
public Node getRoot(){
  return new LOUDSNode(1);
}

Fixed version (ground truth):
public Node getRoot(){
  return new LOUDSNode(0);
}
Program: 101060
Project: 101060
Buggy source:
public void visit(TrieVisitor visitor){
  root.visit(visitor,0);
}

Fixed version (ground truth):
public void visit(NodeVisitor visitor){
  root.visit(visitor,0);
}
Program: 101061
Project: 101061
Buggy source:
public abstract void visit(TrieVisitor visitor,int nest);

Fixed version (ground truth):
public abstract void visit(NodeVisitor visitor,int nest);
Program: 101062
Project: 101062
Buggy source:
public void visit(TrieVisitor visitor,int nest){
  super.visit(visitor,nest);
  if (children != null) {
    nest++;
    for (    LabelNode n : children) {
      n.visit(visitor,nest);
    }
  }
}

Fixed version (ground truth):
public void visit(NodeVisitor visitor,int nest){
  super.visit(visitor,nest);
  if (children != null) {
    nest++;
    for (    LabelNode n : children) {
      n.visit(visitor,nest);
    }
  }
}
Program: 101063
Project: 101063
Buggy source:
public void visit(TrieVisitor visitor,int nest){
  visitor.accept(this,nest);
}

Fixed version (ground truth):
public void visit(NodeVisitor visitor,int nest){
  visitor.visit(this,nest);
}
Program: 101064
Project: 101064
Buggy source:
@Override public Iterable<String> commonPrefixSearch(String query){
  List<String> ret=new ArrayList<String>();
  char[] chars=query.toCharArray();
  int charsIndex=0;
  int nodeId=1;
  int start=0;
  while (true) {
    start=bv.select0(nodeId) + 1;
    int end=bv.next0(start);
    int baseNodeId=bv.rank1(start) - start;
    while (start != end) {
      int i=(start + end) / 2;
      int index=baseNodeId + i;
      int d=chars[charsIndex] - labels[index];
      if (d < 0) {
        end=i;
      }
 else       if (d > 0) {
        if (start == i)         return ret;
 else         start=i;
      }
 else {
        int ti=tail[index];
        boolean tm=term.get(index);
        if (ti != -1) {
          TailCharIterator tci=new TailCharIterator(tails,ti);
          while (tci.hasNext()) {
            charsIndex++;
            if (charsIndex == chars.length)             return ret;
            if (tci.next() != chars[charsIndex])             return ret;
          }
        }
 else {
          charsIndex++;
          if (charsIndex == chars.length)           return ret;
        }
        if (tm)         ret.add(new String(chars,0,charsIndex));
        nodeId=baseNodeId + i;
        break;
      }
    }
    if (start == end)     return ret;
  }
}

Fixed version (ground truth):
@Override public Iterable<String> commonPrefixSearch(String query){
  List<String> ret=new ArrayList<String>();
  char[] chars=query.toCharArray();
  int charsIndex=0;
  int nodeId=0;
  int start=0;
  TailCharIterator tci=new TailCharIterator(tails,-1);
  while (true) {
    start=bv.select0(nodeId) + 1;
    int end=bv.next0(start);
    int baseNodeId=bv.rank1(start) - start;
    while (start != end) {
      int i=(start + end) / 2;
      int index=baseNodeId + i;
      int d=chars[charsIndex] - labels[index];
      if (d < 0) {
        end=i;
      }
 else       if (d > 0) {
        if (start == i)         return ret;
 else         start=i;
      }
 else {
        int ti=tail[index];
        boolean tm=term.get(index);
        charsIndex++;
        if (ti != -1) {
          tci.setIndex(ti);
          while (tci.hasNext()) {
            if (charsIndex == chars.length)             return ret;
            if (tci.next() != chars[charsIndex++])             return ret;
          }
        }
 else {
          if (charsIndex == chars.length)           return ret;
        }
        if (tm)         ret.add(new String(chars,0,charsIndex));
        nodeId=baseNodeId + i;
        break;
      }
    }
    if (start == end)     return ret;
  }
}
Program: 101065
Project: 101065
Buggy source:
@Override public void dump(){
  super.dump();
  System.out.println("String_Node_Str" + bv.toString());
  System.out.print("String_Node_Str");
  for (  char c : labels)   System.out.print(c);
  System.out.println();
}

Fixed version (ground truth):
@Override public void dump(){
  super.dump();
  String bvs=bv.toString();
  System.out.println("String_Node_Str" + ((bvs.length() > 100) ? bvs.substring(0,100) : bvs));
  System.out.print("String_Node_Str");
  int count=0;
  for (  char c : labels) {
    System.out.print(c);
    if (count++ == 99)     break;
  }
  System.out.println();
}
Program: 101066
Project: 101066
Buggy source:
public int next0(int pos){
  if (pos <= node3pos) {
    if (pos <= node1pos)     return node1pos;
 else     if (pos <= node2pos)     return node2pos;
 else     return node3pos;
  }
 else   if ((pos + 1) == size) {
    return size;
  }
  int i=pos / 8;
  int s=pos % 8;
  if (s != 0) {
    for (    byte b : BITPOS0[vector[i] & 0xff]) {
      if (s <= b)       return i * 8 + b;
    }
    i++;
  }
  int n=size / 8 + 1;
  for (; i < n; i++) {
    byte[] poss=BITPOS0[vector[i] & 0xff];
    if (poss.length > 0) {
      return poss[0] + i * 8;
    }
  }
  return -1;
}

Fixed version (ground truth):
public int next0(int pos){
  if (pos <= node3pos) {
    if (pos <= node1pos)     return node1pos;
 else     if (pos <= node2pos)     return node2pos;
 else     return node3pos;
  }
  int i=pos / 8;
  int s=pos % 8;
  if (s != 0) {
    for (    byte b : BITPOS0[vector[i] & 0xff]) {
      if (s <= b)       return i * 8 + b;
    }
    i++;
  }
  int n=size / 8 + 1;
  for (; i < n; i++) {
    byte[] poss=BITPOS0[vector[i] & 0xff];
    if (poss.length > 0) {
      return poss[0] + i * 8;
    }
  }
  return -1;
}
Program: 101068
Project: 101068
Buggy source:
public TailPatriciaTrie(){
  tailBuilder=new SuffixTrieTailBuilder();
  tails=tailBuilder.getTails();
}

Fixed version (ground truth):
public TailPatriciaTrie(TailBuilder builder){
  this.tailBuilder=builder;
  this.tails=builder.getTails();
}
Program: 101069
Project: 101069
Buggy source:
public char next(){
  if (!fetched)   fetchNext();
  if (next == '\0') {
    throw new NoSuchElementException();
  }
  fetched=false;
  return next;
}

Fixed version (ground truth):
public char next(){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  current=next;
  index++;
  char c=chars.charAt(index);
  if (c == '\0') {
    index=-1;
  }
  if (c == '\1') {
    int i=chars.charAt(index + 1);
    i+=chars.charAt(index + 2) << 16;
    index=i;
    c=chars.charAt(index);
  }
  next=c;
  return current;
}
Program: 101070
Project: 101070
Buggy source:
public boolean hasNext(){
  if (!fetched)   fetchNext();
  return next > '\0';
}

Fixed version (ground truth):
public boolean hasNext(){
  return index != -1;
}
Program: 101071
Project: 101071
Buggy source:
public TailCharIterator(CharSequence chars,int index){
  this.chars=chars;
  this.index=index;
  if (index != -1) {
    this.next=chars.charAt(index);
  }
 else {
    this.next='\0';
  }
  this.fetched=true;
  this.current=this.next;
}

Fixed version (ground truth):
public TailCharIterator(CharSequence chars,int index){
  this.chars=chars;
  this.index=index;
  if (this.index != -1) {
    this.next=chars.charAt(index);
  }
}
Program: 101072
Project: 101072
Buggy source:
@Test public void test() throws Exception {
  Trie trie=new TailPatriciaTrie();
  insert(trie,new WikipediaTitles("String_Node_Str"),18);
  dump(trie);
  check(trie,new WikipediaTitles("String_Node_Str"),18);
}

Fixed version (ground truth):
@Test public void test() throws Exception {
  Trie trie=new TailPatriciaTrie();
  insert(trie,new WikipediaTitles("String_Node_Str"),2000000);
  check(trie,new WikipediaTitles("String_Node_Str"),2000000);
}
Program: 101073
Project: 101073
Buggy source:
private void insert(Trie trie,Iterable<String> source,int maxCount){
  int c=0;
  for (  String w : source) {
    trie.insert(w);
    c++;
    if (c == maxCount)     return;
  }
}

Fixed version (ground truth):
private void insert(Trie trie,Iterable<String> source,int maxCount){
  int c=0;
  for (  String w : source) {
    trie.insert(w);
    if (!trie.contains(w)) {
      dump(trie);
      Assert.fail("String_Node_Str" + c + "String_Node_Str"+ w);
    }
    c++;
    if (c == maxCount)     return;
  }
}
Program: 101075
Project: 101075
Buggy source:
@Override public Iterable<String> commonPrefixSearch(String query){
  List<String> ret=new ArrayList<String>();
  char[] chars=query.toCharArray();
  int charsIndex=0;
  int nodeId=0;
  int start=0;
  TailCharIterator tci=new TailCharIterator(tails,-1);
  while (true) {
    start=bv.select0(nodeId) + 1;
    int end=bv.next0(start);
    int baseNodeId=bv.rank1(start) - start;
    while (start != end) {
      int i=(start + end) / 2;
      int index=baseNodeId + i;
      int d=chars[charsIndex] - labels[index];
      if (d < 0) {
        end=i;
      }
 else       if (d > 0) {
        if (start == i)         return ret;
 else         start=i;
      }
 else {
        int ti=tail[index];
        boolean tm=term.get(index);
        charsIndex++;
        if (ti != -1) {
          tci.setIndex(ti);
          while (tci.hasNext()) {
            if (charsIndex == chars.length)             return ret;
            if (tci.next() != chars[charsIndex++])             return ret;
          }
        }
 else {
          if (charsIndex == chars.length)           return ret;
        }
        if (tm)         ret.add(new String(chars,0,charsIndex));
        nodeId=baseNodeId + i;
        break;
      }
    }
    if (start == end)     return ret;
  }
}

Fixed version (ground truth):
@Override public Iterable<String> commonPrefixSearch(String query){
  List<String> ret=new ArrayList<String>();
  char[] chars=query.toCharArray();
  int charsIndex=0;
  int nodeId=0;
  int start=0;
  TailCharIterator tci=new TailCharIterator(tails,-1);
  while (true) {
    start=bv.select0(nodeId) + 1;
    int end=bv.next0(start);
    int baseNodeId=bv.rank1(start) - start;
    while (start != end) {
      int i=(start + end) / 2;
      int index=baseNodeId + i;
      int d=chars[charsIndex] - labels[index];
      if (d < 0) {
        end=i;
      }
 else       if (d > 0) {
        if (start == i)         return ret;
 else         start=i;
      }
 else {
        charsIndex++;
        if (charsIndex == chars.length)         return ret;
        int ti=tail[index];
        if (ti != -1) {
          tci.setIndex(ti);
          while (tci.hasNext()) {
            if (charsIndex == chars.length)             return ret;
            if (tci.next() != chars[charsIndex])             return ret;
            charsIndex++;
          }
        }
        if (term.get(index))         ret.add(new String(chars,0,charsIndex));
        if (charsIndex == chars.length)         return ret;
        nodeId=baseNodeId + i;
        break;
      }
    }
    if (start == end)     return ret;
  }
}
Program: 101076
Project: 101076
Buggy source:
public void append0(){
  int i=size / 8;
  int ci=size / CACHE_WIDTH;
  if (i >= vector.length) {
    extend();
  }
  if (size % CACHE_WIDTH == 0 && ci > 0) {
    countCache[ci]=countCache[ci - 1];
  }
  int r=size % 8;
  vector[i]&=~BITS[r];
  size0++;
  if (size0 == 2) {
    node2pos=size;
  }
  if (size0 % CACHE_WIDTH == 0) {
    indexCache[size0 / CACHE_WIDTH]=size;
  }
  size++;
}

Fixed version (ground truth):
public void append0(){
  int i=size / 8;
  int ci=size / CACHE_WIDTH;
  if (i >= vector.length) {
    extend();
  }
  if (size % CACHE_WIDTH == 0 && ci > 0) {
    countCache[ci]=countCache[ci - 1];
  }
  int r=size % 8;
  vector[i]&=~BITS[r];
  size0++;
  if (size0 == 1) {
    node1pos=size;
  }
 else   if (size0 == 2) {
    node2pos=size;
  }
  if (size0 % CACHE_WIDTH == 0) {
    indexCache[size0 / CACHE_WIDTH]=size;
  }
  size++;
}
Program: 101078
Project: 101078
Buggy source:
public void append(boolean bit){
  int i=size / 8;
  if (i >= vector.length) {
    byte[] n=new byte[(int)(vector.length * 1.2)];
    System.arraycopy(vector,0,n,0,vector.length);
    n[vector.length]=0;
    vector=n;
  }
  int r=size % 8;
  if (bit) {
    vector[i]|=BITS[r];
  }
 else {
    vector[i]&=~BITS[r];
  }
  size++;
}

Fixed version (ground truth):
public void append(boolean bit){
  int i=size / 8;
  if (i >= vector.length) {
    byte[] n=new byte[(int)(vector.length * 1.2) + 1];
    System.arraycopy(vector,0,n,0,vector.length);
    n[vector.length]=0;
    vector=n;
  }
  int r=size % 8;
  if (bit) {
    vector[i]|=BITS[r];
  }
 else {
    vector[i]&=~BITS[r];
  }
  size++;
}
Program: 101080
Project: 101080
Buggy source:
public void dump(){
  System.out.print("String_Node_Str");
  for (int i=0; i < 16; i++) {
    System.out.print(String.format("String_Node_Str",i));
  }
  System.out.println();
  System.out.print("String_Node_Str");
  for (int i=0; i < 16; i++) {
    if (base[i] == BASE_EMPTY) {
      System.out.print("String_Node_Str");
    }
 else {
      System.out.print(String.format("String_Node_Str",base[i]));
    }
  }
  System.out.println();
  System.out.print("String_Node_Str");
  for (int i=0; i < 16; i++) {
    if (check[i] < 0) {
      System.out.print("String_Node_Str");
    }
 else {
      System.out.print(String.format("String_Node_Str",check[i]));
    }
  }
  System.out.println();
  System.out.print("String_Node_Str");
  for (int i=0; i < 16; i++) {
    System.out.print(String.format("String_Node_Str",term.get(i) ? 1 : 0));
  }
  System.out.println();
  System.out.print("String_Node_Str");
  for (  Map.Entry<Character,Integer> e : charCodes.entrySet()) {
    System.out.print(String.format("String_Node_Str",e.getKey(),e.getValue()));
  }
  System.out.println();
}

Fixed version (ground truth):
public void dump(){
  System.out.println("String_Node_Str" + base.length);
  System.out.print("String_Node_Str");
  for (int i=0; i < 16; i++) {
    System.out.print(String.format("String_Node_Str",i));
  }
  System.out.println();
  System.out.print("String_Node_Str");
  for (int i=0; i < 16; i++) {
    if (base[i] == BASE_EMPTY) {
      System.out.print("String_Node_Str");
    }
 else {
      System.out.print(String.format("String_Node_Str",base[i]));
    }
  }
  System.out.println();
  System.out.print("String_Node_Str");
  for (int i=0; i < 16; i++) {
    if (check[i] < 0) {
      System.out.print("String_Node_Str");
    }
 else {
      System.out.print(String.format("String_Node_Str",check[i]));
    }
  }
  System.out.println();
  System.out.print("String_Node_Str");
  for (int i=0; i < 16; i++) {
    System.out.print(String.format("String_Node_Str",term.get(i) ? 1 : 0));
  }
  System.out.println();
  System.out.print("String_Node_Str");
  for (  Map.Entry<Character,Integer> e : charCodes.entrySet()) {
    System.out.print(String.format("String_Node_Str",e.getKey(),e.getValue()));
  }
  System.out.println();
}
Program: 101081
Project: 101081
Buggy source:
@Override public Iterable<String> predictiveSearch(String prefix){
  List<String> ret=new ArrayList<String>();
  char[] chars=prefix.toCharArray();
  int nodeIndex=0;
  for (int i=0; i < chars.length; i++) {
    int cid=findCharId(chars[i]);
    if (cid == -1)     return ret;
    int next=base[nodeIndex] + cid;
    if (next < 0 || check.length <= next || check[next] != nodeIndex)     return ret;
    nodeIndex=next;
  }
  if (term.get(nodeIndex)) {
    ret.add(prefix);
  }
  Deque<Pair<Integer,char[]>> q=new LinkedList<Pair<Integer,char[]>>();
  q.add(Pair.create(nodeIndex,chars));
  while (!q.isEmpty()) {
    Pair<Integer,char[]> p=q.pop();
    int ni=p.getFirst();
    char[] c=p.getSecond();
    for (    Map.Entry<Character,Integer> e : charCodes.entrySet()) {
      int b=base[ni];
      if (b == BASE_EMPTY)       continue;
      int next=b + e.getValue();
      if (check.length <= next)       continue;
      if (check[next] == ni) {
        if (term.get(ni)) {
          ret.add(new StringBuilder().append(c).append(e.getKey()).toString());
        }
        q.push(Pair.create(next,c.clone()));
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
@Override public Iterable<String> predictiveSearch(String prefix){
  List<String> ret=new ArrayList<String>();
  char[] chars=prefix.toCharArray();
  int nodeIndex=0;
  for (int i=0; i < chars.length; i++) {
    int cid=findCharId(chars[i]);
    if (cid == -1)     return ret;
    int next=base[nodeIndex] + cid;
    if (next < 0 || check.length <= next || check[next] != nodeIndex)     return ret;
    nodeIndex=next;
  }
  if (term.get(nodeIndex)) {
    ret.add(prefix);
  }
  Deque<Pair<Integer,char[]>> q=new LinkedList<Pair<Integer,char[]>>();
  q.add(Pair.create(nodeIndex,chars));
  while (!q.isEmpty()) {
    Pair<Integer,char[]> p=q.pop();
    int ni=p.getFirst();
    int b=base[ni];
    if (b == BASE_EMPTY)     continue;
    char[] c=p.getSecond();
    for (    Map.Entry<Character,Integer> e : charCodes.entrySet()) {
      int next=b + e.getValue();
      if (check.length <= next)       continue;
      if (check[next] == ni) {
        String n=new StringBuilder().append(c).append(e.getKey()).toString();
        if (term.get(next)) {
          ret.add(n);
        }
        q.push(Pair.create(next,n.toCharArray()));
      }
    }
  }
  return ret;
}
Program: 101082
Project: 101082
Buggy source:
@Override public Iterable<String> predictiveSearch(String prefix){
  char[] queryChars=prefix.toCharArray();
  int cur=0;
  Node node=root;
  while (node != null) {
    char[] letters=node.getLetters();
    if (letters.length > (queryChars.length - cur))     return Collections.emptyList();
    for (int i=0; i < letters.length; i++) {
      if (letters[i] != queryChars[cur + i]) {
        return Collections.emptyList();
      }
    }
    cur+=letters.length;
    if (queryChars.length == cur) {
      List<String> ret=new ArrayList<String>();
      if (node.isTerminated())       ret.add(prefix);
      enumLetters(node,prefix,ret);
      return ret;
    }
    node=node.getChild(queryChars[cur]);
  }
  return Collections.emptyList();
}

Fixed version (ground truth):
@Override public Iterable<String> predictiveSearch(String prefix){
  char[] queryChars=prefix.toCharArray();
  int cur=0;
  Node node=root;
  while (node != null) {
    char[] letters=node.getLetters();
    int n=Math.min(letters.length,queryChars.length - cur);
    for (int i=0; i < n; i++) {
      if (letters[i] != queryChars[cur + i]) {
        return Collections.emptyList();
      }
    }
    cur+=n;
    if (queryChars.length == cur) {
      List<String> ret=new ArrayList<String>();
      int rest=letters.length - n;
      if (rest > 0) {
        prefix+=new String(letters,n,rest);
      }
      if (node.isTerminated()) {
        ret.add(prefix);
      }
      enumLetters(node,prefix,ret);
      return ret;
    }
    node=node.getChild(queryChars[cur]);
  }
  return Collections.emptyList();
}