Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = list(map(int, input().split()))
s = [int(input()) for i in range(n[1])]
s.append(n[0]+1)
memo = [0] * 100000
def stairs(x):
    memo[0] = 1
    memo[1] = 1
    for i in range(2, x+1):
        memo[i] = memo[i-2] + memo[i-1]

salst = [s[0]-1]
for i in range(n[1]):
    sa = (s[i+1]-1) - (s[i]+1)
    salst.append(sa)
    if sa < 0:
        break
if salst[-1] < 0:
    print(0)
else:
    ans = 1
    maxnum = max(salst)
    stairs(maxnum)
    for l in salst:
        ans *= memo[l]
    print(ans%1000000007)


Fixed submission:
n = list(map(int, input().split()))
s = [int(input()) for i in range(n[1])]
s.append(n[0]+1)
memo = [0] * 100001
def stairs(x):
    memo[0] = 1
    memo[1] = 1
    for i in range(2, x+1):
        memo[i] = memo[i-2] + memo[i-1]

salst = [s[0]-1]
for i in range(n[1]):
    sa = (s[i+1]-1) - (s[i]+1)
    salst.append(sa)
    if sa < 0:
        break
if salst[-1] < 0:
    print(0)
else:
    ans = 1
    maxnum = max(salst)
    stairs(maxnum)
    for l in salst:
        ans *= memo[l]
    print(ans%1000000007)

Buggy python submission (verdict: Runtime Error):
n = list(map(int, input().split()))
s = [int(input()) for i in range(n[1])]
s.append(n[0]+1)

def stairs(x):
    if x > 2:
        return stairs(x-1) + stairs(x-2)
    elif x == 2:
        return 2
    elif x == 1 or x == 0:
        return 1

salst = [s[0]-1]
for i in range(n[1]):
    sa = (s[i+1]-1) - (s[i]+1)
    salst.append(sa)
    if sa < 0:
        break
if salst[-1] < 0:
    print(0)
else:
    ans = 1
    for k in range(len(salst)):
        ans *= stairs(salst[k])

    print(ans%1000000007)


Fixed submission:
n = list(map(int, input().split()))
s = [int(input()) for i in range(n[1])]
s.append(n[0]+1)
memo = [0] * 100001
def stairs(x):
    memo[0] = 1
    memo[1] = 1
    for i in range(2, x+1):
        memo[i] = memo[i-2] + memo[i-1]

salst = [s[0]-1]
for i in range(n[1]):
    sa = (s[i+1]-1) - (s[i]+1)
    salst.append(sa)
    if sa < 0:
        break
if salst[-1] < 0:
    print(0)
else:
    ans = 1
    maxnum = max(salst)
    stairs(maxnum)
    for l in salst:
        ans *= memo[l]
    print(ans%1000000007)

Buggy python submission (verdict: Runtime Error):
n = list(map(int, input().split()))
s = [int(input()) for i in range(n[1])]
s.append(n[0]+1)

def stairs(x):
    if x > 2:
        return stairs(x-1) + stairs(x-2)
    elif x == 2:
        return 2
    elif x == 1 or x == 0:
        return 1

sa = [s[0]-1]
for i in range(n[1]):
    sa.append((s[i+1]-1) - (s[i]+1))
ans = 1
for k in range(len(sa)):
    ans *= stairs(sa[k])

print(ans%1000000007)


Fixed submission:
n = list(map(int, input().split()))
s = [int(input()) for i in range(n[1])]
s.append(n[0]+1)
memo = [0] * 100001
def stairs(x):
    memo[0] = 1
    memo[1] = 1
    for i in range(2, x+1):
        memo[i] = memo[i-2] + memo[i-1]

salst = [s[0]-1]
for i in range(n[1]):
    sa = (s[i+1]-1) - (s[i]+1)
    salst.append(sa)
    if sa < 0:
        break
if salst[-1] < 0:
    print(0)
else:
    ans = 1
    maxnum = max(salst)
    stairs(maxnum)
    for l in salst:
        ans *= memo[l]
    print(ans%1000000007)
Buggy python submission (verdict: Runtime Error):
a = input()
x = input()
b = input()
x_list = list(x)
print(a + x_list[0] + b)



Fixed submission:
a = input()
list = a.split()
a_list = list[0]
x_list = list[1]
b_list = list[2]
print(a_list[0] + x_list[0] + b_list[0])
Buggy python submission (verdict: Runtime Error):
S= input()
days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
for i in days:
    if S==days[0]:
        print(0)
    elif S==days[i]:
        print(7-i)


Fixed submission:
S= input()
days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
for i in range(7):
    if S==days[i]:
        a=7-i
print(a)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# リストの準備
list = [SUN,MON,TUE,WED,THU,FRI,SAT]
# 文字列の入力
s = input()
# indexの検索
a = list.index(s)
# 7-indexで出力
print(7 - b)


Fixed submission:
# -*- coding: utf-8 -*-
import sys
# リストの準備
daylist = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
# 文字列の入力
s = input()
# indexの検索
if s in daylist:
    a = daylist.index(s)
    print(7 - a)
else:
    print("{} is not day of week".format(s))
Buggy python submission (verdict: Runtime Error):
n=int(input())
L=[]
for i in [1,...,9]:
    for j in [1,...,9]:
        L.append(i*j)

if n in L:
    print("Yes")
else:
    print("No")

Fixed submission:
n=int(input())
L=[]
for i in range(1,10):
    for j in range(1,10):
        L.append(i*j)

if n in L:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=[sorted(input()) for n in range(N)]
ans=0

for i in range(N):
    for j in range(1,N-i):
        if s[i]==s[i+j]:
            ans+=1

print(ans)

Fixed submission:
import sys
input=sys.stdin.readline

N=int(input())

D={}
ans=0
for i in range(N):
    s =".".join(sorted(input()))
    if s in D.keys():
        ans+=D[s]
        D[s] += 1
    else:
        D[s]=1

print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
P=[int(input()) for i in range(n)]
sumOfP=sum(P)-P/2
print(sumOfP)

Fixed submission:
n=int(input())
P=[int(input()) for i in range(n)]
sumOfP=int(sum(P)-max(P)/2)
print(sumOfP)
Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())

if (B < C or D < A):
    print("0")
else:
    print(abs(max(A,C)-min(B,D)))

Fixed submission:
N = input()
if N[0] == N[2]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
S = raw_input()

find_val = S.find('ABC')
count = 0
while find_val >= 0:
    count += 1
    list_s = list(S)
    list_s[find_val:find_val+3] = 'BCA'
    S = "".join(list_s)
    find_val = S.find('ABC')
print count


Fixed submission:
S = raw_input()

count = 0
idx = 0
a_count = 0
while idx < len(S):
    if a_count > 0:
        if S[idx: idx+2] == 'BC':
            count += a_count
            idx += 2
            continue
    if S[idx] == 'A':
        a_count += 1
    else:
        a_count = 0
    idx += 1

print count
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, raw_input().split())

count = 0
r_max = int(N / R)+1
g_max = int(N / G)+1

for r in xrange(r_max):
    rest_val = N - R*r
    for g in xrange(g_max):
        rest_val2 = rest_val - G * g
        if rest_val2 % B == 0 and rest_val2 >= 0:
            # print "r="+str(r)+",g="+str(g)+",b="+str(rest_val2/B)
            count += 1

print count

Fixed submission:
R, G, B, N = map(int, raw_input().split())

count = 0
r_max = int(N / R)+1
g_max = int(N / G)+1

for r in xrange(r_max):
    rest_val = N - R*r
    for g in xrange(g_max):
        rest_val2 = rest_val - G * g
        if rest_val2 < 0: break
        if rest_val2 % B == 0:
            # print "r="+str(r)+",g="+str(g)+",b="+str(rest_val2/B)
            count += 1

print count
Buggy python submission (verdict: Time Limit Exceeded):
S = raw_input()

value = int(S, 2)

eval = 0
length = len(S)
if length % 2 == 0: val = 1
else: val = 0
for i in xrange(length):
    if i % 2 == val:
        eval += 2 ** i

count = bin(value ^ eval).count('1')

if count <= 0.5 * length: print count
else: print (length - count)


Fixed submission:
S = raw_input()

value = int(S, 2)

eval = ''
length = len(S)
if length % 2 == 0: val = 1
else: val = 0
for i in xrange(length):
    if i % 2 == val: eval += '1'
    else: eval += '0'

count = bin(value ^ int(eval,2)).count('1')

if count <= 0.5 * length: print count
else: print (length - count)

Buggy python submission (verdict: Time Limit Exceeded):
S = raw_input()

value = int(S, 2)

zero = 0
one = 0
for i in xrange(len(S)):
    if i % 2 == 0:
        zero += 2 ** i
    else:
        one += 2 ** i

count = bin(value ^ zero).count('1')
count_1 = bin(value ^ one).count('1')

if count <= count_1: print count
else: print count_1


Fixed submission:
S = raw_input()

value = int(S, 2)

eval = ''
length = len(S)
if length % 2 == 0: val = 1
else: val = 0
for i in xrange(length):
    if i % 2 == val: eval += '1'
    else: eval += '0'

count = bin(value ^ int(eval,2)).count('1')

if count <= 0.5 * length: print count
else: print (length - count)
Buggy python submission (verdict: Time Limit Exceeded):
S = raw_input()
N = len(S)

count = 0
tmp  = 1
dst = S
while True:
    dst1 = dst.replace('01', '')
    dst2 = dst1.replace('10', '')
    if len(dst) - len(dst2) <= 0: break
    count += len(dst) - len(dst2)
    dst = dst2

print count

Fixed submission:
S = raw_input()
print(min(S.count('1'), S.count('0')) * 2)
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, raw_input().split()))
K = []

array = []
for i in xrange(M): array.append(0)
for i in xrange(N):
    inputs = list(map(int, raw_input().split()))
    K = inputs[0]
    for j in xrange(K):
        array[inputs[j+1]] += 1

count = 0
for i in xrange(M):
    if array[i] == N: count += 1

print str(count)

Fixed submission:
N, M = list(map(int, raw_input().split()))
K = []

array = []
for i in xrange(M): array.append(0)
for i in xrange(N):
    inputs = list(map(int, raw_input().split()))
    K = inputs[0]
    for j in xrange(K):
        array[inputs[j+1]-1] += 1

count = 0
for i in xrange(M):
    if array[i] == N: count += 1

print str(count)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())
A = map(int, raw_input().split())
all_cost = [-10**15, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-10**15] * (N+1)

dp[0] = 0
for i in range(1, N+1, 1):
    max_val = -10**15
    for a in A:
        if i - all_cost[a] >= 0 and dp[i - all_cost[a]] != -10**15:
            val = dp[i - all_cost[a]] + 1
            if val > max_val: max_val = val
    dp[i] = max_val

A.sort(reverse=True)

result = ''
idx = N
while idx > 0:
    for a in A:
        if dp[idx - all_cost[a]] == dp[idx] - 1:
            result += str(a)
            idx -= all_cost[a]
            break

print result

Fixed submission:
N, M = map(int, raw_input().split())
A = map(int, raw_input().split())
all_cost = [-10**15, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-10**15] * (N+1)

dp[0] = 0
for i in range(1, N+1, 1):
    max_val = -10**15
    for a in A:
        if i - all_cost[a] >= 0 and dp[i - all_cost[a]] != -10**15:
            val = dp[i - all_cost[a]] + 1
            if val > max_val: max_val = val
    dp[i] = max_val

A.sort(reverse=True)

result = ''
idx = N
while idx > 0:
    for a in A:
        if idx - all_cost[a] < 0: continue
        if dp[idx - all_cost[a]] == dp[idx] - 1:
            result += str(a)
            idx -= all_cost[a]
            break

print result
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
mli = sorted(list(map(int,input().split())), reverse = False)
hp_min = mli[0]
index = 1
for i in range(1,N):
  if mli[index] % hp_min == 0:
    mli.pop(index)
  else:
    mli[index] = mli[index] % hp_min
    hp_min = mli[index]
    index += 1
    
#if mli[i] % hp_min != 0:
  #hp_min = mli[i] % hp_min 
print(hp_min)

Fixed submission:
A,B = map(int, input().split())
if B % A == 0:
  print(A+B)
else:
  print(B-A)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
w = ""
for x in S:
    if abc.index(x) + 1 + N > 26:
        w += abc[abc.index(x) + N - 26]
    else:
        w += abc[abc.index(x) + N]
print(w)

Fixed submission:
s = input()
 
weeks = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(7 - weeks.index(s))
Buggy python submission (verdict: Runtime Error):
class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y    

w, h, x, y = map(int, input().split(' '))

square_area = w * h

px = w / 2  # 3
py = h / 2  # 3.5

multiple_ans = 0
if px == x and py == y:
    multiple_ans = 1

a = py - y / px - x
b = y - x * a

cross_point = []

cross_x = (h - b) / a  # 一番上
if not 0 <= cross_x <= w:
    cross_point.append(Point(cross_x, h))
cross_x = (b / a) * -1  # 一番下
if not 0 <= cross_x <= w:
    cross_point.append(Point(cross_x, 0))
cross_y = b
if not 0 <= cross_y <= h:
    cross_point.append(Point(0, cross_y))
cross_y = w * a + b
if not 0 <= cross_y <= h:
    cross_point.append(Point(w, cross_y))

cross_1 = cross_point[0]
cross_2 = cross_point[1]

if cross_1.y == 0 and cross_2.x == w:
    area_a = ((h - cross_2.y) * cross_1.x) / 2
    area_b = square_area - area_a
elif cross_2.x == w and cross_1.y == 0:
    area_a = ((w - cross_2.x) * cross_1.y) / 2
    area_b = square_area - area_a
elif cross_2.x == w and cross_1.y == h:
    area_a = (w - cross_1.x) * (h - cross_2.y) / 2
    area_b = square_area - area_a
elif cross_2.x == w and cross_1.y == 0:
    area_a = (cross_1.x * cross_2.x) / 2
    area_b = square_area - area_a
else:
    area_a = (cross_1.y * cross_2.y) / 2
    area_b = square_area - area_a

print('{max_area} {multiple_ans}'.format(max_area=str(min(area_a, area_b)), multiple_ans=str(multiple_ans)))


Fixed submission:
w, h, x, y = map(int, input().split(' '))

max_area = 0
square_area = w * h
multiple_ans = 1 if 2 * x == w and 2 * y == h else 0

print('{max_area} {multiple_ans}'.format(max_area=str(square_area / 2), multiple_ans=str(multiple_ans)))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))
a = []
for i in range(m):
    a.append(int(input()))


s = [0] * (n + 1)
s[0] = 1
for i in range(n):
    j = i + 1
    while(j <= min(n, i + 2)):
        if j not in a:
            s[j] += s[i]
            s[j] = int(s[j] % 1000000007)
        j += 1

print(s[n])


Fixed submission:
n, m = map(int, input().split(' '))
a = set()
for i in range(m):
    a.add(int(input()))


s = [0] * (n + 1)
s[0] = 1
for i in range(n):
    j = i + 1
    while(j <= min(n, i + 2)):
        if j not in a:
            s[j] += s[i]
            s[j] = int(s[j] % 1000000007)
        j += 1

print(s[n])

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split(' '))
a = []
for i in range(m):
    a.append(int(input()))

def t(current, n):
    if current == n:
        return 1
    if current in a:
        return 0
    p1, p2 = 0, 0
    if current + 1 not in a:
        p1 = t(current + 1, n)
    if current + 2 <= n and current + 2 not in a:
        p2 = t(current + 2, n)
    return p1 + p2

result = 1
a.append(n - 1)
for index in range(len(a)):
    if index == 0:
        a1 = 0
    else:
        a1 = a[index - 1] + 1
    a2 = a[index] + 1
    p_step1 = t(a1 + 1,  a2)
    p_step2 = t(a1 + 2,  a2)
    result = (result * (p_step1 + p_step2)) % 1000000007
 
print(result)


Fixed submission:
n, m = map(int, input().split(' '))
a = set()
for i in range(m):
    a.add(int(input()))


s = [0] * (n + 1)
s[0] = 1
for i in range(n):
    j = i + 1
    while(j <= min(n, i + 2)):
        if j not in a:
            s[j] += s[i]
            s[j] = int(s[j] % 1000000007)
        j += 1

print(s[n])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(lambda x: int(x), input().split(' '))
l = []
r = []
for i in range(m):
    l_tmp, r_tmp = map(lambda x: int(x), input().split(' '))
    l.append(l_tmp)
    r.append(r_tmp)

result = 0
card_id = l[0]
for j in range(n):
    for locked_l, locked_r in zip(l, r):
        if not (locked_l <= card_id + j <= locked_r):
            break
    else:   
        result += 1

print(result)


Fixed submission:
n, m = map(lambda x: int(x), input().split(' '))
l = []
r = []
for i in range(m):
    l_tmp, r_tmp = map(lambda x: int(x), input().split(' '))
    l.append(l_tmp)
    r.append(r_tmp)

l_max = max(l)
r_min = min(r)

result = 0
if l_max <= r_min:
    result = r_min - l_max + 1
print(result)
Buggy python submission (verdict: Runtime Error):
argv = sys.argv
a = int(input())


b = int(input())

t = int(input()) + 0.5 - a

r = 0

while t > 0:
    r += b
    t -= a

print(r)


Fixed submission:
args = input()
args = args.split(' ')

a = int(args[0])
b = int(args[1])
t = int(args[2]) + 0.5 - a

r = 0

while t > 0:
    r += b
    t -= a

print(r)

Buggy python submission (verdict: Runtime Error):
import sys

argv = sys.argv
a = int(argv[1])
b = int(argv[2])
t = int(argv[3]) + 0.5 - a

r = 0

while t > 0:
    r += b
    t -= a

print(r)


Fixed submission:
args = input()
args = args.split(' ')

a = int(args[0])
b = int(args[1])
t = int(args[2]) + 0.5 - a

r = 0

while t > 0:
    r += b
    t -= a

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(lambda x: int(x), input().split(' '))
a = list(map(lambda x: int(x), input().split(' ')))

num_dups = []
a_set = set(a)
for elem in a_set:
    num_dups.append(a.count(elem))

num_dups.sort(reverse=True)

ball_to_replace = len(a_set) - k

result = 0
for i in range(ball_to_replace):
    result += num_dups.pop()

print(result)


Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A1 = set(A)
AN = {}
for a in A:
    if not a in AN:
        AN[a] = 0
    AN[a] += 1
AN = sorted(AN.items(), key=lambda x: x[1])
ans = 0
K1 = len(A1) - K
if K1 > 0:
    for k in range(K1):
        ans += AN[k][1]
    print(ans)
else:
    print('0')
Buggy python submission (verdict: Runtime Error):
s = input()

idx_a = None
idx_b = 0

for idx, char in enumerate(s):
    if char =='A' and idx_a:
        idx_a = idx
    if char == 'Z':
        idx_b = idx

print(idx_b - idx_a + 1)


Fixed submission:
s = input()

idx_a = None
idx_b = 0

for idx, char in enumerate(s):
    if char =='A' and idx_a is None:
        idx_a = idx
    if char == 'Z':
        idx_b = idx

print(idx_b - idx_a + 1)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(lambda x: int(x), input().split(' '))

r = 0
for a in range(k + 1):
    if a > s:
        break
    for b in range(k + 1):
        if a + b > s:
            break
        for c in range(k + 1):
            if a + b + c == s:
                r += 1
                break
            if a + b + c > s:
                break
print(r)


Fixed submission:
k, s = map(lambda x: int(x), input().split(' '))
r = 0
for a in range(k + 1):
    if a > s:
        break
    for b in range(k + 1):
        if a + b > s:
            break
        elif s - (a + b) < k + 1:
            r += 1
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(lambda x: int(x), input().split(' '))

r = 0
for a in range(k + 1):
    for b in range(k + 1):
        for c in range(k + 1):
            if a + b + c == s:
                r += 1

print(r)


Fixed submission:
k, s = map(lambda x: int(x), input().split(' '))
r = 0
for a in range(k + 1):
    if a > s:
        break
    for b in range(k + 1):
        if a + b > s:
            break
        elif s - (a + b) < k + 1:
            r += 1
print(r)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
w = ""
for x in S:
    if abc.index(x) + N > 26:
        w += abc[abc.index(x) + N - 26]
    else:
        w += abc[abc.index(x) + N]
print(w)

Fixed submission:
N = int(input())
S = input()
abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
w = ""
for x in S:
    if abc.index(x) + 1 + N > 26:
        w += abc[abc.index(x) + N - 26]
    else:
        w += abc[abc.index(x) + N]
print(w)
Buggy python submission (verdict: Runtime Error):
print(int(input)()**2)

Fixed submission:
print(int(input())**2)
Buggy python submission (verdict: Time Limit Exceeded):
n=list(map(int,input().split()))
men=list([n[1]]*n[0])
for i in range(n[2]):
    men=[j-1 for j in men]
    men[int(input())-1]+=1
y = ["Yes" if i > 0 else "No" for i in men]
print('\n'.join(map(str, y)))

Fixed submission:
n=list(map(int,input().split()))
men=list([n[1]-n[2]]*n[0])
a=[int(input())-1 for i in range(n[2])]
for i in a:
    men[i]+=1
y = ["Yes" if i > 0 else "No" for i in men]
print('\n'.join(map(str, y)))

Buggy python submission (verdict: Time Limit Exceeded):
n=list(map(int,input().split()))
a=[int(input()) for i in range(n[2])]
men=list([n[1]]*n[0])
for i in a:
    men=[j-1 for j in men]
    men[i-1]+=1
for i in men:
    if i > 0:
        print("Yes")
    else:
        print("No")


Fixed submission:
n=list(map(int,input().split()))
men=list([n[1]-n[2]]*n[0])
a=[int(input())-1 for i in range(n[2])]
for i in a:
    men[i]+=1
y = ["Yes" if i > 0 else "No" for i in men]
print('\n'.join(map(str, y)))
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=[i for i in range(a)]
c=int(sum(b))
print(c)

Fixed submission:
n=list(input())
s=list(input())
g=0
for i in range(3):
    if n[i]==s[i]:
        g+=1

print(g)
Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
b=[i for i in range(a)]
c=int(sum(b))
print(c)

Fixed submission:
a=int(input())
b=int(a*(a-1)//2)
print(b)

Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
b=0
for i in range(a):
    b+=i

print(b)

Fixed submission:
a=int(input())
b=int(a*(a-1)//2)
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
s = [''.join(sorted(input())) for i in range(n)]
a=set(s)
c=0

for i in a:
    b=s.count(i)
    if b>1:
        c+=(b*(b-1))//2
print(c)

Fixed submission:
n=int(input())
s = [''.join(sorted(input())) for i in range(n)]
s.sort()
s.append("a")
b=1
c=0
for i in range(n):
    if s[i]!=s[i+1]:
        c+=(b*(b-1))//2
        b=1
    else:
        b+=1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
s = [''.join(sorted(input())) for i in range(n)]
a=set(s)
c=0

for i in a:
    if s.count(i)>1:
        c+=(s.count(i)*(s.count(i)-1))//2
print(c)

Fixed submission:
n=int(input())
s = [''.join(sorted(input())) for i in range(n)]
s.sort()
s.append("a")
b=1
c=0
for i in range(n):
    if s[i]!=s[i+1]:
        c+=(b*(b-1))//2
        b=1
    else:
        b+=1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
s = [''.join(sorted(input())) for i in range(n)]
a=set(s)
c=0

for i in a:
    if s.count(i)>1:
        c+=(s.count(i)*(s.count(i)-1))//2
print(c)

Fixed submission:
n=int(input())
s = [''.join(sorted(input())) for i in range(n)]
s.sort()
s.append("a")
b=1
c=0
for i in range(n):
    if s[i]!=s[i+1]:
        c+=(b*(b-1))//2
        b=1
    else:
        b+=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
g = list([i%2019 for i in range(l,r+1)])
if r - l >= 2019:
    print(0)
    exit()
m=[]
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        m.append(g[i]*g[j]%2019)
print(min(m))

Fixed submission:
l,r=map(int,input().split())
if r - l >= 2019:
    print(0)
    exit()
g = list([i%2019 for i in range(l,r+1)])
m=[]
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        m.append(g[i]*g[j]%2019)
print(min(m))

Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
g = list([i%2019 for i in range(l,r+1)])
m=[]
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        m.append(g[i]*g[j]%2019)
        if g[i]*g[j]%2019 == 0:
            print(0)
            exit()
print(min(m))

Fixed submission:
l,r=map(int,input().split())
if r - l >= 2019:
    print(0)
    exit()
g = list([i%2019 for i in range(l,r+1)])
m=[]
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        m.append(g[i]*g[j]%2019)
print(min(m))

Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
g = list([i%2019 for i in range(l,r+1)])
m=[]
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        m.append(g[i]*g[j]%2019)
print(min(m))

Fixed submission:
l,r=map(int,input().split())
if r - l >= 2019:
    print(0)
    exit()
g = list([i%2019 for i in range(l,r+1)])
m=[]
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        m.append(g[i]*g[j]%2019)
print(min(m))

Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
g = list([i%2019 for i in range(l,r+1)])
min=2020
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        if(min>g[i]*g[j]%2019):
            min=g[i]*g[j]%2019
print(min)

Fixed submission:
l,r=map(int,input().split())
if r - l >= 2019:
    print(0)
    exit()
g = list([i%2019 for i in range(l,r+1)])
m=[]
for i in range(len(g)-1):
    for j in range(i+1,len(g)):
        m.append(g[i]*g[j]%2019)
print(min(m))