[Demonstration 1]

[Buggy Method]
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);
    // Get the search bar bounds and measure the search bar layout
    Rect searchBarSpaceBounds = new Rect();
    if (mSearchBar != null) {
        mConfig.getSearchBarBounds(width, height, mConfig.systemInsets.top, searchBarSpaceBounds);
        mSearchBar.measure(MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.height(), MeasureSpec.EXACTLY));
    }
    boolean showClearAllRecents = Settings.System.getInt(mContext.getContentResolver(), Settings.System.SHOW_CLEAR_ALL_RECENTS, 0) == 1;
    Rect taskStackBounds = new Rect();
    mConfig.getTaskStackBounds(width, height, mConfig.systemInsets.top, mConfig.systemInsets.right, taskStackBounds);
    if (mClearRecents != null && showClearAllRecents) {
        int clearRecentsLocation = Settings.System.getInt(mContext.getContentResolver(), Settings.System.RECENTS_CLEAR_ALL_LOCATION, Constants.DebugFlags.App.RECENTS_CLEAR_ALL_TOP_RIGHT);
        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mClearRecents.getLayoutParams();
        params.topMargin = taskStackBounds.top;
        params.rightMargin = width - taskStackBounds.right;
        params.bottomMargin = mConfig.systemInsets.bottom;
        switch(clearRecentsLocation) {
            case Constants.DebugFlags.App.RECENTS_CLEAR_ALL_TOP_LEFT:
                params.gravity = Gravity.TOP | Gravity.LEFT;
                break;
            case Constants.DebugFlags.App.RECENTS_CLEAR_ALL_TOP_RIGHT:
                params.gravity = Gravity.TOP | Gravity.RIGHT;
                break;
            case Constants.DebugFlags.App.RECENTS_CLEAR_ALL_TOP_CENTER:
                params.gravity = Gravity.TOP | Gravity.CENTER;
                break;
            case Constants.DebugFlags.App.RECENTS_CLEAR_ALL_BOTTOM_LEFT:
                params.gravity = Gravity.BOTTOM | Gravity.LEFT;
                break;
            case Constants.DebugFlags.App.RECENTS_CLEAR_ALL_BOTTOM_RIGHT:
            default:
                params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
                break;
            case Constants.DebugFlags.App.RECENTS_CLEAR_ALL_BOTTOM_CENTER:
                params.gravity = Gravity.BOTTOM | Gravity.CENTER;
                break;
        }
        mClearRecents.setLayoutParams(params);
    } else {
        mClearRecents.setVisibility(View.GONE);
    }
    // Measure each TaskStackView with the full width and height of the window since the
    // transition view is a child of that stack view
    int childCount = getChildCount();
    int taskViewWidth = 0;
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        if (child != mSearchBar && child.getVisibility() != GONE) {
            TaskStackView tsv = (TaskStackView) child;
            // Set the insets to be the top/left inset + search bounds
            tsv.setStackInsetRect(taskStackBounds);
            tsv.measure(widthMeasureSpec, heightMeasureSpec);
            // Retrieve the max width of the task views
            int taskViewChildCount = tsv.getChildCount();
            for (int j = 0; j < taskViewChildCount; j++) {
                View taskViewChild = tsv.getChildAt(j);
                taskViewWidth = Math.max(taskViewChild.getMeasuredWidth(), taskViewWidth);
            }
        }
    }
    if (mClearRecents != null) {
        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mClearRecents.getLayoutParams();
        params.topMargin = taskStackBounds.top;
        if (mSearchBar != null && (searchBarSpaceBounds.width() > taskViewWidth)) {
            // Adjust to the search bar
            params.rightMargin = width - searchBarSpaceBounds.right;
        } else {
            // Adjust to task views
            params.rightMargin = (width / 2) - (taskViewWidth / 2);
        }
        mClearRecents.setLayoutParams(params);
    }
    setMeasuredDimension(width, height);
}

[Buggy Hunk]
Settings.System.SHOW_CLEAR_ALL_RECENTS, 0) == 1;

[Patch]
Settings.System.SHOW_CLEAR_ALL_RECENTS, 1) == 1;

[Demonstration 2]

[Buggy Method]
public String int2seq(long x, int kmerLen) {
    if (x >= (int) Math.pow(5, kmerLen)) {
        throw new IllegalArgumentException("Invalid int value, " + x + ", for kmerLen " + kmerLen);
    }
    StringBuffer seq = new StringBuffer(kmerLen);
    for (int i = 0; i < kmerLen; i++) {
        int baseVal = (int) (x % 5);
        seq.append(int2base(baseVal));
        x = x * 5;
    }
    return seq.reverse().toString();
}

[Buggy Hunk]
x = x * 5;

[Patch]
x = (long)Math.floor(x/5.0);

[Demonstration 3]

[Buggy Method]
@Override
public void onAnimationEnd(Animator animation) {
    if (mStart != null) {
        mStart.setScaleX(1.0f);
        mStart.setScaleY(1.0f);
        mStart.setVisibility(View.INVISIBLE);
    }
}

[Buggy Hunk]
if (mStart != null) {

[Patch]
if (mStart != null && mStartVisibility == View.INVISIBLE) {