Q:

Codeforces 427B: Prison Transfer

I'm sure that among you (users of codereview) there are many who are interested in Codeforces problemset. I tried to solve 427B: Prison Transfer tasks but have Wrong Answer judjment at 4th test.
Maybe you've already solve the problem or is interested in solving? Can you find error in my code please?
PrisonTransfer.java
import java.io.*;
import java.util.StringTokenizer;

public class PrisonTransfer {

    protected static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
    }

    public static void main(String... args) throws IOException {
        calcTransferCombinations();
    }

    protected static void calcTransferCombinations() throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int PRISONERS_NUMBER = in.nextInt();
        final int MAX_AGGRESSION = in.nextInt();
        final int RANK_LENGTH = in.nextInt();

        int combinations = PRISONERS_NUMBER - RANK_LENGTH + 1;
        int distanceToLastDangerous = RANK_LENGTH;
        int itr = 1;
        while (itr <= PRISONERS_NUMBER) {
            int aggression = in.nextInt();
            if (aggression > MAX_AGGRESSION) {
                if (PRISONERS_NUMBER - itr < RANK_LENGTH) {
                    combinations -= Math.min(PRISONERS_NUMBER - itr + 1, distanceToLastDangerous);
                    break;
                }

                int left = min(itr, RANK_LENGTH, distanceToLastDangerous);
                combinations -= left;
                distanceToLastDangerous = 0;
            }
            distanceToLastDangerous++;
            itr++;
        }

        out.print(combinations);
        out.flush();
    }

    protected static int min(int a, int b, int c) {
        int min1 = Math.min(a, b);
        return Math.min(min1, c);
    }
}

PrisonTransferTest.java [all my tests complete succesfully]
import mockit.Mock;
import mockit.MockUp;
import org.junit.Test;

import java.io.IOException;
import java.io.PrintWriter;

import static junit.framework.Assert.assertEquals;

public class PrisonTransferTest {

    private static class FastScannerMockUp extends MockUp<PrisonTransfer.FastScanner> {
        private int[] input0 = new int[] {17, 2, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1};
        private int[] input1 = new int[] {5, 2, 2, 3, 3, 3, 3, 3};
        private int[] input2 = new int[] {8, 2, 5, 1, 3, 1, 1, 1, 1, 3, 1};
        private int[] input3 = new int[] {4, 3, 3, 2, 3, 1, 1};
        private int[] input4 = new int[] {1, 1, 1, 2};
        private int[] input5 = new int[] {11, 4, 2, 2, 2, 0, 7, 3, 2, 2, 4, 9, 1, 4};
        private int[][] inputs = new int[][] {input0, input1, input2, input3, input4, input5};

        private int currInput = 0;
        private int pointer = 0;

        @SuppressWarnings("unused")
        @Mock
        int nextInt() throws IOException {
            return inputs[currInput][pointer++];
        }

        void switchInput() {
            currInput++;
            pointer = 0;
        }

        int getCurrInput() {
            return currInput;
        }

        int getInputsAmount() {
            return inputs.length;
        }
    }

    private static class PrintWriterMockUp extends MockUp<PrintWriter> {
        private int[] expectedResults = new int[] {9, 0, 0, 2, 0, 6};
        private final FastScannerMockUp scannerMockUp;

        public PrintWriterMockUp(FastScannerMockUp scannerMockUp) {
            this.scannerMockUp = scannerMockUp;
        }

        @SuppressWarnings("unused")
        @Mock
        public void print(int i) {
            System.out.println("Print input#" + scannerMockUp.getCurrInput());
            assertEquals(expectedResults[scannerMockUp.getCurrInput()], i);
        }

        @SuppressWarnings("unused")
        @Mock
        public void flush() {
            scannerMockUp.switchInput();
        }
    }

    @Test
    public void calcTransferCombinations_test() throws IOException {
        FastScannerMockUp scannerMockUp = new FastScannerMockUp();
        PrintWriterMockUp writerMockUp = new PrintWriterMockUp(scannerMockUp);
        for (int i = 0; i < scannerMockUp.getInputsAmount(); i++) {
            PrisonTransfer.calcTransferCombinations();
        }
    }
}

A:

I can't help you with the wrong result your code produce, but I would strongly recommend separating the input/output logic from the computational logic.
Your current method is defined as:
protected static void calcTransferCombinations() throws IOException {

When I look at this method I wonder: Why do you need to throw an IOException to do some mathematics?
The answer is that you read from input and print to output inside the method. I don't recommend that.
Instead I recommend:
protected static int calcTransferCombinations(int numPrisoners, int maxCrime, int consecutiveCount) {
    ... calculate combinations ...
    return combinations;
}

That is, extract the input/output from that method. Separation of concerns! A method should only do "one thing".
Also another note: Your current variables are named as constants, while being local variables. Only static final variables should be named LIKE_THIS. Other variables should be named likeThis.

