Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03353 (python)

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

n = len(s)

sub = []
alp = [chr(i) for i in range(ord('a'), ord('z')+1)]

for a in alp:
    if a in s:
        start = -1
        while True:
            start = s.find(a, start+1)
            if start==-1:
                break
            for j in range(start+1, min(start+K+1,n+1)):
                if s[start:j] not in sub:
                    sub.append(s[start:j])
    if len(sub) > K:
        break

sub.sort()
print(sub[K-1])

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())

n = len(s)

sub = []
alp = [chr(i) for i in range(ord('a'), ord('z')+1)]

for a in alp:
    if a in s:
        start = -1
        while True:
            start = s.find(a, start+1)
            if start==-1:
                break
            for j in range(start+1, min(start+K,n+1)):
                if s[start:j] not in sub:
                    sub.append(s[start:j])
    if len(sub) > K:
        break

sub.sort()
print(sub[K-1])
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
s = [input() for i in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

ans = True
for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            continue
        else:
            check = True
            for k in range(len(dx)):
                y = i+dy[k]
                x = j+dx[k]
                if x<0 or x>(W-1) or y<0 or y>(H-1):
                    continue
                else:
                    if s[y][x]=='#':
                        check = False
            if check:
                ans = False
                break
    if not ans:
        break

if ans:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [input() for i in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

ans = True
for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            continue
        else:
            check = True
            for k in range(len(dx)):
                x = i+dx[k]
                y = j+dy[k]
                if x<0 or x>(W-1) or y<0 or y>(H-1):
                    continue
                else:
                    if s[x][y]=='#':
                        check = False
            if check:
                ans = False
                break
    if not ans:
        break

if ans:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [input() for i in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

ans = True
for i in range(H):
    for j in range(W):
        if s[i][j]==".":
            continue
        else:
            check = True
            for k in range(len(dx)):
                x = i+dx[k]
                y = j+dy[k]
                if x<0 or x>(W-1) or y<0 or y>(H-1):
                    continue
                else:
                    if s[x][y]=='#':
                        check = False
            if check:
                ans = False
                break
    if not ans:
        break

if ans:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = [input() for i in range(H)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

ans = True
for i in range(W):
    for j in range(H):
        if s[i][j] == '.':
            continue
        else:
            check = True
            for k in range(len(dx)):
                x = i+dx[k]
                y = j+dy[k]
                if x<0 or x>(W-1) or y<0 or y>(H-1):
                    continue
                else:
                    if s[x][y]=='#':
                        check = False
            if check:
                ans = False
                break
    if not ans:
        break

if ans:
    print("Yes")
else:
    print("No")
Problem p03672 (python)

Fixed submission:
S = input()

def check(s):
    n = len(s)
    if n%2 != 0:
        return False
    else:
        s1 = s[:(n//2)]
        s2 = s[(n//2):]
        if s1 == s2:
            return True
        else:
            return False

for i in range(len(S)-1, 0, -1):
    if check(S[:i]):
        ans = len(S[:i])
        break

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()

def check(s):
    n = len(s)
    if n%2 != 0:
        return False
    else:
        s1 = s[:(n//2)]
        s2 = s[(n//2):]
        if s1 == s2:
            return True
        else:
            return False

for i in range(len(S)-1, 0, -2):
    if check(S[:i]):
        ans = len(S[:i])
        break

print(ans)
Problem p02554 (python)

Fixed submission:
N = int(input())
ans = N*(N-1)
mod = 10**9 + 7
ans %= mod
ans = 1
A = 1
B = 1
C = 1
for i in range(N):
    A *= 10
    B *= 9
    C *= 8
    A %= mod
    B %= mod
    C %= mod

print((A-B*2+C) % mod)

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
print(max(a*c, a*d, b*c, b*d))
Problem p02574 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline
    from math import gcd
    N = int(input())
    A = list(map(int, input().split()))
    g = A[0]
    M = max(A)
    X = [i for i in range(M+1)]
    S = [True for i in range(M+1)]
    S[0] = False
    S[1] = False

    for i in range(1, M+1):
        if S[i]:
            for j in range(i, M+1, i):
                if S[j]:
                    S[j] = False
                    X[j] = i
    flag = True
    s = set()
    ls = 0
    for x in A:
        tmp = set()
        while(X[x] != 1):
            tmp.add(X[x])
            x //= X[x]
        l = len(tmp)
        s |= tmp
        if len(s) == ls + l:
            ls += l
            continue
        else:
            flag = False
            break

    if flag:
        print("pairwise coprime")
    else:
        for x in A[1:]:
            g = gcd(g, x)
        if g == 1:
            print("setwise coprime")

        else:
            print("not coprime")


main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    from math import gcd
    N = int(input())
    A = list(map(int, input().split()))
    g = A[0]

    def factorization(n):
        ret = set()
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                ret.add(i)

        if temp != 1:
            ret.add(temp)

        if len(ret) == 0 and n != 1:
            ret.add(n)

        return ret
	flag = False
    s = set()
    for x in A:
      s |= factorization(x)


    if flag:
        print("pairwise coprime")
    elif g == 1:
        print("setwise coprime")

    else:
        print("not coprime")


main()
Problem p02609 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    X = input().decode()
    K = int(X, 2)
    X = list(X)

    def popcount(x):
        # 2bitごとの組に分け、立っているビット数を2bitで表現する
        x = x - ((x >> 1) & 0x5555555555555555)

        # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
        x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

        x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f  # 8bitごと
        x = x + (x >> 8)  # 16bitごと
        x = x + (x >> 16)  # 32bitごと
        x = x + (x >> 32)  # 64bitごと = 全部の合計
        return x & 0x0000007f

    # X = ['']*N
    # for i in range(N):
    #     X[i] = str(random.randint(0, 1))
    # print("".join(X))
    C = X.count("1")
    dpL = [0]*N
    dpR = [0]*N
    tmp = 1
    dpL[0] = 1 % (C+1)
    L = K % (C+1)

    if C == 1:
        R = 0
    else:
        R = K % (C-1)
        dpR[0] = 1 % (C-1)

    for i in range(1, N):
        dpL[i] = dpL[i-1]*2 % (C+1)
        if C > 1:
            dpR[i] = dpR[i-1]*2 % (C-1)

    dp = [0]*N
    dp[0] = 0
    for i in range(1, N):
        k = i % popcount(i)
        dp[i] = 1 + dp[k]

    # def solve(n, d):

    for i in range(N):
        if X[i] == "0":
            print(dp[(L + dpL[N-i-1]) % (C+1)] + 1)
        else:
            if C == 1:
                print(0)
                continue
            X[i] = '0'
            print(dp[(R - dpR[N-i-1]) % (C-1)] + 1)
            #tmp = dp[int((''.join(X)), 2) % (C-1)] + 1
            X[i] = '1'


main()
# print(dp)

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    X = list(input())

    def popcount(x):
        # 2bitごとの組に分け、立っているビット数を2bitで表現する
        x = x - ((x >> 1) & 0x5555555555555555)

        # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
        x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

        x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f  # 8bitごと
        x = x + (x >> 8)  # 16bitごと
        x = x + (x >> 16)  # 32bitごと
        x = x + (x >> 32)  # 64bitごと = 全部の合計
        return x & 0x0000007f

    # X = ['']*N
    # for i in range(N):
    #     X[i] = str(random.randint(0, 1))
    # print("".join(X))
    C = X.count("1")

    dp = [0]*N
    dp[0] = 0
    for i in range(1, N):
        k = i % popcount(i)
        dp[i] = 1 + dp[k]

    # def solve(n, d):

    for i in range(N):
        if X[i] == "0":
            X[i] = '1'
            print(dp[int((''.join(X)), 2) % (C+1)] + 1)
            #tmp = dp[int((''.join(X)), 2) % (C+1)] + 1
            X[i] = '0'
        else:
            if C == 1:
                print(0)
                continue
            X[i] = '0'
            print(dp[int((''.join(X)), 2) % (C-1)] + 1)
            #tmp = dp[int((''.join(X)), 2) % (C-1)] + 1
            X[i] = '1'


main()
# print(dp)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
A, B = map(int(input().split()))
print(A*B)
Problem p02686 (python)

Fixed submission:
N = int(input())
s = [input() for i in range(N)]
S = [[0]*len(s[i]) for i in range(N)]
for i, x in enumerate(s):
    res = []
    q = 0
    for j in range(len(x)):
        if x[j] == ')':
            S[i][j] = -1
        else:
            S[i][j] = 1
s = [0]*N
m = [len(S[i]) for i in range(N)]
for i, x in enumerate(S):
    tmp = 0
    for j in range(len(x)):
        tmp += S[i][j]
        m[i] = min(tmp, m[i])
    s[i] = tmp

if sum(s) == 0:
    sp = [(m[i], s[i]) for i in range(N) if s[i] > 0]
    mp = [(-(s[i]-m[i]), -s[i]) for i in range(N) if s[i] <= 0]#右から見た場合
    sp.sort(key=lambda x: x[0], reverse=True)
    tmp = 0
    for x, y in sp:
        if tmp + x < 0:
            print("No")
            exit(0)
        tmp += y
    mp.sort(key=lambda x: x[0], reverse=True)
    tmp2 = 0
    for x, y in mp:
        if tmp2 + x < 0:
            print("No")
            exit(0)
        tmp2 += y
    print("Yes")

else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [input() for i in range(N)]
S = [[0]*len(s[i]) for i in range(N)]
for i, x in enumerate(s):
    res = []
    q = 0
    for j in range(len(x)):
        if x[j] == ')':
            S[i][j] = -1
        else:
            S[i][j] = 1
s = [0]*N
m = [len(S[i]) for i in range(N)]
for i, x in enumerate(S):
    tmp = 0
    for j in range(len(x)):
        tmp += S[i][j]
        m[i] = min(tmp, m[i])
    s[i] = tmp
if sum(s) == 0:
    ss = [m[i], s[i]) for i in range(N)]
    ss.sort(key=lambda x: (x[1], x[2]), reverse=True)
    tmp = 0
    for x,y in ss:
        for z in x:
            if tmp + x < 0:
                print("No")
                exit(0)
            tmp += y
                    
    print("Yes")

else:
    print("No")
Problem p02702 (python)

Fixed submission:
import collections
S = list(map(int, list(input())))
N = len(S)

dp = [0]*N
if N < 4:
    print(0)
    exit(0)

ans = 0

D = [0]*N
D[0] = 1
for i in range(1, N):
    D[i] = D[i-1]*10 % 2019
t = collections.defaultdict(int)
tmp = 0

t[0] += 1
for i in range(N):
    tmp += S[N-1-i]*D[i]
    tmp %= 2019
    t[tmp] += 1

for x in t:
    ans += t[x]*(t[x]-1) // 2

# print(N)
# print(*dp, sep='\n')

print(ans)

Buggy submission (verdict: Runtime Error):
import collections
S = list(map(int, list(input())))
N = len(S)

dp = [0]*N
if N < 4:
    print(0)
    exit(0)

ans = 0

D = [0]*2019
D[0] = 1
for i in range(1, N):
    D[i] = D[i-1]*10 % 2019
t = collections.defaultdict(int)
tmp = 0
t[0] += 1
for i in range(N):
    tmp += S[N-1-i]*D[i]
    tmp %= 2019
    t[tmp] += 1

for x in t:
    ans += t[x]*(t[x]-1) // 2

# print(N)
# print(*dp, sep='\n')

print(ans)

Buggy submission (verdict: Runtime Error):
S = list(map(int, list(input())))
N = len(S)

dp = [[0]*N for i in range(N)]
if N < 4:
    print(0)
    exit(0)

D = [[0]*N for i in range(9)]
for i in range(9):
    D[i][i] = (i+1)
    for j in range(i+1, N):
        D[i][j] = D[i][j-1]*10 % 2019


print(D)
ans = 0

dp[0] = S[0]
for i in range(1, N):
    dp[i] = (dp[i-1]*10 + S[i]) % 2019
    if dp[i] == 0:
        ans += 1

for i in range(1, N):
    for j in range(i+1, N):
        dp[i] -= D[S[i-1]][j]
        dp[i] %= 2019
        if dp[i] == 0:
            ans += 1

# print(N)
# print(*dp, sep='\n')
print(ans)
Problem p02719 (python)

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

print(min(N % K, K - N % K))

Buggy submission (verdict: Runtime Error):
N = int(input())
tmp = [i for i in range(1, 10)]
ans = list(tmp)
for i in range(10):
    tmp2 = []
    for x in tmp:
        k = int(str(x)[-1])
        if k != 0:
            ans.append(10*x-1 + k)
            tmp2.append(10*x-1 + k)
        if k != 9:
            tmp2.append(10*x+1 + k)
            ans.append(10*x+1 + k)
        tmp2.append(10*x + k)
        ans.append(10*x + k)
    tmp = list(tmp2)

ans.sort()
print(ans[N-1])
Problem p02797 (python)

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

ans = [0]*N
T = 10**9
if T == S:
    T = 10**9 - 1
for i in range(N):
    if i < K:
        ans[i] = S
    else:
        ans[i] = T
print(" ".join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
N,S,K=map(int,input().split())
ans=[S]*N
for i in range(K):
  ans[i]=S+1
print(*ans)

Buggy submission (verdict: Runtime Error):
N,S,K=map(int,input().split())
ans=[S]*K +[S+1]*(N-K)
print(*ans)

Buggy submission (verdict: Runtime Error):
N,S.K=map(int,input().split())
ans=[S]*K +[S+1]*(N-K)
print(*ans)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
N, M = map(int, input().split())
a = list(map(int, input().split()))
k = a[0]
for i in range(1, N):
    k = (a[i]*k) // gcd(a[i], k)
    if k > M*2:
        print(0)
        exit(0)
    k = int(k)
ans = (M - (k // 2)) // k

if M >= (k // 2):
    flag = True
    for i in range(N):
        if (k // a[i]) % 2 == 0:
            print(0)
            exit(0)
    if flag:
        ans += 1

print(int(ans))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N, M = map(int, input().split())
a = list(map(int, input().split()))
k = a[0]
for i in range(1, N):
    k = (a[i]*k) // gcd(a[i], k)
ans = (M+(0.5*k)) // k

print(int(ans))

Buggy submission (verdict: Runtime Error):
import fractions
N, M = map(int, input().split())

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


k = a[0]

for i in range(1, N):
    k = (a[i]*k) // fractions.gcd(a[i], k)
ans = M // k
if (k * 0.5) < M:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
N, M = map(int, input().split())

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


k = a[0]

for i in range(1, N):
    k = (a[i]*k) // fractions.gcd(a[i], k)
ans = 0
if k * 0.5 <= M:
    ans += 1
ans += M // k
print(ans)
Problem p02838 (python)

Fixed submission:


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

ans = 0
mod = 10**9 + 7


b = bin(max(A))

l = len(b) - 2


for j in range(l):
    tmp = 0
    for i in range(N):
        if (A[i] >> j) % 2 == 1:
            tmp += 1

    ans += (2**j) * tmp * (N-tmp)
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    M = max(A)
    L = M.bit_length()
    ans = 0
    mod = 10**9 + 7
    k = [0]*L
    k[0] = 1
    for i in range(1, L):
        k[i] = k[i-1]*2
    for j in range(L):
        count = 0
        for x in A:
            if (x >> j) % 2 == 1:
                count += 1
        ans += count*(N - count)*k[j]
    ans %= mod
    print(ans)


main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

M = max(A)
L = M.bit_length()
ans = 0
mod = 10**9 + 7
k = [0]*L
k[0] = 1
for i in range(1, L):
    k[i] = k[i-1]*2
for j in range(L):
    count = 0
    for x in A:
        if (x >> j) % 2 == 1:
            count += 1
    ans += count*(N - count)*k[j]
    ans %= mod
print(ans)
Problem p02846 (python)

Fixed submission:
from decimal import Decimal
T = tuple(map(Decimal, input().split()))

A = list(map(Decimal, input().split()))
B = list(map(Decimal, input().split()))


ans = 0
if A[0] < B[0]:
    tmp = (A[0], A[1])
    A[0], A[1] = B[0], B[1]
    B[0], B[1] = tmp[0], tmp[1]

a = abs(T[0]*A[0] - T[0]*B[0])

b = T[0]*(B[0]-A[0])+T[1]*(B[1]-A[1])


if b == 0:
    print("infinity")
elif b < 0:
    print(0)
    exit(0)
else:
    ans += 1
    if b > a:
        print(1)
    elif b == a:
        print("infinity")
    else:
        if a % b == 0:
            print((a//b)*2)
        else:
            print((a//b)*2 + 1)

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
T = tuple(map(Decimal, input().split()))

A = list(map(Decimal, input().split()))
B = list(map(Decimal, input().split()))


ans = 0
if A[0] < B[0]:
    tmp = (A[0], A[1])
    A[0], A[1] = B[0], B[1]
    B[0], B[1] = tmp[0], tmp[1]

a = abs(T[0]*A[0] - T[0]*B[0])

b = T[0]*(B[0]-A[0])+T[1]*(B[1]-A[1])


if b == 0:
    print("Infinity")
elif b < 0:
    print(0)
    exit(0)
else:
    ans += 1
    if b > a:
        print(1)
    elif b == a:
        print("infinity")
    else:
        if a % b == 0:
            print(((a//b)*2)
        else:
            print((a//b)*2 + 1)

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
T = tuple(map(Decimal, input().split()))

A = list(map(Decimal, input().split()))
B = list(map(Decimal, input().split()))


ans = 0
if A[0] < B[0]:
    tmp = (A[0], A[1])
    A[0], A[1] = B[0], B[1]
    B[0], B[1] = tmp[0], tmp[1]

a = abs(T[0]*A[0] - T[0]*B[0])

b = T[0]*(B[0]-A[0])+T[1]*(B[1]-A[1])


if b == 0:
    print("Infinity")
elif b < 0:
    print(0)
    exit(0)
else:
    ans += 1
    if b > a:
        print(1)
    elif b == a:
        print("infinity")
    else:
        if a % b == 0:
            print((a*2)//b)
        else:
            print(((a//b)*2 + 1)
Problem p02850 (python)

Fixed submission:
import collections
import sys
input = sys.stdin.readline
N = int(input())
ab = [list(map(int, input().split())) for i in range(N-1)]
eda = [set() for i in range(N)]
for a, b in ab:
    eda[a-1].add(b)
    eda[b-1].add(a)
max_e = 0
for i in range(N-1):
    max_e = max(max_e, len(eda[i]))
id = 0
for i in range(N):
    if len(eda[i]) == max_e:
        id = i

q = collections.deque([(id, 0)])
print(max_e)
d = dict()
for a, b in ab:
    d[(a-1, b-1)] = 0
    d[(b-1, a-1)] = 0
eda2 = [set() for j in range(N)]

g = [set() for i in range(N)]

for a, b in ab:
    g[a-1].add(b-1)
    g[b-1].add(a-1)


while(q):
    x, color = q.popleft()
    i = 1
    for y in g[x]:
        if i == color:
            i += 1
        d[(x, y)] = i
        d[(y, x)] = i
        g[y].remove(x)
        q.append((y, i))
        i += 1

for a, b in ab:
    print(d[(a-1, b-1)])

Buggy submission (verdict: Runtime Error):
import collections
import sys
input = sys.stdin.readline()
N = int(input())

ab = [list(map(int, input().split())) for i in range(N-1)]

eda = [set() for i in range(N)]

for a, b in ab:
    eda[a-1].add(b)
    eda[b-1].add(a)
max_e = 0
for i in range(N-1):
    max_e = max(max_e, len(eda[i]))
id = 0
for i in range(N):
    if len(eda) == max_e:
        id = i

ans = [1]*(N-1)
q = collections.deque()
q.append(id)
print(max_e)
eda2 = [set() for i in range(N)]
for a, b in ab:
    for i in range(1, max_e+1):
        if i not in eda2[a-1] and i not in eda2[b-1]:
            ans = i
            break
    print(ans)
    eda2[a-1].add(i)
    eda2[b-1].add(i)
Problem p02866 (python)

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

N = int(input())
D = list(map(int, input().split()))
mod = 998244353

if 0 in D[1:] or D[0] != 0:
    print(0)
    exit(0)
else:
    num = [0]*max(D)
    for i in range(1, N):
        if D[i] > 0:
            num[D[i]-1] += 1

    ans = 1
    for i in range(1, len(num)):
        ans *= (num[i-1]**num[i]) % mod

    print(ans % mod)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = int(input())
D = list(map(int, input().split()))
mod = 998244353

if D[0] > 0:
    print(0)
else:
    num = [0]*max(D)
    for i in range(1, N):
        if D[i] > 0:
            num[D[i]-1] += 1

ans = 1
for i in range(1, len(num)):
    ans *= (num[i-1]**num[i]) % mod

print(ans % mod)
Problem p02901 (python)

Fixed submission:
N,M=map(int,input().split())
A=[0]*M
import heapq
import collections
from itertools import permutations
table=collections.defaultdict(list)
AC=[[0,0] for i in range(M)]
C=[set() for i in range(M)]
for i in range(M):
  a,b=map(int,input().split())
  AC[i][0]=a
  tmp=set(map(int,input().split()))
  for x in tmp:
    AC[i][1] |= 1<<(x-1)
dp=[10**9]*(2**N)
dp[0]=0

for i in range(1,2**N):
  k=0
  s=set()
  for j in range(1,i):
    if i & j == j:
      dp[i]=min(dp[i],dp[j]+dp[i^j])
  for a,c in AC:
    if c&i == i:
      dp[i]=min(dp[i],a)
  #print(dp[i],bin(i))
  
if dp[-1]==10**9:
  print(-1)
else:
  print(dp[-1])
#print(dp)

  
  
#print(AC)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[0]*M
import collections
table=collections.defaultdict(list)
C=[set() for i in range(M)]
for i in range(M):
  a,b=map(int,input().split())
  A[i]=a
  c=list(map(int,input().split()))
  C[i]=set(c)
  for x in c:
    table[x].append((a,i))

opened=set()
used=set()
for i in range(1,N+1):
  if used & C[i]:
    opened.add(i)
    continue
  table[i].sort(key=lambda x:x[0])
  used.add(table[i][0][1])
  opened.add(i)
ans=0
for x in used:
  ans+=A[x]
print(ans)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
count = 0
for i in range(3):
    if S[i] == T[i]:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
ans=0
tmp=0
for i in range(N-1):
  if H[i]>=H[i+1]:
    tmp+=1
  else:
    tmp=0
  anｓ=max(tmp,ans)
  
print(ans)
Problem p02939 (python)

Fixed submission:
S = input()
ans = []

prev = ""
now = ""
for i in range(len(S)):
    now = now + S[i]
    if now != prev:
        ans.append(now)
        prev = now
        now = ""


print(len(ans))

Buggy submission (verdict: Runtime Error):
S = input()
dp = [-1, -1]*len(S)


def solve(s):
    l = len(s)
    if dp[l-1] != -1:
        return dp[l-1]
    else:

        if l >= 2:
            dp[l-2] = solve(s[:-1])
        else:
            dp[0] = [1, 1]
            return dp[0]
        if s[-1] != s[-2]:
            if dp[l-2][1] == 2 and s[-2] == s[-3]:
                dp[l-1] = [dp[l-2][0] + 1, 2]
            else:
                dp[l-1] = [dp[l-2][0] + 1, 1]
        else:
            if dp[l-2][1] == 2:
                dp[l-1] = [dp[l-2][0] + 1, 1]
            else:
                dp[l-1] = [dp[l-2][0], 2]

        return dp[l-1]


ans = solve(S)
print(ans[0])

Buggy submission (verdict: Runtime Error):
S = input()
dp = [-1, -1]*len(S)


def solve(s):
    l = len(s)
    if dp[l-1] != -1:
        return dp[l-1]
    else:

        if l >= 2:
            dp[l-2] = solve(s[:-1])
        else:
            dp[0] = [1, 1]
            return dp[0]
        if s[-1] != s[-2]:
            if dp[l-2][1] == 2:
                dp[l-1] = [dp[l-2][0] + 1, 2]
            else:
                dp[l-1] = [dp[l-2][0] + 1, 1]
        else:
            if dp[l-2][1] == 2:
                dp[l-1] = [dp[l-2][0] + 1, 1]
            else:
                dp[l-1] = [dp[l-2][0], 2]

        return dp[l-1]


ans = solve(S)
print(ans[0])