nus-yam/ex-repair huggingface dataset:
Program: 100984
Project: 100984
Buggy source:
@Override public int select0(int count){
  if (count > size0)   return -1;
  if (count <= 3) {
    if (count == 1)     return node1pos;
 else     if (count == 2)     return node2pos;
 else     if (count == 3)     return node3pos;
 else     return -1;
  }
  int c=count - 1;
  int ci=bvD.rank1(c) - 1;
  int u=ci + arS[bvR.rank1(ci) - 1];
  if (u != 0) {
    int ui=u * 8;
    int r=u == 0 ? 0 : rank0(ui - 1);
    return ui + find0(longs[u],c - r);
  }
 else {
    return find0(longs[0],c);
  }
}

Fixed version (ground truth):
@Override public int select0(int count){
  if (count > size0)   return -1;
  if (count <= 3) {
    if (count == 1)     return node1pos;
 else     if (count == 2)     return node2pos;
 else     if (count == 3)     return node3pos;
 else     return -1;
  }
  int c=count - 1;
  int ci=bvD.rank1(c) - 1;
  int u=ci + arS[bvR.rank1(ci) - 1];
  if (u != 0) {
    int ui=u * 8;
    int r=rank0(ui - 1);
    int bi=u % 8;
    return ui + BITPOS0[(int)((longs[u / 8] >>> ((7 - bi) * 8)) & 0xff)][c - r];
  }
 else {
    return BITPOS0[(int)((longs[0] >>> 56) & 0xff)][c];
  }
}
Program: 100985
Project: 100985
Buggy source:
public void append1(){
  int blockIndex=size / BITS_IN_BLOCK;
  int indexInBlock=size % BITS_IN_BLOCK;
  int cacheBlockIndex=size / BITS_IN_COUNTCACHE0;
  if (blockIndex >= longs.length) {
    extendLongsAndCountCache0();
  }
  if (size % BITS_IN_COUNTCACHE0 == 0 && cacheBlockIndex > 0) {
    countCache0[cacheBlockIndex]=countCache0[cacheBlockIndex - 1];
  }
  longs[blockIndex]|=0x8000000000000000L >>> (size % BITS_IN_BLOCK);
  if (indexInBlock == 0) {
    prevBsC=currentBsC;
    currentBsC=false;
    arS[arSSize - 1]++;
  }
  size++;
  if (size % BITS_IN_BLOCK == 0) {
    first0bitInBlock=true;
  }
}

Fixed version (ground truth):
public void append1(){
  int blockIndex=size / BITS_IN_BLOCK;
  int cacheBlockIndex=size / BITS_IN_COUNTCACHE0;
  if (blockIndex >= longs.length) {
    extendLongsAndCountCache0();
  }
  if (size % BITS_IN_COUNTCACHE0 == 0 && cacheBlockIndex > 0) {
    countCache0[cacheBlockIndex]=countCache0[cacheBlockIndex - 1];
  }
  longs[blockIndex]|=0x8000000000000000L >>> (size % BITS_IN_BLOCK);
  if ((size % 8) == 0) {
    prevBsC=currentBsC;
    currentBsC=false;
    arS[arSSize - 1]++;
  }
  size++;
  if (size % 8 == 0) {
    first0bitInBlock=true;
  }
}
Program: 100986
Project: 100986
Buggy source:
public void append0(){
  int blockIndex=size / BITS_IN_BLOCK;
  int indexInBlock=size % BITS_IN_BLOCK;
  int cacheBlockIndex=size / BITS_IN_COUNTCACHE0;
  int indexInCacheBlock=size % BITS_IN_COUNTCACHE0;
  if (blockIndex >= longs.length) {
    extendLongsAndCountCache0();
  }
  if (indexInCacheBlock == 0 && cacheBlockIndex > 0) {
    countCache0[cacheBlockIndex]=countCache0[cacheBlockIndex - 1];
  }
  size0++;
switch (size0) {
case 1:
    node1pos=size;
  break;
case 2:
node2pos=size;
break;
case 3:
node3pos=size;
break;
}
countCache0[cacheBlockIndex]++;
if (first0bitInBlock) {
bvD.append1();
first0bitInBlock=false;
}
 else {
bvD.append0();
}
if (indexInBlock == 0) {
if (bvR.size() == 0 || !currentBsC) {
bvR.append1();
addArS();
}
 else {
bvR.append0();
}
prevBsC=currentBsC;
currentBsC=true;
}
 else if (!currentBsC) {
if (bvR.size() == 0 || !prevBsC) {
bvR.append1();
}
 else {
bvR.append0();
}
arS[arSSize - 1]--;
if (!prevBsC) {
addArS();
}
currentBsC=true;
}
size++;
if (size % 8 == 0) {
first0bitInBlock=true;
}
}

Fixed version (ground truth):
public void append0(){
  int blockIndex=size / BITS_IN_BLOCK;
  int cacheBlockIndex=size / BITS_IN_COUNTCACHE0;
  int indexInCacheBlock=size % BITS_IN_COUNTCACHE0;
  if (blockIndex >= longs.length) {
    extendLongsAndCountCache0();
  }
  if (indexInCacheBlock == 0 && cacheBlockIndex > 0) {
    countCache0[cacheBlockIndex]=countCache0[cacheBlockIndex - 1];
  }
  size0++;
switch (size0) {
case 1:
    node1pos=size;
  break;
case 2:
node2pos=size;
break;
case 3:
node3pos=size;
break;
}
countCache0[cacheBlockIndex]++;
if (first0bitInBlock) {
bvD.append1();
first0bitInBlock=false;
}
 else {
bvD.append0();
}
if ((size % 8) == 0) {
if (bvR.size() == 0 || !currentBsC) {
bvR.append1();
addArS();
}
 else {
bvR.append0();
}
prevBsC=currentBsC;
currentBsC=true;
}
 else if (!currentBsC) {
if (bvR.size() == 0 || !prevBsC) {
bvR.append1();
}
 else {
bvR.append0();
}
arS[arSSize - 1]--;
if (!prevBsC) {
addArS();
}
currentBsC=true;
}
size++;
if (size % 8 == 0) {
first0bitInBlock=true;
}
}
Program: 100987
Project: 100987
Buggy source:
@Test public void test_count0CacheSize() throws Exception {
  Assert.assertEquals(0,new LongsSuccinctBitVector(0).getCountCache0().length);
  Assert.assertEquals(1,new LongsSuccinctBitVector(1).getCountCache0().length);
  Assert.assertEquals(1,new LongsSuccinctBitVector(64).getCountCache0().length);
  Assert.assertEquals(2,new LongsSuccinctBitVector(LongsSuccinctBitVector.CACHE_WIDTH_BITS + 1).getCountCache0().length);
}

Fixed version (ground truth):
@Test public void test_count0CacheSize() throws Exception {
  Assert.assertEquals(0,new LongsSuccinctBitVector(0).getCountCache0().length);
  Assert.assertEquals(1,new LongsSuccinctBitVector(1).getCountCache0().length);
  Assert.assertEquals(1,new LongsSuccinctBitVector(64).getCountCache0().length);
  Assert.assertEquals(2,new LongsSuccinctBitVector(LongsSuccinctBitVector.BITS_IN_COUNTCACHE0 + 1).getCountCache0().length);
}
Program: 100988
Project: 100988
Buggy source:
@Test public void test_append_countCache0_1() throws Exception {
  LongsSuccinctBitVector sbv=new LongsSuccinctBitVector();
  for (int i=0; i < LongsSuccinctBitVector.CACHE_WIDTH_BITS; i++) {
    sbv.append0();
    Assert.assertEquals(i + 1,sbv.getCountCache0()[0]);
  }
  for (int i=0; i < LongsSuccinctBitVector.CACHE_WIDTH_BITS; i++) {
    sbv.append0();
    Assert.assertEquals(LongsSuccinctBitVector.CACHE_WIDTH_BITS,sbv.getCountCache0()[0]);
    Assert.assertEquals(LongsSuccinctBitVector.CACHE_WIDTH_BITS + i + 1,sbv.getCountCache0()[1]);
  }
}

Fixed version (ground truth):
@Test public void test_append_countCache0_1() throws Exception {
  LongsSuccinctBitVector sbv=new LongsSuccinctBitVector();
  for (int i=0; i < LongsSuccinctBitVector.BITS_IN_COUNTCACHE0; i++) {
    sbv.append0();
    Assert.assertEquals(i + 1,sbv.getCountCache0()[0]);
  }
  for (int i=0; i < LongsSuccinctBitVector.BITS_IN_COUNTCACHE0; i++) {
    sbv.append0();
    Assert.assertEquals(LongsSuccinctBitVector.BITS_IN_COUNTCACHE0,sbv.getCountCache0()[0]);
    Assert.assertEquals(LongsSuccinctBitVector.BITS_IN_COUNTCACHE0 + i + 1,sbv.getCountCache0()[1]);
  }
}
Program: 100989
Project: 100989
Buggy source:
@Test public void test_append_indexCache0_1() throws Exception {
  LongsSuccinctBitVector sbv=new LongsSuccinctBitVector();
  for (int i=0; i < LongsSuccinctBitVector.BITS0_COUNT_IN_EACH_INDEX * 3; i++) {
    sbv.append0();
  }
  Assert.assertEquals(0,sbv.getIndexCache0().get(0));
  Assert.assertEquals(LongsSuccinctBitVector.BITS0_COUNT_IN_EACH_INDEX - 1,sbv.getIndexCache0().get(1));
  Assert.assertEquals(LongsSuccinctBitVector.BITS0_COUNT_IN_EACH_INDEX * 2 - 1,sbv.getIndexCache0().get(2));
  Assert.assertEquals(LongsSuccinctBitVector.BITS0_COUNT_IN_EACH_INDEX * 3 - 1,sbv.getIndexCache0().get(3));
}

Fixed version (ground truth):
@Test public void test_append_indexCache0_1() throws Exception {
  LongsSuccinctBitVector sbv=new LongsSuccinctBitVector();
  for (int i=0; i < LongsSuccinctBitVector.ZEROBITS_IN_EACH_INDEX * 3; i++) {
    sbv.append0();
  }
  Assert.assertEquals(0,sbv.getIndexCache0().get(0));
  Assert.assertEquals(LongsSuccinctBitVector.ZEROBITS_IN_EACH_INDEX - 1,sbv.getIndexCache0().get(1));
  Assert.assertEquals(LongsSuccinctBitVector.ZEROBITS_IN_EACH_INDEX * 2 - 1,sbv.getIndexCache0().get(2));
  Assert.assertEquals(LongsSuccinctBitVector.ZEROBITS_IN_EACH_INDEX * 3 - 1,sbv.getIndexCache0().get(3));
}
Program: 100990
Project: 100990
Buggy source:
@Test public void test_append_countCache0_2() throws Exception {
  LongsSuccinctBitVector sbv=new LongsSuccinctBitVector();
  for (int i=0; i < 10000; i++) {
    sbv.append0();
    Assert.assertEquals(i + 1,sbv.getCountCache0()[i / LongsSuccinctBitVector.CACHE_WIDTH_BITS]);
  }
}

Fixed version (ground truth):
@Test public void test_append_countCache0_2() throws Exception {
  LongsSuccinctBitVector sbv=new LongsSuccinctBitVector();
  for (int i=0; i < 10000; i++) {
    sbv.append0();
    Assert.assertEquals(i + 1,sbv.getCountCache0()[i / LongsSuccinctBitVector.BITS_IN_COUNTCACHE0]);
  }
}
Program: 100991
Project: 100991
Buggy source:
@Test public void test_append_countCache0_3() throws Exception {
  LongsSuccinctBitVector sbv=new LongsSuccinctBitVector();
  for (int i=0; i < 10000; i++) {
    sbv.append0();
    sbv.append1();
    String msg=i + "String_Node_Str";
    Assert.assertEquals(msg,i + 1,sbv.getCountCache0()[i * 2 / LongsSuccinctBitVector.CACHE_WIDTH_BITS]);
  }
}

Fixed version (ground truth):
@Test public void test_append_countCache0_3() throws Exception {
  LongsSuccinctBitVector sbv=new LongsSuccinctBitVector();
  for (int i=0; i < 10000; i++) {
    sbv.append0();
    sbv.append1();
    String msg=i + "String_Node_Str";
    Assert.assertEquals(msg,i + 1,sbv.getCountCache0()[i * 2 / LongsSuccinctBitVector.BITS_IN_COUNTCACHE0]);
  }
}
Program: 100992
Project: 100992
Buggy source:
@Override public Iterable<Pair<String,Integer>> predictiveSearchWithTermId(String query){
  List<Pair<String,Integer>> ret=new ArrayList<Pair<String,Integer>>();
  char[] chars=query.toCharArray();
  int charsLen=chars.length;
  int nodeId=0;
  Range r=new Range();
  TailCharIterator tci=tailArray.newIterator();
  String pfx=null;
  int charsIndexBack=0;
  for (int charsIndex=0; charsIndex < charsLen; charsIndex++) {
    charsIndexBack=charsIndex;
    int child=getChildNode(nodeId,chars[charsIndex],r);
    if (child == -1)     return ret;
    tci.setOffset(tailArray.getIteratorOffset(child));
    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]);
    tci.setOffset(tailArray.getIteratorOffset(nid));
    while (tci.hasNext())     b.append(tci.next());
    String letter=b.toString();
    if (term.get(nid))     ret.add(Pair.create(letter,nid));
    bvtree.getChildNodeIds(nid,r);
    for (int i=(r.getEnd() - 1); i >= r.getStart(); i--) {
      queue.offerFirst(Pair.create(i,letter));
    }
  }
  return ret;
}

Fixed version (ground truth):
@Override public Iterable<Pair<String,Integer>> predictiveSearchWithTermId(String query){
  List<Pair<String,Integer>> ret=new ArrayList<Pair<String,Integer>>();
  char[] chars=query.toCharArray();
  int charsLen=chars.length;
  int nodeId=0;
  Range r=new Range();
  TailCharIterator tci=tailArray.newIterator();
  String pfx=null;
  int charsIndexBack=0;
  for (int charsIndex=0; charsIndex < charsLen; charsIndex++) {
    charsIndexBack=charsIndex;
    int child=getChildNode(nodeId,chars[charsIndex],r);
    if (child == -1)     return ret;
    tci.setOffset(tailArray.getIteratorOffset(child));
    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());
    if (nid > 0) {
      b.append(labels[nid]);
    }
    tci.setOffset(tailArray.getIteratorOffset(nid));
    while (tci.hasNext())     b.append(tci.next());
    String letter=b.toString();
    if (term.get(nid)) {
      ret.add(Pair.create(letter,nid));
    }
    bvtree.getChildNodeIds(nid,r);
    for (int i=(r.getEnd() - 1); i >= r.getStart(); i--) {
      queue.offerFirst(Pair.create(i,letter));
    }
  }
  return ret;
}
Program: 100993
Project: 100993
Buggy source:
@Override public Iterable<Pair<String,Integer>> predictiveSearchWithTermId(String query){
  List<Pair<String,Integer>> ret=new ArrayList<Pair<String,Integer>>();
  char[] chars=query.toCharArray();
  int charsLen=chars.length;
  int nodeId=0;
  Range r=new Range();
  TailCharIterator tci=tailArray.newIterator();
  String pfx=null;
  int charsIndexBack=0;
  for (int charsIndex=0; charsIndex < charsLen; charsIndex++) {
    charsIndexBack=charsIndex;
    int child=getChildNode(nodeId,chars[charsIndex],r);
    if (child == -1)     return ret;
    tci.setOffset(tailArray.getIteratorOffset(child));
    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());
    if (nid > 0) {
      b.append(labels[nid]);
    }
    tci.setOffset(tailArray.getIteratorOffset(nid));
    while (tci.hasNext())     b.append(tci.next());
    String letter=b.toString();
    if (term.get(nid)) {
      ret.add(Pair.create(letter,nid));
    }
    bvtree.getChildNodeIds(nid,r);
    for (int i=(r.getEnd() - 1); i >= r.getStart(); i--) {
      queue.offerFirst(Pair.create(i,letter));
    }
  }
  return ret;
}

Fixed version (ground truth):
@Override public Iterable<Pair<String,Integer>> predictiveSearchWithTermId(String query){
  List<Pair<String,Integer>> ret=new ArrayList<Pair<String,Integer>>();
  char[] chars=query.toCharArray();
  int charsLen=chars.length;
  int nodeId=0;
  Range r=new Range();
  TailCharIterator tci=tailArray.newIterator();
  String pfx=null;
  int charsIndexBack=0;
  for (int charsIndex=0; charsIndex < charsLen; charsIndex++) {
    charsIndexBack=charsIndex;
    int child=getChildNode(nodeId,chars[charsIndex],r);
    if (child == -1)     return ret;
    tci.setOffset(tailArray.getIteratorOffset(child));
    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());
    if (nid > 0) {
      b.append(labels[nid]);
    }
    tci.setOffset(tailArray.getIteratorOffset(nid));
    while (tci.hasNext())     b.append(tci.next());
    String letter=b.toString();
    if (term.get(nid)) {
      ret.add(Pair.create(letter,term.rank1(nid) - 1));
    }
    bvtree.getChildNodeIds(nid,r);
    for (int i=(r.getEnd() - 1); i >= r.getStart(); i--) {
      queue.offerFirst(Pair.create(i,letter));
    }
  }
  return ret;
}
Program: 100994
Project: 100994
Buggy source:
@Override public Iterable<Pair<String,Integer>> commonPrefixSearchWithTermId(String query){
  List<Pair<String,Integer>> ret=new ArrayList<Pair<String,Integer>>();
  char[] chars=query.toCharArray();
  int charsLen=chars.length;
  int nodeId=0;
  TailCharIterator tci=tailArray.newIterator();
  Range r=new Range();
  for (int charsIndex=0; charsIndex < charsLen; charsIndex++) {
    int child=getChildNode(nodeId,chars[charsIndex],r);
    if (child == -1)     return ret;
    tci.setOffset(tailArray.getIteratorOffset(child));
    while (tci.hasNext()) {
      charsIndex++;
      if (charsLen <= charsIndex)       return ret;
      if (chars[charsIndex] != tci.next())       return ret;
    }
    if (term.get(child)) {
      ret.add(Pair.create(new String(chars,0,charsIndex + 1),child));
    }
    nodeId=child;
  }
  return ret;
}

Fixed version (ground truth):
@Override public Iterable<Pair<String,Integer>> commonPrefixSearchWithTermId(String query){
  List<Pair<String,Integer>> ret=new ArrayList<Pair<String,Integer>>();
  char[] chars=query.toCharArray();
  int charsLen=chars.length;
  int nodeId=0;
  TailCharIterator tci=tailArray.newIterator();
  Range r=new Range();
  for (int charsIndex=0; charsIndex < charsLen; charsIndex++) {
    int child=getChildNode(nodeId,chars[charsIndex],r);
    if (child == -1)     return ret;
    tci.setOffset(tailArray.getIteratorOffset(child));
    while (tci.hasNext()) {
      charsIndex++;
      if (charsLen <= charsIndex)       return ret;
      if (chars[charsIndex] != tci.next())       return ret;
    }
    if (term.get(child)) {
      ret.add(Pair.create(new String(chars,0,charsIndex + 1),term.rank1(child) - 1));
    }
    nodeId=child;
  }
  return ret;
}
Program: 100995
Project: 100995
Buggy source:
public void trimToSize(){
  int vectorSize=size / 64 + 1;
  longs=Arrays.copyOf(longs,Math.min(longs.length,vectorSize));
  int blockSize=CACHE_WIDTH_BITS / 8;
  int size=vectorSize / blockSize + (((vectorSize % blockSize) != 0) ? 1 : 0);
  int countCacheSize0=size;
  countCache0=Arrays.copyOf(countCache0,Math.min(countCache0.length,countCacheSize0));
}

Fixed version (ground truth):
public void trimToSize(){
  longs=Arrays.copyOf(longs,longsSize(size));
  countCache0=Arrays.copyOf(countCache0,countCache0Size(size));
}
Program: 100996
Project: 100996
Buggy source:
public int select0(int count){
  if (count > size)   return -1;
  if (count <= 3) {
    if (count == 1)     return node1pos;
 else     if (count == 2)     return node2pos;
 else     if (count == 3)     return node3pos;
 else     return -1;
  }
  int idx=count / CACHE_WIDTH;
  int start=indexCache0[idx];
  if (count % CACHE_WIDTH == 0)   return start;
  start/=CACHE_WIDTH;
  int end=0;
  if (indexCache0.length > (idx + 1)) {
    int c=(indexCache0[idx + 1]) / CACHE_WIDTH + 1;
    if (c != 1)     end=c;
  }
  if (end == 0) {
    int vectorSize=size / 8 + 1;
    int blockSize=CACHE_WIDTH / 8;
    end=vectorSize / blockSize + (((vectorSize % blockSize) != 0) ? 1 : 0);
    if (end == 0) {
      end=size;
    }
  }
  int m=0;
  int d=0;
  while (start != end) {
    m=(start + end) / 2;
    d=count - countCache0[m];
    if (d < 0) {
      end=m;
      continue;
    }
 else     if (d > 0) {
      if (start != m)       start=m;
 else       break;
    }
 else {
      break;
    }
  }
  if (d > 0) {
    count=d;
  }
 else {
    while (m >= 0 && count <= countCache0[m])     m--;
    if (m >= 0)     count-=countCache0[m];
  }
  int n=size / 8 + 1;
  for (int i=(m + 1) * CACHE_WIDTH / 8; i < n; i++) {
    int bits=bytes[i] & 0xff;
    int c=BITCOUNTS0[bits];
    if (count <= c) {
      return i * 8 + BITPOS0[bits][count - 1];
    }
    count-=c;
  }
  return -1;
}

Fixed version (ground truth):
public int select0(int count){
  if (count > size)   return -1;
  if (count <= 3) {
    if (count == 1)     return node1pos;
 else     if (count == 2)     return node2pos;
 else     if (count == 3)     return node3pos;
 else     return -1;
  }
  int idx=count / CACHE_WIDTH;
  int start=indexCache0[idx];
  if (count % CACHE_WIDTH == 0)   return start;
  start/=CACHE_WIDTH;
  int end=0;
  if (indexCache0.length > (idx)) {
    int c=(indexCache0[idx]) / CACHE_WIDTH;
    if (c != 0)     end=c + 1;
  }
  if (end == 0) {
    int vectorSize=containerBytesCount(size);
    int blockSize=CACHE_WIDTH / 8;
    end=vectorSize / blockSize + (((vectorSize % blockSize) != 0) ? 1 : 0);
    if (end == 0) {
      end=size;
    }
  }
  int m=0;
  int d=0;
  while (start != end) {
    m=(start + end) / 2;
    d=count - countCache0[m];
    if (d < 0) {
      end=m;
      continue;
    }
 else     if (d > 0) {
      if (start != m)       start=m;
 else       break;
    }
 else {
      break;
    }
  }
  if (d > 0) {
    count=d;
  }
 else {
    while (m >= 0 && count <= countCache0[m])     m--;
    if (m >= 0)     count-=countCache0[m];
  }
  int n=containerBytesCount(size);
  for (int i=(m + 1) * CACHE_WIDTH / 8; i < n; i++) {
    int bits=bytes[i] & 0xff;
    int c=BITCOUNTS0[bits];
    if (count <= c) {
      return i * 8 + BITPOS0[bits][count - 1];
    }
    count-=c;
  }
  return -1;
}
Program: 100998
Project: 100998
Buggy source:
private void build(Trie orig,BvTree bvtree,TailArrayBuilder tailArrayBuilder,FastBitSet termBs,NodeListener listener){
  this.bvtree=bvtree;
  this.size=orig.size();
  this.labels=new char[size];
  LinkedList<Node> queue=new LinkedList<Node>();
  int count=0;
  if (orig.getRoot() != null)   queue.add(orig.getRoot());
  while (!queue.isEmpty()) {
    Node node=queue.pollFirst();
    int index=count++;
    if (index >= labels.length) {
      extend();
    }
    listener.listen(node,index);
    if (node.isTerminate()) {
      termBs.set(index);
    }
 else     if (termBs.size() <= index) {
      termBs.ensureCapacity(index);
    }
    for (    Node c : node.getChildren()) {
      bvtree.appendChild();
      queue.offerLast(c);
    }
    bvtree.appendSelf();
    char[] letters=node.getLetters();
    if (letters.length == 0) {
      labels[index]=0xffff;
      tailArrayBuilder.appendEmpty(index);
    }
 else {
      labels[index]=letters[0];
      if (letters.length >= 2) {
        tailArrayBuilder.append(index,letters,1,letters.length - 1);
      }
 else {
        tailArrayBuilder.appendEmpty(index);
      }
    }
  }
  nodeSize=count;
  this.tailArray=tailArrayBuilder.build();
}

Fixed version (ground truth):
private void build(Trie orig,BvTree bvtree,TailArrayBuilder tailArrayBuilder,FastBitSet termBs,NodeListener listener){
  this.bvtree=bvtree;
  this.size=orig.size();
  this.labels=new char[size];
  LinkedList<Node> queue=new LinkedList<Node>();
  int count=0;
  if (orig.getRoot() != null)   queue.add(orig.getRoot());
  while (!queue.isEmpty()) {
    Node node=queue.pollFirst();
    int index=count++;
    if (index >= labels.length) {
      extend();
    }
    listener.listen(node,index);
    if (node.isTerminate()) {
      termBs.set(index);
    }
 else     if (termBs.size() <= index) {
      termBs.ensureCapacity(index);
    }
    for (    Node c : node.getChildren()) {
      bvtree.appendChild();
      queue.offerLast(c);
    }
    bvtree.appendSelf();
    char[] letters=node.getLetters();
    if (letters.length == 0) {
      labels[index]=0xffff;
      tailArrayBuilder.appendEmpty(index);
    }
 else {
      labels[index]=letters[0];
      if (letters.length >= 2) {
        tailArrayBuilder.append(index,letters,1,letters.length - 1);
      }
 else {
        tailArrayBuilder.appendEmpty(index);
      }
    }
  }
  this.nodeSize=count;
  this.tailArray=tailArrayBuilder.build();
}
Program: 100999
Project: 100999
Buggy source:
public MapTailLOUDSPPTrie(MapTrie<T> orig,BvTree bvtree,TailArrayBuilder tailArrayBuilder){
  final List<T> values=new ArrayList<T>();
  setTrie(new TailLOUDSTrie(orig,bvtree,tailArrayBuilder,new NodeListener(){
    @Override @SuppressWarnings("String_Node_Str") public void listen(    Node node,    int id){
      if (node.isTerminate()) {
        values.add(((MapNode<T>)node).getValue());
      }
    }
  }
));
  setValues(values.toArray());
}

Fixed version (ground truth):
public MapTailLOUDSPPTrie(MapTrie<T> orig,TailArrayBuilder tailArrayBuilder){
  final List<T> values=new ArrayList<T>();
  setTrie(new TailLOUDSTrie(orig,tailArrayBuilder,new NodeListener(){
    @Override @SuppressWarnings("String_Node_Str") public void listen(    Node node,    int id){
      if (node.isTerminate()) {
        values.add(((MapNode<T>)node).getValue());
      }
    }
  }
));
  setValues(values.toArray());
}
Program: 101000
Project: 101000
Buggy source:
public MapTailLOUDSTrie(MapTrie<T> orig,BvTree bvtree,TailArrayBuilder tailArrayBuilder){
  final List<T> values=new ArrayList<T>();
  setTrie(new TailLOUDSTrie(orig,bvtree,tailArrayBuilder,new NodeListener(){
    @Override @SuppressWarnings("String_Node_Str") public void listen(    Node node,    int id){
      if (node.isTerminate()) {
        values.add(((MapNode<T>)node).getValue());
      }
    }
  }
));
  setValues(values.toArray());
}

Fixed version (ground truth):
public MapTailLOUDSTrie(MapTrie<T> orig,TailArrayBuilder tailArrayBuilder){
  final List<T> values=new ArrayList<T>();
  setTrie(new TailLOUDSTrie(orig,tailArrayBuilder,new NodeListener(){
    @Override @SuppressWarnings("String_Node_Str") public void listen(    Node node,    int id){
      if (node.isTerminate()) {
        values.add(((MapNode<T>)node).getValue());
      }
    }
  }
));
  setValues(values.toArray());
}
Program: 101001
Project: 101001
Buggy source:
public TailLOUDSTrie(Trie orig,BvTree bvtree,TailArrayBuilder tailArrayBuilder,NodeListener listener){
  super(orig,bvtree,tailArrayBuilder,listener);
}

Fixed version (ground truth):
TailLOUDSTrie(Trie orig,TailArrayBuilder tailArrayBuilder,NodeListener listener,BvTree bvTree){
  super(orig,bvTree,tailArrayBuilder,listener);
}
Program: 101002
Project: 101002
Buggy source:
@Override public void writeExternal(ObjectOutput out) throws IOException {
  out.writeInt(size);
  bv.writeExternal(out);
}

Fixed version (ground truth):
@Override public void writeExternal(ObjectOutput out) throws IOException {
  out.writeObject(sbv);
  out.writeInt(size);
}
Program: 101003
Project: 101003
Buggy source:
@Override public int get(int nodeId){
  if (nodeId == 0) {
    if (bv.isZero(0))     return -1;
 else     return 0;
  }
  int s=bv.select0(nodeId);
  if (bv.isZero(s + 1))   return -1;
  return bv.rank1(s);
}

Fixed version (ground truth):
@Override public int get(int nodeId){
  if (nodeId == 0) {
    if (sbv.isZero(0))     return -1;
 else     return 0;
  }
  int s=sbv.select0(nodeId);
  if (sbv.isZero(s + 1))   return -1;
  return sbv.rank1(s);
}
Program: 101004
Project: 101004
Buggy source:
public SBVTailIndex(byte[] bits,int bitSize,int size){
  this.size=size;
  this.bv=new BytesSuccinctBitVector(bits,bitSize);
}

Fixed version (ground truth):
public SBVTailIndex(byte[] bits,int bitSize,int size){
  this.sbv=new BytesSuccinctBitVector(bits,bitSize);
  this.size=size;
}
Program: 101005
Project: 101005
Buggy source:
@Override public void readExternal(ObjectInput in) throws IOException {
  size=in.readInt();
  bv.readExternal(in);
}

Fixed version (ground truth):
@Override public void readExternal(ObjectInput in) throws ClassNotFoundException, IOException {
  sbv=(SuccinctBitVector)in.readObject();
  size=in.readInt();
}
Program: 101006
Project: 101006
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public MapNode<T> getRoot(){
  return new MapTailPatriciaTrieNodeAdapter<T>((MapTailPatriciaTrieNode<T>)super.getRoot(),getTails());
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public MapNode<T> getRoot(){
  return new MapTailPatriciaTrieNodeAdapter<T>((MapTailPatriciaTrieNode<T>)((TailPatriciaTrieNodeAdapter)super.getRoot()).getNode(),getTails());
}
Program: 101007
Project: 101007
Buggy source:
@Test public void test_termId() throws Exception {
  String[] words={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  TermIdTrie t=buildSecondTrie(trieWithWords(words));
  Set<Integer> ids=new HashSet<>();
  for (int i=0; i < words.length; i++) {
    ids.add(i);
  }
  Assert.assertEquals(words.length,ids.size());
  for (  String w : words) {
    ids.remove(t.getTermId(w));
  }
  Assert.assertEquals(0,ids.size());
}

Fixed version (ground truth):
@Test public void test_termId() throws Exception {
  String[] words={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  TermIdTrie t=buildSecondTrie(trieWithWords(words));
  Set<Integer> ids=new HashSet<Integer>();
  for (int i=0; i < words.length; i++) {
    ids.add(i);
  }
  Assert.assertEquals(words.length,ids.size());
  for (  String w : words) {
    ids.remove(t.getTermId(w));
  }
  Assert.assertEquals(0,ids.size());
}
Program: 101008
Project: 101008
Buggy source:
public void unsetIfLE(int index){
  if (size <= index) {
    extend(index);
  }
  size=index + 1;
}

Fixed version (ground truth):
public void unsetIfLE(int index){
  if (index / 8 >= bytes.length) {
    extend(index);
  }
  size=index + 1;
}
Program: 101010
Project: 101010
Buggy source:
@Override public char[] getLetters(){
  StringBuilder ret=new StringBuilder();
  if (firstChar != 0)   ret.append(firstChar);
  int nid=nodeId;
  while (true) {
    if (term.get(nid))     return ret.toString().toCharArray();
    CharSequence children=listupChildChars(nid);
    int n=children.length();
    if (n == 0 || n > 1)     return ret.toString().toCharArray();
    char c=children.charAt(0);
    ret.append(c);
    nid=base[nid] + charToCode[c];
  }
}

Fixed version (ground truth):
@Override public char[] getLetters(){
  StringBuilder ret=new StringBuilder();
  if (firstChar != 0)   ret.append(firstChar);
  return ret.toString().toCharArray();
}
Program: 101011
Project: 101011
Buggy source:
public BytesSuccinctBitVector(int initialCapacity){
  vector=new byte[initialCapacity / 8 + 1];
  int blockSize=CACHE_WIDTH;
  int size=initialCapacity / blockSize + 1;
  countCache0=new int[size];
  indexCache0=new int[size + 1];
}

Fixed version (ground truth):
public BytesSuccinctBitVector(byte[] bytes,int bits){
  this.vector=Arrays.copyOf(bytes,containerBytesCount(bits));
  int size=bits / CACHE_WIDTH + 1;
  countCache0=new int[size];
  indexCache0=new int[size + 1];
  throw new UnsupportedOperationException();
}
Program: 101012
Project: 101012
Buggy source:
public Rank0OnlySuccinctBitVector(byte[] bytes,int bits){
  vector=Arrays.copyOf(bytes,bits / 8 + (bits % 8 != 0 ? 1 : 0));
  int blockSize=CACHE_WIDTH;
  int size=vector.length / blockSize + 1;
  countCache0=new int[size];
  int sum=0;
  for (int i=0; i < bytes.length; i++) {
    sum+=BITCOUNTS0[bytes[i] & 0xff];
    int ci=size / CACHE_WIDTH;
    countCache0[ci]=sum;
  }
}

Fixed version (ground truth):
public Rank0OnlySuccinctBitVector(byte[] bytes,int bits){
  this.size=bits;
  this.vector=Arrays.copyOf(bytes,containerCount(bits,8));
  this.countCache0=new int[containerCount(vector.length,8)];
  int sum=0;
  int n=vector.length;
  for (int i=0; i < n; i++) {
    sum+=BITCOUNTS0[bytes[i] & 0xff];
    countCache0[i / 8]=sum;
  }
}
Program: 101013
Project: 101013
Buggy source:
public void append1(){
  int i=size / 8;
  int ci=size / CACHE_WIDTH;
  if (i >= vector.length) {
    extend();
  }
  if (size % CACHE_WIDTH == 0 && ci > 0) {
    countCache1[ci]=countCache1[ci - 1];
  }
  int r=size % 8;
  vector[i]|=BITS[r];
  size++;
}

Fixed version (ground truth):
public void append1(){
  int i=size / 8;
  int ci=size / CACHE_WIDTH;
  prepareAppend(i,ci);
  countCache1[ci]++;
  int r=size % 8;
  vector[i]|=BITS[r];
  size++;
}
Program: 101014
Project: 101014
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) {
    countCache1[ci]=countCache1[ci - 1];
  }
  countCache1[ci]++;
  size++;
}

Fixed version (ground truth):
public void append0(){
  int i=size / 8;
  int ci=size / CACHE_WIDTH;
  prepareAppend(i,ci);
  size++;
}
Program: 101015
Project: 101015
Buggy source:
public Rank1OnlySuccinctBitVector(byte[] bytes,int bits){
  this.vector=Arrays.copyOf(bytes,bits / 8 + (bits % 8 != 0 ? 1 : 0));
  this.size=bits;
  int blockSize=CACHE_WIDTH;
  int size=vector.length / blockSize + 1;
  countCache1=new int[size];
  int sum=0;
  for (int i=0; i < bytes.length; i++) {
    sum+=BITCOUNTS1[bytes[i] & 0xff];
    int ci=size / CACHE_WIDTH;
    countCache1[ci]=sum;
  }
}

Fixed version (ground truth):
public Rank1OnlySuccinctBitVector(byte[] bytes,int bits){
  this.size=bits;
  this.vector=Arrays.copyOf(bytes,containerCount(bits,8));
  this.countCache1=new int[containerCount(vector.length,8)];
  int sum=0;
  int n=vector.length;
  for (int i=0; i < n; i++) {
    sum+=BITCOUNTS1[bytes[i] & 0xff];
    countCache1[i / 8]=sum;
  }
}
Program: 101016
Project: 101016
Buggy source:
@Override public int getTermId(String text){
  int nodeIndex=0;
  int n=text.length();
  for (int i=0; i < n; i++) {
    char cid=charToCode[text.charAt(i)];
    if (cid == 0)     return -1;
    int next=base[nodeIndex] + cid;
    if (next < 0 || check[next] != nodeIndex)     return -1;
    nodeIndex=next;
  }
  return term.get(nodeIndex) ? term.rank1(nodeIndex) - 1 : -1;
}

Fixed version (ground truth):
@Override public int getTermId(String text){
  int nid=getNodeId(text);
  return term.get(nid) ? term.rank1(nid) - 1 : -1;
}
Program: 101017
Project: 101017
Buggy source:
@Override public int getNodeId(){
  return nodeId;
}

Fixed version (ground truth):
public int getNodeId(String text){
  int nodeIndex=0;
  int n=text.length();
  for (int i=0; i < n; i++) {
    char cid=charToCode[text.charAt(i)];
    if (cid == 0)     return -1;
    int next=base[nodeIndex] + cid;
    if (next < 0 || check[next] != nodeIndex)     return -1;
    nodeIndex=next;
  }
  return nodeIndex;
}
Program: 101018
Project: 101018
Buggy source:
public void ensureCapacity(int index){
  if (index / 8 >= bytes.length) {
    extend(index);
  }
}

Fixed version (ground truth):
public void ensureCapacity(int index){
  if ((index / 8 + 1) >= bytes.length) {
    extend(index);
  }
}
Program: 101019
Project: 101019
Buggy source:
public void unsetIfLE(int index){
  if (index / 8 >= bytes.length) {
    extend(index);
  }
  size=index + 1;
}

Fixed version (ground truth):
public void unsetIfLE(int index){
  if ((index / 8 + 1) >= bytes.length) {
    extend(index);
  }
  size=Math.max(size,index + 1);
}
Program: 101020
Project: 101020
Buggy source:
@Override public boolean contains(String text){
  int nodeIndex=0;
  int n=text.length();
  for (int i=0; i < n; i++) {
    char cid=charToCode[text.charAt(i)];
    if (cid == 0)     return false;
    int next=base[nodeIndex] + cid;
    if (check[next] != nodeIndex)     return false;
    nodeIndex=next;
  }
  return term.get(nodeIndex);
}

Fixed version (ground truth):
@Override public boolean contains(String text){
  int nodeIndex=0;
  int n=text.length();
  for (int i=0; i < n; i++) {
    char cid=charToCode[text.charAt(i)];
    if (cid == 0)     return false;
    int next=base[nodeIndex] + cid;
    if (next < 0 || check[next] != nodeIndex)     return false;
    nodeIndex=next;
  }
  return term.get(nodeIndex);
}
Program: 101021
Project: 101021
Buggy source:
private int getIndex(String text){
  try {
    int nodeIndex=0;
    int n=text.length();
    for (int i=0; i < n; i++) {
      int cid=findCharId(text.charAt(i));
      if (cid == -1)       return -1;
      int next=base[nodeIndex] + cid;
      if (check[next] != nodeIndex)       return -1;
      nodeIndex=next;
    }
    return nodeIndex;
  }
 catch (  ArrayIndexOutOfBoundsException e) {
    return -1;
  }
}

Fixed version (ground truth):
private int getIndex(String text){
  try {
    int nodeIndex=0;
    int n=text.length();
    for (int i=0; i < n; i++) {
      int cid=findCharId(text.charAt(i));
      if (cid == -1)       return -1;
      int next=base[nodeIndex] + cid;
      if (next < 0 || check[next] != nodeIndex)       return -1;
      nodeIndex=next;
    }
    return nodeIndex;
  }
 catch (  ArrayIndexOutOfBoundsException e) {
    return -1;
  }
}
Program: 101022
Project: 101022
Buggy source:
@Override public boolean contains(String text){
  int nodeIndex=0;
  FastTailCharIterator it=new FastTailCharIterator(tails,-1);
  int n=text.length();
  for (int i=0; i < n; i++) {
    char cid=charToCode[text.charAt(i)];
    if (cid == 0)     return false;
    int next=base[nodeIndex] + cid;
    if (check[next] != nodeIndex)     return false;
    nodeIndex=next;
    int ti=tail[nodeIndex];
    if (ti == -1)     continue;
    it.setIndex(ti);
    char c;
    while ((c=it.getNext()) != '\0') {
      i++;
      if (i == n)       return false;
      if (text.charAt(i) != c)       return false;
    }
  }
  return term.get(nodeIndex);
}

Fixed version (ground truth):
@Override public boolean contains(String text){
  int nodeIndex=0;
  FastTailCharIterator it=new FastTailCharIterator(tails,-1);
  int n=text.length();
  for (int i=0; i < n; i++) {
    char cid=charToCode[text.charAt(i)];
    if (cid == 0)     return false;
    int next=base[nodeIndex] + cid;
    if (next < 0 || check[next] != nodeIndex)     return false;
    nodeIndex=next;
    int ti=tail[nodeIndex];
    if (ti == -1)     continue;
    it.setIndex(ti);
    char c;
    while ((c=it.getNext()) != '\0') {
      i++;
      if (i == n)       return false;
      if (text.charAt(i) != c)       return false;
    }
  }
  return term.get(nodeIndex);
}
Program: 101024
Project: 101024
Buggy source:
@SuppressWarnings("String_Node_Str") public MapNode<T> getNode(String text){
  MapNode<T> node=root;
  int n=text.length();
  for (int i=0; i < n; i++) {
    node=(MapNode<T>)node.getChild(text.charAt(i));
    if (node == null)     return null;
    char[] letters=node.getLetters();
    int lettersLen=letters.length;
    for (int j=1; j < lettersLen; j++) {
      i++;
      if (i == n)       return null;
      if (text.charAt(i) != letters[j])       return null;
    }
  }
  return node;
}

Fixed version (ground truth):
public MapNode<T> getNode(String text){
  MapNode<T> node=root;
  int n=text.length();
  for (int i=0; i < n; i++) {
    node=node.getChild(text.charAt(i));
    if (node == null)     return null;
    char[] letters=node.getLetters();
    int lettersLen=letters.length;
    for (int j=1; j < lettersLen; j++) {
      i++;
      if (i == n)       return null;
      if (text.charAt(i) != letters[j])       return null;
    }
  }
  return node;
}
Program: 101025
Project: 101025
Buggy source:
@Override public Node getRoot(){
  return new DoubleArrayNode(0);
}

Fixed version (ground truth):
@Override public IdNode getRoot(){
  return new DoubleArrayNode(0);
}
Program: 101026
Project: 101026
Buggy source:
public void save(OutputStream os) throws IOException {
  ObjectOutputStream out=new ObjectOutputStream(os);
  try {
    writeExternal(new ObjectOutputStream(os));
  }
  finally {
    out.flush();
  }
}

Fixed version (ground truth):
public void save(OutputStream os) throws IOException {
  ObjectOutputStream out=new ObjectOutputStream(os);
  try {
    writeExternal(out);
  }
  finally {
    out.flush();
  }
}
Program: 101027
Project: 101027
Buggy source:
public void save(OutputStream os) throws IOException {
  ObjectOutputStream out=new ObjectOutputStream(os);
  try {
    writeExternal(new ObjectOutputStream(os));
  }
  finally {
    out.flush();
  }
}

Fixed version (ground truth):
public void save(OutputStream os) throws IOException {
  ObjectOutputStream out=new ObjectOutputStream(os);
  try {
    writeExternal(out);
  }
  finally {
    out.flush();
  }
}
Program: 101028
Project: 101028
Buggy source:
public void save(OutputStream os) throws IOException {
  ObjectOutputStream out=new ObjectOutputStream(os);
  try {
    writeExternal(new ObjectOutputStream(os));
  }
  finally {
    out.flush();
  }
}

Fixed version (ground truth):
public void save(OutputStream os) throws IOException {
  ObjectOutputStream out=new ObjectOutputStream(os);
  try {
    writeExternal(out);
  }
  finally {
    out.flush();
  }
}
Program: 101029
Project: 101029
Buggy source:
@Override public Iterable<String> predictiveSearch(String prefix){
  List<String> ret=new ArrayList<String>();
  char[] chars=prefix.toCharArray();
  int charsLen=chars.length;
  int checkLen=check.length;
  int nodeIndex=0;
  for (int i=0; i < charsLen; i++) {
    int cid=findCharId(chars[i]);
    if (cid == -1)     return ret;
    int next=base[nodeIndex] + cid;
    if (next < 0 || next >= checkLen || check[next] != nodeIndex)     return ret;
    nodeIndex=next;
  }
  if (term.get(nodeIndex)) {
    ret.add(prefix);
  }
  Deque<Pair<Integer,String>> q=new LinkedList<Pair<Integer,String>>();
  q.add(Pair.create(nodeIndex,prefix));
  while (!q.isEmpty()) {
    Pair<Integer,String> p=q.pop();
    int ni=p.getFirst();
    int b=base[ni];
    if (b == BASE_EMPTY)     continue;
    String c=p.getSecond();
    for (    char v : this.chars) {
      int next=b + charToCode[v];
      if (next >= checkLen)       continue;
      if (check[next] == ni) {
        String n=new StringBuilder(c).append(v).toString();
        if (term.get(next)) {
          ret.add(n);
        }
        q.push(Pair.create(next,n));
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
@Override public Iterable<String> predictiveSearch(String prefix){
  List<String> ret=new ArrayList<String>();
  char[] chars=prefix.toCharArray();
  int charsLen=chars.length;
  int checkLen=check.length;
  int nodeIndex=0;
  for (int i=0; i < charsLen; i++) {
    int cid=findCharId(chars[i]);
    if (cid == -1)     return ret;
    int next=base[nodeIndex] + cid;
    if (next < 0 || next >= checkLen || check[next] != nodeIndex)     return ret;
    nodeIndex=next;
  }
  if (term.get(nodeIndex)) {
    ret.add(prefix);
  }
  Deque<Pair<Integer,String>> q=new LinkedList<Pair<Integer,String>>();
  q.add(Pair.create(nodeIndex,prefix));
  while (!q.isEmpty()) {
    Pair<Integer,String> p=q.pop();
    int ni=p.getFirst();
    int b=base[ni];
    if (b == BASE_EMPTY)     continue;
    String c=p.getSecond();
    for (    char v : this.chars) {
      int next=b + charToCode[v];
      if (next < 0 || next >= checkLen)       continue;
      if (check[next] == ni) {
        String n=new StringBuilder(c).append(v).toString();
        if (term.get(next)) {
          ret.add(n);
        }
        q.push(Pair.create(next,n));
      }
    }
  }
  return ret;
}
Program: 101030
Project: 101030
Buggy source:
@Override public Iterable<String> predictiveSearch(String prefix){
  List<String> ret=new ArrayList<String>();
  char[] chars=prefix.toCharArray();
  int charsLen=chars.length;
  int checkLen=check.length;
  int nodeIndex=0;
  for (int i=0; i < charsLen; i++) {
    int cid=findCharId(chars[i]);
    if (cid == -1)     return ret;
    int next=base[nodeIndex] + cid;
    if (next < 0 || next >= checkLen || check[next] != nodeIndex)     return ret;
    nodeIndex=next;
  }
  if (term.get(nodeIndex)) {
    ret.add(prefix);
  }
  Deque<Pair<Integer,String>> q=new LinkedList<Pair<Integer,String>>();
  q.add(Pair.create(nodeIndex,prefix));
  while (!q.isEmpty()) {
    Pair<Integer,String> p=q.pop();
    int ni=p.getFirst();
    int b=base[ni];
    if (b == BASE_EMPTY)     continue;
    String c=p.getSecond();
    for (    char v : this.chars) {
      int next=b + charToCode[v];
      if (next >= checkLen)       continue;
      if (check[next] == ni) {
        String n=new StringBuilder(c).append(v).toString();
        if (term.get(next)) {
          ret.add(n);
        }
        q.push(Pair.create(next,n));
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
@Override public Iterable<String> predictiveSearch(String prefix){
  List<String> ret=new ArrayList<String>();
  char[] chars=prefix.toCharArray();
  int charsLen=chars.length;
  int checkLen=check.length;
  int nodeIndex=0;
  for (int i=0; i < charsLen; i++) {
    int cid=findCharId(chars[i]);
    if (cid == -1)     return ret;
    int next=base[nodeIndex] + cid;
    if (next < 0 || next >= checkLen || check[next] != nodeIndex)     return ret;
    nodeIndex=next;
  }
  if (term.get(nodeIndex)) {
    ret.add(prefix);
  }
  Deque<Pair<Integer,String>> q=new LinkedList<Pair<Integer,String>>();
  q.add(Pair.create(nodeIndex,prefix));
  while (!q.isEmpty()) {
    Pair<Integer,String> p=q.pop();
    int ni=p.getFirst();
    int b=base[ni];
    if (b == BASE_EMPTY)     continue;
    String c=p.getSecond();
    for (    char v : this.chars) {
      int next=b + charToCode[v];
      if (next < 0 || next >= checkLen)       continue;
      if (check[next] == ni) {
        String n=new StringBuilder(c).append(v).toString();
        if (term.get(next)) {
          ret.add(n);
        }
        q.push(Pair.create(next,n));
      }
    }
  }
  return ret;
}
Program: 101031
Project: 101031
Buggy source:
public DoubleArray(Trie trie,int arraySize){
  size=trie.size();
  base=new int[arraySize];
  Arrays.fill(base,BASE_EMPTY);
  check=new int[arraySize];
  Arrays.fill(check,-1);
  term=new BitSet(65536);
  build(trie.getRoot(),0);
}

Fixed version (ground truth):
public DoubleArray(Trie trie,int arraySize){
  if (arraySize <= 1)   arraySize=2;
  size=trie.size();
  base=new int[arraySize];
  Arrays.fill(base,BASE_EMPTY);
  check=new int[arraySize];
  Arrays.fill(check,-1);
  term=new BitSet(arraySize);
  build(trie.getRoot(),0);
}
Program: 101032
Project: 101032
Buggy source:
public TailDoubleArray(Trie orig,TailBuilder tb){
  size=orig.size();
  base=new int[size];
  Arrays.fill(base,BASE_EMPTY);
  check=new int[size];
  Arrays.fill(check,-1);
  tail=new int[size];
  Arrays.fill(tail,-1);
  term=new BitSet(65536);
  Arrays.fill(charToCode,(char)0);
  build(orig.getRoot(),0,tb);
  tails=tb.getTails();
}

Fixed version (ground truth):
public TailDoubleArray(Trie orig,TailBuilder tb){
  size=orig.size();
  int as=size;
  if (as <= 1)   as=2;
  base=new int[as];
  Arrays.fill(base,BASE_EMPTY);
  check=new int[as];
  Arrays.fill(check,-1);
  tail=new int[as];
  Arrays.fill(tail,-1);
  term=new BitSet(65536);
  Arrays.fill(charToCode,(char)0);
  build(orig.getRoot(),0,tb);
  tails=tb.getTails();
}
Program: 101033
Project: 101033
Buggy source:
private void extend(){
  int vectorSize=(int)(vector.length * 1.2) + 1;
  vector=Arrays.copyOf(vector,vectorSize);
  int blockSize=CACHE_WIDTH / 8;
  int size=vectorSize / blockSize + (((vectorSize % blockSize) != 0) ? 1 : 0);
  countCache0=Arrays.copyOf(countCache0,size);
  indexCache0=Arrays.copyOf(indexCache0,size);
}

Fixed version (ground truth):
private void extend(){
  int vectorSize=(int)(vector.length * 1.2) + 1;
  vector=Arrays.copyOf(vector,vectorSize);
  int blockSize=CACHE_WIDTH / 8;
  int size=vectorSize / blockSize + (((vectorSize % blockSize) != 0) ? 1 : 0);
  countCache0=Arrays.copyOf(countCache0,size);
  indexCache0=Arrays.copyOf(indexCache0,size + 1);
}
Program: 101034
Project: 101034
Buggy source:
private void extend(){
  int nsz=(int)(labels.length * 1.2);
  labels=Arrays.copyOf(labels,nsz);
  tail=Arrays.copyOf(tail,nsz);
}

Fixed version (ground truth):
private void extend(){
  int nsz=(int)(labels.length * 1.2);
  if (nsz <= labels.length)   nsz=labels.length * 2 + 1;
  labels=Arrays.copyOf(labels,nsz);
  tail=Arrays.copyOf(tail,nsz);
}
Program: 101035
Project: 101035
Buggy source:
public void save(OutputStream os) throws IOException {
  DataOutputStream dos=new DataOutputStream(os);
  dos.writeInt(size);
  dos.writeInt(size0);
  dos.writeInt(node1pos);
  dos.writeInt(node2pos);
  dos.writeInt(node3pos);
  trimToSize();
  dos.write(vector);
  for (  int e : countCache0) {
    dos.writeInt(e);
  }
  for (  int e : indexCache0) {
    dos.writeInt(e);
  }
}

Fixed version (ground truth):
public void save(OutputStream os) throws IOException {
  DataOutputStream dos=new DataOutputStream(os);
  dos.writeInt(size);
  dos.writeInt(size0);
  dos.writeInt(node1pos);
  dos.writeInt(node2pos);
  dos.writeInt(node3pos);
  trimToSize();
  dos.writeInt(vector.length);
  dos.write(vector);
  dos.writeInt(countCache0.length);
  for (  int e : countCache0) {
    dos.writeInt(e);
  }
  dos.writeInt(indexCache0.length);
  for (  int e : indexCache0) {
    dos.writeInt(e);
  }
  dos.flush();
}