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

Fixed submission:
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.buffer.readline().strip().decode()
def mdata(): return map(int, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)
INF=int(10e9)


s=data()
t=data()
dp=[[0]*(len(s)+1) for i in range(len(t)+1)]
for i in range(1,len(t)+1):
    for j in range(1,len(s)+1):
        if s[j-1]==t[i-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
m=max(max(dp))
ans=''
for i in range(len(t)-1,-1,-1):
    for j in range(len(s)-1,-1,-1):
        if dp[i+1][j+1]==m and s[j]==t[i]:
            ans=s[j]+ans
            m-=1
            break
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)
INF=int(10e9)


s=input()
t=input()
dp1=[0]*len(s)
for i in range(len(t)):
    m=0
    dp2=dp1.copy()
    for j in range(len(s)):
        if s[j]==t[i]:
            dp2[j]=max(m+1,dp1[j])
        m=max(m,dp1[j])
    dp1=dp2.copy()

dp3=[0]*len(s)
for i in range(len(t)-1,-1,-1):
    m=0
    dp2=dp3.copy()
    for j in range(len(s)-1,-1,-1):
        if s[j]==t[i]:
            dp2[j]=max(m+1,dp3[j])
        m=max(m,dp3[j])
    dp3=dp2.copy()

m=max(dp1)
cnt=max(dp1)
ans=''
for j in range(len(s)-1,-1,-1):
    if dp1[j]>=cnt and dp3[j]>=m-cnt+1:
        ans=s[j]+ans
        cnt-=1
    if cnt==0:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)
INF=int(10e9)


s=data()
t=data()
dp1=[0]*len(s)
for i in range(len(t)):
    m=0
    dp2=dp1.copy()
    for j in range(len(s)):
        if s[j]==t[i]:
            dp2[j]=max(m+1,dp1[j])
        m=max(m,dp1[j])
    dp1=dp2.copy()

dp3=[0]*len(s)
for i in range(len(t)-1,-1,-1):
    m=0
    dp2=dp3.copy()
    for j in range(len(s)-1,-1,-1):
        if s[j]==t[i]:
            dp2[j]=max(m+1,dp3[j])
        m=max(m,dp3[j])
    dp3=dp2.copy()

m=max(dp1)
cnt=max(dp1)
ans=''
for j in range(len(s)-1,-1,-1):
    if dp1[j]>=cnt and dp3[j]>=m-cnt+1:
        ans=s[j]+ans
        cnt-=1
    if cnt==0:
        break
print(ans)
Problem p03168 (python)

Fixed submission:
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.buffer.readline().strip().decode()
def mdata(): return map(float, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)
INF=int(1e9)
mod=int(1e9)+7


n=int(data())
P=list(mdata())
dp=[0]*(n//2+2)
dp[1]=1
for i in range(n):
    dp1=dp[:]
    for j in range(1,len(dp)):
        k=dp[j-1]*(1-P[i])+dp[j]*(P[i])
        dp1[j]=k
    dp=dp1[:]
print(sum(dp))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.buffer.readline().strip().decode()
def mdata(): return map(float, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)
INF=int(1e9)
mod=int(1e9)+7


n=int(data())
P=list(mdata())
dp=[0]*(n//2+2)
dp[1]=1
for i in range(n):
    dp1=dp.copy()
    for j in range(1,len(dp)):
        k=dp[j-1]*(1-P[i])+dp[j]*(P[i])
        dp1[j]=k
    dp=dp1.copy()
print(sum(dp))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.buffer.readline().strip().decode()
def mdata(): return map(float, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)
INF=int(1e9)
mod=int(1e9)+7


n=int(data())
P=list(mdata())
dp=[0]*(n//2+2)
dp[1]=1
for i in range(n):
    dp1=dp.copy()
    for j in range(1,len(dp)):
        k=dp[j-1]*(1-P[i])+dp[j]*(P[i])
        dp1[j]=k
    dp=dp1.copy()
print(sum(dp))
Problem p02609 (python)

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

pop = [0]*(N+1)
amari = [0]*(N+1)
for i in range(1,N+1):
    pop[i]=pop[i-(i&(-i))]+1
    amari[i] = amari[i%pop[i]]+1

cnt1 = 0
for i in range(N):
    if X[i]=="1":
        cnt1+=1
Y = cnt1+1
Z = cnt1-1

baseY = 0
baseZ = 0
for i in range(N):
    K = int(X[N-1-i])
    if K==1:
        baseY += pow(2,i,Y)
        if Z!=0:
            baseZ += pow(2,i,Z)
        else:
            baseZ =-1
baseY = baseY%Y
if Z!=0:
    baseZ = baseZ%Z
else:
    baseZ = -1

for i in range(N):
    if X[i]=="0":
        out = (baseY + pow(2,N-1-i,Y))%Y
        print(amari[out]+1)
    elif X[i]=="1":
        if Z!=0:
            out = (baseZ - pow(2,N-1-i,Z))%Z
            print(amari[out]+1)
        else:
            print(0)

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

pop = [0]*(N+1)
amari = [0]*(N+1)
for i in range(1,N+1):
    pop[i]=pop[i-(i&(-i))]+1
    amari[i] = amari[i%pop[i]]+1

cnt1 = 0
for i in range(N):
    if X[i]=="1":
        cnt1+=1
Y = cnt1+1
Z = cnt1-1

baseY = 0
baseZ = 0
for i in range(N):
    K = int(X[N-1-i])
    if K==1:
        baseY += pow(2,i,Y)
        baseZ += pow(2,i,Z)
baseY = baseY%Y
baseZ = baseZ%Z


for i in range(N):
    if X[i]=="0":
        out = (baseY + pow(2,N-1-i,Y))%Y
        print(amari[out]+1)
    elif X[i]=="1":
        out = (baseZ - pow(2,N-1-i,Z))%Z
        print(amari[out]+1)
Problem p02616 (python)

Fixed submission:
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
p = 10**9+7
Aplus = []
Nplus = 0
Aminus = []
Nminus = 0
Aabs = []
for i in range(N):
    if A[i]>=0:
        Aplus.append(A[i])
        Nplus += 1
    else:
        Aminus.append(A[i])
        Nminus += 1
Aplus.sort(reverse=True)
Aminus.sort(reverse=False)

if K==N:
    out=1
    for i in range(K):
        out = out*A[i]%p
    print(out)
elif Nminus==N and K%2==1:
    out=1
    for i in range(K):
        out = out*Aminus[N-i-1]%p
    print(out)
else:
    l=0
    r=0
    out=1
    inf = float('inf')
    while K>0:
        if l+1<=Nplus-1:
            cand1 = Aplus[l]*Aplus[l+1]
        elif l==Nplus-1:
            cand1 = Aplus[l]
        else:
            cand1 = -1*inf

        if r+1<=Nminus-1:
            cand2 = Aminus[r]*Aminus[r+1]
        elif r==Nminus-1:
            cand2 = Aminus[r]
        else:
            cand2 = -1*inf

        if cand1>cand2 or K==1:
            out=out*Aplus[l]%p
            K += -1
            l += 1
        else:
            out=out*Aminus[r]*Aminus[r+1]%p
            K += -2
            r += 2
    print(out)

Buggy submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
p = 10**9+7
Aplus = []
Nplus = 0
Aminus = []
Nminus = 0
Aabs = []
for i in range(N):
    if A[i]>=0:
        Aplus.append(A[i])
        Nplus += 1
    else:
        Aminus.append(A[i])
        Nminus += 1
Aplus.sort(reverse=True)
Aminus.sort(reverse=False)

if Nplus==0:
    if K%2==0:
        t=0
        out = 1
        while t<=K-1:
            out = out*Aminus[t]%p
            t+=1
    else:
        t=0
        out = 1
        while t<=K-1:
            out = out*Aminus[N-1-t]%p
            t+=1
    print(out)
else:
    Aminus2 = []
    for i in range(Nminus//2):
        Aminus2.append(Aminus[2*i]*Aminus[2*i+1])

    out = 1
    l = 0
    r = 0
    while K>0:
        cand = [0,0]
        flag = 0
        if r<=Nminus-1 and K>=2 and Aminus2[r]>0:
            cand[0] = Aminus2[r]
            flag=1
        if l+1<=Nplus-1:
            cand[1] = Aplus[l]*Aplus[l+1]
            flag=1
        if flag==1:
            if cand[0]>cand[1]:
                r+=2
                K+=-2
                out = out*cand[0]%p
            elif cand[0]<=cand[1]:
                l+=1
                K+=-1
                out = out*cand[1]%p
        else:
            if l==Nplus-1 and r==Nminus-1 and K==2:
                out = out*Aplus[l]*Aminus2[r]%p
            elif l==Nplus-1 and r==Nminus-1 and K==1:
                out = out*Aplus[l]%p
            elif K==2:
                out = out*Aplus[l]*Aplus[l+1]%p
            else:
                out = out*Aplus[l]%p
            break
    print(out)
Problem p02691 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = []
for i in range(N):
    L.append(S[i]-1)

from collections import Counter
M = Counter(L)
out = 0
for i in range(N):
    if (T[i]-1>=0)and(len(L)-1>=T[i]-1):
        out += M[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = [0]*max(S)
for i in range(N):
    if (S[i]-1>=0)and(len(L)-1>=S[i]-1):
        L[S[i]-1]+=1

out = 0
for i in range(N):
    if (T[i]-1>=0)and(len(L)-1>=T[i]-1):
        out += L[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = [0]*max(S)
for i in range(N):
    L[S[i]-1]+=1

out = 0
for i in range(N):
    if (T[i]-1>=0)and(len(L)-1>=T[i]-1):
        out += L[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
S = []
T = []
for i in range(1,N+1):
    S.append(i+A[i-1])
    T.append(i-A[i-1])

L = [0]*max(S)
for i in range(N):
    L[S[i]-1]+=1

out = 0
for i in range(N):
    if T[i]>0:
        out += L[T[i]-1]
        if T[i]==S[i]:
            out += -1
print(out)
Problem p02713 (python)

Fixed submission:
import fractions
K = int(input())
out = 0
L = [0]*K
gcd = [[0]*K for i in range(K)]
for i in range(1,K+1):
    for j in range(1,K+1):
        A = fractions.gcd(i,j)
        gcd[i-1][j-1] = A
        L[A-1]+=1


for i in range(1,K+1):
    for j in range(1,K+1):
        out+=gcd[i-1][j-1]*L[j-1]

print(out)

Buggy submission (verdict: Runtime Error):
import fractions
K = int(input())
out = 0
L = [0]*K
gcd = [[0]*K for i in range(K)]
for i in range(1,201):
    for j in range(1,201):
        A = fractions.gcd(i,j)
        gcd[i-1][j-1] = A
        L[A-1]+=1


for i in range(1,201):
    for j in range(1,201):
        out+=gcd[i-1][j-1]*L[j-1]

print(out)
Problem p02721 (python)

Fixed submission:
N,K,C = list(map(int,input().split()))
S = list(input())
L = []
R = []
life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[i]=="o":
        if life <= 0:
            life = C
            L.append(i)
            cnt += -1
        else:
            life += -1
    elif S[i]=="x":
        life += -1

life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[N-1-i]=="o":
        if life <= 0:
            life = C
            R.append(N-1-i)
            cnt += -1
        else:
            life += -1
    elif S[N-1-i]=="x":
        life += -1

L.sort()
R.sort()
for i in range(min(len(L),len(R))):
    if L[i]==R[i]:
        print(L[i]+1)

Buggy submission (verdict: Runtime Error):
N,K,C = list(map(int,input().split()))
S = list(input())
L = []
R = []
life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[i]=="o":
        if life <= 0:
            life = C
            L.append(i)
            cnt += -1
        else:
            life += -1
    elif S[i]=="x":
        life += -1

life = 0
cnt = K
for i in range(N):
    if cnt==0:
        break
    if S[N-1-i]=="o":
        if life <= 0:
            life = C
            R.append(N-1-i)
            cnt += -1
        else:
            life += -1
    elif S[N-1-i]=="x":
        life += -1

out = set(L) & set(R)
out.sort()
for a in out:
    print(a+1)
Problem p02804 (python)

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

A.sort()

MAXN = 10**5+10
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

MA = 0
for i in range(N-K+1):
    MA = (MA + A[N-1-i]*nCr(N-1-i,K-1))%p

MI = 0
for i in range(N-K+1):
    MI = (MI + A[i]*nCr(N-1-i,K-1))%p

out = MA-MI
if out<0:
    out += p
print(out)

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

A.sort()

X = A[:(N-K+1)]
Y = A[(K-1):]
Y.sort(reverse=True)
output = 0
Z = len(X)
C = 1
l=K
r=1
for i in range(Z):
    output += (Y[-1*(i+1)]-X[-1*(i+1)])*C
    if output >= 10**9+7:
        output = output % (10**9+7)
    C = int(C*l/r)
    l+=1
    r+=1
print(output)

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

A.sort()


C = [1]
r = 1
l = K
for i in range(1,N-K+1):
    C.append(int(C[i-1]*l/r))
    l+=1
    r+=1

C = C[::-1]

X = A[:(N-K+1)]
Y = A[(K-1):]
Y.sort(reverse=True)
output = 0
Z = len(X)
for i in range(Z):
    output += (Y[i]-X[i])*C[i]
    if output >= 10**9+7:
        output = output % (10**9+7)

print(output)
Problem p02924 (python)

Fixed submission:
N = int(input())
output = int(N*(N-1)//2)
print(output)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
    A.append(list(map(int,input().split())))

output = 0
memo = [0] * N
newmemo = [0] * N
owari = [0] * N
flag = 0
while flag < N:
    ng = 0
    for i in range(N):
        check = A[i][memo[i]]-1
        if i==A[check][memo[check]]-1:
            if memo[i] < N-2:
                newmemo[i]+=1
            elif (memo[i] == N-2) and (owari[i]==0):
                owari[i] = 1
                flag += 1
            else:
                continue
        else:
            ng += 1
    if ng == N:
        output = -1
        break
    memo = newmemo[:]
    output += 1

print(output)
Problem p03006 (python)

Fixed submission:
N = int(input())
XY = []
for i in range(N):
    XY.append(list(map(int,input().split())))

if N!=1:
    pqs = []
    for i in range(N):
        for j in range(i+1,N):
            X1 = XY[i][0]
            Y1 = XY[i][1]
            X2 = XY[j][0]
            Y2 = XY[j][1]
            pqs.append(str(X1-X2)+","+str(Y1-Y2))
            pqs.append(str(X2-X1)+","+str(Y2-Y1))

    from collections import Counter
    C = dict(Counter(pqs))
    out = N - max(C.values())
    print(out)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
N = int(input())
XY = []
for i in range(N):
    XY.append(list(map(int,input().split())))

pqs = []
for i in range(N):
    for j in range(i+1,N):
        X1 = XY[i][0]
        Y1 = XY[i][1]
        X2 = XY[j][0]
        Y2 = XY[j][1]
        pqs.append(str(X1-X2)+","+str(Y1-Y2))
        pqs.append(str(X2-X1)+","+str(Y2-Y1))

from collections import Counter
C = dict(Counter(pqs))
out = N - max(C.values())
print(out)
Problem p03044 (python)

Fixed submission:
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    A,B,C = list(map(int,input().split()))
    G[A-1].append([C,B-1]) #重み、向かう先の順番
    G[B-1].append([C,A-1])

from collections import deque
dist = [None]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for c,w in G[v]:
        if dist[w] is not None:
            continue
        dist[w] = d + c
        que.append(w)
for i in range(N):
    print(dist[i]%2)

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

N = int(input())

listX =[]
while True:
    try:
        listX.append(list(map(int,input().split())))
    except:
        break;

table = np.zeros((N,N))
point = np.zeros(N)
for i in range(N-1):
    x = listX[i][0]
    y = listX[i][1]
    table[x-1,y-1] = listX[i][2]
    table[y-1,x-1] = listX[i][2]

for j in range(0,N):
    for k in range(j+1,N):
        point[k] += table[j,k]

output = (point%2==0)
output = list(map(int,output))

outstr = str(output[0])

for i in range(1,N):
    outstr += "\n"+str(output[i])

print(outstr)
Problem p03569 (python)

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

cnt = 0
l = 0
r = N-1
while l<=r:
    if S[l]=="x" and S[r]!="x":
        l += 1
        cnt += 1
    elif S[l]!="x" and S[r]=="x":
        r += -1
        cnt += 1
    elif S[l]=="x" and S[r]=="x":
        l += 1
        r += -1
    elif S[l]!="x" and S[r]!="x":
        if S[l]==S[r]:
            l += 1
            r += -1
        else:
            cnt = -1
            break
print(cnt)

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

cnt = 0
l = 0
r = N-1
while l<=r:
    if S[l]=="x" and S[r]!="x":
        l += 1
        cnt += 1
    if S[l]!="x" and S[r]=="x":
        r += -1
        cnt += 1
    if S[l]=="x" and S[r]=="x":
        l += 1
        r += -1
    if S[l]!="x" and S[r]!="x":
        if S[l]==S[r]:
            l += 1
            r += -1
        else:
            cnt = -1
            break
print(cnt)
Problem p03575 (python)

Fixed submission:
N,M = list(map(int,input().split()))
AB = []
from collections import deque

for i in range(M):
    AB.append(list(map(int,input().split())))


out = 0
for remove in range(M):
    G = [[] for i in range(N)]
    for i in range(M):
        if i==remove:
            continue
        else:
            A,B=AB[i]
            G[A-1].append(B-1)
            G[B-1].append(A-1)
    s = 0
    visit = [0]*N
    que = deque([s])
    visit[s] = 1
    while que:
        v = que.popleft()
        for w in G[v]:
            if visit[w] == 1:
                continue
            visit[w] =  1
            que.append(w)
    if sum(visit)!=N:
        out+=1
print(out)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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

AB = []
for i in range(M):
    AB.append(list(map(int,input().split())))

out = 0
for break in range(M):
    Network = UnionFind(N)
    for j in range(M):
        if j!=break:
            A,B=AB[j][0],AB[j][1]
            Network.union(A-1, B-1)
    if Network.group_count()==2:
        out+=1
print(out)
Problem p03638 (python)

Fixed submission:
H,W = list(map(int,input().split()))
N = int(input())
A = list(map(int,input().split()))
cnt = 0
L = []
i = 1
while cnt<H*W:
    if A[i-1]>0:
        A[i-1]+=-1
        L.append(i)
        cnt+=1
    else:
        i+=1
for i in range(H):
    out = [0]*W
    if i%2==0:
        for j in range(W):
            out[j]=L[W*i+j]
    else:
        for j in range(W):
            out[W-1-j]=L[W*i+j]
    print(*out)

Buggy submission (verdict: Runtime Error):
H,W = list(map(int,input().split()))
N = int(input())
A = list(map(int,input().split()))
cnt = 0
L = []
i = 1
while cnt<H*W:
    if A[i-1]>0:
        A[i-1]+=-1
        L.append(i)
        cnt+=1
    else:
        i+=1
for i in range(H):
    out = [0]*W
    if i%2==0:
        for j in range(W):
            out[j]=L[H*i+j]
    else:
        for j in range(W):
            out[W-1-j]=L[H*i+j]
    print(*out)
Problem p02690 (python)

Fixed submission:
x = int(input())

flag = False
for a in range(-200, 200):
    for b in range(-200, 200):
        if a ** 5 - b ** 5 == x:
            flag = True
            print(str(a) + " " + str(b))
            break
    if flag:
        break

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

b = 0
while True:
    if int((x + b ** 5) ** 0.2) == (x + b ** 5) ** 0.2:
        a = int((x + b ** 5) ** 0.2)
        break
    elif int((x - b ** 5) ** 0.2) == (x - b ** 5) ** 0.2:
        a = int((x - b ** 5) ** 0.2)
        b *= -1
        break
    else:
        b += 1

print(str(a) + " " + str(b))
Problem p02697 (python)

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

if n % 2 == 0:
    i = 1
    while i <= m:
        a_i = str(i)
        
        if i <= (n - 2) // 4:
            b_i = str(n - i)
        else:
            b_i = str(n - i - 1)
        
        print(a_i + " " + b_i)
        i += 1
        
elif n % 2 == 1:
    for i in range(1, m + 1):
        a_i = str(i)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

if n % 2 == 0:
    i = 1
    while i <= m:
        if i < (n - 2) // 2
            a_i = str(i)
        else:
            a_i = str(i + 1)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)
        i += 1
        
elif n % 2 == 1:
    for i in range(1, m + 1):
        a_i = str(i)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

if n % 2 == 0:
    i = 1
    while i <= m:
        if i < (n - 2) // 2
            a_i = str(i)
        else:
            a_i = str(i + 1)
        b_i = str(n - i)
        
        print(a_i)
        i += 1
        
elif n % 2 == 1:
    for i in range(1, m + 1):
        a_i = str(i)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200000)

n = int(input())
 
G = {}
for i in range(n):
    G.update({i: []})
 
for i in range(n - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append([v - 1, w % 2])
    G[v - 1].append([u - 1, w % 2])
 
color = [-1 for i in range(n)]
 
def dfs(graph, v, c):
    color[v] = c
    
    for next_v in graph[v]:
        dis = next_v[1]
        if color[next_v[0]] != -1:
            continue
        
        if dis == 0:
            n_c = c
        elif dis == 1:
            n_c = 1 - c
        
        dfs(graph, next_v[0], n_c)
 
dfs(G, 0, 0)
[print(i) for i in color]

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

G = {}
for i in range(n):
    G.update({i: []})

for i in range(n - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append([v - 1, w % 2])
    G[v - 1].append([u - 1, w % 2])

color = [-1 for i in range(n)]

def dfs(graph, v, c):
    color[v] = c
    
    for next_v in graph[v]:
        dis = next_v[1]
        if color[next_v[0]] != -1:
            continue
        
        if dis == 0:
            n_c = c
        elif dis == 1:
            n_c = 1 - c
        
        dfs(graph, next_v[0], n_c)

dfs(G, 0, 0)
[print(i) for i in color]