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

Fixed submission:
import sys
input = sys.stdin.readline
vs = set()
def dfs_w(d, stack):
    depth = defaultdict(int)
    pvs = set()
    while stack:
        v = stack.pop()
        vs.add(v)
        pvs.add(v)
        for u, dpd in d[v]:
            if u in pvs:
                if depth[u] != depth[v] + dpd:
                    return False
            if u in vs:
                continue
            depth[u] = depth[v] + dpd
            stack.append(u)
    return True

if __name__ == '__main__':
    from collections import defaultdict
    N, M = map(int, input().split())
    G = defaultdict(set)
    for _ in range(M):
        a, b, c = map(int, input().split())
        G[a].add((b,c))
        G[b].add((a,-c))
    for i in range(N):
        if i+1 in vs:
            continue
        stack = [i+1] 
        r =  dfs_w(G, stack)
        if not r:
            break
    if r:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
vs = set()
def dfs_w(d, stack):
    depthh = [-1] + [0]*N
    pvs = set()
    if stack[0] in vs:
        return True
    while stack:
        v, dpd = stack.pop()
        vs.add(v)
        pvs.add(v)

        for u, dpd in d[v]:
            if u in pvs:
                if depthh[u] != depthh[v] + dpd:
                    return False
            if u in vs:
                continue
            depth[u] = depth[v] + dpd
            stack += [(u, dpd)]

    return True
#    return S, F, depth, depthh

if __name__ == '__main__':
    N, M = map(int, input().split())
    G = [set() for _ in range(N+1)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        G[a].add((b,c))
        G[b].add((a,-c))
    for i in range(N):
        if i in vs:
            continue
        stack = [(i+1, 0)] 
        r =  dfs_w(G, stack)
        if not r:
            break
    if r:
        print("Yes")
    else:
        print("No")
Problem p03455 (python)

Fixed submission:
a, b  = map(int, input().split())
if (a*b%2):
 print("Odd")
else:
 print("Even")

Buggy submission (verdict: Runtime Error):
if (a*b%2):
 print("Odd")
else:
 print("Even")
Problem p03497 (python)

Fixed submission:
N, K = map(int, input().split())
X = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
for x in X:
    d[x] += 1

l = sorted(list(d.values()))
print(sum(l[:max(0, len(l)-K)]))

Buggy submission (verdict: Runtime Error):
N, = map(int, input().split())
A = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
for a in A:
    d[a] += 1
r = 0
for a in d:
    if a > d[a]:
        r += d[a]
    else:
        r += d[a]-a
print(r)
Problem p03552 (python)

Fixed submission:
N, Y, Z = map(int, input().split())
As = list(map(int, input().split()))
dpx, dpy = [0]*(N-1), [0]*(N-1)
#dpx[i] = min(dpy[i+1]...dpy[N-2], abs(As[N-1]-As[i]))
#dpy[i] = max(dpx[i+1]...dpx[N-2], abs(As[N-1]-As[i]))
for i in range(N-2, -1, -1):
    mny, mxx = 10**10, 0
    for j in range(i+1, N-1):
        mny = min(mny, dpy[j])
        mxx = max(mxx, dpx[j])
    dpx[i] = min(mny, abs(As[N-1]-As[i]))
    dpy[i] = max(mxx, abs(As[N-1]-As[i]))
dpx.append(abs(As[N-1]-Z))
print(max(dpx))

Buggy submission (verdict: Runtime Error):
N, Y, Z = map(int, input().split())
As = list(map(int, input().split()))
dpx, dpy = [0]*(N-1), [0]*(N-1)
#dpx[i] = min(dpy[i+1]...dpy[N-2], abs(As[N-1]-As[i]))
#dpy[i] = max(dpx[i+1]...dpx[N-2], abs(As[N-1]-As[i]))
for i in range(N-2, -1, -1):
    mny, mxx = 10**10, 0
    for j in range(i+1, N-1):
        mny = min(mny, dpy[j])
        mxx = max(mxx, dpx[j])
    dpx[i] = min(mny, abs(As[N-1]-As[i]))
    dpy[i] = min(mxx, abs(As[N-1]-As[i]))
#print(dpx)
print(max(max(dpx),abs(As[N-1]-Z)))
Problem p03676 (python)

Fixed submission:
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (2*10**5)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, = map(int, input().split())
ps = list(map(int, input().split()))
p2i = dict()
i = 0
for p in ps:
    if p not in p2i:
        i += 1
        p2i[p] = i
        continue
    x = p2i[p]
    break
X = min(x-1, i-1)
Y = min(N-x, N-i)
for i in range(1, N+2):
    print((cmb(N+1, i) - cmb(X+Y, i-1))%mod)

Buggy submission (verdict: Runtime Error):
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (10**5)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, = map(int, input().split())
ps = list(map(int, input().split()))
p2i = dict()
i = 0
for p in ps:
    if p not in p2i:
        i += 1
        p2i[p] = i
        continue
    x = p2i[p]
    break
X = min(x-1, i-1)
Y = min(N-x, N-i)
for i in range(1, N+2):
    print((cmb(N+1, i) - cmb(X+Y, i-1))%mod)
Problem p03716 (python)

Fixed submission:
# ABC140E
class SegTree:
    def __init__(self, init_val, ide_ele, seg_func):
        self.segfunc = seg_func
        N = len(init_val)
        self.num = 2**(N-1).bit_length()
        self.ide_ele = ide_ele
        self.seg=[self.ide_ele]*2*self.num
        for i in range(N):
            self.seg[i+self.num-1]=init_val[i]    
        for i in range(self.num-2,-1,-1) :
            self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
        
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])
        
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res=self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res,self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res,self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res,self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
        return res
N, = map(int, input().split())
A = list(map(int, input().split()))
B = sorted([(a, i) for i, a in enumerate(A)], key=lambda x:x[0])
z = dict()
for i, (b, j) in enumerate(B):
    z[(b, j)] = i

ss = SegTree([3*N]*3*N, 3*N, min)
bs = []
y = 0
for i, x in enumerate(A):
    if i == 2*N:
        break
    ss.update(z[(x, i)], z[(x, i)])
    y += x
    if i < N-1:
        continue
    if i == N-1:
        bs.append(y)
    else:
        mx = ss.query(0, 3*N)
        y = y - B[mx][0]
        ss.update(mx, 3*N)
        bs.append(y)

ss = SegTree([-1]*3*N, -1, max)
nbs = []
#tmp = set()
y = 0
for i, x in enumerate(A[::-1]):
    if i == 2*N:
        break
    ss.update(z[(x, 3*N-i-1)], z[(x, 3*N-i-1)])
#    tmp.add((x, i))
    y += x
    if i < N-1:
        continue
    if i == N-1:
        nbs.append(y)
    else:
        mx = ss.query(0, 3*N)
#        print(max(tmp), B[mx])
#        tmp.remove(max(tmp))
        y = y - B[mx][0]
        ss.update(mx, -1)
        nbs.append(y)

#print(B)
#print(bs)
#print(nbs)
r = -10**18
for i in range(N+1):
    r = max(r, bs[i] - nbs[N-i])
print(r)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

mnr = 10**9
for a in range(1, W//2 + 1):
    b1 = (H*W)//(a + W)
    b2 = b1+1
    mc = max(abs((W-a)*b1-a*b1), abs(b1*(a+W) - H*W))
    mc2 = max(abs((W-a)*b2-a*b2), abs(b2*(a+W) - H*W))
    mnr = min([mnr, mc, mc2])
H, W = W, H
for a in range(1, W//2 + 1):
    b1 = (H*W)//(a + W)
    b2 = b1+1
    mc = max(abs((W-a)*b1-a*b1), abs(b1*(a+W) - H*W))
    mc2 = max(abs((W-a)*b2-a*b2), abs(b2*(a+W) - H*W))
    mnr = min([mnr, mc, mc2])
if H % 3 == 0 or W % 3== 0:
    mnr = 0
elif H % 3:
    mnr = min(W, mnr)
else:
    mnr = min(H, mnr)
print(mnr)
Problem p03781 (python)

Fixed submission:
x = int(input())
for i in range(1, 10**5):
    if x <= i*(i+1)//2:
        break
print(i)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [a for a in A if a <K]
N = len(A)
dp2 = [1] + [0]*K
dpm = [[0]*(K+1) for _ in range(N+1)]
dpm[0][0] = 1
for i, a in enumerate(A):
    for j in range(K, -1, -1):
        dpm[i+1][j] = dpm[i][max(0, j-a)] + dpm[i][j]
#print(dpm)

r = 0
for i, a in enumerate(A[::-1]):
    f = True
    for j in range(K, -1, -1):
        # 後ろiこの合計がjのもの
        if f and dp2[j] > 0:
            # K-j > x >= K-j-a
            if dpm[N-i-1][max(0, K-j-a)] > dpm[N-i-1][K-j]:
                f = False
        if j-a>=0:
            dp2[j] = dp2[j] + dp2[j-a]
    if f:
        r += 1
#    for j in range(K-1, 0, -1):
#        print("aa", i, N-i-1)
print(r)
Problem p03782 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [a for a in A if a <K]
N = len(A)
#dpm = [+1) for _ in range(N+1)]
dpm = [0]*(N+1)
dpm[0] = 1<<(K-1)
for i, a in enumerate(A):
    dpm[i+1] = dpm[i] | (dpm[i] >> a)

r = 0
dp2 = 1
for i, a in enumerate(A[::-1]):
    for j in range(a):
        if dp2 & dpm[N-i-1]:
            break
        dpm[N-i-1] >>= 1
    else:
        r += 1
    dp2 |= dp2<<a
    dp2 &= (1<<K)-1
print(r)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [a for a in A if a <K]
N = len(A)
#dpm = [+1) for _ in range(N+1)]
dpm = [0]*(N+1)
dpm[0] = 1<<(K-1)
for i, a in enumerate(A):
    dpm[i+1] = dpm[i] | (dpm[i] >> a)

r = 0
dp2 = 1
for i, a in enumerate(A[::-1]):
    for j in range(a):
        if dp2 & tmp:
            break
        dpm[N-i-1] >>= 1
    else:
        r += 1
    dp2 |= dp2<<a
    dp2 &= (1<<K)-1
print(r)
Problem p03968 (python)

Fixed submission:
from collections import defaultdict
N, = map(int, input().split())

def normal(xs):
    mnx = min(xs)
    xi = xs.index(mnx)
    if xs[(xi+3)%4] == mnx:
        if xs[(xi+2)%4] == mnx:
            xi = (xi+2)%4
        else:
            xi = (xi+3)%4
    if xs[(xi+1)%4] > xs[(xi+3)%4]:
        xi = (xi+2)%4
    return (xs[xi%4], xs[(xi+1)%4], xs[(xi+2)%4], xs[(xi+3)%4])
#x = (0,2,2,0)
#print(normal(x))

dd = defaultdict(int)
ss = []
for _ in range(N):
    a, b, c, d = map(int, input().split())
    x = normal([a,b,c,d])
    n=1
    if x[0] == x[2] and x[1] == x[3]:
        n *= 2
        if x[0] == x[1]:
            n *= 2
    dd[x] += n
    ss.append(x)

def icr(x):
    n = 1
    if x[0] == x[2] and x[1] == x[3]:
        n *= 2
        if x[0] == x[1]:
            n *= 2
    dd[x] += n

def dcr(x):
    n = 1
    if x[0] == x[2] and x[1] == x[3]:
        n *= 2
        if x[0] == x[1]:
            n *= 2
    dd[x] -= n

def f(ff, gg):
    #print(dd)
    a,b,c,d=ff
    e,h,g,f=gg
    tl = list(map(normal, [(a,e,f,b), (b,f,g,c), (c,g,h,d), (d,h,e,a)]))
    r = 1
    for cp in tl:
        if cp not in dd:
            r = 0
            break
        r *= dd[cp]
        dcr(cp)
    for cp in tl:
        if cp not in dd:
            break
        icr(cp)
    return r

r = 0
for i in range(N):
    ff = ss[i]
    dcr(ff)
    for j in range(i+1, N):
        sl = ss[j]
        dcr(sl)
        x, y, z, w = sl
        sls = [(x,y,z,w), (y,z,w,x), (z,w,x,y), (w,x,y,z)]
        for s in sls:
            r += f(ff, s)
        icr(sl)
    icr(ff)
print(r//3)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N, = map(int, input().split())
dd = defaultdict(int)
ss = []
for _ in range(N):
    a, b, c, d = map(int, input().split())
    dd[(a,b,c,d)] += 1
    dd[(b,c,d,a)] += 1
    dd[(c,d,a,b)] += 1
    dd[(d,a,b,c)] += 1
    ss.append((a,b,c,d))
def icr(x):
    a, b, c, d = x
    for faf in [(b,c,d,a), (c,d,a,b), (d,a,b,c), (a,b,c,d)]:
        dd[faf] += 1
def dcr(x):
    a, b, c, d = x
    for faf in [(b,c,d,a), (c,d,a,b), (d,a,b,c), (a,b,c,d)]:
        dd[faf] -= 1

def f(ff, gg):
    a,b,c,d=ff
    e, h, g, f = gg
    tl = [(a,e,f,b), (b,f,g,c), (c,g,h,d), (d,h,e,a)]
    r = 1
    for cp in tl:
        r *= dd[cp]
        dcr(cp)
    for cp in tl:
        icr(cp)
    return r

r = 0
for i in range(N):
    a,b,c,d = ss[i]
    ff = (a,b,c,d)
    dcr(ff)
    for j in range(I+1, N):
        if i == j:
            continue
        x, y, z, w = ss[j]
        sl = [(x,y,z,w), (y,z,w,x), (z,w,x,y), (w,x,y,z)]
        for s in sl:
            dcr(s)
            r += f(ff,s)
            icr(s)
    icr(ff)
print(r//3)
Problem p04046 (python)

Fixed submission:
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0: return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else: return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))
def div2(a, b):
    return mul(a, modinv(b))

def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (10**6)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
H, W, A, B = map(int, input().split())

r = 0
for i in range(H-A):
#    (0, 0) -> (i, B-1)
#    (i, B) -> (H-1, W-1)
    r = (r + mul(cmb(i+B-1, i), cmb(H-1-i+W-1-B, H-1-i)))%mod
print(r)

Buggy submission (verdict: Runtime Error):
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0: return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else: return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))
def div2(a, b):
    return mul(a, modinv(b))

def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (10**5)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
H, W, A, B = map(int, input().split())

r = 0
for i in range(H-A):
#    (0, 0) -> (i, B-1)
#    (i, B) -> (H-1, W-1)
    r = (r + mul(cmb(i+B-1, i), cmb(H-1-i+W-1-B, H-1-i)))%mod
print(r)
Problem p03254 (python)

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

arr.sort()
cnt = 0
for ele in arr:
    if x < ele:
        break
    x -= ele
    cnt += 1

if cnt == N and x > 0:
    cnt -= 1

print(cnt)

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

arr.sort()
cnt = 0
for ele in arr:
    if x < ele:
        break
    x -= ele
    cnt += 1

if cnt = N and x > 0:
    cnt -= 1

print(cnt)

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

arr.sort()
cnt = 0
for ele in arr:
    if x < ele:
        break
    x -= ele
    cnt += 1

if cnt = N and x != 0:
    cnt -= 1

print(cnt)
Problem p03261 (python)

Fixed submission:
N = int(input())
ans = "Yes"
arr = []
for i in range(N):
    arr.append(input())
    if not i == 0:
        if arr[i-1][-1] == arr[i][0] and not arr[i] in arr[:-2]:
            pass
        else:
            ans = "No"
            break

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = "Yes"
arr = []
for i in range(N)
    arr.append(input())
    if not i == 1:
        if arr[i] in arr and arr[i-1][-1] == arr[i][0]
            pass
        else:
            ans = "No"
            break

print(ans)
Problem p03486 (python)

Fixed submission:
s = str(input())
s_asc = ''.join(sorted(s))

t = str(input())
t_desc = ''.join(sorted(t, reverse=True))

if t_desc > s_asc:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = str(input())
t = str(input())

sd = sorted(s)
td = sorted(t, reverse=True)

ans = "No"
for i in range(len(sd)):
    if td[i] > sd[i]:
        ans = "Yes"
        break
    elif td[i] == sd[i]:
        pass
    else:
        break;

print(ans)
Problem p02555 (python)

Fixed submission:
INF=1000000000+7

s=int(input())
dp=[0]*(2000+1);
	
dp[0]=dp[1]=dp[2]=0
dp[3]=1


for i in range(4,s+1):
	temp=1
	for j in range(3,i-2):
		temp+=dp[j]%INF;
	temp%=INF;
	dp[i]=temp
print(dp[s])

Buggy submission (verdict: Runtime Error):
INF=1000000000+7

s=int(input())
dp=[0]*(s+1);
dp[0]=dp[1]=dp[2]=0
dp[3]=1
for i in range(4,s+1):
	temp=1
	for j in range(3,i-2):
		temp+=dp[j]%INF;
	temp%=INF;
	dp[i]=temp
print(dp[s])
Problem p02576 (python)

Fixed submission:
n,x,t=map(int,input().split())
ans=0;
while(n>0):
	ans+=t;
	n-=x;
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
ans=0
for i in range(1,n):
	if(arr[i]<arr[i-1]):
		ans+=arr[i-1]-arr[i]
		arr[i]+=arr[i-1]-arr[i]
		
print(ans)
Problem p02576 (python)

Fixed submission:
n,x,t = map(int,input().split())
if n % x == 0:
    print(n//x*t)
else:
    print((n//x+1)*t)

Buggy submission (verdict: Runtime Error):
h,w,m = map(int,input().split())
hli = [0]*h
wli = [0]*w
li = []
for i in range(m):
    a,b = map(int,input().split())
    li.append([a,b])
    hli[a-1] += 1
    wli[b-1] += 1
a = max(hli)
b = max(wli)
hli2 = []
wli2 = []
for i in range(h):
    if hli[i] == a:
        hli2.append(i+1)
for i in range(w):
    if wli[i] == b:
        wli2.append(i+1)
for i in hli2:
    for j in wli2:
        if [i,j] not in li:
            print(a + b)
            exit()
print(a + b - 1)
Problem p02683 (python)

Fixed submission:
n,m,x = map(int,input().split())
li1 = []
li2 = []
for i in range(n):
    li1.append(list(map(int,input().split())))
for i in range(2**n):
    b = '0'*(n-len(bin(i))+2)+bin(i)[2:]
    total = 0
    li3 = [0]*m
    f = 1
    for j in range(n):
        if b[j] == "1":
            total += li1[j][0]
            for k in range(m):
                li3[k] += li1[j][k+1]
    for j in range(m):
        if li3[j] < x:
            f = 0
    if f == 1:
        li2.append(total)
if len(li2) >= 1:
    print(min(li2))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
li1 = []
li2 = []
for i in range(n):
    li1.append(list(map(int,input().split())))
for i in range(2**n):
    b = '0'*(n-len(bin(i))+2)+bin(i)[2:]
    total = 0
    li3 = [0]*m
    f = 1
    for j in range(n):
        if b[j] == "1":
            total += li1[j][0]
            for k in range(m):
                li3[k] += li1[j][k+1]
    for j in range(m):
        if li3[j] < x:
            f = 0
    if f == 1:
        li2.append(total)
print(min(li2))
Problem p02802 (python)

Fixed submission:
n,m = map(int,input().split())
li = [[0,0] for _ in range(n)]
t1,t2 = 0,0
for i in range(m):
    a,b = input().split()
    if li[int(a)-1][0] != 1:
        if b == "WA":
            li[int(a)-1][1] += 1
        if b == "AC":
            li[int(a)-1][0] += 1
for i in range(n):
    t1 += li[i][0]
    t2 += li[i][1]*li[i][0]
print(t1,t2)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
li = [[0,0] for _ in range(n)]
t1,t2 = 0,0
for i in range(m):
    a,b = input().split()
    if li[int(a)-1][0] != 1:
        if b == "WA":
            li[int(a)-1][1] += 1
        else b == "AC":
            li[int(a)-1][0] += 1
for i in range(n):
    t1 += li[i][0]
    t2 += li[i][1]
print(t1,t2)
Problem p02898 (python)

Fixed submission:
n,k = map(int,input().split())
li = list(map(int,input().split()))
count = 0
for i in range(n):
    if li[i] >= k:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
lia = []
lib = list(map(int,input().split()))
for i in range(1,n+1):
    lia.append(i)
for i in range(n):
    if lia[i] != lib[i]:
        count += 1
    if count > 3:
        print("NO")
        break
if count <= 2:
    print("YES")
Problem p02947 (python)

Fixed submission:
n = int(input())
li = []
count = 0
f = 1
for i in range(n):
    a = input()
    li.append("".join(sorted(a)))
li.sort()
for i in range(n-1):
    if li[i] == li[i+1]:
        f += 1
    else:
        count += (f*(f-1))//2
        f = 1
count += (f*(f-1))//2
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = []
li.append(0)
count = 0
f = 1
for i in range(n):
    a = input()
    li.append("".join(sorted(a)))
li.sort()
for i in range(n-1):
    if li[0] == li[1]:
        f += 1
        del li[0]
    else:
        count += (f*(f-1))//2
        f = 1
        del li[0]
print(count)
Problem p02958 (python)

Fixed submission:
n = int(input())
li1 = list(map(int,input().split()))
li2 = []
count = 0
for i in range(n):
    li2.append(i+1)
for i in range(n):
    if li1[i] != li2[i]:
        count += 1
if count == 0 or count == 2:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
li1 = list(map(int,inpout().split()))
li2 = []
count = 0
for i in range(n):
    li2.append(i+1)
for i in range(n):
    if li1[i] != li2[i]:
        count += 1
if count == 0 or count == 2:
    print("YES")
else:
    print("NO")
Problem p02995 (python)

Fixed submission:
import math
a,b,c,d = map(int,input().split())
lcm = c*d//(math.gcd(c,d))
e,f,g = b//c - (a-1)//c,b//d - (a-1)//d,b//(lcm) - (a-1)//(lcm)
print(b-a+1-e-f+g)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
e,f,g,h,i,j = b // c,b // d,(a-1) // c,(a-1) // d,b // ((c*d)/math.gcd(c,d)),(a-1) // ((c*d)/math.gcd(c,d))
print(int(b-(e+f-i)-(a-1-(g+h-j))))
Problem p03037 (python)

Fixed submission:
n,m = map(int,input().split())
li,lia = [],[]
for i in range(m):
    a,b = map(int,input().split())
    li.append(a)
    lia.append(b)
if min(lia)-max(li)+1 <= 0:
    print(0)
else:
    print(min(lia)-max(li)+1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
li,lia = [],[]
for i in range(m):
    a,b = map(int,input().split())
    li.append(a)
    lia.append(b)
print(min(min(lia)-max(li)+1),0)