Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
lines = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)
ans = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, parent):
    for u in lines[v]:
        if u != parent:
            ans[u] += ans[v]
            dfs(u, v)

dfs(0, -1)
print (*ans)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
lines = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)
ans = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, parent):
    for u in lines[v]:
        if u != parent:
            ans[u] += ans[v]
            dfs(u, v)

dfs(0, -1)
print (*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [0]*N
for i in range(0, N):
    s[i] = input()
t = []
c = 0
for i in range(0, N):
    s[i] = sorted(s[i])
    for j in range(0,len(t)):
        if s[i] == t[j][0]:
            c = c+t[j][1]
            t[j][1] = t[j][1]+1
            break
    else:
        t.append([s[i],1])
print (c)

Fixed submission:
N = int(input())
s = [input() for _ in range(N)]
for i in range(0, N):
    s[i] = "".join(sorted(s[i]))
t = {}
c = 0
for i in range(0, N):
    if s[i] in t:
        c = c+t[s[i]]
        t[s[i]] = t[s[i]]+1
    else:
        t[s[i]] = 1
print (c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [0]*N
for i in range(0, N):
    s[i] = input()
t = []
c = 0
for i in range(0, N):
    s[i] = sorted(s[i])
    for j in range(0,len(t)):
        if s[i] == t[j][0]:
            c = c+t[j][1]
            t[j][1] = t[j][1]+1
            break
    else:
        t.append([s[i],1])
print (c)

Fixed submission:
N = int(input())
s = [input() for _ in range(N)]
for i in range(0, N):
    s[i] = "".join(sorted(s[i]))
t = {}
c = 0
for i in range(0, N):
    if s[i] in t:
        c = c+t[s[i]]
        t[s[i]] = t[s[i]]+1
    else:
        t[s[i]] = 1
print (c)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
mod = 2019
s = 2018
for i in range(L, R):
    for j in range(i+1, R+1):
        t = (i%mod)*(j%mod)%mod
        if s > t:
            s = t
print (s)

Fixed submission:
L, R = map(int, input().split())
mod = 2019
s = 2018
for i in range(L, min(R, L+2018)):
    for j in range(i+1, min(R+1, L+2019)):
        t = (i%mod)*(j%mod)%mod
        if s > t:
            s = t
print (s)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
pos = 0
for i in range(N+1):
    if pos <= X:
        pos += L[i]
    else:
        print (i)
        break
else:
    print (N+1)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
pos, ans = 0, 1
for i in range(N):
    pos += L[i]
    if pos <= X:
        ans += 1
    else:
        break
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
mod = 1000000007
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
    if i not in a:
        if i == 1:
            dp[i] = dp[i-1]
        else:
            dp[i] = (dp[i-1]+dp[i-2])%mod
print (dp[N])

Fixed submission:
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a = set(a)
mod = 1000000007
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
    if i not in a:
        if i == 1:
            dp[i] = dp[i-1]
        else:
            dp[i] = (dp[i-1]+dp[i-2])%mod
print (dp[N])

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a = set(a)
mod = 1000000007
dp = [0]*(N+1)
dp[0] = 1
if a[0] != 1:
    dp[1] = 1
for i in range(2, N+1):
    if i not in a:
        dp[i] = (dp[i-1]+dp[i-2])%mod
print (dp[N])

Fixed submission:
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a = set(a)
mod = 1000000007
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
    if i not in a:
        if i == 1:
            dp[i] = dp[i-1]
        else:
            dp[i] = (dp[i-1]+dp[i-2])%mod
print (dp[N])

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
mod = 1000000007
dp = [0]*(N+1)
dp[0] = 1
if a[0] != 1:
    dp[1] = 1
for i in range(2, N+1):
    if i not in a:
        dp[i] = (dp[i-1]+dp[i-2])%mod
print (dp[N])

Fixed submission:
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a = set(a)
mod = 1000000007
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
    if i not in a:
        if i == 1:
            dp[i] = dp[i-1]
        else:
            dp[i] = (dp[i-1]+dp[i-2])%mod
print (dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

node = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    node[a-1].append(b-1)
    node[b-1].append(a-1)

# 頂点1からの距離が奇数:1、偶数:0
group = [False] * N
# 親ノードを格納する
parents = list(range(N))
stack = [0]

# ノードの選択
while stack:
    p = stack.pop()
    # 子ノードの選択
    for c in node[p]:
        # 親ノードも選択されるので、その場合は飛ばす
        if c != parents[p]:
            # 子ノードの親を自分にする
            parents[c] = p
            # 子ノードのグループを自分と逆に設定する
            group[c] = not group[p]
            stack.append(c)
true_num = sum(map(int, group))
false_num = N - true_num
p = [0] * N
mod_0 = [int(i) for i in range(1,N+1) if i%3 == 0]
mod_1 = [int(i) for i in range(1,N+1) if i%3 == 1]
mod_2 = [int(i) for i in range(1,N+1) if i%3 == 2]

if true_num >= N/3 and false_num >= N/3:
    for i in range(N):
        if group[i]:
            if mod_1:
                p[i] = mod_1.pop(0)
            else:
                p[i] = mod_0.pop(0)
        else:
            if mod_2:
                p[i] = mod_2.pop(0)
            else:
                p[i] = mod_0.pop(0)
elif false_num < N/3:
    for i in range(N):
        if group[i]:
            if mod_1:
                p[i] = mod_1.pop(0)
            elif mod_2:
                p[i] = mod_2.pop(0)
            else:
                p[i] = mod_0.pop(0)
        else:
            p[i] = mod_0.pop(0)
elif true_num < N/3:
    for i in range(N):
        if not group[i]:
            if mod_1:
                p[i] = mod_1.pop(0)
            elif mod_2:
                p[i] = mod_2.pop(0)
            else:
                p[i] = mod_0.pop(0)
        else:
            p[i] = mod_0.pop(0)

print(" ".join(map(str, p)))

Fixed submission:
N = int(input())

node = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    node[a-1].append(b-1)
    node[b-1].append(a-1)

# 頂点1からの距離が奇数:1、偶数:0
group = [False] * N
# 親ノードを格納する
parents = list(range(N))
stack = [0]

# ノードの選択
while stack:
    p = stack.pop()
    # 子ノードの選択
    for c in node[p]:
        # 親ノードも選択されるので、その場合は飛ばす
        if c != parents[p]:
            # 子ノードの親を自分にする
            parents[c] = p
            # 子ノードのグループを自分と逆に設定する
            group[c] = not group[p]
            stack.append(c)

p = [0] * N
three = 3
if group.count(True) <= N // 3:
    other = 1
    # Trueのところには３の倍数を、Falseにはそれ以外を
    for i in range(N):
        if not group[i] and other <= N:
            p[i] = other
            other += other % 3
        else:
            p[i] = three
            three += 3
elif group.count(False) <= N // 3:
    other = 1
    # Trueのところには３の倍数を、Falseにはそれ以外を
    for i in range(N):
        if group[i] and other <= N:
            p[i] = other
            other += other % 3
        else:
            p[i] = three
            three += 3

else:
    one, two = 1, 2
    # Trueのところには３の倍数を、Falseにはそれ以外を
    for i in range(N):
        if not group[i] and one <= N:
            p[i] = one
            one += 3
        elif group[i] and two <= N:
            p[i] = two
            two += 3
        else:
            p[i] = three
            three += 3
print(" ".join(map(str, p)))
Buggy python submission (verdict: Runtime Error):
A, B = [int(i) for i in input().split()]

ans = []

true_A_max = A + 0.999
true_B_max = B + 0.999

X_A = math.floor(A / 0.08)
X_max_A = math.ceil(true_A_max /0.08)
X_B = math.floor(B / 0.1)
X_max_B = math.ceil(true_B_max /0.08)

if X_max_A - X_A >= X_max_B - X_B:
    X_min = X_B
    X_max = X_max_B

else:
    X_min = X_A
    X_max = X_max_A

for X in range(X_min, X_max):
    cal_A = math.floor(X * 0.08)
    cal_B = math.floor(X * 0.1)
    
    if cal_A == A and cal_B == B:
        ans.append(X)
            
if len(ans) > 0:
    print(min(ans))
else:
    print(-1)

Fixed submission:
import math

A, B = [int(i) for i in input().split()]

ans = []

true_A_max = A + 0.999
true_B_max = B + 0.999

X_A = math.floor(A / 0.08)
X_max_A = math.ceil(true_A_max /0.08)
X_B = math.floor(B / 0.1)
X_max_B = math.ceil(true_B_max /0.08)

if X_max_A - X_A >= X_max_B - X_B:
    X_min = X_B
    X_max = X_max_B

else:
    X_min = X_A
    X_max = X_max_A

for X in range(X_min, X_max):
    cal_A = math.floor(X * 0.08)
    cal_B = math.floor(X * 0.1)
    
    if cal_A == A and cal_B == B:
        ans.append(X)
            
if len(ans) > 0:
    print(min(ans))
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Queries = [[j for j in input().split()] for i in range(Q)]

f = 0
for query in Queries:
    if query[0] == "1":
        if f == 0:
            f = 1
        else:
            f = 0
    else:
        if f == 0:
            if query[1] == "1":
                S = query[2] + S
            else:
                S = S + query[2]
        else:
            if query[1] == "2":
                S = query[2] + S
            else:
                S = S + query[2] 
if f == 1:
    S = S[::-1]
print(S)

Fixed submission:
S = input()
Q = int(input())

front = ""
end = ""
f = 0
for i in range(Q):
    query = input().split()

    if query[0] == "1":
        if f == 0:
            f = 1
        else:
            f = 0
    else:
        if f == 0:
            if query[1] == "1":
                front = query[2] + front
            else:
                end = end + query[2]
        else:
            if query[1] == "2":
                front = query[2] + front
            else:
                end = end + query[2]

S = front + S + end
if f == 1:
    S = S[::-1]
print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Queries = [[j for j in input().split()] for i in range(Q)]

for query in Queries:
    if query[0] == "1":
        S = S[::-1]
    else:
        if query[1] == "1":
            S = query[2] + S
        else:
            S = S + query[2]
            
print(S)

Fixed submission:
S = input()
Q = int(input())

front = ""
end = ""
f = 0
for i in range(Q):
    query = input().split()

    if query[0] == "1":
        if f == 0:
            f = 1
        else:
            f = 0
    else:
        if f == 0:
            if query[1] == "1":
                front = query[2] + front
            else:
                end = end + query[2]
        else:
            if query[1] == "2":
                front = query[2] + front
            else:
                end = end + query[2]

S = front + S + end
if f == 1:
    S = S[::-1]
print(S)
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())

S = [input() for i in range(N)]

result = collections.Counter(S)

result_max = sorted([i for i in result.keys() if result[i] == max(result.values())])

for r in result_max:
    print(r)

Fixed submission:
ABC = [int(i) for i in input().split()]

if len(set(ABC)) == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S = input()

if len(S) == 2:
    print(S)
elif len(S) == 3:
    str_list = list(reversed(S))
    new_str = ''.join(list(reversed(org_str)))
    print(new_str)

Fixed submission:
S = input()

if len(S) == 2:
    print(S)
elif len(S) == 3:
    #str_list = list(reversed(S))
    new_str = ''.join(list(reversed(S)))
    print(new_str)
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

total_list = []
count = 0
break_flag = False
for i in range(int(10e100)):
    if break_flag:
        break
    for i in range(A):
        total_list.append("b")
        if len(total_list) <= N:
            count += 1
        else:
            break_flag = True
            break
    for i in range(B):
        total_list.append("r")
        if len(total_list) >= N:
            break_flag = True
            break
    if len(total_list) >= N:
        break

print(count)

Fixed submission:
N, A, B = map(int, input().split())

amari = N % (A + B)
sho = N // (A + B)

blue_num = 0

if amari < A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A

print(blue_num)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

total_list = []
count = 0
for i in range(int(10e100)):
    for i in range(A):
        total_list.append("b")
        if len(total_list) <= N:
            count += 1
        else:
            break
    for i in range(B):
        total_list.append("r")
    if len(total_list) >= N:
        break

print(count)

Fixed submission:
N, A, B = map(int, input().split())

amari = N % (A + B)
sho = N // (A + B)

blue_num = 0

if amari < A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A

print(blue_num)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

total_list = []
count = 0
for i in range(int(10e100)):
    for i in range(A):
        total_list.append("b")
        if len(total_list) <= N:
            count += 1
    for i in range(B):
        total_list.append("r")
    if len(total_list) >= N:
        break

print(count)

Fixed submission:
N, A, B = map(int, input().split())

amari = N % (A + B)
sho = N // (A + B)

blue_num = 0

if amari < A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A

print(blue_num)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

total_list = []
for i in range(int(10e100)):
    for i in range(A):
        total_list.append("b")
    for i in range(B):
        total_list.append("r")
    if len(total_list) >= N:
        break

count = 0
for i in range(N):
    if total_list[i] == 'b':
        count += 1
print(count)

Fixed submission:
N, A, B = map(int, input().split())

amari = N % (A + B)
sho = N // (A + B)

blue_num = 0

if amari < A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A

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

a_list = list(map(int, input().split()))
a_list_2 = list(map(int, input().split()))
a_list_3 = list(map(int, input().split()))

a_total_list = np.array([a_list, a_list_2, a_list_3])
bingo_array = np.zeros((3, 3))

N = int(input())

b_list = []

for i in range(N):
    b = int(input())
    if b in a_total_list:
        bingo_array[np.where(a_total_list == b)[0][0]][np.where(a_total_list == b)[1][0]] = 1

bingo_x_y = 0
break_flag = False
for i in range(3):
    bingo_x = 0
    bingo_y = 0
    if break_flag is True:
        break
    for j in range(3):
        if bingo_array[i][j] == 1:
            bingo_x += 1
        if bingo_x == 3:
            break_flag = True
            break
        if i == 0:
            if bingo_array[j][i] == 1:
                bingo_y += 1
            if bingo_y == 3:
                break_flag = True
                break
        if i == j:
            if bingo_array[i][j] == 1:
                bingo_x_y += 1
            if bingo_x_y == 3:
                break_flag = True
                break

if bingo_x == 3:
    print("Yes")
elif bingo_y == 3:
    print("Yes")
elif bingo_x_y == 3:
    print("Yes")
elif bingo_array[0][2] == 1 and bingo_array[1][1] == 1 and bingo_array[2][0] == 1:
    print("Yes")
else:
    print("No")

Fixed submission:
import numpy as np

a_list = list(map(int, input().split()))
a_list_2 = list(map(int, input().split()))
a_list_3 = list(map(int, input().split()))

a_total_list = np.array([a_list, a_list_2, a_list_3])
bingo_array = np.zeros((3, 3))

N = int(input())

b_list = []

for i in range(N):
    b = int(input())
    if b in a_total_list:
        bingo_array[np.where(a_total_list == b)[0][0]][np.where(a_total_list == b)[1][0]] = 1

bingo_x_y = 0
break_flag = False
for i in range(3):
    if break_flag is True:
        break
    else:
        bingo_x = 0
        bingo_y = 0
    for j in range(3):
        if bingo_array[i][j] == 1:
            bingo_x += 1
            if bingo_x == 3:
                break_flag = True
                break
        if bingo_array[j][i] == 1:
            bingo_y += 1
            if bingo_y == 3:
                break_flag = True
                break
        if i == j:
            if bingo_array[i][j] == 1:
                bingo_x_y += 1
                if bingo_x_y == 3:
                    break_flag = True
                    break

if bingo_x >= 3:
    print("Yes")
    exit()
elif bingo_y >= 3:
    print("Yes")
    exit()
elif bingo_x_y >= 3:
    print("Yes")
    exit()
elif bingo_array[0][2] == 1 and bingo_array[1][1] == 1 and bingo_array[2][0] == 1:
    print("Yes")
    exit()
else:
    print("No")
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
p_list = list(map(int, input().split()))

number_list = []

sum_max = 0
for index, p in enumerate(p_list):
    number_list.append((p * (p + 1)) / 2 / p)
    if index >= K - 1:
        sum_total = sum(number_list[index-(K - 1):index + 1])
        if sum_max < sum_total:
            sum_max = sum_total

print('{:.12f}'.format(float(sum_max)))

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

number_list = []

sum_max = 0
tmp_max = 0
past_max = 0
tmp_max_list = []
for index, p in enumerate(p_list):
    if index >= K:
        tmp_max += (p * (p + 1)) / 2 / p
        tmp_max -= tmp_max_list[index - K]
        if sum_max < tmp_max:
            sum_max = tmp_max
        tmp_max_list.append((p * (p + 1)) / 2 / p)
    else:
        tmp_max += (p * (p + 1)) / 2 / p
        tmp_max_list.append((p * (p + 1)) / 2 / p)

if N == 1:
    print('{:.12f}'.format(float(p_list[0] * (p_list[0] + 1) / 2 / p_list[0])))
elif N == K:
    print('{:.12f}'.format(float(sum(tmp_max_list))))
else:
    print('{:.12f}'.format(float(sum_max)))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
p_list = list(map(int, input().split()))

number_list = []

for p in p_list:
    number_list.append((p * (p + 1)) / 2 / p)

sum_max = 0
for i in range(0, len(number_list)):
    sum_total = sum(number_list[i:i+K])
    if sum_max < sum_total:
        sum_max = sum_total

print('{:.12f}'.format(float(sum_max)))

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

number_list = []

sum_max = 0
tmp_max = 0
past_max = 0
tmp_max_list = []
for index, p in enumerate(p_list):
    if index >= K:
        tmp_max += (p * (p + 1)) / 2 / p
        tmp_max -= tmp_max_list[index - K]
        if sum_max < tmp_max:
            sum_max = tmp_max
        tmp_max_list.append((p * (p + 1)) / 2 / p)
    else:
        tmp_max += (p * (p + 1)) / 2 / p
        tmp_max_list.append((p * (p + 1)) / 2 / p)

if N == 1:
    print('{:.12f}'.format(float(p_list[0] * (p_list[0] + 1) / 2 / p_list[0])))
elif N == K:
    print('{:.12f}'.format(float(sum(tmp_max_list))))
else:
    print('{:.12f}'.format(float(sum_max)))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h_list = list(map(int, input().split()))

sort_h_list = sorted(h_list, reverse=True)
sort_h_list_length = len(sort_h_list)

for i in range(K):
    if i >= sort_h_list_length:
        break
    sort_h_list.pop(0)

print(sum(sort_h_list))

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

sort_h_list = sorted(h_list, reverse=True)
sort_h_list_length = len(sort_h_list)

print(sum(sort_h_list[K:]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
c_list = list(map(int, input().split()))

minus_count = 0
rember_list = []
for i, x in enumerate(c_list):
    if i == 0:
        rember_list.append(x)
        continue
    min_rember = min(rember_list)
    if x > min_rember:
        minus_count += 1
    rember_list.append(x)

print(len(c_list) - minus_count)

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

minus_count = 0
rember_number = 0
for i, x in enumerate(c_list):
    if i == 0:
        rember_number = x
        continue
    else:
        if x < rember_number:
            rember_number = x
        if x > rember_number:
            minus_count += 1

print(len(c_list) - minus_count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
c_list = list(map(int, input().split()))

minus_count = 0
for i, x in enumerate(zip(reversed(c_list))):
    for x2 in zip(reversed(c_list[:-i -1])):
        if x > x2:
            minus_count += 1
            break

print(len(c_list) - minus_count)

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

minus_count = 0
rember_number = 0
for i, x in enumerate(c_list):
    if i == 0:
        rember_number = x
        continue
    else:
        if x < rember_number:
            rember_number = x
        if x > rember_number:
            minus_count += 1

print(len(c_list) - minus_count)
Buggy python submission (verdict: Runtime Error):
N = int(input())

g_list = [[]]
for i in range(N):
    for j in range(N):
        g_list[i][j] = -1

for i in range(N):
    m = int(input())
    for j in range(m):
        a_x = list(map(int, input().split()))
        a = a_x[0]
        a -= 1
        x = a_x[1]
        g_list[i][a] = x

ans = 0

for i in range(1<<N):
    d = [0 for l in range(N)]
    for j in range(N):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(N):
        if d[j]:
            for k in range(N):
                if g_list[j][k] == -1:
                    continue
                if g_list[j][k] != d[k]:
                    ok = False
    if ok:
        total = sum(bin(i)[2:])
        ans = max(ans, total)

print(ans)

Fixed submission:
N = int(input())

g_list = [[-1 for i in range(N)] for j in range(N)]

for i in range(N):
    m = int(input())
    for j in range(m):
        a_x = list(map(int, input().split()))
        a = a_x[0]
        a -= 1
        x = a_x[1]
        g_list[i][a] = x

ans = 0

for i in range(1 << N):
    d = [0 for l in range(N)]
    for j in range(N):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(N):
        if d[j]:
            for k in range(N):
                if g_list[j][k] == -1:
                    continue
                if g_list[j][k] != d[k]:
                    ok = False
    if ok:
        total = list(bin(i)[2:].rjust(N, '0'))
        count = 0
        for t in total:
            if t == '1':
                count += 1
        ans = max(ans, count)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
S = list(str(input()))

length = len(S)

number_list = []
for v in itertools.combinations(S, 3):
    number = ''.join(v)
    number_list.append(number)

uniq_number_list = set(number_list)

print(len(uniq_number_list))

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

X = []
for i in range(10):
    X.append(str(i))

ans = 0
for i in X:
    if i in S:
        T = S[S.index(i) + 1:]
        for j in X:
            if j in T:
                U = T[T.index(j) + 1:]
                for k in X:
                    if k in U:
                        ans += 1

print(ans)