import java.util.*;
import java.lang.*;
import java.io.*;


class dasu {
    static String s_card;
    ArrayList<String> strong_card;
    HashMap<char, Integer> suto;
    HashMap<Integer, String> power_table;
    
    static int judge(String s) {
        if(s.euqlas("BJOKER") || s.euqlas("RJOKER")) {
            return Integer.MAX_VALUE;
        }
        char shape = s.charAt(0);
        int shape_power = suto.get("shape");

        String num_string = s.substring(1, s.length());
        if (num_string=="J") num_string = "11";
        if (num_string=="Q") num_string = "12";
        if (num_string=="K") num_string = "13";
        if (num_string=="A") num_string = "1";
        int num_power = Integer.parseInt(num_string);
        
        num_power = (num_power+10) % 13;
        return num_power+shape_power;
        
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        s_card = sc.next();
        ArrayList<String> strong_card = new ArrayList<>();
        power_table = new HashMap<>();
        
        int a = sc.nextInt();
        suto = new HashMap<>();
        suto.put('S', 100000);
        suto.put('H', 10000);
        suto.put('D', 1000);
        suto.put('C', 100);

        int s_power = judge(s_card);
        
        for (int i=0; i<a; i++) {
            String d_card = sc.next();
            int this_power = judge(d_card);
            if(this_power > s_power) {
                power_table.put(this_power, d_card);
            }
        }

        ArrayList<Integer> num_list = new ArrayList<>(power_table.keySet());

        System.out.println(num_list.length());
        for (int i : num_list) {
            System.out.println(power_table.get(i));
        }

        


        
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: