Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

r = [i for i, x in enumerate(s) if x == 'R']
g = [i for i, x in enumerate(s) if x == 'G']
b = [i for i, x in enumerate(s) if x == 'B']

c = 0

for k in r:
    for j in g:
        for i in b:
            a = []
            a.append(k)
            a.append(j)
            a.append(i)
            a.sort()
            if a[1] - a[0] != a[2] - a[1]:
                c += 1

print(c)

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

r = s.count('R')
g = s.count('G')
b = s.count('B')

# 1つ目の条件を満たす組の数
ans = r * g * b

# 2つ目の条件を満たす組の数
c = 0
for i in range(n):
    for j in range(i+1,n):
        k = 2 * j -i
        if k > n-1:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c += 1

print(ans - c)

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

r = [i for i, x in enumerate(l_dup) if x == 'R']
g = [i for i, x in enumerate(l_dup) if x == 'G']
b = [i for i, x in enumerate(l_dup) if x == 'B']

c = 0

for k in r:
    for j in g:
        for i in b:
            a = list(k, j, i)
            a.sort
            if a[0] - a[1] != a[1] - a[2]:
                c += 1

print(c)

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

r = s.count('R')
g = s.count('G')
b = s.count('B')

# 1つ目の条件を満たす組の数
ans = r * g * b

# 2つ目の条件を満たす組の数
c = 0
for i in range(n):
    for j in range(i+1,n):
        k = 2 * j -i
        if k > n-1:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c += 1

print(ans - c)

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

c = 0

for k in range(n):
    for j in range(k):
        if s[j] != s[k]:
            for i in range(j):
                if (k-j) != (j-i):
                    if s[i] != s[j] and s[i] != s[k]:
                        c += 1

print(c)

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

r = s.count('R')
g = s.count('G')
b = s.count('B')

# 1つ目の条件を満たす組の数
ans = r * g * b

# 2つ目の条件を満たす組の数
c = 0
for i in range(n):
    for j in range(i+1,n):
        k = 2 * j -i
        if k > n-1:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c += 1

print(ans - c)

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

c = 0

for k in range(n):
    for j in range(k):
        for i in range(j):
            if (k-j) != (j-i):
                if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                    c += 1

print(c)

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

r = s.count('R')
g = s.count('G')
b = s.count('B')

# 1つ目の条件を満たす組の数
ans = r * g * b

# 2つ目の条件を満たす組の数
c = 0
for i in range(n):
    for j in range(i+1,n):
        k = 2 * j -i
        if k > n-1:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            c += 1

print(ans - c)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
k = int(input())

def gen(n):
    if n < 10:
        yield n
    else:
        for m in gen(n/10):
            yield m
        yield n%10
c = 9
if k >= 10:
    for i in range(10, 10**5):
        a = np.array( [int(i) for i in gen(i)])
        b = np.diff(a)
        if max(abs(b)) <= 1:
            c = c + 1
        if c == k:
            break

if k <= 10:
    print(k)
else:
    print(i)

Fixed submission:
from collections import deque

k = int(input())
d = deque([1,2,3,4,5,6,7,8,9])

for i in range(k):
    x = d.popleft()
    if x % 10 != 0:
        d.append(10 * x + x % 10 - 1)

    d.append(10 * x + x % 10)
    
    if x % 10 != 9:
        d.append(10 * x + x % 10 + 1)

print(x)
Buggy python submission (verdict: Runtime Error):
import numpy as np

c = np.zeros(int(2e5))
c_1 = np.ones(int(2e5))

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

for i in range(n):
    c[a[i] - 1] += 1

ans = int(sum(c * (c - c_1) / 2))

for i in range(n):
    print(ans - int(c[a[i]-1]-1))

Fixed submission:
import numpy as np

c = np.zeros(int(2e5))
c_1 = np.ones(int(2e5))

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

for i in range(n):
    c[a[i] - 1] += 1

ans = int(sum(c * (c - c_1) / 2))

for i in range(n):
    print(ans - int(c[a[i]-1]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())

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


for i in range(N):
    ans = 0
    a_slice = a[:i] + a[i+1:]
    c = collections.Counter(a_slice)
    counter = c.most_common()
    for j in range(len(counter)):
        ans += int(counter[j][1] * (counter[j][1] - 1) / 2)
    
    print(ans)

Fixed submission:
import numpy as np

c = np.zeros(int(2e5))
c_1 = np.ones(int(2e5))

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

for i in range(n):
    c[a[i] - 1] += 1

ans = int(sum(c * (c - c_1) / 2))

for i in range(n):
    print(ans - int(c[a[i]-1]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())

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


for i in range(N):
    ans = 0
    a_slice = a[:i] + a[i+1:]
    c = collections.Counter(a_slice)
    counter = c.most_common()
    for j in range(len(counter)):
        ans += int(counter[j][1] * (counter[j][1] - 1) / 2)
    
    print(ans)

Fixed submission:
import numpy as np

c = np.zeros(int(2e5))
c_1 = np.ones(int(2e5))

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

for i in range(n):
    c[a[i] - 1] += 1

ans = int(sum(c * (c - c_1) / 2))

for i in range(n):
    print(ans - int(c[a[i]-1]-1))
Buggy python submission (verdict: Runtime Error):
import math
a, b, c = map(int, input().split())

if (4 * math.sqrt(a * b)) < (c - a - b):
    print('Yes')
else:
    print('No')

Fixed submission:
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(a[K-1])

Buggy python submission (verdict: Runtime Error):
import math
a, b, c = map(int, input().split())

if 4 * math.sqrt(a * b) < c - a - b:
    print('Yes')
else:
    print('No')

Fixed submission:
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(a[K-1])

Buggy python submission (verdict: Runtime Error):
a, b, c = map(float, input().split())

if 4 * a * b < (c - a - b) ** 2:
    print('Yes')
else:
    print('No')

Fixed submission:
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(a[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())

counter = 0
for i in range(a, b+1):
    if i % x == 0:
        counter += 1

print(counter)

Fixed submission:
import numpy as np
a, b, x = map(int, input().split())
upper = b // x
lower = (a-1)//x

ans = upper - lower

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

counter = [0] * 26

for i in s:
    counter[ord(i)-97] += 1

flag = 'Yes'
for i in counter:
    if (i % 2) == 1:
        flag = 'No'

print(flag)

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n > k:
    print(k * x + (n-k)*y)
else:
    print(n*x)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(_) for _ in input().split()]
l=[a[i]+i for i in range(n)]
r=[i-a[i] for i in range(n)]
ans=0
for i in range(n):ans+=r.count(l[i])
print(ans)

Fixed submission:
import collections
n=int(input())
a=[int(_) for _ in input().split()]
l=[a[i]+i for i in range(n)]
r=[i-a[i] for i in range(n)]
c=collections.Counter(r)
ans=0
for i in range(n):ans+=c[l[i]]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(_) for _ in input().split()]
ans=0
for i in range(n):
    t=a[i]
    for j in range(i+t,n):
        ans+=a[j]==j-i-t
print(ans)

Fixed submission:
import collections
n=int(input())
a=[int(_) for _ in input().split()]
l=[a[i]+i for i in range(n)]
r=[i-a[i] for i in range(n)]
c=collections.Counter(r)
ans=0
for i in range(n):ans+=c[l[i]]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(_) for _ in input().split()]
ans=0
for i in range(n):
    t=a[i]
    for j in range(i,n):
        ans+=a[j]==j-i-t
print(ans)

Fixed submission:
import collections
n=int(input())
a=[int(_) for _ in input().split()]
l=[a[i]+i for i in range(n)]
r=[i-a[i] for i in range(n)]
c=collections.Counter(r)
ans=0
for i in range(n):ans+=c[l[i]]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(_) for _ in input().split()]
ans=0
for i in range(n):
    for j in range(i,n):
        if a[i]+a[j]==j-i:ans+=1
print(ans)

Fixed submission:
import collections
n=int(input())
a=[int(_) for _ in input().split()]
l=[a[i]+i for i in range(n)]
r=[i-a[i] for i in range(n)]
c=collections.Counter(r)
ans=0
for i in range(n):ans+=c[l[i]]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(_) for _ in input().split()]
b=[0 for _ in range(n)]
for i in a:
    b[i-1]+=1
for i in range(n):
    print(b[i])


Fixed submission:
import math
print(int(input())*2*math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[[int(_),0] for _ in input().split()]
for i in range(n): a[i][1]=i
a.sort(reverse=True)
dp=[[0 for _ in range(n)] for __ in range(n)]
for l in range(n):
    for r in range(n):
        if l+r < n:
            if l<n-1:dp[l+1][r]=max(dp[l+1][r], dp[l][r]+a[l+r][0]*abs(a[l+r][1]-l))
            if r<n-1:dp[l][r+1]=max(dp[l][r+1], dp[l][r]+a[l+r][0]*abs(a[l+r][1]-(n-r-1)))
print(max([dp[i][n-i] for i in range(1,n)]))

Fixed submission:
n=int(input())
a=[[int(_),0] for _ in input().split()]
for i in range(n): a[i][1]=i
a.sort(reverse=True)
dp=[[0 for _ in range(n)] for __ in range(n)]
for l in range(n):
    for r in range(n):
        if l+r < n:
            if l<n-1:dp[l+1][r]=max(dp[l+1][r], dp[l][r]+a[l+r][0]*abs(a[l+r][1]-l))
            if r<n-1:dp[l][r+1]=max(dp[l][r+1], dp[l][r]+a[l+r][0]*abs(a[l+r][1]-(n-r-1)))
print(max([dp[i][n-i] for i in range(1,n)]))
Buggy python submission (verdict: Runtime Error):
import math
def pFactorize(num):
    factor_list = []
    for i in range(2, math.floor(math.sqrt(num))+ 1):
        if num % i == 0:
            factor_list.append([i,1])
            num //= i
        while num % i == 0:
            factor_list[-1][1] += 1
            num //= i
    if not num == 1:
        factor_list.append([num,1])
    return factor_list
a,b=[int(_) for _ in input().split()]
c=pFactorize(math.gcd(a,b))
print(len(c)+1)

Fixed submission:
import fractions
import math
def pFactorize(num):
    factor_list = []
    for i in range(2, math.floor(math.sqrt(num))+ 1):
        if num % i == 0:
            factor_list.append([i,1])
            num //= i
        while num % i == 0:
            factor_list[-1][1] += 1
            num //= i
    if not num == 1:
        factor_list.append([num,1])
    return factor_list
a,b=[int(_) for _ in input().split()]
c=pFactorize(fractions.gcd(a,b))
print(len(c)+1)
Buggy python submission (verdict: Runtime Error):
from math import factorial
n,k=[int(_) for _ in input().split()]
mod=10**9+7
if n!=k:
    for i in range(1,k+1):print((((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))%mod)
else:
    print(1)
    for i in range(1,k):print(0)

Fixed submission:
from math import factorial
n,k=[int(_) for _ in input().split()]
mod=10**9+7
if n!=k:
    if k+1 > n-k+2:
        for i in range(1,n-k+2):print((((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))%mod)
        for i in range(2*k-n-1):print(0)
    else:
        for i in range(1,k+1):print((((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))%mod)
else:
    print(1)
    for i in range(1,k):print(0)

Buggy python submission (verdict: Runtime Error):
from math import factorial
n,k=[int(_) for _ in input().split()]
mod=10**9+7
for i in range(1,k+1):
    print(((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))

Fixed submission:
from math import factorial
n,k=[int(_) for _ in input().split()]
mod=10**9+7
if n!=k:
    if k+1 > n-k+2:
        for i in range(1,n-k+2):print((((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))%mod)
        for i in range(2*k-n-1):print(0)
    else:
        for i in range(1,k+1):print((((factorial(k-1)//factorial(i-1)//factorial(k-i))%mod)*((factorial(n-k+1)//factorial(i)//factorial(n-k-i+1))%mod))%mod)
else:
    print(1)
    for i in range(1,k):print(0)
Buggy python submission (verdict: Runtime Error):
from math import factorial
n,k=[int(_) for _ in input().split()]
max = factorial(n-1)//factorial(n-3)//2
if k > max or k < max-n+1:
    print(-1)
else:
    cnt=max-k
    for i in range(2,n+1):
        print(1,i)
    nn=2
    while cnt > 0:
        print(nn,nn+1)
        nn+=1
        cnt-=1

Fixed submission:
from math import factorial
n,k=[int(_) for _ in input().split()]
if n == 2 and k == 1:
    print(-1)
elif n == 2 and k == 0:
    print(1)
    print(1,2)
else:
    max = factorial(n-1)//factorial(n-3)//2
    if k > max:
        print(-1)
    else:
        cnt=max-k
        print(n+cnt-1)
        for i in range(2,n+1):
            print(1,i)
        nn=2
        while cnt > 0:
            print((nn%(n-1)+2),((nn%(n-1)+2)+((nn-2)//(n-1)-1))%(n-1)+2)
            nn+=1
            cnt-=1
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
b = []
for i in range(n):
    if s[i] == '#':
        b.append(i)
if len(b) == 0:
    print(0)
else:
    ans = min(s[b[0]::].count('.'), s.count('#'))
    for i in range(1,len(b)-1):
        ans = min(ans, i+n-b[i]-len(b[i::]))
    print(ans)


Fixed submission:
n = int(input())
s = input()
b = []
for i in range(n):
    if s[i] == '#':
        b.append(i)
if len(b) == 0:
    print(0)
else:
    ans = min(s[b[0]::].count('.'), s.count('#'))
    nb = len(b)
    for i in range(1,len(b)-1):
        ans = min(ans, i + n-b[i]-nb+i)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
b = []
for i in range(n):
    if s[i] == '#':
        b.append(i)
if len(b) == 0:
    print(0)
else:
    ans = min(s[b[0]::].count('.'), s.count('#'))
    for i in range(1,len(b)-1):
        ans = min(ans, len(b[:i])+s[b[i]::].count('.'))
    print(ans)


Fixed submission:
n = int(input())
s = input()
b = []
for i in range(n):
    if s[i] == '#':
        b.append(i)
if len(b) == 0:
    print(0)
else:
    ans = min(s[b[0]::].count('.'), s.count('#'))
    nb = len(b)
    for i in range(1,len(b)-1):
        ans = min(ans, i + n-b[i]-nb+i)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, o = [int(_) for _ in input().split()]
a = sorted([int(_) for _ in input().split()])[::-1]
b = sorted([int(_) for _ in input().split()])[::-1]
c = sorted([int(_) for _ in input().split()])[::-1]

def isBorder(p):
    l = []
    for i in range(x):
        for j in range(y):
            for k in range(z):
                if a[i]+b[j]+c[k] < p : break
                l.append(a[i]+b[j]+c[k])
    return l if len(l) >= o else []

l, r = 0, a[0]+b[0]+c[0]
while True:
    if r==l : break
    p = (l+r)//2
    q = isBorder(p)
    if q == []:
        r = p-1
    else:
        l = p+1
q.sort(reverse=True)
for i in range(o):
    print(q[i])


Fixed submission:
x, y, z, k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse=True)
abc = []
for i in range(min(k, x*y)):
    for j in range(z):
        abc.append(ab[i] + c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse=True)
abc = []
for i in range(min(k, x*y)):
    for j in range(z):
        abc.append(ab[i] + c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])


Fixed submission:
x, y, z, k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse=True)
abc = []
for i in range(min(k, x*y)):
    for j in range(z):
        abc.append(ab[i] + c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab = sorted(ab)[::-1][:k]
abc = []
for i in range(min(k, x*y)):
    for j in range(z):
        abc.append(ab[i] + c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])

Fixed submission:
x, y, z, k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse=True)
abc = []
for i in range(min(k, x*y)):
    for j in range(z):
        abc.append(ab[i] + c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
d = [a[i]-b[i] for i in range(n)]
e = [i for i in d if i > 0]
f = [i for i in d if i < 0]
e.sort(reverse = True)
f.sort()
if sum(d) < 0:
    print(-1)
else:
    if f == []:
        print(0)
    else:
        for i in range(len(e)+1):
            if sum(e[0:i]) >=  abs(sum(f)):
                print(i+len(f))
                break


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
d = [a[i]-b[i] for i in range(n)]
e = [i for i in d if i > 0]
f = [i for i in d if i < 0]
e.sort(reverse = True)
g = abs(sum(f))
if sum(d) < 0:
    print(-1)
else:
    if f == []:
        print(0)
    else:
        sum = 0
        for i in range(len(e)):
            sum += e[i]
            if sum >=  g:
                print(i+len(f)+1)
                break
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(_) for _ in input().split()]
h = [int(_) for _ in input().split()]
mc = [0]
for i in range(1,n):
    ans = 1e9
    for j in range(max(i-k, 0), i):
        ans = min(ans, mc[j]+abs(h[i]-h[j]))
    mc.append(ans)
print(ans)

Fixed submission:
n, k = [int(_) for _ in input().split()]
h = [int(_) for _ in input().split()]
mc = [0]
for i in range(1,n):
    ans = 1e9
    for j in range(max(i-k, 0), i):
        ans = min(ans, mc[j]+abs(h[i]-h[j]))
    mc.append(ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
import fraction
from functools import reduce

def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)

n,x = [int(i) for i in input().split()]
pos = [abs(int(i) - x) for i in input().split()]

print(gcd_list(pos))


Fixed submission:
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n,x = [int(i) for i in input().split()]
pos = [abs(int(i) - x) for i in input().split()]

print(gcd_list(pos))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
a = [int(i) for i in input().split()]
s = [sum(a[:i]) for i in range(1,n+1)]
c = collections.Counter(s)
d = [i*(i-1)//2 for i in c.values() if i>1]
print(sum(d)+c[0])


Fixed submission:
import collections
n = int(input())
a = [int(i) for i in input().split()]
s = [a[0]]
for i in range(1,n):s.append(s[i-1]+a[i])
c = collections.Counter(s)
d = [i*(i-1)//2 for i in c.values()]
print(sum(d)+c[0])
Buggy python submission (verdict: Runtime Error):
s,t = [i for i in input().split()]
list(s).sort()
list(t).sort(reverse = True)
if s < t :
  print('Yes')
else:
  print('No')

Fixed submission:
s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
if ''.join(s) < ''.join(t) :
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(_) for _ in input().split()]
ans=-10**15
for i in range(n,2*n+1):ans=max(ans, sum(sorted(a[:i])[i-n:])-sum(sorted(a[i:])[:n]))
print(ans)

Fixed submission:
from heapq import heappush,heappop
n=int(input()); a=[int(_) for _ in input().split()]
fh=[]; lh=[]
for i in range(n):
    heappush(fh, a[i])
    heappush(lh, -1*a[-i-1])
f=[sum(fh)]; l=[-1*sum(lh)]
for i in range(n,2*n):
    heappush(fh, a[i]); f.append(f[-1]+a[i]-heappop(fh))
    heappush(lh, -1*a[-i-1]); l.append(l[-1]+a[-i-1]+heappop(lh))
ans=-10**15
for i,j in zip(f,l[::-1]):ans=max(ans, i-j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(_) for _ in input().split()]
ans=-10**15
for i in range(n,2*n+1):ans=max(ans, sum(sorted(a[:i])[i-n:])-sum(sorted(a[i:])[:n]))
print(ans)

Fixed submission:
from heapq import heappush,heappop
n=int(input()); a=[int(_) for _ in input().split()]
fh=[]; lh=[]
for i in range(n):
    heappush(fh, a[i])
    heappush(lh, -1*a[-i-1])
f=[sum(fh)]; l=[-1*sum(lh)]
for i in range(n,2*n):
    heappush(fh, a[i]); f.append(f[-1]+a[i]-heappop(fh))
    heappush(lh, -1*a[-i-1]); l.append(l[-1]+a[-i-1]+heappop(lh))
ans=-10**15
for i,j in zip(f,l[::-1]):ans=max(ans, i-j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(_) for _ in input().split()]
ans=-10**15
for i in range(n,2*n+1):ans=max(ans, sum(sorted(a[:i])[::-1][:n])-sum(sorted(a[i:])[:n]))
print(ans)

Fixed submission:
from heapq import heappush,heappop
n=int(input()); a=[int(_) for _ in input().split()]
fh=[]; lh=[]
for i in range(n):
    heappush(fh, a[i])
    heappush(lh, -1*a[-i-1])
f=[sum(fh)]; l=[-1*sum(lh)]
for i in range(n,2*n):
    heappush(fh, a[i]); f.append(f[-1]+a[i]-heappop(fh))
    heappush(lh, -1*a[-i-1]); l.append(l[-1]+a[-i-1]+heappop(lh))
ans=-10**15
for i,j in zip(f,l[::-1]):ans=max(ans, i-j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(_) for _ in input().split()]
ans=-10**15
for i in range(n,2*n+1):ans=max(ans, sum(sorted(a[:i])[::-1][:n])-sum(sorted(a[i:])[:n]))
print(ans)

Fixed submission:
from heapq import heappush,heappop
n=int(input()); a=[int(_) for _ in input().split()]
fh=[]; lh=[]
for i in range(n):
    heappush(fh, a[i])
    heappush(lh, -1*a[-i-1])
f=[sum(fh)]; l=[-1*sum(lh)]
for i in range(n,2*n):
    heappush(fh, a[i]); f.append(f[-1]+a[i]-heappop(fh))
    heappush(lh, -1*a[-i-1]); l.append(l[-1]+a[-i-1]+heappop(lh))
ans=-10**15
for i,j in zip(f,l[::-1]):ans=max(ans, i-j)
print(ans)
Buggy python submission (verdict: Runtime Error):
if scan()=="SUN":
  print("7")
elif scan()=="MON":
  print("6")
elif scan()=="TUE":
  print("5")
elif scan()=="WED":
  print("4")  
elif scan()=="TUH":
  print("3")
elif scan()=="FRI":
  print("2")
else:
  print("1")

Fixed submission:
week =input()

if week=="SUN":
  print("7")
elif week=="MON":
  print("6")
elif week=="TUE":
  print("5")
elif week=="WED":
  print("4")  
elif week=="THU":
  print("3")
elif week=="FRI":
  print("2")
else:
  print("1")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

id = [0 for _ in range(n)]
for i in range(len(a)):
	id[a[i]-1] += 1

for i in id:
	print(i

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

id = [0 for _ in range(n)]
for i in range(len(a)):
	id[a[i]-1] += 1

for i in id:
	print(i)