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

Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(10**9)
N,M = map(int,input().split())

d = defaultdict(lambda:[])

for _ in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    d[x].append(y)

dp = [-1]*N

def dist(s):
    if dp[s] >= 0:
        return dp[s]
    if d[s] == []:
        dp[s] = 0
        return 0
    res = 0
    for t in d[s]:
        res = max(res,1+dist(t))
    dp[s] = res
    return res

ans = 0
for i in range(N):
    ans = max(ans,dist(i))

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys
sys.setrecursionlimit(10**10)
N,M = map(int,input().split())

d = defaultdict(lambda:[])

for _ in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    d[x].append(y)

dp = [-1]*N

def dist(s):
    if dp[s] >= 0:
        return dp[s]
    if d[s] == []:
        dp[s] = 0
        return 0
    res = 0
    for t in d[s]:
        res = max(res,1+dist(t))
    dp[s] = res
    return res

ans = 0
for i in range(N):
    ans = max(ans,dist(i))

print(ans)

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

d = defaultdict(lambda:[])

for _ in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    d[x].append(y)

dp = [-1]*N

def dist(s):
    if dp[s] >= 0:
        return dp[s]
    if d[s] == []:
        dp[s] = 0
        return 0
    res = 0
    for t in d[s]:
        res = max(res,1+dist(t))
    dp[s] = res
    return res

ans = 0
for i in range(N):
    ans = max(ans,dist(i))

print(ans)
Problem p03171 (python)

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

dp = [[0]*(N+1) for _ in range(N+1)]

for i in range(N-1, -1, -1):
    for j in range(i, N):
        dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1])

print(dp[0][N-1])

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

cum = [0]*(N+1)
for i in range(N):
    cum[i] = cum[i-1]+a[i]

dp = [[-1]*N for _ in range(N)]
for i in range(N):
    dp[i][i] = a[i]

def cal(i,j):
    if dp[i][j] == -1:
        dp[i][j] = cum[j]-cum[i-1]-min(cal(i+1,j),cal(i,j-1))
    return dp[i][j]

print(2*cal(0,N-1)-cum[N-1])
Problem p03216 (python)

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

def cal(k):
    M = 0
    C = 0
    MC = 0
    res = 0
    k = min(k,N)
    for i in range(k):
        if S[i] == 'M':
            M += 1
        elif S[i] == 'C':
            C += 1
            MC += M
    for i in range(N-k):
        if S[i] == 'D':
            res += MC
        elif S[i] == 'M':
            M -= 1
            MC -= C
        elif S[i] == 'C':
            C -= 1
        if S[i+k] == 'M':
            M += 1
        elif S[i+k] == 'C':
            C += 1
            MC += M
    for i in range(N-k,N):
        if S[i] == 'D':
            res += MC
        elif S[i] == 'M':
            M -= 1
            MC -= C
        elif S[i] == 'C':
            C -= 1

    return res

Q = int(input())
K = list(map(int,input().split()))
for k in K:
    print(cal(k))

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

while S[0] != 'D':
    S = S[1:]
S = S[::-1]
while S[0] != 'C':
    S = S[1:]
S = S[::-1]

N = len(S)
D = []
C = []
M = [0]*N
for i in range(1,N):
    M[i] = M[i-1]
    if S[i] == 'M':
        M[i] += 1
    elif S[i] == 'D':
        D.append(i)
    elif S[i] == 'C':
        C.append(i)

def cal(k): 
    j = 0
    c = C[0]
    nc = len(C)
    res = 0
    for i in range(len(D)):
        a = D[i]
        while c-a < k:
            res += M[c]-M[a]
            if j < nc-1:
                j += 1
                c = C[j
            else:
                break
    return res

Q = int(input())
K = list(map(int,input().split()))
for k in K:
    print(cal(k))

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

while S[0] != 'D':
    S = S[1:]
S = S[::-1]
while S[0] != 'C':
    S = S[1:]
S = S[::-1]

N = len(S)
D = []
C = []
M = [0]*N
for i in range(1,N):
    M[i] = M[i-1]
    if S[i] == 'M':
        M[i] += 1
    elif S[i] == 'D':
        D.append(i)
    elif S[i] == 'C':
        C.append(i)

def cal(k): 
    j = 0
    c = C[0]
    nc = len(C)
    res = 0
    for i in range(len(D)):
        a = D[i]
        while c-a < k:
            res += M[c]-M[a]
            if j < nc:
                j += 1
                c = C[j]
    return res

Q = int(input())
K = list(map(int,input().split()))
for k in K:
    print(cal(k))
Problem p03218 (python)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
Mod = 998244353

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

a.sort()

ans = 1
for i in range(N):
    ans *= gcd(a[i],i)
    ans %= Mod

print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input()))
print(min(a))
Problem p03224 (python)

Fixed submission:
N = int(input())
Nlist = [k*(k-1)//2 for k in range(10**3)]
if N not in Nlist:
    print('No')
    exit()
print('Yes')
k = Nlist.index(N)
S = [[0]*i for i in range(k)]
S[0] = [i+1 for i in range(k-1)]
for i in range(k-1):
    S[i+1] = [S[j][i] for j in range(i+1)]
    S[i+1] += [S[i][k-2]+j+1 for j in range(k-1-(i-1))]
print(k)
S = [[str(S[i][j]) for j in range(k-1)] for i in range(k)]
for i in range(k):
    print(' '.join([str(k-1)]+S[i]))

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    print('Yes')
    print('1 1')
    print('1 1)
elif N == 3:
    print('Yes')
    print('2 1 2')
    print('2 3 1')
    print('2 2 3')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 1:
  print('Yes')
  print('1 1')
  print('1 1)
elif N == 3:
  print('Yes')
  print('2 1 2')
  print('2 3 1')
  print('2 2 3')
else:
  print('No')
Problem p03233 (python)

Fixed submission:
N = int(input())
A = []
B = []
Sa = 0
Sb = 0
for i in range(N):
    a,b = map(int,input().split())
    A.append([a,i])
    B.append([b,i])
    Sa += a
    Sb += b
C = sorted(A+B)
ind = []
ans = 0
for i in range(N):
    ind.append(C[i][1])
    ans += C[i][0]
ind = set(ind)
if len(ind) == N:
    if C[N-1][1] != C[N][1]:
        ans += C[N][0]-C[N-1][0]
    else:
        ans += min(C[N][0]-C[N-2][0],C[N+1][0]-C[N-1][0])
ans = min(Sa,Sb,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
C = [list(map(int,input().split())) for i in range(N)]
C.sort()
ans0 = 0
ans1 = 0
ans2 = 0
AM = []
Am = []
BM = []
Bm = []
for i in range(N):
    ans0 += C[i][0]
    ans1 += C[i][1]
    Min = min(C[i][0],C[i][1])
    Max = max(C[i][0],C[i][1])
    ans2 += Min
    if Min == C[i][0]:
        Am.append(C[i][0])
        BM.append(C[i][1])
    else:
        AM.append(C[i][0])
        Bm.append(C[i][1])
ans3 = sum(sorted(A+B)[:N])
if ans3 == ans2:
    ans3 += min(min(AM)-max(Am),min(BM)-max(Bm))
    
ans = min(ans0,ans1,ans3)
print(ans)
Problem p03263 (python)

Fixed submission:
H,W = map(int,input().split())
a = [list(map(int,input().split())) for i in range(H)]
def next(i,j):
    if i%2==0:
        if j == W-1:
            return i+1,j
        else:
            return i,j+1
    else:
        if j == 0:
            return i+1,j
        else:
            return i,j-1
ans = []
i,j = 0,0
while True:
    i_,j_ = next(i,j)
    if i_ == H:
        break
    if a[i][j]%2==1:
        a[i][j] -= 1
        a[i_][j_] += 1
        ans.append('{} {} {} {}'.format(i+1,j+1,i_+1,j_+1))
    i,j = i_,j_
print(len(ans))
for s in ans:
    print(s)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
a = [list(map(int,input().split())) for i in range(H)]
def next(i,j):
    if i%2==0:
        if j == W-1:
            return i+1,j
        else:
            return i,j+1
    else:
        if j == 0:
            return i+1,j
        else:
            return i,j-1
ans = []
i,j = 0,0
while i < H:
    i_,j_ = next(i,j)
    if a[i][j]%2==1:
        a[i][j] -= 1
        a[i_][j_] += 1
        ans.append('{} {} {} {}'.format(i+1,j+1,i_+1,j_+1))
    i,j = i_,j_
print(len(ans))
for s in ans:
    print(s)
Problem p03283 (python)

Fixed submission:
import numpy as np
N,M,Q = map(int,input().split())
c = [[0]*(N+1) for i in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    c[l][r] += 1
c = np.cumsum(np.cumsum(c,axis=0),axis=1)
for i in range(Q):
    p,q = map(int,input().split())
    print(c[q][q]-c[q][p-1]-c[p-1][q]+c[p-1][p-1])

Buggy submission (verdict: Runtime Error):
mport bisect
from collections import defaultdict
N,M,Q = map(int,input().split())
lr = [tuple(map(int,input().split())) for i in range(M)]
pq = [tuple(map(int,input().split())) for i in range(Q)]
lr.sort()
l = [lr[i][0] for i in range(M)]
r = [lr[i][1] for i in range(M)]

l_I = {}
for p in range(1,N+1):
    l_I[p] = bisect.bisect_left(l,p)

r_d = {}
for i in range(1,N+1):
    r_d[i] = sorted(r[l_I[i]:])
ans = defaultdict(lambda:{})
for p in range(1,N+1):
    for q in range(p,N+1):
        ans[p][q] = bisect.bisect(r_d[p],q)
for i in range(Q):
    p,q = pq[i]
    print(ans[p][q])

Buggy submission (verdict: Runtime Error):
import bisect
import numpy as np
N,M,Q = map(int,input().split())
lr = [0]*M
for i in range(M):
    l,r = map(int,input().split())
    lr[i] = [l,r]
lr = sorted(lr,key=lambda x:x[0])
lr_t = list(np.array(lr).transpose())
index_dict={}
r_dict={} 
d = {}
for i in range(N):
    index_dict[i+1]=bisect.bisect_left(lr_t[0],i+1)
    r_dict[i+1]=sorted(lr_t[1][index_dict[i+1]:])
for i in range(Q):
    p,q = map(int,input().split())
    if p not in d:
        d[p]={}
        I = index_dict[p]
        r = r_dict[p]
        I = bisect.bisect(r,q)
        print(I)
        d[p][q]=I
    else:
        if q not in d[p]:
            I = index_dict[p]
            r = r_dict[p]
            I = bisect.bisect(r,q)
            print(I)
            d[p][q]=I
        else:
            print(d[p][q])
Problem p03310 (python)

Fixed submission:
INF = float('inf')
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))
S = [0]*N
for i in range(N):
    S[i] = S[i-1]+A[i]

ans = INF
for i in range(2,N-1):
    j = bisect(S,S[i-1]/2)
    k = bisect(S,(S[-1]+S[i-1])/2)
    for p in {j-1,min(j,i-2)}:
        for q in {k-1,i,min(k,N-2)}:
            a,b,c,d = S[p],S[i-1]-S[p],S[q]-S[i-1],S[-1]-S[q]
            m = min(a,b,c,d)
            M = max(a,b,c,d)
            ans = min(ans,M-m)

print(ans)

Buggy submission (verdict: Runtime Error):
INF = float('inf')
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))
S = [0]*N
for i in range(N):
    S[i] = S[i-1]+A[i]

ans = INF
i = bisect(S,S[-1]/2)
for I in {min(i,N-2),min(i+1,N-2)}:
    l = S[:I]
    r = S[I:]
    j = bisect(l,l[-1]/2)
    k = bisect(r,(r[-1]+l[-1])/2)
    for p in {j-1,min(j,i-2)}:
        for q in {k-1,min(k,N-i-2)}:
            a,b,c,d = l[p],l[-1]-l[p],r[q]-l[-1],r[-1]-r[q]
            m = min(a,b,c,d)
            M = max(a,b,c,d)
            ans = min(ans,M-m)

print(ans)

Buggy submission (verdict: Runtime Error):
INF = float('inf')
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))
S = [0]*N
for i in range(N):
    S[i] = S[i-1]+A[i]

ans = INF
i = bisect(S,S[-1]/2)
for r in {i,min(i+1,N-2)}:
    l = S[:r]
    r = S[r:]
    j = bisect(l,l[-1]/2)
    k = bisect(r,(r[-1]+l[-1])/2)
    for p in {j-1,min(j,i-2)}:
        for q in {k-1,min(k,N-i-2)}:
            a,b,c,d = l[p],l[-1]-l[p],r[q]-l[-1],r[-1]-r[q]
            m = min(a,b,c,d)
            M = max(a,b,c,d)
            ans = min(ans,M-m)

print(ans)
Problem p03318 (python)

Fixed submission:
def snk_cal(i):
    snk = i
    i = str(i)
    q = 0
    for j in range(len(i)):
        q += int(i[j])
    snk /= q
    return snk

K = int(input())
if K <= 9:
    for i in range(K):
        print(i+1)
else:
    for i in range(9):
        print(i+1)
    K -= 9
    snk = 9
    while K > 0:
        res = snk+1
        d = len(str(res))
        l = []
        for i in range(d):
            n = int(str(res)[:-i-1]+'9'*(i+1))
            l.append(snk_cal(n))
        i = l.index(min(l))
        snk = int(str(res)[:-i-1]+'9'*(i+1))
        print(snk)
        K -= 1

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

snuke = [1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,99,199,299,399,499,599,699,799,899,999]

for n in range(3,16):
    for k in range(1,11):
        snuke.append(10**(n-1)*(10+k)-1)
    for k in range(2,10):
        snuke.append((k+1)*10**n-1)

for k in range(K):
    print(snuke[k])

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

snuke = [1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,99,199,299,399,499,599,699,799,899,999]

for n in range(3,16):
    for k in range(1,10):
        snuke.append(10**(n-1)*(10+k)-1)
    for k in range(2,10):
        snuke.append((k+1)*10**n-1)

for k in range(K):
    print(snuke[k])
Problem p03330 (python)

Fixed submission:
import numpy as np
D = []
c = []
d0 = {}
d1 = {}
d2 = {}

N,C = map(int,input().split())
a = np.zeros((3,C))
for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split())))

D = np.array(D)
c = np.array(c)

for i in range(N):
    for j in range(N):
        a[(i+j)%3] += D[c[i][j]-1]

l = []
for C1 in range(C):
    for C2 in range(C):
        for C3 in range(C):
            if C1 != C2 and C2 != C3 and C3 != C1:
                l.append(a[0][C1]+a[1][C2]+a[2][C3])

print(int(min(l)))

Buggy submission (verdict: Runtime Error):
from math import inf
D = []
c = []
d = {}
N,C = map(int,input().split())
for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split())))

for C1 in range(C):
    for C2 in range(C):
        for C3 in range(C):
            if C1 != C2 and C2 != C3 and C3 != C1:
                d[(C1+1,C2+1,C3+1)]=0
            else:
                d[C1+1,C2+1,C3+1]=inf

for i in range(N):
    for j in range(N):
        for C1 in range(C):
            for C2 in range(C):
                for C3 in range(C):
                    if (i+j)%3==0:
                        d[(C1+1,C2+1,C3+1)]+=D[c[i][j]-1][C1]
                    elif (i+j)%3==1:
                        d[(C1+1,C2+1,C3+1)]+=D[c[i][j]-1][C2]
                    else:
                        d[(C1+1,C2+1,C3+1)]+=D[c[i][j]-1][C3]

l = []
for x in d:
    l.append(d[x])
print(min(l))

Buggy submission (verdict: Runtime Error):
from math import inf
D = []
c = []
d = {}
N,C = map(int,input().split())
for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split())))

for C1 in range(C):
    for C2 in range(C):
        for C3 in range(C):
            if C1 != C2 and C2 != C3 and C3 != C1:
                d[(C1+1,C2+1,C3+1)]=0
            else:
                d[C1+1,C2+1,C3+1]=inf

for i in range(N):
    for j in range(N):
        for C1 in range(C):
            for C2 in range(C):
                for C3 in range(C):
                    if (i+j)%3==0:
                        d[(C1+1,C2+1,C3+1)]+=D[c[i][j]-1][C1]
                    elif (i+j)%3==1:
                        d[(C1+1,C2+1,C3+1)]+=D[c[i][j]-1][C2]
                    else:
                        d[(C1+1,C2+1,C3+1)]+=D[c[i][j]-1][C3]

l = []
for x in d:
    l.append(d[x])
print(min(l))
Problem p03359 (python)

Fixed submission:
a,b = map(int,input().split())
if b < a:
    a -= 1
print(a)

Buggy submission (verdict: Runtime Error):
p = []
def is_prime_trial_division(n):
    if n < 2:
        return False
    else:
        for i in range(2, n):
            if i * i > n:
                break
            elif n % i == 0:
                return False
        return True
for i in range(2,55555):
    if is_prime_trial_division(i):
        p.append(i)
N = int(input())
s = ""
for i in range(N):
    s += str(p[5500+i*2]) + " "
s = s[:-1]
print(s)
Problem p03363 (python)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
s = [0]*(len(a)+1)
for i in range(len(a)):
    s[i+1] = s[i] + a[i]
b = {}
for x in s:
    if str(x) not in b:
        b[str(x)] = 1
    else:
        b[str(x)] += 1
n = 0
for x in b:
    n += b[x]*(b[x]-1)/2
print(int(n))

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
n = 0
for i in range(1,N+1):
    for j in range(N+1-i):
        S = 0
        for x in a[j:j+i]:
            S += x
        if S == 0:
            n += 1
print(n)
Problem p03370 (python)

Fixed submission:
N,X = map(int, input().split())
m = [int(input()) for i in range(N)]
for x in m:
  X -= x
m.sort()
n = int(X/m[0])
print(n + len(m))

Buggy submission (verdict: Runtime Error):
N,X = map(int, input())
m = [int(input()) for i in range(N)]
for x in m:
  X -= x
m.sort()
n = int(X/m[0])
print(n + len(m))
Problem p03379 (python)

Fixed submission:
N = int(input())
l = list(map(int,input().split()))
ll = sorted(l)
n = int(N/2)
a = ll[n-1]
b = ll[n]
for i in range(N):
    if l[i] <= a:
        print(b)
    else:
        print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
import numpy as np
l = np.array(map(int,input().split()))
for i in range(N):
    print(np.delete(l,i).median())
Problem p03388 (python)

Fixed submission:
import math
Q = int(input())
for i in range(Q):
    a = list(map(int,input().split()))
    a.sort()
    A = a[0]
    B = a[1]
    n = 0
    if A==B:
        n = 2*A-2
    elif B == A+1:
        n = 2*A-2
    else:
        C = math.ceil(math.sqrt(A*B)-1)
        if C*(C+1)>=A*B:
            n = 2*C-2
        else:
            n = 2*C-1
    print(n)

Buggy submission (verdict: Runtime Error):
Q = int(input())
for i in range(Q):
    a = list(map(int,input().split()))
    a.sort()
    A = a[0]
    B = a[1]
    n = 0
    if A==B:
        n = 2*A-2
    elif B == A+1:
        n = 2*A-2
    else:
        j = 0
        while True:
            j+=1
            if j*j >= A*B:
                C = j-1
                break
        if C*(C+1)>=A*B:
            n = 2*C-2
        else:
            n = 2*C-1
    print(C)
Problem p03402 (python)

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

d = {}
for i in range(50):
    d[i] = ["."]*100
for i in range(50,100):
    d[i] = ["#"]*100
a = 1
b = 1

for i in range(10):
    if a == B:
        break
    for j in range(50):
        if a == B:
            break
        else:
            d[i*2][j*2] = "#"
            a += 1
    
        
        
for i in range(10):
    if b == A:
        break
    for j in range(50):
        if b == A:
            break
        else:
            d[i*2+51][j*2] = "."
            b += 1
    

print("100 100")
def l_to_str(l):
    s = ""
    for x in l:
        s+=x
    return s
for i in range(100):
    print(l_to_str(d[i]))

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

l = [["."]*100]*50
ll = [["#"]*100]*50

a = 1
b = 1

for i in range(5):
    for j in range(50):
        l[i*2][j*2] = "."
        a += 1
        if a == B:
            break
            break
for i in range(5):
    for j in range(50):
        ll[i*2][j*2] = "#"
        b += 1
        if b == A:
            break
            break

print(100 100)
def l_to_str(l):
    s = ""
    for x in l:
        s+=x
    return s
for i in l:
    print(l_to_str(i))
for i in ll:
    print(l_to_str(i))
Problem p03410 (python)

Fixed submission:
import numpy as np
N = int(input())
A = np.int32(input().split())
B = np.int32(input().split())

ans_arr = np.zeros(29,int)
for k in range(29):
    a = np.sort(A%(2**(k+1)))
    b = B%(2**(k+1))
    ans_arr[k] += np.sum(np.searchsorted(a,2**(k+1)-1-b,side='right')-np.searchsorted(a,2**k-b))
    ans_arr[k] += np.sum(N-np.searchsorted(a,3*2**k-b))
    ans_arr[k] %= 2

ans = 0
for k in range(29):
    ans += ans_arr[k]*2**k

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
n = ""
for i in range(29):
    Atmp = list(map(lambda x:x%pow(2,i+1),A))
    Btmp = list(map(lambda x:x%pow(2,i+1),B))
    Btmp.sort()
    T = pow(2,i)
    nn = 0
    for a in Atmp:
        j = bisect.bisect_right(Btmp,T-a)
        k = bisect.bisect_right(Btmp,2*T-a)-1
        if j<=k:
            nn += k-j+1
        j = bisect.bisect_right(Btmp,3*T-a)
        k = bisect.bisect_right(Btmp,4*T-a)-1
        if j<=k:
            nn += k-j+1
    nn = nn%2
    n = str(nn)+n
nn = 0
for i in range(29):
    if n[-i-1] == "1":
        nn += pow(2,i)
print(nn)
Problem p03415 (python)

Fixed submission:
print(input()[0]+input()[1]+input()[2])

Buggy submission (verdict: Runtime Error):
print(inpit()[0]+input()[1]+input()[2])
Problem p03480 (python)

Fixed submission:
S = input()
T = []
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        T.append(max(i+1,len(S)-i-1))
if T != []:
    print(min(T))
else:
    print(len(S))

Buggy submission (verdict: Runtime Error):
S = input()
T = []
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        T.append(max(i+1,len(S)-i-1))
print(min(T))
Problem p03488 (python)

Fixed submission:
s = input()
x,y = map(int,input().split())
count = 0
d = []
s = s.split('T')
d = [len(x) for x in s]

if len(d) == 0:
    d.append(0)
if len(d) == 1:
    d.append(0)
dpx = [d[0]]
dpy = [d[1],-d[1]]
for i in range(2,len(d)):
    di = d[i]
    trans = set()
    if i%2==0:
        for xj in dpx:
            trans.add(xj+di)
            trans.add(xj-di)
        dpx = list(trans)
    else:
        for yj in dpy:
            trans.add(yj+di)
            trans.add(yj-di)
        dpy = list(trans)
ans = (x in dpx)&(y in dpy)

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

Buggy submission (verdict: Runtime Error):
s = input()
x,y = map(int,input().split())
count = 0
d = []
for i in range(len(s)):
    if s[i] == 'F':
        count += 1
    else:
        d.append(count)
        count = 0
if count != 0:
    d.append(count)

dx = [d[i] for i in range(len(d)) if i%2==0]
dy = [d[i] for i in range(len(d)) if i%2==1]
if len(dx) == 0:
    dx = [0]
if len(dy) == 0:
    dy = [0]
dpx = [dx[0]]
dpy = [dy[0],-dy[0]]
for i in range(len(dx)-1):
    trans = set()
    for j in range(len(dpx)):
        trans.add(dpx[j]+dx[i+1])
        trans.add(dpx[j]-dx[i+1])
    dpx = list(trans)
for i in range(len(dy)-1):
    trans = set()
    for j in range(len(dpy[1])):
        trans.add(dpy[1][j]+dy[i+1])
        trans.add(dpy[1][j]-dy[i+1])
    dpy = list(trans)
ans = (x in dpx)&(y in dpy)

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

Buggy submission (verdict: Runtime Error):
s = input()
x,y = map(int,input().split())
count = 0
d = []
for i in range(len(s)):
    if s[i] == 'F':
        count += 1
    else:
        d.append(count)
        count = 0
if count != 0:
    d.append(count)

dx = [d[i] for i in range(len(d)) if i%2==0]
dy = [d[i] for i in range(len(d)) if i%2==1]
if len(dx) == 0:
    dx = [0]
if len(dy) == 0:
    dy = [0]
dpx = [[] for i in range(len(dx))]
dpx[0] = [dx[0]]
dpy = [[] for i in range(len(dy))]
dpy[0] = [dy[0],-dy[0]]
for i in range(len(dx)-1):
    trans = set()
    for j in range(len(dpx[i])):
        trans.add(dpx[i][j]+dx[i+1])
        trans.add(dpx[i][j]-dx[i+1])
    dpx[i+1] = trans
for i in range(len(dy)-1):
    trans = set()
    for j in range(len(dpy[i])):
        trans.add(dpy[i][j]+dy[i+1])
        trans.add(dpy[i][j]-dy[i+1])
    dpy[i+1] = trans
ans = (x in dpx[-1])&(y in dpy[-1])

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

Buggy submission (verdict: Runtime Error):
s = input()
x,y = map(int,input().split())
count = s.count('F')
ans = abs(x)+abs(y) <= count
def bfs(x,y,s,count):
    if count < abs(x)+abs(y):
        return False
    elif x==0 and y==0 and s == '':
        return True
    else:
        if s[0] == 'F':
            x -= 1
            s = s[1:]
            count -= 1
            return bfs(x,y,s,count)
        else:
            s = s[1:]
            return bfs(y,-x,s,count) or bfs(-y,x,s,count)
ans = bfs(x,y,s,count)
if ans:
    print('Yes')
else:
    print('No')