[Demonstration 1]

[Buggy Method]
public static void encode(byte[] data, int off, int len, OutputStream ostream) throws IOException {
    if (len <= 0)
        return;
    byte[] out = new byte[4];
    int rindex = off;
    int rest = len - off;
    while (rest >= 3) {
        int i = ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8) + (data[rindex + 2] & 0xff);
        out[0] = (byte) S_BASE64CHAR[i >> 18];
        out[1] = (byte) S_BASE64CHAR[(i >> 12) & 0x3f];
        out[2] = (byte) S_BASE64CHAR[(i >> 6) & 0x3f];
        out[3] = (byte) S_BASE64CHAR[i & 0x3f];
        ostream.write(out, 0, 4);
        rindex += 3;
        rest -= 3;
    }
    if (rest == 1) {
        int i = data[rindex] & 0xff;
        out[0] = (byte) S_BASE64CHAR[i >> 2];
        out[1] = (byte) S_BASE64CHAR[(i << 4) & 0x3f];
        out[2] = (byte) S_BASE64PAD;
        out[3] = (byte) S_BASE64PAD;
        ostream.write(out, 0, 4);
    } else if (rest == 2) {
        int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
        out[0] = (byte) S_BASE64CHAR[i >> 10];
        out[1] = (byte) S_BASE64CHAR[(i >> 4) & 0x3f];
        out[2] = (byte) S_BASE64CHAR[(i << 2) & 0x3f];
        out[3] = (byte) S_BASE64PAD;
        ostream.write(out, 0, 4);
    }
}

[Buggy Hunk]
int rest = len-off;

[Patch]
int rest = len;

[Demonstration 2]

[Buggy Method]
public int selectColor(int x, int y, int color) {
    if (x >= TILE_DIM || y >= TILE_DIM || x < 0 || y < 0) {
        throw new IndexOutOfBoundsException("Pick a position within 0 < POSITION < TILE_DIM: " + TILE_DIM + "\n");
    }
    int trueColor = (color - 1) % (1 << (bitDepth));
    colorSelected[x][y] = trueColor;
    return trueColor;
}

[Buggy Hunk]
int trueColor = (color - 1) % (1 << (bitDepth));

[Patch]
int trueColor = (color) % (1 << (bitDepth));

[Demonstration 3]

[Buggy Method]
private Map<Goal, Double> scaleFD(Map<Goal, Double> fd, double wt) {
    if (wt == 1.0)
        return fd;
    Map<Goal, Double> ret = new HashMap<Goal, Double>();
    ret.putAll(fd);
    for (Map.Entry<Goal, Double> val : fd.entrySet()) {
        val.setValue(val.getValue() * wt);
    }
    return ret;
}

[Buggy Hunk]
for (Map.Entry<Goal, Double> val : fd.entrySet()) {

[Patch]
for (Map.Entry<Goal, Double> val : ret.entrySet()) {