package net.ipipip0129.yukicoder.No723; import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int num_len = scan.nextInt(); int base_num = scan.nextInt(); int[] num_array = new int[num_len]; Map> num_map = new HashMap<>(); int ans_cnt = 0; for (int i = 0; i < num_len; i++) { int a = scan.nextInt(); num_array[i] = a; List li; if (num_map.containsKey(a)) li = num_map.get(a); else li = new ArrayList<>(); li.add(i); num_map.put(a, li); } Arrays.sort(num_array); for (int i = 0; i < num_len; i++) { int sub = base_num - num_array[i]; if (num_array[i] <= base_num) { if (num_map.containsKey(sub)) { List li = num_map.get(sub); ans_cnt += li.size(); } } else { break; } } System.out.println(ans_cnt); } }