def match_countries(df_to_match, olympics):
    """Changes the names of the countries in the df_to_match df so that they match
    the names of the countries in the olympics df.

    Parameters
    -----------
    df_to_match : either of the two dataframes:
                  - gdp
                  - pop
    olympics    : the olympics dataframe

    Returns
    -----------
    df_to_match      : the dataframe given as first parameter that now its countries
                       match the countries in the olympics df
    common_countries : a list with the common countries in the two dataframes
    """

    # countries in the to_match df
    df_countries = set(df_to_match.columns.tolist())
    # countries in the olympics df
    ol_regions = set(sorted(olympics.region.unique().tolist()))

    # countries in the to_match df that are not in the olympics df
    not_in_ol = df_countries.difference(ol_regions)
    # countries in the olympics df that are not in the to_match df
    not_in_df = ol_regions.difference(df_countries)

    # After printing not_in_il and not_int_df, we see that some countries are simply named differently
    # Therefore, I renames these countries in the to_match df so that they match the countries from the olympics df
    df_to_match.rename(columns={"United States": "USA",
                                "United Kingdom": "UK",
                                "Antigua and Barbuda": "Antigua",
                                "Congo, Dem. Rep.": "Democratic Republic of the Congo",
                                "Lao": "Laos",
                                "North Macedonia": "Macedonia",
                                "Cote d'Ivoire": "Ivory Coast",
                                "Trinidad and Tobago": "Trinidad",
                                "Micronesia, Fed. Sts.": "Micronesia",
                                "St. Vincent and the Grenadines": "Saint Vincent",
                                "St. Lucia": "Saint Lucia",
                                "St. Kitts and Nevis": "Saint Kitts",
                                "Slovak Republic": "Slovakia",
                                "Kyrgyz Republic": "Kyrgyzstan",
                                "Bolivia": "Boliva",
                                "Congo, Rep.": "Republic of Congo"},
                       inplace=True)

    # Check which countries still remain unmatched
    df_countries = set(df_to_match.columns.tolist())
    ol_regions = set(sorted(olympics.region.unique().tolist()))

    # Countries in the to_match df that are still not in the olympics df
    not_in_ol = df_countries.difference(ol_regions)
    # Countries in the olympics df that are still not in the to_match df
    not_in_df = ol_regions.difference(df_countries)

    # Printing not_in_ol and not_in_df shows which countries are still not matched. Used as a check.

    # save the resulting common countries
    common_countries = ol_regions.intersection(df_countries)

    return df_to_match, common_countries