Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
c = 0
for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            continue
        for k in range(j + 1, n):
            if j - i == k - j:
                continue
            if s[i] == s[j] or s[i] == s[k] or s[j] == s[k]:
                continue
            c += 1
print(c)

Fixed submission:
n = int(input())
s = []
r, g, b = [0] * 3
for c in input():
    if c == 'R':
        s.append(0)
        r += 1
    elif c == 'G':
        s.append(1)
        g += 1
    else:
        s.append(2)
        b += 1

c = r * g * b
for i in range(n):
    for j in range(i + 1, n):
        k = j + (j - i)
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c -= 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
c = 0
for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            continue
        for k in range(j + 1, n):
            if s[i] == s[j] or s[i] == s[k] or s[j] == s[k]:
                continue
            if j - i == k - j:
                continue
            c += 1
print(c)

Fixed submission:
n = int(input())
s = []
r, g, b = [0] * 3
for c in input():
    if c == 'R':
        s.append(0)
        r += 1
    elif c == 'G':
        s.append(1)
        g += 1
    else:
        s.append(2)
        b += 1

c = r * g * b
for i in range(n):
    for j in range(i + 1, n):
        k = j + (j - i)
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c -= 1

print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = (int(x) for x in input().split())

c = {} 
t = 0
for x in range(k, 0, -1):
    q = k // x
    c[x] = q ** n - sum(c[x * y] for y in range(2, q + 1))
    t += c[x] * x
    t = t % 1000000007

print(t)

Fixed submission:
n, k = (int(x) for x in input().split())
c = {} 
t = 0
MOD = 1000000007
for x in range(k, 0, -1):
    q = k // x
    c[x] = pow(q, n, MOD) - sum(c[x * y] for y in range(2, q + 1))
    t += c[x] * x
    t = t % 1000000007
print(t)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = (int(x) for x in input().split())

c = {} 
t = 0
for x in range(k, 0, -1):
    c[x] = (k // x) ** n
    c[x] = c[x] - sum(c[x * y] for y in range(2, k // x + 1))
    s = c[x] * x
    t += s
    t = t % 1000000007

print(t)

Fixed submission:
n, k = (int(x) for x in input().split())
c = {} 
t = 0
MOD = 1000000007
for x in range(k, 0, -1):
    q = k // x
    c[x] = pow(q, n, MOD) - sum(c[x * y] for y in range(2, q + 1))
    t += c[x] * x
    t = t % 1000000007
print(t)
Buggy python submission (verdict: Runtime Error):
import collections
import math

N, *A = map(int, open(0).read().split())
a = dict(enumerate(A, 1))
dp = collections.defaultdict(int)
dp[1, 1] = a[1]

for i in range(2, N + 1):
    jj = range(math.floor(i // 2 - 1), math.ceil((i + 1) // 2) + 1)
    debug(jj)
    for j in jj:
        x = dp[i - 2, j - 1] + a[i]
        y = dp[i - 1, j]
        dp[i, j] = max(x, y)

print(dp[N, N // 2])

Fixed submission:
#!/usr/bin/env python3
# coding: utf-8
import collections
import math
def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        print(arg, file=sys.stderr)

N, *A = map(int, open(0).read().split())
a = dict(enumerate(A, 1))
# dp = collections.defaultdict(int)
dp = collections.defaultdict(lambda: -float("inf"))
dp[0, 0] = 0 
dp[1, 0] = 0 
dp[1, 1] = a[1]
for i in range(2, N + 1):
    jj = range(max(math.floor(i // 2 - 1), 1), math.ceil((i + 1) // 2) + 1)
    debug(jj)
    for j in jj:
        x = dp[i - 2, j - 1] + a[i]
        y = dp[i - 1, j]

        dp[i, j] = max(x, y)
        debug([i - 2, j - 1])
        debug([i - 1, j])
        debug([i, j])
        debug(dp[i, j])
print(dp[N, N // 2])
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# coding: utf-8
# import pprint
# import numpy as np
# import code
# import functools

if __debug__:
    def debug(arg):
        pass
else:
    import sys
    def debug(arg):
        debug = lambda *x: None
        print(arg, file=sys.stderr)

n, k = (int(x) for x in input().split())

d = abs(n - k)
debug(d)
if(n >= k):
    a = n % d
    debug(a)
else:
    a = n
    debug(a)
debug([a, k])
m = min(a, abs(a - k))
debug(m)
print(m)


Fixed submission:
#!/usr/bin/env python3
# coding: utf-8

def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        print(arg, file=sys.stderr)

def main():
    N, K = map(int, open(0).read().split())
    debug([N, K])
    r = N % K
    a = min(r, K - r)
    print(a)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# coding: utf-8
# import pprint
# import numpy as np
# import code
import functools

def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        debug = lambda *x: None
        print(arg, file=sys.stderr)

n, x, y = (int(x) for x in input().split())
d = dict.fromkeys(range(1, n), 0)
debug(d)
for i in range(1, n):
    for j in range(i + 1, n + 1):
        debug([i, j, x, y])
        dd1=abs(x - i) + 1 + abs(y - j)
        dd2= j - i
        d[min(dd1, dd2)] += 1
        debug(d)

for n in d.values():
    print(n)




Fixed submission:
#!/usr/bin/env python3
# coding: utf-8
# import pprint
# import numpy as np
# import code
import functools

if __debug__:
    def debug(arg):
        pass
else:
    import sys
    def debug(arg):
        debug = lambda *x: None
        print(arg, file=sys.stderr)

n, x, y = (int(x) for x in input().split())
d = dict.fromkeys(range(1, n), 0)
debug(d)
for i in range(1, n):
    for j in range(i + 1, n + 1):
        debug([i, j, x, y])
        dd1=abs(x - i) + 1 + abs(y - j)
        dd2= j - i
        if dd1 < dd2:
            d[dd1] += 1
        else:
            d[dd2] += 1
        debug(d)

for n in d.values():
    print(n)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# coding: utf-8
# import pprint
# import numpy as np
# import code
import functools

def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        debug = lambda *x: None
        print(arg, file=sys.stderr)

n, x, y = (int(x) for x in input().split())
d = dict.fromkeys(range(1, n), 0)
debug(d)
for i in range(1, n):
    for j in range(i + 1, n + 1):
        debug([i, j, x, y])
        dd1=abs(x - i) + 1 + abs(y - j)
        dd2= j - i
        d[min(dd1, dd2)] += 1
        debug(d)

for k in sorted(d.keys()):
    print(d[k])


Fixed submission:
#!/usr/bin/env python3
# coding: utf-8
# import pprint
# import numpy as np
# import code
import functools

if __debug__:
    def debug(arg):
        pass
else:
    import sys
    def debug(arg):
        debug = lambda *x: None
        print(arg, file=sys.stderr)

n, x, y = (int(x) for x in input().split())
d = dict.fromkeys(range(1, n), 0)
debug(d)
for i in range(1, n):
    for j in range(i + 1, n + 1):
        debug([i, j, x, y])
        dd1=abs(x - i) + 1 + abs(y - j)
        dd2= j - i
        if dd1 < dd2:
            d[dd1] += 1
        else:
            d[dd2] += 1
        debug(d)

for n in d.values():
    print(n)
Buggy python submission (verdict: Time Limit Exceeded):


n = 0
a = []

def format_input(filename = None):
	global n
	global a
	if filename == None:
		n = int(input())
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(2, 2 * 10**5)
		a = [rng(1, i) for i in range(1, n)]
		print(n)
		print(' '.join(list(map(str, a))))

def get_answer():
	for i in range(1, n+1):
		print(a.count(i))

if __name__ == '__main__':
	format_input()

	get_answer()


Fixed submission:


n = 0
a = []

def format_input(filename = None):
	global n
	global a
	if filename == None:
		n = int(input())
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(2, 2 * 10**5)
		a = [rng(1, i) for i in range(1, n)]
		print(n)
		print(' '.join(list(map(str, a))))

def get_answer():
	count = [0] * (n+1)
	for i in a:
		count[i] += 1
	for i in range(1, n+1):
		print(count[i])

if __name__ == '__main__':
	format_input()

	get_answer()
Buggy python submission (verdict: Time Limit Exceeded):


n = 0
a = []

def format_input(filename = None):
	global n
	global a
	if filename == None:
		n = int(input())
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(2, 2 * 10**5)
		a = [rng(-1 * 10**9, 10**9) for i in range(n)]
		print(n)
		print(' '.join(list(map(str, a))))

def get_answer():
	odd = [0]
	even = [0]
	for i in range(n // 2):
		odd.append(odd[-1] + a[2*i])
		even.append(even[-1] + a[2*i+1])
	if n % 2 == 1:
		odd.append(odd[-1] + a[-1])

	answer = -1 * 10**9 * n
	if n % 2 == 0:
		for i in range(n // 2 + 1):
			answer = max(answer, odd[i] - even[i] + even[-1])
	else:
		for i in range(n // 2 + 2):
			if i < n // 2 + 1:
				for j in range(i+1):
					answer = max(answer, odd[j] - even[j] + even[i] - odd[i+1] + odd[-1])
			else:
				for j in range(i):
					answer = max(answer, odd[j] - even[j] + even[-1])
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Fixed submission:


n = 0
a = []

def format_input(filename = None):
	global n
	global a
	if filename == None:
		n = int(input())
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(2, 2 * 10**5)
		a = [rng(-1 * 10**9, 10**9) for i in range(n)]
		print(n)
		print(' '.join(list(map(str, a))))

def get_answer():
	odd = [0]
	even = [0]
	for i in range(n // 2):
		odd.append(odd[-1] + a[2*i])
		even.append(even[-1] + a[2*i+1])
	if n % 2 == 1:
		odd.append(odd[-1] + a[-1])

	answer = -1 * 10**9 * n
	if n % 2 == 0:
		for i in range(n // 2 + 1):
			answer = max(answer, odd[i] - even[i] + even[-1])
	else:
		even_range = [even[0] - odd[1]]
		for i in range(n // 2):
			add = a[2*i+1] - a[2*i+2]
			min = - a[2*i] + add
			even_range.append(max(even_range[-1] + add, min))
		answer = odd[-1] + max(even_range)
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)
Buggy python submission (verdict: Runtime Error):


a, b, c = [0] * 3
x = []

def format_input(filename = None):
	global a, b, c
	global x
	if filename == None:
		a, b, c = list(map(int, input().split()))
		x = [list(map(int, input().split())) for i in range(n)]

	elif filename == '__random__'
		from random import randint as rng
		a = rng(1, 10**1)
		b = rng(1, 10**1)
		c = rng(1, 10**1)
		x = [[rng(1, 10**1), rng(1, 10**1)] for i in range(n)]

def get_answer(a, b, c, x):
	answer = 0
	return answer

if __name__ == '__main__':
	format_input('__random__')

	ans = get_answer(a, b, c, x)
	print(ans)


Fixed submission:


s, t= [""] * 2
a, b = [0] * 2
u = [""]

def format_input(filename = None):
	global s,t
	global a,b
	global u
	if filename == None:
		s, t = list(map(str, input().split()))
		a, b = list(map(int, input().split()))
		u = list(map(str, input().split())).pop()

def get_answer():
	answer = [a, b]
	if u == s:
		answer[0] -= 1
	else:
		answer[1] -= 1

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans[0], ans[1])

Buggy python submission (verdict: Runtime Error):


s, t= [""] * 2
a, b = [0] * 2
u = [""]

def format_input(filename = None):
	global s,t
	global a,b
	global u
	if filename == None:
		s, t = list(map(str, input().split()))
		a, b = list(map(int, input().split()))
		u = list(map(str, input().split())).pop()

def get_answer():
	answer = [a, b]
	if u == s:
		answer[0] -= 1
	else:
		answer[1] -= 1

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans[0], ans[1])


Fixed submission:


s, t= [""] * 2
a, b = [0] * 2
u = [""]

def format_input(filename = None):
	global s,t
	global a,b
	global u
	if filename == None:
		s, t = list(map(str, input().split()))
		a, b = list(map(int, input().split()))
		u = list(map(str, input().split())).pop()

def get_answer():
	answer = [a, b]
	if u == s:
		answer[0] -= 1
	else:
		answer[1] -= 1

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans[0], ans[1])
Buggy python submission (verdict: Time Limit Exceeded):


n, k= [0] * 2
p = []

def format_input(filename = None):
	global n, k
	global p
	if filename == None:
		n, k = list(map(int, input().split()))
		p = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(1, 2 * 10**5)
		k = rng(1, n)
		p = [rng(1, 10**3) for i in range(n)]

def get_answer():
	e = []
	for i in range(n - k + 1):
		e.append(sum(p[i:i+k]))
	e.sort()
	answer = float(e.pop() + k) / 2.0
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Fixed submission:


n, k= [0] * 2
p = []

def format_input(filename = None):
	global n, k
	global p
	if filename == None:
		n, k = list(map(int, input().split()))
		p = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(1, 2 * 10**5)
		k = rng(1, n)
		p = [rng(1, 10**3) for i in range(n)]

def get_answer():
	e = []
	e.append(sum(p[0:k]))
	for i in range(n - k):
		e.append(e[i]-p[i]+p[i+k])
	e.sort()
	answer = float(e.pop() + k) / 2.0
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
A_list = list(map(int, input().split()))

l = [-1] * N
loopcnt = 0
inicnt = 0
place = 1
i = 0
l[place - 1] = 0

while i <= K:
    i += 1
    next_place = A_list[place - 1]
    place = next_place
    if l[next_place - 1] != -1:
        loopcnt = i - l[next_place - 1]
        inicnt = l[next_place - 1]
        break
    else:
        l[next_place - 1] = i

last_move_cnt = (K - inicnt) % loopcnt

j = 1
while j <= last_move_cnt:
    j += 1
    next_place = A_list[place - 1]
    place = next_place
    
print(place)

Fixed submission:
N, K = list(map(int, input().split()))
A_list = list(map(int, input().split()))

l = [-1] * N
loopcnt = 0
inicnt = 0
place = 1
i = 0
l[place - 1] = 0

while i < K:
    i += 1
    next_place = A_list[place - 1]
    place = next_place
    if l[next_place - 1] != -1:
        loopcnt = i - l[next_place - 1]
        inicnt = l[next_place - 1]
        break
    else:
        l[next_place - 1] = i
if i >= K:
    print(place)

else:
    last_move_cnt = (K - inicnt) % loopcnt

    j = 1
    while j <= last_move_cnt:
        j += 1
        next_place = A_list[place - 1]
        place = next_place
    print(place)
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
H_list = list(map(int, input().split()))
road_list = []

for _ in range(M):
    road_list.append([])
for i in range(M):
    a, b = list(map(int, input().split()))
    H_a, H_b = [H_list[a - 1], H_list[b - 1]]
    if H_a <= H_b:
        road_list[a - 1].append(a)
    elif H_b <= H_a:
        road_list[b - 1].append(b)

ans = 0
for road in road_list:
    if len(road) == 0:
        ans += 1
print(ans)

Fixed submission:
N, M = list(map(int, input().split()))
H_list = list(map(int, input().split()))

road_list = []
for _ in range(N):
    road_list.append([])
    
for i in range(M):
    a, b = list(map(int, input().split()))
    
    H_a, H_b = [H_list[a - 1], H_list[b - 1]]
    
    if H_a <= H_b:
        road_list[a - 1].append(b)

    if H_b <= H_a:
        road_list[b - 1].append(a)

ans = 0
for road in road_list:
    if len(road) == 0:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))
for i in range(1, N + 1):
    print(A_list.count(i))

Fixed submission:
import collections
N = int(input())
A_list = list(map(int, input().split()))
c = collections.Counter(A_list)
for i in range(1, N + 1):
    print(c[i])
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
ans = N
x = abs(x - K * max(x // K, 1))
while ans > x:
    ans = x
    x = abs(x - K * max(x // K, 1))
print(ans)

Fixed submission:
N, K = map(int, input().split())
ans = N
x = abs(N - K * max(N // K, 1))
while ans > x:
    ans = x
    x = abs(x - K * max(x // K, 1))
print(ans)
Buggy python submission (verdict: Runtime Error):
a_list = []
for i in range(3):
    for j in list(map(int, input().split())):
        a_list.append()

N = int(input())

b_list = []
for i in range(N):
    b_list.append(int(input()))    
        
for b in b_list:
    if b in a_list:
        a_list[a_list.index(b)] = 0
# 123
# 456
# 789
# とした場合のビンゴラインごとのリスト
line_list = [
    a_list[:3],    # 123
    a_list[3:6],   # 456
    a_list[6:9],   # 789
    a_list[::3],   # 147
    a_list[1::3],  # 258
    a_list[2::3],  # 369
    a_list[::4],   # 159
    a_list[2:7:2], # 357    
]
line_sum_list = list(map(sum, line_list))
if 0 in line_sum_list:
    print('Yes')
else:
    print('No') 

Fixed submission:
a_list = []
for i in range(3):
    for j in list(map(int, input().split())):
        a_list.append(j)

N = int(input())

b_list = []
for i in range(N):
    b_list.append(int(input()))    
        
for b in b_list:
    if b in a_list:
        a_list[a_list.index(b)] = 0
# 123
# 456
# 789
# とした場合のビンゴラインごとのリスト
line_list = [
    a_list[:3],    # 123
    a_list[3:6],   # 456
    a_list[6:9],   # 789
    a_list[::3],   # 147
    a_list[1::3],  # 258
    a_list[2::3],  # 369
    a_list[::4],   # 159
    a_list[2:7:2], # 357    
]
line_sum_list = list(map(sum, line_list))
if 0 in line_sum_list:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
x, y = input().split()
x = int(x)
y = int(y)
xy_sum = x + y
point_num = 0
kimari = 10 ** 9 + 7
if (xy_sum % 3 == 0):
    point_num += ((xy_sum - 1) / 3) ** 2
    point_num += (xy_sum - 1) // 6
    count = 2 ** point_num
    print(count % kimari)
else:
    print(0)


Fixed submission:
r = int(input())
print(r ** 2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))
sorted_A_list = sorted(A_list)
sorted_A_list
for a in sorted_A_list:
    print(A_list.index(a) + 1, end=' ')


Fixed submission:
N = int(input())
A_list = list(map(int, input().split()))
index_add_A_list = []
for i, A in enumerate(A_list):
    index_add_A_list.append([i, A])
sorted_index_add_A_list = sorted(index_add_A_list, key=lambda x: x[1])
for a in sorted_index_add_A_list:
    print(a[0] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = list(map(int, input().split()))

A_list = []

for _ in range(Q):
    A_list.append(int(input()))

for n in range(1, N + 1):
    n_lost_point = Q - A_list.count(n)
    if n_lost_point < K:
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)

Fixed submission:
import collections

N, K, Q = list(map(int, input().split()))

A_list = []

for _ in range(Q):
    A_list.append(int(input()))

A_list_collections = collections.Counter(A_list)
    
for n in range(1, N + 1):
    n_lost_point = Q - A_list_collections[n]
    if n_lost_point < K:
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy

N = int(input())
A_list= []

for _ in range(N):
    A_list.append(int(input()))

for i, a in enumerate(A_list):
    temp_A_list = copy.copy(A_list)
    temp_A_list.pop(i)
    print(max(temp_A_list))

Fixed submission:
N = int(input())
A_list= []
for _ in range(N):
    A_list.append(int(input()))

sorted_A_list = sorted(A_list, reverse=True)

for a in A_list:
    if a == sorted_A_list[0]:
        ans = sorted_A_list[1]
    else:
        ans = sorted_A_list[0]
    print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
N = int(N)
M = int(M)
line_list = []
for i in range(M):
    line = input().split()
    new_list=[]
    for l in line:
        new_list.append(int(l))
    new_list.pop(0)
    line_list.append(new_list)
old_p_list = input().split()
p_list = []
for p in old_p_list:
    p_list.append(int(p))

A = []
for n in range(N):
    A.append([True,False])
pattern_list = list(itertools.product(*A))
pattern_num = 0
for pattern in pattern_list:
    ok_flug = 1
    for i, line in enumerate(line_list):
            on_num = 0
            for l in line:
                if pattern[l-1]:
                    on_num += 1
            if on_num%2 != p_list[i]:
                ok_flug = 0
    if ok_flug == 1:
        pattern_num += 1
print(pattern_num)

Fixed submission:
import itertools
N,M = input().split()
N = int(N)
M = int(M)
line_list = []
for i in range(M):
    line = input().split()
    new_list=[]
    for l in line:
        new_list.append(int(l))
    new_list.pop(0)
    line_list.append(new_list)
old_p_list = input().split()
p_list = []
for p in old_p_list:
    p_list.append(int(p))

A = []
for n in range(N):
    A.append([True,False])
pattern_list = list(itertools.product(*A))
pattern_num = 0
for pattern in pattern_list:
    ok_flug = 1
    for i, line in enumerate(line_list):
            on_num = 0
            for l in line:
                if pattern[l-1]:
                    on_num += 1
            if on_num%2 != p_list[i]:
                ok_flug = 0
    if ok_flug == 1:
        pattern_num += 1
print(pattern_num)

Buggy python submission (verdict: Runtime Error):
N = int(N)
M = int(M)
line_list = []
for i in range(M):
    line = input().split()
    new_list=[]
    for l in line:
        new_list.append(int(l))
    new_list.pop(0)
    line_list.append(new_list)
old_p_list = input().split()
p_list = []
for p in old_p_list:
    p_list.append(int(p))
#　スイッチ組み合わせ
import itertools
A = []
for n in range(N):
    A.append([True,False])
pattern_list = list(itertools.product(*A))
pattern_num = 0
for pattern in pattern_list:
    ok_flug = 1
    for i, line in enumerate(line_list):
            on_num = 0
            for l in line:
                if pattern[l-1]:
                    on_num += 1
            if on_num%2 != p_list[i]:
                ok_flug = 0
    if ok_flug == 1:
        pattern_num += 1
print(pattern_num)

Fixed submission:
import itertools
N,M = input().split()
N = int(N)
M = int(M)
line_list = []
for i in range(M):
    line = input().split()
    new_list=[]
    for l in line:
        new_list.append(int(l))
    new_list.pop(0)
    line_list.append(new_list)
old_p_list = input().split()
p_list = []
for p in old_p_list:
    p_list.append(int(p))

A = []
for n in range(N):
    A.append([True,False])
pattern_list = list(itertools.product(*A))
pattern_num = 0
for pattern in pattern_list:
    ok_flug = 1
    for i, line in enumerate(line_list):
            on_num = 0
            for l in line:
                if pattern[l-1]:
                    on_num += 1
            if on_num%2 != p_list[i]:
                ok_flug = 0
    if ok_flug == 1:
        pattern_num += 1
print(pattern_num)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = list(map(int, input().split()))

pass_num_set = {}

for i in range(M):
    L, R = list(map(int, input().split()))
    if i == 0:
        pass_num_set = set(range(L, R + 1))
    else:
        pass_num_set = pass_num_set & set(range(L, R + 1))

ans = len(pass_num_set)

print(ans)

Fixed submission:
N, M = list(map(int, input().split()))

L_list = []
R_list = []

for i in range(M):
    L, R = list(map(int, input().split()))
    L_list.append(L)
    R_list.append(R)
    
ans = max(min(R_list) - max(L_list) + 1, 0)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
List = list(map(int, input().split()))

for i in range(1,n):
  print(List.count(i))
print("0")


Fixed submission:
# -*- coding: utf-8 -*-
import collections

n = int(input())
List = list(map(int, input().split()))
c = collections.Counter(List)
for i in range(1,n):
  print(c[i])
print("0")