import re
# 读取输入的行,每行都是一串数字
lines = []
while True:
line = input().strip()
if not line:
break
lines.append(line)
# 第一行
first_line = lines[0]
# 以3结尾的偶数个数字
pattern = r'(\d+[03])( \d+[03])*'
match = re.match(pattern, first_line)
if not match:
print('没有符合条件的数字')
else:
# 计算数字总和
total = sum(map(int, match.group().split()))
print(total)
这个程序用正则表达式匹配第一行中符合条件的数字,然后将它们的总和输出。