Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0 or (2*X-Y)<0:
    print(0)
    sys.exit()

A = int((2*X-Y)/3)
B = int(Y-2*A)

if A>B:

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)


Fixed submission:
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0:
    print(0)
    sys.exit()

A = int((2*X-Y)/3)
B = int(X-2*A)

if A<0 or B<0:
    print(0)
    sys.exit()

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
A, B = map(int, input().split())



saidai_kouyaku = gcd(A,B)
kouyaku = [0 for _ in range(saidai_kouyaku+1)]
kouyaku[1] = 1

for i in range(2,saidai_kouyaku+1):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i

answer = 0
for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1
print(answer)

Fixed submission:
from fractions import gcd
A, B = map(int, input().split())

saidai_kouyaku = gcd(A,B)

#%%
kouyaku = [0 for _ in range(int(saidai_kouyaku**0.5)+2)]
kouyaku[1] = 1


for i in range(2,len(kouyaku)):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i

answer = 0
for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1

if saidai_kouyaku > 1:
    print(answer+1)
else:
    print(answer)

Buggy python submission (verdict: Runtime Error):
from math import gcd
A, B = map(int, input().split())
max_range = int(max(A, B)**0.5)

kouyaku = [0 for _ in range(max_range+1)]
kouyaku[1] = 1


saidai_kouyaku = gcd(A,B)
print(saidai_kouyaku)
for i in range(2,max_range):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i
sum_num = sum(kouyaku)
answer = 0

for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1
print(answer)

Fixed submission:
from fractions import gcd
A, B = map(int, input().split())

saidai_kouyaku = gcd(A,B)

#%%
kouyaku = [0 for _ in range(int(saidai_kouyaku**0.5)+2)]
kouyaku[1] = 1


for i in range(2,len(kouyaku)):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i

answer = 0
for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1

if saidai_kouyaku > 1:
    print(answer+1)
else:
    print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

dp = [[0 for _ in range(n)] for _ in range(n)]
all_patterns = dict()
max_val = 0
for i in range(n):
    for j in range(i,n):
        target = s[i:j+1]
        if target in all_patterns: 
            if len(target) > max_val:
                if i>all_patterns[target][1]:
                    max_val = len(target)
        else:
            all_patterns[target] = [i,j]

print(max_val)

Fixed submission:
n = int(input())
s = input()

def z_algorithm(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A


length = n

ans = 0
for i in range(length):
    temp = z_algorithm(s[i:])
    for j in range(len(temp)):
        if min(temp[j],j) > ans:
            ans = min(temp[j],j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

dp = [[0 for _ in range(n)] for _ in range(n)]
all_patterns = dict()
max_val = 0
for i in range(n):
    for j in range(i,n):
        target = s[i:j+1]
        if target in all_patterns and len(target) > max_val and i>all_patterns[target][1]:
            max_val = len(target)
        else:
            all_patterns[target] = [i,j]

print(max_val)

Fixed submission:
n = int(input())
s = input()

def z_algorithm(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A


length = n

ans = 0
for i in range(length):
    temp = z_algorithm(s[i:])
    for j in range(len(temp)):
        if min(temp[j],j) > ans:
            ans = min(temp[j],j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

dp = [[0 for _ in range(n)] for _ in range(n)]
all_patterns = dict()
max_val = 0
for i in range(n):
    for j in range(i,n):
        target = s[i:j+1]
        if target in all_patterns and len(target) > max_val and i>all_patterns[target][1]:
            max_val = len(target)
        else:
            all_patterns[target] = [i,j]

print(max_val)

Fixed submission:
n = int(input())
s = input()

def z_algorithm(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A


length = n

ans = 0
for i in range(length):
    temp = z_algorithm(s[i:])
    for j in range(len(temp)):
        if min(temp[j],j) > ans:
            ans = min(temp[j],j)
print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.append([100000,0])
ab = sorted(ab, key=lambda x:x[0])



max_values = [0 for _ in range(m)]
hq = []

possible_days = 0

for now in range(n+1):
    # if necessary day exceed the (now_day), extract the most valuable work
    if possible_days-2 >= len(max_values):
        break
    while possible_days <= ab[now][0]:
        if len(hq) < 1:
            pass
        else:
            max_values[possible_days-2] = -heapq.heappop(hq)
        possible_days += 1
    heapq.heappush(hq, -ab[now][1])
print(sum(max_values))

Fixed submission:
import heapq

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.append([m+1,0])
ab = sorted(ab, key=lambda x:x[0])



max_values = [0 for _ in range(m)]
hq = []

possible_days = 0

for now in range(n+1):
    # if necessary day exceed the (now_day), extract the most valuable work
    while possible_days <= ab[now][0]:
        if len(hq) < 1:
            pass
        else:
            max_values[possible_days-2] = -heapq.heappop(hq)
        possible_days += 1
    if possible_days-2 > m-1:
        break
    heapq.heappush(hq, -ab[now][1])
print(sum(max_values))

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

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.append([m+1,0])
ab = sorted(ab, key=lambda x:x[0])



max_values = [0 for _ in range(m)]
hq = []

possible_days = 0

for now in range(n+1):
    # if necessary day exceed the (now_day), extract the most valuable work
    while possible_days <= ab[now][0]:
        if len(hq) < 1:
            pass
        else:
            max_values[possible_days-2] = -heapq.heappop(hq)
        possible_days += 1
    heapq.heappush(hq, -ab[now][1])
print(sum(max_values))

Fixed submission:
import heapq

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.append([m+1,0])
ab = sorted(ab, key=lambda x:x[0])



max_values = [0 for _ in range(m)]
hq = []

possible_days = 0

for now in range(n+1):
    # if necessary day exceed the (now_day), extract the most valuable work
    while possible_days <= ab[now][0]:
        if len(hq) < 1:
            pass
        else:
            max_values[possible_days-2] = -heapq.heappop(hq)
        possible_days += 1
    if possible_days-2 > m-1:
        break
    heapq.heappush(hq, -ab[now][1])
print(sum(max_values))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
As = list(map(int, input().split()))
BCs = [list(map(int, input().split())) for _ in range(M)]

BCs = sorted(BCs,reverse = True, key = lambda x: x[1])
As = sorted(As, key = lambda x:x)

#%%
A_ind = 0

for BC in BCs:
    count = BC[0]
    value = BC[1]
    
    for i in range(count):
        if As[A_ind] < value:
            As[A_ind] = value
            A_ind += 1
            
            if A_ind >= len(As):
                break
    else:
        continue
    break

print(sum(As))

Fixed submission:
N, M = map(int, input().split())
As = list(map(int, input().split()))
BCs = [list(map(int, input().split())) for _ in range(M)]

BCs = sorted(BCs,reverse = True, key = lambda x: x[1])
As = sorted(As, key = lambda x:x)

#%%
A_ind = 0

for BC in BCs:
    count = BC[0]
    value = BC[1]
    
    for i in range(count):
        if As[A_ind] < value:
            As[A_ind] = value
            A_ind += 1
            if A_ind >= len(As):
                break
        else:
            break
        
    else:
        continue
    break

print(sum(As))
Buggy python submission (verdict: Runtime Error):

N, M = map(int, input().split())
XYZs = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

groups = [-1 for _ in range(N)]
connections = set()

now = 0
for XYZ in XYZs:
    if groups[XYZ[0]] == -1 and groups[XYZ[1]] == -1:
        now += 1
        groups[XYZ[0]] = now
        groups[XYZ[1]] = now
    elif groups[XYZ[0]] == -1:
        groups[XYZ[0]] = groups[XYZ[1]]
    elif groups[XYZ[1]] == -1:
        groups[XYZ[1]] = groups[XYZ[0]]
    elif groups[XYZ[0]] != groups[XYZ[1]]:
        if groups[XYZ[0]] > groups[XYZ[1]]:
            connections.add(str(groups[XYZ[1]])+"-"+str(groups[XYZ[0]]))
        else:
            connections.add(str(groups[XYZ[0]])+"-"+str(groups[XYZ[1]]))

print(connections)

answer = 0
for i in range(N):
    if groups[i] == -1:
        answer+=1
connections_list = []
for connection in connections:
    connections_list.append(list(map(int,connection.split("-"))))

connections_list = sorted(connections_list)
groups_set = set([i for i in range(now)])

for connection in connections_list:
    groups_set.remove(connection[0])

print(answer+len(groups_set))

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
N, M = map(int, input().split())
XYZs = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

uf = UnionFind(N)

for XYZ in XYZs:
    uf.union(XYZ[0], XYZ[1])

print(uf.group_count())
Buggy python submission (verdict: Runtime Error):


N = int(input())
a = list(map(int, input().split()))

A = (a[0:N])
A = deque(sorted(A))
B = deque(a[N:2*N])
C = a[2*N:3*N]
C = deque(sorted(C, reverse = True))

original_score = 0
for i in range(N):
    original_score += A[i] - C[i]

left = 0
right = 0

for i in range(N):
    left_candidate = B[left] - A[left]
    right_candidate = C[right] - B[-1-right]
    
    if left_candidate >= right_candidate:
        left+=1
        original_score+=left_candidate
    else:
        right+=1
        original_score+=right_candidate
print(original_score)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 18:58:46 2020

@author: naoki
"""
from heapq import heappush, heappop
import sys

N = int(input())
a = list(map(int,input().split()))

hq = []
hq_r = []
for i in range(N):
    heappush(hq,a[i])
    heappush(hq_r,-1*a[-1-i])


max_A = [0 for _ in range(N+1)]
max_A[0] = sum(hq)

min_C = [0 for _ in range(N+1)]
min_C[0] = sum(hq_r) * (-1)

for i in range(N):
    heappush(hq, a[N+i])
    heappush(hq_r, -1*a[-N-1-i])
    minus = heappop(hq)
    minus_r = heappop(hq_r)
    max_A[i+1] = max_A[i] + a[N+i] - minus
    min_C[i+1] = min_C[i] + a[-N-1-i] + minus_r
    
max_val = -10e+100
for i in range(N+1):
    kari = max_A[i] - min_C[-1-i]
    if max_val < kari:
        max_val =kari
print(max_val)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)

print('AC x ', c['AC'])
print('WA x ', c['WA'])
print('TLE x ', c['TLE'])
print('RE x ', c['RE'])

Fixed submission:
import collections

n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)

print('AC x ', c['AC'])
print('WA x ', c['WA'])
print('TLE x ', c['TLE'])
print('RE x ', c['RE'])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n, m, x = map(int, input().split())
a = []
for i in range(n):
    tmp = list(map(int, input().split()))
    a.append(tmp)
a2 = list(itertools.permutations(a))

ans = 10 ** 6
w = [0] * m
for i in a2:
    w = [0] * m
    w_ans = 0
    for j in i:
        w = [x + y for x, y in zip(w, j[1:])]
        w_ans += j[0]

        if all([i >= x for i in w]):
            ans = min(ans, w_ans)
            break

print(-1 if ans == 10**6 else ans)

Fixed submission:
n, m, x = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]

add = []
for i in range(2**n):
    skill = [0] * (m+1)
    for j in range(n):
        if (i>>j)&1:
            skill = list(map(sum, zip(skill, l[j])))
    if min(skill[1:]) >= x:
        add.append(skill)
if add:
    add.sort()
    print(add[0][0])
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 0
for i in range(n):
    c = a.count(i+1)
    del a[:c]
    print(c)

Fixed submission:
import collections

n = int(input())
a = list(map(int, input().split()))
l = collections.Counter(a)
for i in range(n):
    print(l[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(n):
    c = a.count(i+1)
    print(c)
    if c > 0:
        a.remove(i+1)

Fixed submission:
import collections

n = int(input())
a = list(map(int, input().split()))
l = collections.Counter(a)
for i in range(n):
    print(l[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
import collections

n = int(input())
a = list(map(int, input().split()))
l = collections.Counter(a)
for i in range(n):
    print(l[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
t = 0
for i1 in range(1, k+1):
    for i2 in range(1, k+1):
        for i3 in range(1, k+1):
            t+=math.gcd(math.gcd(i1, i2), i3)
print(t)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
t = 0
for i1 in range(1, k+1):
    for i2 in range(1, k+1):
        for i3 in range(1, k+1):
            t += gcd(gcd(i1, i2), i3)
print(t)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math

k = int(input())
ans = 0
t = 0
for x, y, z in itertools.product(range(1, k+1), range(1, k+1),range(1, k+1)):
    ans = math.gcd(x, y)
    ans = math.gcd(ans, z)
    t+=ans

print(t)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
t = 0
for i1 in range(1, k+1):
    for i2 in range(1, k+1):
        for i3 in range(1, k+1):
            t += gcd(gcd(i1, i2), i3)
print(t)

Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
t = 0
for i1 in range(1, k+1):
    for i2 in range(1, k+1):
        for i3 in range(1, k+1):
            ans = math.gcd(i1, i2)
            ans = math.gcd(ans, i3)
            t+=ans
print(t)


Fixed submission:
from math import gcd
k = int(input())
ans = 0
t = 0
for i1 in range(1, k+1):
    for i2 in range(1, k+1):
        for i3 in range(1, k+1):
            t += gcd(gcd(i1, i2), i3)
print(t)
Buggy python submission (verdict: Time Limit Exceeded):
k, n = map(int, input().split())
a =  list(map(int, input().split()))

minv = 9999
for i in range(len(a)):
        t = 0
        s = i
        e = s + 1
        for j in range(len(a) - 1):
                if s >= len(a):
                        s = len(a) - s
                if e >= len(a):
                        e = len(a) - e
                if s > e:
                        t = t + abs((k - a[s]) + a[e])
                else:
                        t = t + abs(a[e] - a[s])

                s = s + 1
                e = e + 1
        if minv > t:
                minv = t
print(minv)

Fixed submission:
k, n = map(int, input().split())
a = list(map(int, input().split()))
ma = min(a)
a = [x - ma for x in a]
a.append(k)
md = 0
for i in range(len(a) - 1):
    if md < (a[i+1] - a[i]):
        md = a[i+1] - a[i]
print(k - md)
Buggy python submission (verdict: Runtime Error):
l=[]
for i in range(3):
    l.append(list(map(int, input().split())))
n = int(input())
for i in range(n):
    m = int(input())

    for j in range(3):
        for k in range(3):
            if l[j][k] == m:
                l[j][k] = -1
o=0
p=0
for j in range(3):
    for k in range(3):
        o+=l[j][k]
        p+=l[k][j]
    if o==-3 or p==-3:
        print('Yes')
        exit()
    o=0
    p=0
if l[0][0]+l[1][1]+l[2][2]==-3 or l[0][2]+l[1][1]+l[2][0]==-3:
    print('Yes')
else:
    print('No')

Fixed submission:
q, mod = divmod(int(input()), 2)
if mod == 1:
  q+=1
print(q)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
ls = []
for i in range(n):
    s = input()
    ls.append(s)
c = collections.Counter(ls)
ls2 = [i for i in c if c[i] == max(c.values())]
for l in sorted(ls2):
    print(l)

Fixed submission:
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if not s in dic.keys():
        dic[s]=1
    else:
        dic[s]+=1
maxv = max(dic.values())
ls = [i for i in dic if dic[i] == maxv]
for key in sorted(ls):
    print(key)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dic = {}
for i in range(n):
        s = input()
        if s in dic     :
                dic[s]+=1
        else:
                dic[s]=1
ls = [i for i in dic if dic[i] == max(dic.values())]
for key in sorted(ls):
        print(key)

Fixed submission:
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if not s in dic.keys():
        dic[s]=1
    else:
        dic[s]+=1
maxv = max(dic.values())
ls = [i for i in dic if dic[i] == maxv]
for key in sorted(ls):
    print(key)
Buggy python submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
b = len(list(map(int, input().split())))
s = set(a)
if len(a) == len(s):
    print('YES')
else:
    print('NO')

Fixed submission:
n = input()
a = list(map(int, input().split()))
s = set(a)
if len(a) == len(s):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

for i in range(k):
    h.pop(h.index(max(h)))
    if len(h) == 0:
        break
print(sum(h))

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
if len(h) > k:
    print(sum(h[:n - k]))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))
Buggy python submission (verdict: Runtime Error):
s = input()

l = len(s)//2
if len(s)==1:
    print(0)
    exit()
elif l%2==0:
    s1 = s[:l]
    s2 = s[l:]
else:
    s1 = s[:l]
    s2 = s[l+1:]

s2=s2[::-1]
c=0
for i in range(len(s2)):
    if s1[i] != s2[i]:
        c+=1
print(c)

Fixed submission:
S = input()
cnt = 0

for i in range(len(S)//2):
    if S[i] != S[-(i+1)]:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
s = input()

l = len(s)//2
if l%2==0:
    s1 = s[:l]
    s2 = s[l:]
else:
    s1 = s[:l]
    s2 = s[l+1:]

s2=s2[::-1]
c=0
for i in range(len(s2)):
    if s1[i] != s2[i]:
        c+=1
print(c)

Fixed submission:
S = input()
cnt = 0

for i in range(len(S)//2):
    if S[i] != S[-(i+1)]:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
sc = [k] * n

for i in a:
    sc = [j - 1 for j in sc]
    sc[i - 1]+=1
for j in sc:
    print('Yes' if j > 0 else 'No')

Fixed submission:
n, k, q = map(int, input().split())
sc = [k - q] * n

for i in range(q):
    sc[int(input()) - 1] += 1

for j in sc:
    print('Yes' if j > 0 else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for _ in range(n)]

c = 0
for i in range(len(s)):
    t1 = list(s[i])
    t1.sort()

    for j in range(i+1, len(s)):
        t2 = list(s[j])
        t2.sort()

        if t1 == t2:
            c+=1
print(c)

Fixed submission:
from collections import Counter

n = int(input())
s = ["".join(sorted(list(input()))) for _ in range(n)]
ans = 0
for i in Counter(s).values():
    ans+=(i*(i-1))/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
import fractions

a, b, c, d = map(int, input().split())

b_c = b//c - (a-1)//c
d_c = b//d - (a-1)//d
cd = (c * d) // fractions.gcd(c, d)
cd_c = b//cd - (a-1)//cd

print((b - a + 1) - (b_c + d_c - cd_c))


Fixed submission:
s = list(input())

p = ''
for i in s:
    if p == i:
        print('Bad')
        exit()
    else:
        p = i
print('Good')

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

a, b, c, d = map(int, input().split())

b_c = b//c - (a-1)//c
d_c = b//d - (a-1)//d
cd = (c * d) // math.gcd(c, d)
cd_c = b//cd - (a-1)//cd

print((b - a + 1) - (b_c + d_c - cd_c))


Fixed submission:
s = list(input())

p = ''
for i in s:
    if p == i:
        print('Bad')
        exit()
    else:
        p = i
print('Good')
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

b_c = b//c - (a-1)//c
d_c = b//d - (a-1)//d
cd = (c * d) // math.gcd(c, d)
cd_c = b//cd - (a-1)//cd

print((b - a + 1) - (b_c + d_c - cd_c))

Fixed submission:
import fractions

a, b, c, d = map(int, input().split())

b_c = b//c - (a-1)//c
d_c = b//d - (a-1)//d
cd = (c * d) // fractions.gcd(c, d)
cd_c = b//cd - (a-1)//cd

print((b - a + 1) - (b_c + d_c - cd_c))