Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
K, S = [int(i) for i in input().split()]

counter = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if x + y + z == S:
                counter += 1

print(counter)

Fixed submission:
K, S = [int(i) for i in input().split()]

counter = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z and z <= K:
            counter += 1
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

count = 0
for i in range(1000):
    num = "{:03}".format(i)
    cur_idx = 0
    for c in S:
        if c == num[cur_idx]:
            cur_idx += 1
        if cur_idx == 3:
            count += 1
            break
print(count)

Fixed submission:
N = int(input())
S = list(input())

count = 0
for i in range(1000):
    num = "{:03}".format(i)
    cursor = -1
    ok = True
    for c in num:
        slice = S[cursor + 1:]
        if c not in slice:
            ok = False
            break
        cursor += slice.index(c) + 1
    if ok:
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
s = input()
for i in range(Q):
    l, r = map(int, input().split())
    _s = s[l - 1:r]
    num_ac = 0
    ex_a = False
    for c in _s:
        if ex_a and c == "C":
            num_ac += 1
        if c == "A":
            ex_a = True
        else:
            ex_a = False
    print(num_ac)

Fixed submission:
N, Q = map(int, input().split())
s = input()
ac_cum_list = []
ac_cum = 0
ex_a = False
for c in s:
    if ex_a and c == "C":
        ac_cum += 1
    if c == "A":
        ex_a = True
    else:
        ex_a = False
    ac_cum_list.append(ac_cum)

for i in range(Q):
    l, r = map(int, input().split())
    print(ac_cum_list[r - 1] - ac_cum_list[l - 1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
n, m = map(int, input().split())
x = list(map(int, input().split()))

x = sorted(x)
diff = np.asarray([x[i + 1] - x[i] for i in range(len(x) - 1)])
argsort = diff.argsort()[::-1][:n - 1]

x_list = []
start = 0
for split_idx in argsort:
    x_list.append(x[start:split_idx+1])
    start = split_idx+1
x_list.append(x[start:])

sum_length = 0
for cur_x in x_list:
    sum_length += cur_x[-1] - cur_x[0]

print(sum_length)

Fixed submission:
import numpy as np
n, m = map(int, input().split())
x = list(map(int, input().split()))

x = sorted(x)
diff = np.asarray([x[i + 1] - x[i] for i in range(len(x) - 1)])
argsort = diff.argsort()[::-1][:n - 1]

start = 0
sum_length = 0
for split_idx in argsort:
    sum_length += x[split_idx] - x[start]
    start = split_idx + 1
sum_length += x[-1] - x[start]

print(sum_length)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())

alp = "abcdefghijklmnopqrstuvwxyz"

target = K
candidate = set()
for a in alp:
    idx_list = []
    for i, _s in enumerate(s):
        if a == _s:
            idx_list.append(i)
            candidate.add(_s)

    if len(candidate) >= K:
        break

    ng_idx_list = []
    for j in range(1, len(s) + 1):
        if set(ng_idx_list) == set(idx_list):
            break
        for _idx in idx_list:
            if _idx in ng_idx_list:
                continue
            if _idx + j > len(s) - 1:
                ng_idx_list.append(_idx)
                continue
            _sub = s[_idx: _idx + 1 + j]
            candidate.add(_sub)

    if len(candidate) >= K:
        break

print(sorted(list(candidate))[K - 1])

Fixed submission:
s = input()
K = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
candidate_orig = set()

def hoge(c_list, rank, candidate):
    if len(candidate) >= 5:
        return candidate

    cur_targets = {}
    for l in sorted(c_list):
        if l + rank > len(s) - 1:
            continue
        _sub = s[l: l + 1 + rank]
        if _sub not in cur_targets:
            cur_targets[_sub] = [l]
        else:
            cur_targets[_sub].append(l)

    if len(cur_targets) == 0:
        return candidate

    for _d in sorted(cur_targets.items(), key=lambda x: x[0]):
        candidate.add(_d[0])
        candidate = hoge(_d[1], rank + 1, candidate)
        return candidate

    return candidate

for a in alp:
    idx_list = []
    for i, _s in enumerate(s):
        if a == _s:
            idx_list.append(i)
            candidate_orig.add(_s)
    candidate = hoge(idx_list, 1, candidate_orig)
    if len(candidate) >= 5:
        break

print(sorted(list(candidate_orig))[K - 1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans *= i

if ans > 10**18:
    ans = -1

print(ans)


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

for i in a:
    if i == 0:
        print(0)
        exit()

ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        ans = -1
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
d = {}
for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] != s[j]:
            d[(i, j)] = s[i] + s[j]

for k, v in d.items():
    for i in range(k[1]+1, n):
        if s[k[0]] == s[i]:
            continue
        if s[k[1]] == s[i]:
            continue
        if k[1] - k[0] != i - k[1]:
            ans += 1

print(ans)


Fixed submission:
n = int(input())
s = input()
r = 0
g = 0
b = 0

for c in s:
    if c == "R":
        r += 1
    elif c == "G":
        g += 1
    elif c == "B":
        b += 1

sub = 0
for i in range(n):
    for j in range(i+1, n):
        k = j * 2 - i
        if k >= n:
            continue
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            sub += 1

print(r*g*b-sub)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = [0.0] * 10000

rmax = -1
pos = -1
for i in range(n-k+1):
    _t = sum(p[i: i+k])
    if pos < _t:
        pos = _t
        rmax = i

ans = 0.0
p = p[rmax: rmax+k]
p = sorted(p, reverse=True)

for i in range(k):
    if tmp[p[i]] == 0:
        t = 0
        for j in range(1, p[i]+1):
            t += j
            tmp[j] = t / j
        ans += tmp[p[i]]
    else:
        ans += tmp[p[i]]

print(ans)


Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
s = [0] * (n+1)

for i in range(0, n):
    s[i+1] = s[i] + p[i]

s_max = -1
pos = 0
for i in range(n-k+1):
    ss = s[i+k] - s[i]
    if ss > s_max:
        s_max = ss
        pos = i

ans = 0.0
for i in range(pos, pos+k):
    ans += (p[i]+1) / 2

print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = [0] * 10000

rmax = -1
pos = -1
for i in range(n-k+1):
    _t = sum(p[i: i+k])
    if pos < _t:
        pos = _t
        rmax = i

ans = 0
for i in range(rmax, rmax+k):
    if tmp[i] == 0:
        t = 0
        for j in range(1, p[i]+1):
            t += j
            #tmp[j] = t / j
        t = t / p[i]

        tmp[i] = t
        ans += t
#        print(t)
#    else:
#        ans += tmp[i]
#        print(tmp[i])

print(ans)


Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
s = [0] * (n+1)

for i in range(0, n):
    s[i+1] = s[i] + p[i]

s_max = -1
pos = 0
for i in range(n-k+1):
    ss = s[i+k] - s[i]
    if ss > s_max:
        s_max = ss
        pos = i

ans = 0.0
for i in range(pos, pos+k):
    ans += (p[i]+1) / 2

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import OrderedDict

input = sys.stdin.readline
r = OrderedDict()

n = int(input())
for _ in range(n):
    x, l = map(int, input().split())
    r[x-l] = x+l

r = sorted(r.items(), key=lambda x: x[0])

cp = 0
fp = 1
ans = n
while True:
    if r[cp][1] > r[fp][0]:
        ans -= 1
        fp += 1
    else:
        cp = fp
        fp += 1

    if n <= fp:
        break

print(ans)


Fixed submission:
import sys

input = sys.stdin.readline
p = []
n = int(input())
for _ in range(n):
    x, l = map(int, input().split())
    p.append([x-l, x+l])

r = sorted(p, key=lambda x: x[1])

ans = 0
cur = - (1<<60)

for i in r:
    if cur > i[0]:
        continue
    ans += 1
    cur = i[1]

print(ans)
Buggy python submission (verdict: Runtime Error):
abcx = input().split(" ")
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
x = int(abcd[3])
if x <= a:
    print(x)
elif x <= a + b:
    print(a)
else:
    print(2*a + b - x)

Fixed submission:
abcx = input().split(" ")
a = int(abcx[0])
b = int(abcx[1])
x = int(abcx[3])
if x <= a:
    print(x)
elif x <= a + b:
    print(a)
else:
    print(2 * a + b - x)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = []
for i in range(a):
    c = input()
    if c not in b == True:
        b.append(c)
print(ren(b))

Fixed submission:
a = int(input())
b = []
for i in range(a):
    b.append(input())
print(len(set(b)))
Buggy python submission (verdict: Runtime Error):
a = input().split(" ")
b = input().split(" ")
c = 0
for i in b:
    c += int(i)
if a >= c:
    print(a - c)
else:
    print(-1)

Fixed submission:
a = input().split(" ")
b = input().split(" ")
c = 0
for i in b:
    c += int(i)
if int(a[0]) >= c:
    print(int(a[0]) - c)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
a=input().split(' ')
b=input().split(' ')
c=0
for i in int(a[1]):
    if i != int(a[1])-1:
        if int(b[i+1]) - int(b[i]) > c:
            c = int(b[i+1]) - int(b[i])
    else:
        if int(a[0]) - int(b[-1])+ int(b[0]) > c:
            c = int(a[0]) - int(b[-1])+ int(b[0])
print(int(a[0])-c)


Fixed submission:
a=input().split(' ')
b=input().split(' ')
c=0
for i in range(int(a[1])):
    if i != int(a[1])-1:
        if int(b[i+1]) - int(b[i]) > c:
            c = int(b[i+1]) - int(b[i])
    else:
        if int(a[0]) - int(b[-1])+ int(b[0]) > c:
            c = int(a[0]) - int(b[-1])+ int(b[0])
print(int(a[0])-c)

Buggy python submission (verdict: Runtime Error):
a=input().split(' ')
b=input().split(' ')
c=0
for i in int(a[1]):
    if i != a[1]-1:
        if int(b[i+1]) - int(b[i]) > c:
            c = int(b[i+1]) - int(b[i])
    else:
        if int(a[0]) - int(b[-1])+ int(b[0]) > c:
            c = int(a[0]) - int(b[-1])+ int(b[0])
print(int(a[0])-c)

Fixed submission:
a=input().split(' ')
b=input().split(' ')
c=0
for i in range(int(a[1])):
    if i != int(a[1])-1:
        if int(b[i+1]) - int(b[i]) > c:
            c = int(b[i+1]) - int(b[i])
    else:
        if int(a[0]) - int(b[-1])+ int(b[0]) > c:
            c = int(a[0]) - int(b[-1])+ int(b[0])
print(int(a[0])-c)
Buggy python submission (verdict: Runtime Error):
a = input().split(" ")
n = int(a[0])
b = int(a[1])
r = int(a[2])
c = a // (b + r)
bb = c * b
d = a % (b + r)
if d >= b:
	bb += b
else:
	bb += d 
print(bb)

Fixed submission:
a = input().split(" ")
n = int(a[0])
b = int(a[1])
r = int(a[2])
c = n // (b + r)
bb = c * b
d = n % (b + r)
if d >= b:
	bb += b
else:
	bb += d 
print(bb)
Buggy python submission (verdict: Runtime Error):
a = input()
b = int(input())
c = 0
for i in range(b):
	d = input().split(" ")
	if d[0] == "1":
		c += 1
	else:
		if c % 2 == 0:
			if d[1] == "1":
				a = d[2] + a
			else:
				a = a + d[2]
		else:
			if d[1] == "2":
				a = d[2] + a
			else:
				a = a + d[2]
if c % 2 == 1:
	a = a[::-1]
print(a)

Fixed submission:
a = input().split(" ")
t8 = int(a[0])
t10 = int(a[1])

for i in range(13, 1001):
	b = int(i * 0.08)
	c = int(i * 0.1)
	if b == t8 and c == t10:
		print(i)
		break
	if i == 1000:
		print(-1)
		break
Buggy python submission (verdict: Runtime Error):
a = input().split(" ")
l = input().split(" ")
x = int(a[1])
y = 0
num = 1
for i in l:
    y += i
    if y <= x:
        num += 1
    else:
        break
print(num)

Fixed submission:
a = input().split(" ")
l = input().split(" ")
x = int(a[1])
y = 0
num = 1
for i in l:
    y += int(i)
    if y <= x:
        num += 1
    else:
        break
print(num)
Buggy python submission (verdict: Runtime Error):
a = input().split(" ")
w = int(a[0])
h = int(a[1])
x = int(a[2])
y = int(a[3])
s = w * h / 2
if w % 2 == 0:
    if h %  2 == 0:
        if x == int(w/2):
            if y == int(h/2):
                how = 1
else:
    how = 0
print(str(s) + " " + str(how))

Fixed submission:
a = input().split(" ")
w = int(a[0])
h = int(a[1])
x = int(a[2])
y = int(a[3])
s = w * h / 2
if w % 2 == 0:
    if h %  2 == 0:
        if x == int(w/2):
            if y == int(h/2):
                how = 1
            else:
                how = 0
        else:
            how = 0
    else:
        how = 0
else:
    how = 0
print(str(s) + " " + str(how))
Buggy python submission (verdict: Time Limit Exceeded):
n = map(int, input().split())
a = map(int, input().split())
ans = 1
for i in a:
    ans *= i

print(ans if ans <= 10**18 else -1)


Fixed submission:
n = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
flag = True if 0 in a else False

if flag:
    print(0)
    exit()

for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = map(int, input().split())
a = list(map(int, input().split()))
ans = 1

for i in a:
    ans *= i

print(ans if ans <= 10**18 else -1)


Fixed submission:
n = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
flag = True if 0 in a else False

if flag:
    print(0)
    exit()

for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
s = input()

mx = 0
mxstr = ""
index = []
for i in range(len(s)):
    if s[i] == "?":
        index.append(i)

for i in product(range(2), repeat=s.count("?")):
    tmp = s
    for indx, zerone in zip(index, i):
        if zerone:
            tmp = tmp[:indx] + "P" + tmp[indx+1:]
        else:
            tmp = tmp[:indx] + "D" + tmp[indx+1:]
    sm = tmp.count("D") + tmp.count("PD")
    if sm > mx:
        mx = sm
        mxstr = tmp
print(mxstr)


Fixed submission:
s = input()
s = s.replace("?", "D")
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
t = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ab = math.gcd(a, b)
            d = math.gcd(ab, c)
            t += d

print(t)


Fixed submission:
import math
k = int(input())
t = 0
# a = b = c
for x in range(1, k+1):
    t += x
# a = b != c
for a in range(1, k+1):
    for b in range(a+1, k+1):
        t += 6*math.gcd(a, b)
# a != b != c
for a in range(1, k+1):
    for b in range(a+1, k+1):
        for c in range(b+1, k+1):
            d = math.gcd(a, b)
            t += 6*math.gcd(d, c)
print(t)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
t = 0

r = []
g = []
b = []
for n, c in enumerate(s):
    if c == "R":
        r.append(n)
    elif c == "G":
        g.append(n)
    elif c == "B":
        b.append(n)
for x in r:
    for y in g:
        for z in b:
            ary = sorted([x,y,z])
            if (ary[2]-ary[1] != ary[1] - ary[0]):
                t += 1

print(t)


Fixed submission:
n = int(input())
s = input()
t = s.count("R")*s.count("G")*s.count("B")
for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            t -= 1

print(t)

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

r = []
g = []
b = []
for n, c in enumerate(s):
    if c == "R":
        r.append(n)
    elif c == "G":
        g.append(n)
    elif c == "B":
        b.append(n)
for x in r:
    for y in g:
        for z in b:
            ary = sorted([x,y,z])
            if (ary[2]-ary[1] != ary[1] - ary[0]):
                t += 1

print(t)


Fixed submission:
n = int(input())
s = input()
t = s.count("R")*s.count("G")*s.count("B")
for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            t -= 1

print(t)

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

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

print(t)


Fixed submission:
n = int(input())
s = input()
t = s.count("R")*s.count("G")*s.count("B")
for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            t -= 1

print(t)

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

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

print(t)


Fixed submission:
n = int(input())
s = input()
t = s.count("R")*s.count("G")*s.count("B")
for i in range(n):
    for j in range(i+1, n):
        k = 2*j - i
        if k < n and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            t -= 1

print(t)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
D = collections.defaultdict(int)

for k, i in B.items():
    for l, j in B.items():
        if k == l:
            x = (j-1)*(j-2) // 2
            D[k] += x if x > 0 else 0
        else:
            x = j*(j-1) // 2
            D[k] += x if x > 0 else 0

for a in A:
    print(D[a])


Fixed submission:
import collections

n = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)

s = 0
for k, i in B.items():
    s += i*(i-1) // 2
for a in A:
    print(s-(B[a]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
A = list(map(int, input().split()))
b = collections.Counter(A)

for a in A:
    C = b.copy()
    x = 0
    # a == A[k]
    C[a] -= 1
    for d in C.values():
        x += d*(d-1)//2
    print(x)


Fixed submission:
import collections

n = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)

s = 0
for k, i in B.items():
    s += i*(i-1) // 2
for a in A:
    print(s-(B[a]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
A = list(map(int, input().split()))
b = collections.Counter(A)

for a in A:
    C = b.copy()
    x = 0
    # a == A[k]
    C[a] -= 1
    for d in C.values():
        x += d*(d-1)//2
    print(x)


Fixed submission:
import collections

n = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)

s = 0
for k, i in B.items():
    s += i*(i-1) // 2
for a in A:
    print(s-(B[a]-1))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
d = True
for i in range(q):
    t, *u= input().split()
    if t == "1":
        d = not d
    else:
        f, c = u[0], u[1]
        if d:
            if f == "1":
                s = c + s
            else:
                s = s + c
        else:
            if f == "1":
                s = s + c
            else:
                s = c + s

print(s if d else s[::-1])


Fixed submission:
s = input()
q = int(input())
d = True
head = []
tail = []
for i in range(q):
    t, *u= input().split()
    if t == "1":
        d = not d
    else:
        f, c = u[0], u[1]
        if d:
            if f == "1":
                head.append(c)
            else:
                tail.append(c)
        else:
            if f == "1":
                tail.append(c)
            else:
                head.append(c)
s = "".join(head)[::-1] + s + "".join(tail)
print(s if d else s[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    t, *u= input().split()
    if t == "1":
        s = s[::-1]
    elif t == "2":
        f, c = u[0], u[1]
        if f == "1":
            s = c + s
        elif f == "2":
            s = s + c

print(s)


Fixed submission:
s = input()
q = int(input())
d = True
head = []
tail = []
for i in range(q):
    t, *u= input().split()
    if t == "1":
        d = not d
    else:
        f, c = u[0], u[1]
        if d:
            if f == "1":
                head.append(c)
            else:
                tail.append(c)
        else:
            if f == "1":
                tail.append(c)
            else:
                head.append(c)
s = "".join(head)[::-1] + s + "".join(tail)
print(s if d else s[::-1])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

ans = [-1]*n
a = 0
for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and n != 1:
        a = -1
    elif ans[s-1] not in [-1, c]:
        a = -1
    else:
        ans[s-1] = c

if a == -1:
    print(a)
else:
    b = ""
    if ans[0] == -1 and n != 1:
        ans[0] = 1
    for x in ans:
        if x == -1:
            b += "0"
        else:
            b += str(x)
    print(b)


Fixed submission:
n = int(input())
print(n//2 + (1 if n % 2 else 0))
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9 + 7
n, a, b = map(int, input().split())

ans = pow(2, n, mod)

def C(n, k):
    x, y = 1, 1
    for i in range(k):
        x *= n - i
        y *= i+1

    return (x * pow(y, mod-2, mod)) % mod

print((ans - C(n, a) - C(n, b) - 1) % mod)



Fixed submission:
mod = 10**9 + 7
n, a, b = map(int, input().split())

ans = pow(2, n, mod)

def C(n, k):
    x, y = 1, 1
    for i in range(k):
        x = x *(n - i) % mod
        y = y *(i+1) % mod

    return (x * pow(y, mod-2, mod)) % mod

print((ans - C(n, a) - C(n, b) - 1) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())
s = input()

print(len(set(combinations(s, 3))))


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

passwd = ["{:03}".format(x) for x in range(1000)]
ans = 0

for p in passwd:
    p = iter(p)
    c = next(p)
    n = 0
    for t in s:
        if c == t:
            n += 1
            if n == 3:
                ans += 1
                break
            c = next(p)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())
s = input()

print(len(set(combinations(s, 3))))


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

passwd = ["{:03}".format(x) for x in range(1000)]
ans = 0

for p in passwd:
    p = iter(p)
    c = next(p)
    n = 0
    for t in s:
        if c == t:
            n += 1
            if n == 3:
                ans += 1
                break
            c = next(p)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations, tee
import numpy as np

n = int(input())
pos = [np.array(list(map(int, input().split()))) for _ in range(n)]

def pairwise(itr):
    a, b = tee(itr)
    next(b, None)
    return zip(a, b)

dist = np.array([])
for p in permutations(pos):
    d = 0
    for i, j in pairwise(p):
        d += np.linalg.norm(i-j)
    dist = np.append(dist, d)
print(np.mean(dist))


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

dst = 0
for i in range(n-1):
    for j in range(i+1, n):
        dst += ((pos[i][0]-pos[j][0])**2 + (pos[i][1]-pos[j][1])**2)**(1/2)
print(dst*2/n)

Buggy python submission (verdict: Runtime Error):
from itertools import permutations, tee
import numpy as np

n = int(input())
pos = [np.array(list(map(int, input().split()))) for _ in range(n)]

def pairwise(itr):
    a, b = tee(itr)
    next(b, None)
    return zip(a, b)

dist = np.array([])
for p in permutations(pos):
    d = 0
    for i, j in pairwise(p):
        d += np.linalg.norm(i-j)
    dist = np.append(dist, d)
print(np.mean(dist))


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

dst = 0
for i in range(n-1):
    for j in range(i+1, n):
        dst += ((pos[i][0]-pos[j][0])**2 + (pos[i][1]-pos[j][1])**2)**(1/2)
print(dst*2/n)