@@ -0,0 +1,1869 @@
+//https://www.hackerrank.com/challenges/board-cutting%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic class Solution %7B%0A    private final static int MOD = 1000000007;%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        StringBuffer sb = new StringBuffer();%0A        %0A        //INPUT%0A        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0A        for(byte T = Byte.parseByte(br.readLine()); T %3E 0; --T)%7B%0A            String%5B%5D input = br.readLine().split(%22 %22);%0A            final int M = Integer.parseInt(input%5B0%5D) - 1;%0A            final int N = Integer.parseInt(input%5B1%5D) - 1;%0A            final int%5B%5D Ys = strToArr(M, br.readLine());%0A            final int%5B%5D Xs = strToArr(N, br.readLine());%0A            %0A            //SOLVE%0A            Arrays.sort(Xs);%0A            Arrays.sort(Ys);%0A            %0A            int vSegs = 1;%0A            int hSegs = 1;%0A            int y = M - 1;%0A            int x = N - 1;%0A            long cost = 0L;%0A            %0A            while (x %3E= 0 && y %3E= 0)%7B%0A                if (Xs%5Bx%5D %3E Ys%5By%5D)%7B%0A                    ++vSegs;%0A                    cost = (cost + ((long)Xs%5Bx--%5D)*hSegs)%25MOD;%0A                %7D else %7B%0A                    ++hSegs;%0A                    cost = (cost + ((long)Ys%5By--%5D)*vSegs)%25MOD;%0A                %7D%0A                %0A            %7D%0A            while (x %3E= 0)%7B%0A                cost = (cost + ((long)Xs%5Bx--%5D)*hSegs)%25MOD;%0A            %7D%0A            while (y %3E= 0)%7B%0A                cost = (cost + ((long)Ys%5By--%5D)*vSegs)%25MOD;%0A            %7D%0A            %0A            //OUTPUT%0A            sb.append(cost + %22%5Cn%22);%0A        %7D%0A        System.out.print(sb);%0A    %7D%0A    private static int%5B%5D strToArr(int n, String line)%7B%0A        int%5B%5D arr = new int%5Bn%5D;%0A        String%5B%5D Vs = line.split(%22 %22);%0A        while (n-- %3E 0)%7B%0A            arr%5Bn%5D = Integer.parseInt(Vs%5Bn%5D);%0A        %7D%0A        return arr;%0A    %7D%0A%7D%0A

Create board-cutting.java