# Help me out with this!

#Written for python3.6
#My attempt against UCL problem titled UEFA league
#Code is working fine on PC IDE but showing incorrect answer when submitted

t=int(input())
for i in range(t):
team=[]
pts=[]
score_diff=[]
for j in range(12):
result=input()
result_list=list(result.split(’ '))
if result_list[0] not in team:
team.append(result_list[0])
pts.append(0)
score_diff.append(0)
if result_list[4] not in team:
team.append(result_list[4])
pts.append(0)
score_diff.append(0)

``````    N=len(team)

for k in range(N):
if result_list[0]==team[k]:
if int(result_list[1]) > int(result_list[3]):
pts[k] +=3
if int(result_list[1]) == int(result_list[3]):
pts[k] +=1
score_diff[k] += int(result_list[1]) - int(result_list[3])
elif result_list[4]==team[k]:
if int(result_list[1]) < int(result_list[3]):
pts[k] +=3
if int(result_list[1]) == int(result_list[3]):
pts[k] +=1
score_diff[k] += int(result_list[3]) - int(result_list[1])

i_top1=0
i_top2=N-1
for m in range(1,N):
if pts[m] > pts[i_top1]:
i_top2=i_top1
i_top1=m
elif pts[m]>pts[i_top2]:
i_top2=m
elif pts[m]==pts[i_top1]:
if score_diff[m]>score_diff[i_top1]:
i_top2=i_top1
i_top1=m
elif score_diff[m]>score_diff[i_top2]:
i_top2=m

print(team[i_top1],team[i_top2])``````

Because there’s something called undefined behaviour, and there’s another thing called code being wrong but produce correct answer for sample test case.