public void solve() throws IOException {
    String[] input = nextLine().split(" ");
    int[] arr = new int[input.length];
    for (int i = 0; i < input.length; i++) {
      arr[i] = Integer.parseInt(input[i]);
    }
    
    boolean swapped = true;
    int count = 0;
    while (swapped) {
      swapped = false;
      for (int i = 1; i < input.length; i++) {
        if (arr[i] < arr[i - 1]) {
          int temp = arr[i];
          arr[i] = arr[i - 1];
          arr[i - 1] = temp;
          count++;
          swapped = true;
        }
      }
    }
    System.out.println(count);
    for (int val : arr) {
      System.out.print(val + " ");
    }
  }