I attempted this sample question from the Australia Infomatics Competition. TL;DR - Each line of input contains two numbers, representing a pair of knights that will fight and thus cannot be invited to the same meeting. The output needs to be the number representing maximum number of knights that could be invited to a meeting. Exact Words:InputYour program should read from the file arthin.txt.The first line of input will contain N, the number of knights.  The second line of input will contain P, the number of pairs of duel-prone knights.Each of the following P lines will contain two space-separated integers a and b, representing two knights who cannot be invited to the same meeting. It is guaranteed that a b and that the same pair will not appear twice in the input. Knights are labelled from 1 to N.OutputYour program should write to the file arthout.txt. It should output a single integer: the maximum number of knights that can be invited to the first meeting without any chance of a duel occurring at either the first or second meeting. Here is my current code (in python 2.6.6 as per the comp's requirements):list_id = {}with open(arthin.txt,r) as Input:    for i,line in enumerate(Input):        if i > 2:            a,b = [int(each) for each in line.split()]            #if list_id[a] != None and list_id[b] != None:            if list_id[a] == True:                list_id[b] = False            elif list_id[a] == False:                list_id[b] = True            elif list_id[b] == True:                list_id[a] = False            elif list_id[b] == False:                list_id[a] = True            else:                list_id[a] = True                list_id[b] = False        elif i == 2:            a,b = sorted([int(each) for each in line.split()])            list_id[a] = True            list_id[b] = False        elif i == 0:            Knight_no = int(line)            #list_id #True = 1st meeting, false = second meeting            for x in xrange(1,Knight_no+1):                list_id[x] = Nonefirst_meeting = set(k for k,v in list_id.items() if v == True)second_meeting = set(k for k,v in list_id.items() if v == False)pascifist_knights = set(k for k,v in list_id.items() if v == None)longest_set = max(len(first_meeting),len(second_meeting))if len(first_meeting) == longest_set:    first_meeting = first_meeting.union(pascifist_knights)    fileOutput = open(arthout.txt, w)    fileOutput.write(str(len(first_meeting)))    fileOutput.close()else:    second_meeting = second_meeting.union(pascifist_knights)    #print second_meeting    fileOutput = open(arthout.txt, w)    fileOutput.write(str(len(second_meeting)))    fileOutput.close()The code seems to be mostly broken - it works for the sample input and some cases I made up, but I think that there are still many flaws in the method. I would be really appreciative if someone could point me in the right direction to get more cases right. 
AIO Programming Challenge 2012- King Arthur II - How many non-conflicting people can we fit?
programming challenge