from collections import Counter
def calculate_similarity_score(input_data):
# Parse the input into two lists
left_list = []
right_list = []
for line in input_data.strip().split("\n"):
left, right = map(int, line.split())
left_list.append(left)
right_list.append(right)
# Count occurrences in the right list
right_counts = Counter(right_list)
# Calculate the similarity score
similarity_score = 0
for number in left_list:
similarity_score += number * right_counts.get(number, 0)
return similarity_score
# Example Input
input_data = """
3 4
4 3
2 5
1 3
3 9
3 3
"""
# Calculate and print the result
result = calculate_similarity_score(input_data)
print("Similarity Score:", result)# your code goes here
ZnJvbSBjb2xsZWN0aW9ucyBpbXBvcnQgQ291bnRlcgoKZGVmIGNhbGN1bGF0ZV9zaW1pbGFyaXR5X3Njb3JlKGlucHV0X2RhdGEpOgogICAgIyBQYXJzZSB0aGUgaW5wdXQgaW50byB0d28gbGlzdHMKICAgIGxlZnRfbGlzdCA9IFtdCiAgICByaWdodF9saXN0ID0gW10KICAgIAogICAgZm9yIGxpbmUgaW4gaW5wdXRfZGF0YS5zdHJpcCgpLnNwbGl0KCJcbiIpOgogICAgICAgIGxlZnQsIHJpZ2h0ID0gbWFwKGludCwgbGluZS5zcGxpdCgpKQogICAgICAgIGxlZnRfbGlzdC5hcHBlbmQobGVmdCkKICAgICAgICByaWdodF9saXN0LmFwcGVuZChyaWdodCkKICAgIAogICAgIyBDb3VudCBvY2N1cnJlbmNlcyBpbiB0aGUgcmlnaHQgbGlzdAogICAgcmlnaHRfY291bnRzID0gQ291bnRlcihyaWdodF9saXN0KQogICAgCiAgICAjIENhbGN1bGF0ZSB0aGUgc2ltaWxhcml0eSBzY29yZQogICAgc2ltaWxhcml0eV9zY29yZSA9IDAKICAgIGZvciBudW1iZXIgaW4gbGVmdF9saXN0OgogICAgICAgIHNpbWlsYXJpdHlfc2NvcmUgKz0gbnVtYmVyICogcmlnaHRfY291bnRzLmdldChudW1iZXIsIDApCiAgICAKICAgIHJldHVybiBzaW1pbGFyaXR5X3Njb3JlCgoKIyBFeGFtcGxlIElucHV0CmlucHV0X2RhdGEgPSAiIiIKMyAgIDQKNCAgIDMKMiAgIDUKMSAgIDMKMyAgIDkKMyAgIDMKIiIiCgojIENhbGN1bGF0ZSBhbmQgcHJpbnQgdGhlIHJlc3VsdApyZXN1bHQgPSBjYWxjdWxhdGVfc2ltaWxhcml0eV9zY29yZShpbnB1dF9kYXRhKQpwcmludCgiU2ltaWxhcml0eSBTY29yZToiLCByZXN1bHQpIyB5b3VyIGNvZGUgZ29lcyBoZXJl