Problem:
Joisino is planning to open a shop in a shopping street.  Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods.  There are already N stores in the street, numbered 1 through N.  You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2.  Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}.  Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.

Incorrect submission (verdict: Wrong Answer):

import copy

shop_num = int(input().rstrip())

# business hour
shop_data = {}
for i in range(shop_num):
	shop_data[i] = input().rstrip().split(' ')


shop_benefit = {}
for i in range(shop_num):
	shop_benefit[i] = input().rstrip().split(' ')

patterns = [0, 1, 2];

targets = []
for pattern1 in patterns:
	list1 = []
	if pattern1 == 1:
		list1.append(0)
	elif pattern1 == 2:
		list1.append(1)
	else:
		list1.append(0)
		list1.append(1)

	for pattern2 in patterns:
		list2 = copy.deepcopy(list1)
		if pattern2 == 1:
			list2.append(2)
		elif pattern2 == 2:
			list2.append(3)
		else:
			list2.append(2)
			list2.append(3)
		for pattern3 in patterns:
			list3 = copy.deepcopy(list2)
			if pattern3 == 1:
				list3.append(4)
			elif pattern3 == 2:
				list3.append(5)
			else:
				list3.append(4)
				list3.append(5)
			for pattern4 in patterns:
				list4 = copy.deepcopy(list3)
				if pattern4 == 1:
					list4.append(6)
				elif pattern4 == 2:
					list4.append(7)
				else:
					list4.append(6)
					list4.append(7)
				for pattern5 in patterns:
					list5 = copy.deepcopy(list4)
					if pattern5 == 1:
						list5.append(8)
					elif pattern5 == 2:
						list5.append(9)
					else:
						list5.append(8)
						list5.append(9)

					targets.append(copy.deepcopy(list5))

ben_list = []
for target in targets:
	ben = 0
	for key in shop_data:
		count = 0
		for time in range(10):
			data = int(shop_data[key][time])
			if time in target:
				if data == 1:
					count += 1
			else:
				if data == 0:
					count += 1

		ben += int(shop_benefit[key][count])

	ben_list.append(ben)

print(ben_list)
print(max(ben_list))

Fixed, accepted submission:

import copy

shop_num = int(input().rstrip())

# business hour
shop_data = {}
for i in range(shop_num):
	shop_data[i] = input().rstrip().split(' ')


shop_benefit = {}
for i in range(shop_num):
	shop_benefit[i] = input().rstrip().split(' ')

patterns = [0, 1, 2, 3];

targets = []
for pattern1 in patterns:
	list1 = []
	if pattern1 == 1:
		list1.append(0)
	elif pattern1 == 2:
		list1.append(1)
	elif pattern1 == 3:
		list1.append(0)
		list1.append(1)

	for pattern2 in patterns:
		list2 = copy.deepcopy(list1)
		if pattern2 == 1:
			list2.append(2)
		elif pattern2 == 2:
			list2.append(3)
		elif pattern2 == 3:
			list2.append(2)
			list2.append(3)
		for pattern3 in patterns:
			list3 = copy.deepcopy(list2)
			if pattern3 == 1:
				list3.append(4)
			elif pattern3 == 2:
				list3.append(5)
			elif pattern3 == 3:
				list3.append(4)
				list3.append(5)
			for pattern4 in patterns:
				list4 = copy.deepcopy(list3)
				if pattern4 == 1:
					list4.append(6)
				elif pattern4 == 2:
					list4.append(7)
				elif pattern4 == 3:
					list4.append(6)
					list4.append(7)
				for pattern5 in patterns:
					list5 = copy.deepcopy(list4)
					if pattern5 == 1:
						list5.append(8)
					elif pattern5 == 2:
						list5.append(9)
					elif pattern5 == 3:
						list5.append(8)
						list5.append(9)

					targets.append(copy.deepcopy(list5))

ben_list = []
for target in targets:
	if (len(target) <= 0):
		continue;
	ben = 0
	for key in shop_data:
		count = 0
		for time in range(10):
			data = int(shop_data[key][time])
			if time in target:
				if data == 1:
					count += 1

		ben += int(shop_benefit[key][count])

	ben_list.append(ben)

print(max(ben_list))