Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
X = {i:0 for i in range(-2*N,4*N+2)}
k = 0
while k<K:
    for i in range(1,N+1):
        d = A[i]
        X[2*i-2*d-1] += 1
        X[2*i+2*d+1] -= 1
    for i in range(-2*N+1,4*N+2):
        X[i] += X[i-1]
    X[0]=0
    A = [X[2*i] for i in range(N+1)]
    X = {i:0 for i in range(-2*N,4*N+2)}
    if sum(A)==N*N:
        break
    k += 1
print(*A[1:])

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0
while cnt<K:
    B = [0 for _ in range(N+1)]
    for i in range(N):
        a = A[i]
        B[max(i-a,0)] += 1
        B[min(i+a,N-1)+1] -= 1
    for i in range(1,N+1):
        B[i] += B[i-1]
    A = B[:N]
    flag = 0
    for i in range(N):
        if A[i]<N:
            flag = 1
            break
    if flag==0:break
    cnt += 1
print(*A)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
X = {i:0 for i in range(-2*N,4*N+2)}
k = 0
while k<K:
    for i in range(1,N+1):
        d = A[i]
        X[2*i-2*d-1] += 1
        X[2*i+2*d+1] -= 1
    for i in range(-2*N+1,4*N+2):
        X[i] += X[i-1]
    for i in range(1,N+1):
        A[i] = X[2*i]
    X = {i:0 for i in range(-2*N,4*N+2)}
    cnt = 0
    for i in range(1,N+1):
        cnt += A[i]
    if cnt==N*N:
        break
    k += 1
print(*A[1:])

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0
while cnt<K:
    B = [0 for _ in range(N+1)]
    for i in range(N):
        a = A[i]
        B[max(i-a,0)] += 1
        B[min(i+a,N-1)+1] -= 1
    for i in range(1,N+1):
        B[i] += B[i-1]
    A = B[:N]
    flag = 0
    for i in range(N):
        if A[i]<N:
            flag = 1
            break
    if flag==0:break
    cnt += 1
print(*A)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
X = {i:0 for i in range(-2*N,4*N+2)}
k = 0
while k<K:
    for i in range(1,N+1):
        d = A[i]
        X[2*i-2*d-1] += 1
        X[2*i+2*d+1] -= 1
    for i in range(-2*N+1,4*N+2):
        X[i] += X[i-1]
    for i in range(1,N+1):
        A[i] = X[2*i]
    X = {i:0 for i in range(-2*N,4*N+2)}
    cnt = 0
    for i in range(1,N):
        cnt += A[i]
    if cnt==N*N:
        break
    k += 1
print(*A[1:])

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0
while cnt<K:
    B = [0 for _ in range(N+1)]
    for i in range(N):
        a = A[i]
        B[max(i-a,0)] += 1
        B[min(i+a,N-1)+1] -= 1
    for i in range(1,N+1):
        B[i] += B[i-1]
    A = B[:N]
    flag = 0
    for i in range(N):
        if A[i]<N:
            flag = 1
            break
    if flag==0:break
    cnt += 1
print(*A)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
C = {}
for i in range(N):
    a,b = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
    if b not in C:
        C[b] = 0
    C[b] += 1
C = sorted(list(C.keys()))
if N%2==1:
    k = (N+1)//2
    a = C[k-2]
    b = C[-(k-1)]
    print(b-a+1)
else:
    k = N//2
    a = C[k-2]
    a1 = C[k-1]
    b = C[-(k-1)]
    b1 = C[-(k-1)-1]
    print(b+b1-a-a1+1)
    

Fixed submission:
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
A = sorted([X[i][0] for i in range(N)])
B = sorted([X[i][1] for i in range(N)])
if N%2==1:
    k = (N+1)//2
    a = A[k-1]
    b = B[k-1]
    print(b-a+1)
else:
    a2 = A[N//2-1]+A[N//2]
    b2 = B[N//2-1]+B[N//2]
    print(b2-a2+1)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
cur = A[1]
T = 1
while cur!=1:
    cur = A[cur]
    T += 1
K = K%T
cnt = 0
while cnt<K:
    cur = A[cur]
    cnt += 1
print(cur)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
B = {1:1}
x = A[1]
st = 0
while True:
    if x not in B:
        B[x] = 1
        x = A[x]
    else:
        st = x
        break
x = 1
t = 0
while x!=st:
    x = A[x]
    t += 1
x = st
x = A[x]
T = 1
while x!=st:
    x = A[x]
    T += 1
if K<=t:
    x = 1
    cnt = 0
    while cnt<K:
        x = A[x]
        cnt += 1
    print(x)
else:
    K -= t
    K = K%T
    x = st
    cnt = 0
    while cnt<K:
        x = A[x]
        cnt += 1
    print(x)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
B = [1]
x = A[1]
while x!=1:
    B.append(x)
    x = A[x]
T = len(B)
k = K%T
print(B[k])

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
B = {1:1}
x = A[1]
st = 0
while True:
    if x not in B:
        B[x] = 1
        x = A[x]
    else:
        st = x
        break
x = 1
t = 0
while x!=st:
    x = A[x]
    t += 1
x = st
x = A[x]
T = 1
while x!=st:
    x = A[x]
    T += 1
if K<=t:
    x = 1
    cnt = 0
    while cnt<K:
        x = A[x]
        cnt += 1
    print(x)
else:
    K -= t
    K = K%T
    x = st
    cnt = 0
    while cnt<K:
        x = A[x]
        cnt += 1
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
S = input().strip()
A = [0 for _ in range(len(S))]
A[-1] = int(S[-1])%3
for i in range(2,len(S)+1):
    A[-i] = (A[-i+1]+int(S[-i]))%3
B = [0 for _ in range(len(S))]
B[-1] = int(S[-1])%673
for i in range(2,len(S)+1):
    B[-i] = (int(S[-i])*10**(i-1)+B[-i+1])%673
C = {}
for i in range(len(S)):
    a = A[i]
    b = B[i]
    if (a,b) not in C:
        C[(a,b)] = 0
    C[(a,b)] += 1
if (0,0) in C:
    C[(0,0)] += 1
cnt = 0
for c in C:
    n = C[c]
    cnt += (n*(n-1))//2
print(cnt)

Fixed submission:
S = input().strip()
A = [0 for _ in range(len(S))]
A[-1] = int(S[-1])%3
for i in range(2,len(S)+1):
    A[-i] = (A[-i+1]+int(S[-i]))%3
B = [0 for _ in range(len(S))]
B[-1] = int(S[-1])%673
a = 1
for i in range(2,len(S)+1):
    a = (a*10)%673
    B[-i] = (int(S[-i])*a+B[-i+1])%673
C = {}
for i in range(len(S)):
    a = A[i]
    b = B[i]
    if (a,b) not in C:
        C[(a,b)] = 0
    C[(a,b)] += 1
if (0,0) in C:
    C[(0,0)] += 1
cnt = 0
for c in C:
    n = C[c]
    cnt += (n*(n-1))//2
print(cnt)
Buggy python submission (verdict: Runtime Error):
def rn(x):
    z = list(map(int,list(str(x))))
    N = len(z)
    z.insert(0,0)
    dp = [[[0 for _ in range(10)] for _ in range(2)] for _ in range(N+1)]
    dp[1][0][z[1]]=1
    for j in range(z[1]):
        cp[1][1][j]=1
    for i in range(2,N+1):
        if abs(z[i]-z[i-1])<=1:
            dp[i][0][z[i]] = 1
        for j in range(10):
            dp[i][1][j] = dp[i-1][0][z[i-1]]*int(j<z[i])*int(abs(j-z[i-1])<=1)
            for k in range(10):
                dp[i][1][j] += dp[i-1][1][k]*int(abs(j-k)<=1)
    cnt = dp[N][0][z[N]]
    for j in range(10):
        cnt += dp[N][1][j]
    return cnt
K = int(input())
high = 3234566667
low = 0
while high-low>1:
    mid = (high+low)//2
    if rn(mid)>=K:
        high = mid
    else:
        low = mid
print(high)

Fixed submission:
def f(N): # N is string
    k = len(N)
    dp = [[[[0 for _ in range(10)] for _ in range(2)] for _ in range(2)] for _ in range(k+1)]
    for j in range(10):
        dp[1][0][0][j]=(j==int(N[0]))
        dp[1][0][1][j]=0
        dp[1][1][0][j]=(j<int(N[0]))
        dp[1][1][1][j]=0
    for i in range(2,k+1):
        for j in range(10):
            for m in range(10):
                dp[i][0][1][j] += (dp[i-1][0][0][m]+dp[i-1][0][1][m])*(abs(m-j)<=1)*(j==int(N[i-1]))
            dp[i][1][0][j]=1
            for m in range(10):
                dp[i][1][1][j] += (dp[i-1][0][0][m]+dp[i-1][0][1][m])*(abs(m-j)<=1)*(j<int(N[i-1]))\
                                    +dp[i-1][1][1][m]*(abs(m-j)<=1)
            for m in range(1,10):
                dp[i][1][1][j] += dp[i-1][1][0][m]*(abs(m-j)<=1)
    cnt = 0
    for j in range(10):
        cnt += dp[k][0][0][j]+dp[k][0][1][j]+dp[k][1][0][j]+dp[k][1][1][j]
    return cnt-1
K = int(input())
low = 0
high = 4*10**9
while high-low>1:
    mid = (high+low)//2
    n = f(str(mid))
    if n<K:
        low = mid
    elif n>=K:
        high = mid
print(high)
Buggy python submission (verdict: Runtime Error):
for x in product((0,1),repeat=H-1):
    cur = 0
    cnt = 0
    h = sum(x)+1
    A = [0 for _ in range(h)]
    flag = 0
    for j in range(W):
        ind = 0
        A0 = [0 for _ in range(h)]
        for i in range(H):
            if i<H-1 and x[i]==1:
                A0[ind] += S[i][j]
                ind += 1
            else:
                A0[ind] += S[i][j]
        B = [A[i]+A0[i] for i in range(h)]
        if j==0 and max(B)>K:
            flag = 1
            break
        if max(B)>K:
            cur = j
            cnt += 1
            A = A0[:]
        else:
            A = B[:]
    if flag ==0:
        cmin = min(cmin,cnt+sum(x))
print(cmin)  

Fixed submission:
from itertools import product
INFTY = 10**4
H,W,K = map(int,input().split())
S = [list(map(int,list(input()))) for _ in range(H)]
cmin = INFTY
for x in product((0,1),repeat=H-1):
    cur = 0
    cnt = 0
    h = sum(x)+1
    A = [0 for _ in range(h)]
    for j in range(W):
        ind = 0
        A0 = [0 for _ in range(h)]
        for i in range(H):
            if i<H-1 and x[i]==1:
                A0[ind] += S[i][j]
                ind += 1
            else:
                A0[ind] += S[i][j]
        B = [A[i]+A0[i] for i in range(h)]
        if max(A0)>K:
            cnt = INFTY
            break
        if max(B)>K:
            cur = j
            cnt += 1
            A = A0[:]
        else:
            A = B[:]
    cmin = min(cmin,cnt+sum(x))
print(cmin)
Buggy python submission (verdict: Runtime Error):
from collections import deque
D1 = {i:chr(i+96) for i in range(1,27)}
D2 = {val:key for key,val in D1.items()}

N = int(input())
heap = deque([(D[1],1)])
A = []
while heap:
    a,n = heap.popleft()
    if n<N:
        j = D2[a[-1]]
        for i in range(1,min(j+1,26)+1):
            heap.append((a+D1[i],n+1))
    if n==N:
        A.append(a)
A = sorted(A)
for i in range(len(A)):
    print(A[i])

Fixed submission:
from itertools import combinations
def g(i):
    return chr(i+96)
def f(n,i):
    global Ind
    if n==0:
        B.append("".join(A))
        return
    if n==1:
        j = Ind.pop()
        A[j] = g(i)
        B.append("".join(A))
        A[j]=0
        Ind.append(j)
        Ind = sorted(Ind)
        return
    j0 = Ind.pop(0)
    Ind1 = Ind[:]
    A[j0] = g(i)
    for k in range(n):
        for x in combinations(Ind1,n-1-k):
            tmp = []
            for j in range(n-1-k):
                A[x[j]] = g(i)
                tmp.append(x[j])
            for j in tmp:
                Ind.remove(j)
            f(k,i+1)
            for j in tmp:
                A[j] = 0
                Ind.append(j)
            Ind = sorted(Ind)
    Ind.append(j0)
    Ind = sorted(Ind)
    
N = int(input())
A = [0 for _ in range(N)]
Ind = list(range(N))
B = []
f(N,1)
B = sorted(B)
for b in B:
    print(b)

Buggy python submission (verdict: Runtime Error):
from itertools import combinations
def g(i):
    return chr(i+96)
def f(n,i):
    global Ind
    if n==0:
        B.append("".join(A))
        return
    if n==1:
        j = Ind.pop()
        A[j] = g(i)
        B.append("".join(A))
        A[j]=0
        Ind.append(j)
        Ind = sorted(Ind)
        return
    j = Ind.pop(0)
    A[j] = g(i)
    for k in range(n):
        for x in combinations(Ind,n-1-k):
            tmp = []
            for j in range(n-1-k):
                A[x[j]] = g(i)
                tmp.append(x[j])
            for j in tmp:
                Ind.remove(j)
            f(k,i+1)
            for j in tmp:
                A[j] = 0
                Ind.append(j)
            Ind = sorted(Ind)
    
N = int(input())
A = [0 for _ in range(N)]
Ind = list(range(N))
B = []
f(N,1)
B = sorted(B)
for b in B:
    print(b)

Fixed submission:
from itertools import combinations
def g(i):
    return chr(i+96)
def f(n,i):
    global Ind
    if n==0:
        B.append("".join(A))
        return
    if n==1:
        j = Ind.pop()
        A[j] = g(i)
        B.append("".join(A))
        A[j]=0
        Ind.append(j)
        Ind = sorted(Ind)
        return
    j0 = Ind.pop(0)
    Ind1 = Ind[:]
    A[j0] = g(i)
    for k in range(n):
        for x in combinations(Ind1,n-1-k):
            tmp = []
            for j in range(n-1-k):
                A[x[j]] = g(i)
                tmp.append(x[j])
            for j in tmp:
                Ind.remove(j)
            f(k,i+1)
            for j in tmp:
                A[j] = 0
                Ind.append(j)
            Ind = sorted(Ind)
    Ind.append(j0)
    Ind = sorted(Ind)
    
N = int(input())
A = [0 for _ in range(N)]
Ind = list(range(N))
B = []
f(N,1)
B = sorted(B)
for b in B:
    print(b)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,M,K = map(int,input().split())
F = {i:set() for i in range(1,N+1)}
B = {i:set() for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    F[a].add(b)
    F[b].add(a)
for _ in range(K):
    c,d = map(int,input().split())
    B[c].add(d)
    B[d].add(c)
A = []
hist = [-1 for _ in range(N+1)]
cnt = -1
for i in range(1,N+1):
    if hist[i]<0:
        cnt += 1
        A1 = set()
        que = deque([i])
        hist[i] = cnt
        A1.add(i)
        while que:
            x = que.popleft()
            for y in F[x]:
                if hist[y]<0:
                    A1.add(y)
                    que.append(y)
                    hist[y]=cnt
        A.append(A1)
C = []
for i in range(1,N+1):
    cnt = hist[i]
    C.append(len(A[cnt]-F[i]-B[i])-1)
print(*C)   

Fixed submission:
def rt(x):
    while x!=T[x][0]:
        x = T[x][0]
    return x
N,M,K = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
D = {i:[] for i in range(1,N+1)}
for _ in range(K):
    c,d = map(int,input().split())
    D[c].append(d)
    D[d].append(c)
T = {i:[i,0] for i in range(1,N+1)}
for a in G:
    for b in G[a]:
        r1 = rt(a)
        r2 = rt(b)
        if r1!=r2:
            if T[r1][1]>=T[r2][1]:
                T[r2][0] = r1
                if T[r1][1]==T[r2][1]:
                    T[r1][1] += 1
            else:
                T[r1][0] = r2
C = {}
for i in range(1,N+1):
    rt1 = rt(i)
    if rt1 not in C:
        C[rt1] = 0
    C[rt1] += 1
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    rt1 = rt(i)
    numc = C[rt1]
    numd = len(G[i])
    B[i] = numc-1-numd
    for j in D[i]:
        if rt(j)==rt1:
            B[i] -= 1
print(*B[1:])
Buggy python submission (verdict: Runtime Error):
N = int(input())
C = {}
for _ in range(N):
    s = input().strip()
    if s not in C:
        C[s] = 0
    C[s] += 1
C = sorted(list(C.items()),key=lambda x:x[0])
C = sorted(C,key=lambda x:x[1],reverse=True)
k = C[0][1]
for i in range(N):
    if C[i][1]==k:
        print(C[i][0])
    else:break


Fixed submission:
N = int(input())
C = {}
for _ in range(N):
    s = input().strip()
    if s not in C:
        C[s] = 0
    C[s] += 1
C = sorted(list(C.items()),key=lambda x:x[0])
C = sorted(C,key=lambda x:x[1],reverse=True)
k = C[0][1]
for i in range(len(C)):
    if C[i][1]==k:
        print(C[i][0])
    else:break
Buggy python submission (verdict: Runtime Error):
S = input().strip()
dp = [[INFTY for _ in range(2)] for _ in range(len(S))]
for k in range(10):
    n = int(S[-1])
    if k>= n:
        dp[0][0] = min(dp[0][0],2*k-n)
    else:
        dp[0][1] = min(dp[0][1],2*k-n+10)
for i in range(1,len(S)):
    n = int(S[-(1+i)])
    for k in range(10):
        if k>n:
            dp[i][0] = min(dp[i][0],2*k-n+dp[i-1][0],k+(k-1)-n+dp[i-1][1])
        elif k==n:
            dp[i][0] = min(dp[i][0],2*k-n+dp[i-1][0])
            if n==0:
                dp[i][1] = min(dp[i][1],k+(k-1)%10-n+dp[i-1][1])
            else:
                dp[i][1] = min(dp[i][1],k+10-n+k-1+dp[i-1][1])
        elif k<n:
            dp[i][1] = min(dp[i][1],k+10-n+k+dp[i-1][0],k+10-n+k-1+dp[i-1][1])
print(min(dp[len(S)-1][0],dp[len(S)-1][1]+1))

Fixed submission:
S = input().strip()
INFTY=10**8
dp = [[INFTY for _ in range(2)] for _ in range(len(S))]
for k in range(10):
    n = int(S[-1])
    if k>= n:
        dp[0][0] = min(dp[0][0],2*k-n)
    else:
        dp[0][1] = min(dp[0][1],2*k-n+10)
for i in range(1,len(S)):
    n = int(S[-(1+i)])
    for k in range(10):
        if k>n:
            dp[i][0] = min(dp[i][0],2*k-n+dp[i-1][0],k+(k-1)-n+dp[i-1][1])
        elif k==n:
            dp[i][0] = min(dp[i][0],2*k-n+dp[i-1][0])
            if n==0:
                dp[i][1] = min(dp[i][1],k+(k-1)%10-n+dp[i-1][1])
            else:
                dp[i][1] = min(dp[i][1],k+10-n+k-1+dp[i-1][1])
        elif k<n:
            dp[i][1] = min(dp[i][1],k+10-n+k+dp[i-1][0],k+10-n+k-1+dp[i-1][1])
print(min(dp[len(S)-1][0],dp[len(S)-1][1]+1))
Buggy python submission (verdict: Runtime Error):
A = list(map(int,list(input())))
N = len(A)
K = int(input())
dp = [[[[0 for _ in range(100)]] for _ in range(2)] for _ in range(N+1)]
dp[1][0][1] = 1
for i in range(2,N+1):
    for j in range(100):
        dp[i][1][j] = dp[i-1][1][j-1]*9
        if A[i-1]==0:
            dp[i][0][j] = dp[i-1][0][j]
        else:
            dp[i][0][j] = dp[i-1][0][j-1]
            dp[i][1][j] += dp[i-1][0][j-1]*(A[i-1]-1)*(A[i-1]>1)+dp[i-1][0][j]*(A[i-1]==1)
print(dp[N][0][K]+dp[N][1][K])

Fixed submission:
N = input().strip()
n = len(N)
A = [0 for _ in range(n)]
A[0]=1
for i in range(1,n):
    if N[i]=="0":
        A[i] = A[i-1]
    else:
        A[i] = A[i-1]+1
K = int(input())
if K>n:
    print(0)
else:
    dp = [[[0 for _ in range(n+1)] for _ in range(2)] for _ in range(n+1)]
    dp[0][0][0] = 1
    for i in range(1,n+1):
        for k in range(n+1):
            if k==A[i-1]:
                dp[i][0][k] = 1
                break
    for i in range(1,n+1):
        for k in range(n+1):
            dp[i][1][k] = dp[i-1][1][k]
            if int(N[i-1])>0:
                dp[i][1][k] += dp[i-1][0][k]
            if k>=1:
                dp[i][1][k] += dp[i-1][1][k-1]*9
                if i==1 and k-1==0 and int(N[i-1])>=2:
                    dp[i][1][k] += dp[i-1][0][k-1]*(int(N[i-1])-1)
                elif i>=2 and k-1==A[i-2] and int(N[i-1])>=2:
                    dp[i][1][k] += dp[i-1][0][k-1]*(int(N[i-1])-1)
    print(dp[n][0][K]+dp[n][1][K])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
for i in range(1,N+1):
    a = str(i)
    a0 = a[0]
    an = a[-1]
    if an=="0":continue
    k = 0
    while eval(an+"9"*k+a0)<=N:
        cnt += 10**k
        k += 1
    for j in range(10**k):
        b = str(j)
        b = "0"*(k-len(b))+b
        if eval(an+b+a0)<=N:
            cnt += 1
    if a0==an and int(a0)<=N:
        cnt += 1
print(cnt)

Fixed submission:
def f(x):
    if 1<=x<=9:
        return 1
    if x%10==0:
        return 0
    x = str(x)
    a = x[0]
    b = x[-1]
    k = len(x)
    if int(a)<int(b):
        if k==2:
            return 0
        else:
            return 2*(10**(k-2)-1)//9
    elif int(a)>int(b):
        return 2*(10**(k-1)-1)//9
    else:
        if k==2:
            return 3
        else:
            return (1+(10**(k-2)-1)//9+int(x[1:k-1]))*2+1

N = int(input())
dp = [0 for _ in range(N+1)]
for i in range(min(N,9)+1):
    dp[i] = i
for i in range(10,N+1):
    dp[i] = dp[i-1]+f(i)
print(dp[N])
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [0 for _ in range(N+1)]
B = [0 for _ in range(N+1)]
for _ in range(M):
    p,S = input().split()
    p = int(p)
    if S=="AC":
        if A[p]==0:
            A[p]=1
    else:
        if A[p]==0:
            B[p] += 1
for i in range(N+1):
    if A[p]==0:
        B[p]=0
print(sum(A),sum(B))

Fixed submission:
N,M = map(int,input().split())
C = {str(i):[0,0] for i in range(1,N+1)}
for _ in range(M):
    p,s = input().split()
    if s == "AC":
        if C[p][0]==0:
            C[p][0] = 1
    else:
        if C[p][0]==0:
            C[p][1] += 1
A = [0,0]
for i in range(1,N+1):
    if C[str(i)][0]==1:
        A[0] += 1
        A[1] += C[str(i)][1]
print(*A)
Buggy python submission (verdict: Runtime Error):
from itertools import permutations
N = int(input())
P = tuple(list(map(int,input().split())))
Q = tuple(list(map(int,input().split())))
cnt = 0
for x in permutations(range(1,N+1),N):
    if P==x:
        indP = cnt
    elif Q==x:
        indQ = cnt
    cnt += 1
print(abs(indP-indQ))

Fixed submission:
from itertools import permutations
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
A = []
for x in permutations(range(1,N+1),N):
    A.append(list(x))
A = sorted(A)
indP = A.index(P)
indQ = A.index(Q)
print(abs(indP-indQ))
Buggy python submission (verdict: Runtime Error):
cd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,M = map(int,input().split())
A = list(set(list(map(int,input().split()))))
B = []
for i in range(len(A)):
    B.append((A[i]//2)%2)
B = list(set(B))
if len(B)==2:
    print(0)
else:
    a = A[0]
    for i in range(1,len(A)):
        a = gcd(a,A[i])
    b = a
    for x in A:
        b *= x//a
    if B[0]==1:
        k = (M-b//2)//b
        print(k+1)
    else:
        A = sorted(A)
        flag = 1
        for i in range(1,len(A)):
            if A[i]%A[i-1]!=0:
                flag = 0
                break
        if flag==1:
            k = (M-b//2)//b
            print(k+1)
        else:
            print(0)
        

Fixed submission:
def eveCheck(a):
    k = 0
    while a%2==0:
        a = a//2
        k += 1
    return k
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,M = map(int,input().split())
A = list(map(int,input().split()))
k = eveCheck(A[0])
flag = 0
for i in range(1,N):
    if k!=eveCheck(A[i]):
        flag = 1
        break
if flag==1:
    print(0)
else:
    m = A[0]
    for i in range(1,N):
        m = m*(A[i]//gcd(m,A[i]))
    a = m//2
    print((M-a)//m+1)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
INFTY = 10**5
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
X = int(input())
ind = bisect_left(Q,X)
print(Q[ind])

Fixed submission:
from bisect import bisect_left
INFTY = 10**5+10
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
X = int(input())
ind = bisect_left(Q,X)
print(Q[ind])

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_right
INFTY = 10**5
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
X = int(input())
ind = bisect_right(Q,X)
print(Q[ind])

Fixed submission:
from bisect import bisect_left
INFTY = 10**5+10
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
X = int(input())
ind = bisect_left(Q,X)
print(Q[ind])

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_right
INFTY = 10**5
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
X = int(input())
ind = bisect_right(Q,X)
print(Q[ind])

Fixed submission:
from bisect import bisect_left
INFTY = 10**5+10
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
X = int(input())
ind = bisect_left(Q,X)
print(Q[ind])