문제 링크
문제 풀이
내 코드
from sys import stdin
from collections import defaultdict
def subtotal(lst, select):
global answer
for i in lst[0]:
for j in lst[1]:
if select == "ab":
subtotal_a_b[i + j] += 1
else:
answer += subtotal_a_b[0 - (i + j)]
if __name__ == "__main__":
answer = 0
subtotal_a_b = defaultdict(int)
n = int(stdin.readline())
nums = [list(map(int, stdin.readline().split())) for _ in range(n)]
nums = list(map(list, zip(*nums)))
subtotal(nums[:2], "ab")
subtotal(nums[2:], "cd")
print(answer)