input: Write a function to count the most common words in a list of tweets and plot the top N most used words.
  assert count_and_plot_words(["hello world", "hello everyone"], 2) == {'hello': 2, 'world': 1, 'everyone': 1}
  assert count_and_plot_words(["test this code", "this is a test", "test again"], 3) == {'test': 3, 'this': 2, 'code': 1}
output: def count_and_plot_words(tweets, top_n):
      from collections import Counter
      import matplotlib.pyplot as plt
  
      # Combine all tweets into a single list of words
      all_words = ' '.join(tweets).split()
  
      # Count the frequency of each word
      word_count = Counter(all_words)
  
      # Get the most common words
      common_words = dict(word_count.most_common(top_n))
  
      # Plotting the most common words
      plt.bar(common_words.keys(), common_words.values())
      plt.xlabel('Words')
      plt.ylabel('Frequency')
      plt.title('Top {} Most Common Words'.format(top_n))
      plt.show()
  
      return common_words