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

Fixed submission:
import math
import itertools

def swap(a,b):
    return max(a,b),min(a,b)

def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

_ = input()
an = list(map(int,input().split()))
#an = [5,10,12]
an.sort()
target = an[-1]/2
res = min(enumerate(an), key=lambda x: abs(target - x[1]))
print(an[-1], res[1])

Buggy submission (verdict: Runtime Error):
import math
import itertools

def swap(a,b):
    return max(a,b),min(a,b)

def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N = int(input())
an = [int(input()) for i in range(N)]
#an = [5,10,12]
an.sort()

max_v = 0
max_e = None
for c in itertools.combinations(an, 2):
    v = comb(swap(c))
    if v > max_v:
        max_v = v
        max_e = swap(c)
    #print(c, comb(*c))

print(max_e)
Problem p02768 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def powr(i, j, d):
    p = j
    ans = 1
    while p != 0:
        if p % 2 == 1:
            ans = (ans * i) % d
        i = i**2 % d
        p >>= 1
    return ans

def div(i, j):
    # 1/i mod(j)
    # calc i**(j-2) mod(j)
    return powr(i, j-2, j)

# def make_comb(m, d):
#     fac = [0] * (m+1)
#     ifac = [0] * (m+1)
#     # nCk
#     fac[0] = 1
#     ifac[0] = 1
#     for i in range(m):
#         fac[i+1] = (fac[i] * (i+1)) % d
#         ifac[i+1] = (ifac[i] * div(i+1, d)) % d
#     def comb(n, k):
#         if n == 0 and k == 0:
#             return 1
#         if n < k or n < 0:
#             return 0
#         return (fac[n] * ifac[k] * ifac[n-k]) % d
#     return comb

def nck(n, k, d):
    ans = 1
    for i in range(n-(k-1), n+1):
        ans *= i % d
        ans %= d
    for i in range(1, k+1):
        ans *= div(i, d)
        ans %= d
    return ans % d

def main():
    n, a, b = list(map(int, input().strip().split()))
    d = 10**9+7
    # comb = make_comb(10**6, d)
    ans = (powr(2, n, d) - 1 - nck(n, a, d) - nck(n, b, d)) % d
    if ans < 0:
        print(ans + d)
    else:
        print(ans)

    # print(comb(10, 2))
    # print(comb(5, 2))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def powr(i, j, d):
    p = j
    ans = 1
    while p != 0:
        if p % 2 == 1:
            ans = (ans * i) % d
        i = i**2 % d
        p >>= 1
    return ans

def div(i, j):
    # 1/i mod(j)
    # calc i**(j-2) mod(j)
    return powr(i, j-2, j)

def make_comb(m, d):
    fac = [0] * (m+1)
    ifac = [0] * (m+1)
    # nCk
    fac[0] = 1
    ifac[0] = 1
    for i in range(m):
        fac[i+1] = (fac[i] * (i+1)) % d
        ifac[i+1] = (ifac[i] * div(i+1, d)) % d
    def comb(n, k):
        if n == 0 and k == 0:
            return 1
        if n < k or n < 0:
            return 0
        return (fac[n] * ifac[k] * ifac[n-k]) % d
    return comb

def main():
    n, a, b = list(map(int, input().strip().split()))
    d = 10**9+7
    comb = make_comb(10**6, d)
    ans = (powr(2, n, d) - 1 - comb(n, a) - comb(n, b)) % d
    if ans < 0:
        print(ans + d)
    else:
        print(ans)

    # print(comb(10, 2))
    # print(comb(5, 2))


if __name__ == '__main__':
    main()
Problem p02900 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def gcd(a, b):
    if a % b != 0:
        return gcd(b, a % b)
    else:
        return b

def hurui(n):
    is_prime = [0] * (n+10)
    for i in range(2, n+1):
        is_prime[i] = 1
    for i in range(2, n+1):
        if is_prime[i] == 1:
            j = i*2
            while j <= n:
                is_prime[j] = 0
                j += i
    return is_prime

def main():
    a, b = list(map(int, input().strip().split()))
    g = gcd(a, b)
    # is_prime = hurui(10**6+10)
    i = 2
    c = 0
    # print(g)
    ans = []
    while i**2 <= g:
        if g % i == 0:
            ans.append([i, 0])
            while g % i == 0:
                g /= i
                ans[-1][1] += 1
        i += 1
    if g != 1:
        ans.append([g, 1])
    # print(ans)
    print(len(ans)+1)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def gcd(a, b):
    if a % b != 0:
        return gcd(b, a % b)
    else:
        return b

def hurui(n):
    is_prime = [0] * (n+10)
    for i in range(2, n+1):
        is_prime[i] = 1
    for i in range(2, n+1):
        if is_prime[i] == 1:
            j = i*2
            while j <= n:
                is_prime[j] = 0
                j += i
    return is_prime

def main():
    a, b = list(map(int, input().strip().split()))
    g = gcd(a, b)
    is_prime = hurui(10**6+10)
    i = 1
    c = 0
    while i**2 <= g:
        if g % i == 0:
            if is_prime[i] == 1:
                # print("i: ", i)
                c += 1
            if i != g // i and is_prime[g//i] == 1:
                # print("i: ", i)
                c += 1
        i += 1
    # print(g)
    print(c+1)

if __name__ == '__main__':
    main()
Problem p03006 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from collections import Counter

def main():
    n = int(input().strip())
    p = []
    for i in range(n):
        x, y = map(int, input().strip().split())
        p.append((x, y))
    vtable = [0] * n**2
    for i in range(n):
        for j in range(n):
            vtable[i * n + j] = (p[i][0] - p[j][0], p[i][1] - p[j][1])
    c = sorted(Counter(vtable).values(), reverse=True)
    if len(c) == 1:
        print(1)
    else:
        print(n - c[1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from collections import Counter

def main():
    n = int(input().strip())
    p = []
    for i in range(n):
        x, y = map(int, input().strip().split())
        p.append((x, y))
    vtable = [0] * n**2
    for i in range(n):
        for j in range(n):
            vtable[i * n + j] = (p[i][0] - p[j][0], p[i][1] - p[j][1])
    c = sorted(Counter(vtable).values(), reverse=True)
    print(n - c[1])


if __name__ == '__main__':
    main()
Problem p03240 (python)

Fixed submission:
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			needH = -1
			for i in range(n):
				if h[i] > 0:
					tmp = h[i] + abs(x[i]-s) + abs(y[i]-t)
					if needH == -1:
						needH = tmp
					elif needH != tmp:
						needH = -2
						break
			if needH == -2:
				continue
			for i in range(n):
				if h[i] == 0 and needH > abs(x[i]-s) + abs(y[i]-t):
					needH = -2
					break
			if needH == -2:
				continue
			else:
				print("{} {} {}".format(s, t, needH))

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			gr = set()
			for i in range(n):
				if h[i] != 0:
					H = h[i] + abs(x[i]-s) + abs(y[i]-t)
					gr.add(H)
				else:
					for k in gr:
						if k > abs(x[i]-s) + abs(y[i]-t):
							gr.remove(k)

			if len(gr) == 1:
				h = gr.pop()
				if h >= 0:
					print(s, t, h)
					return

if __name__ == '__main__':
	main()
Problem p03263 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(h)]
	for i in range(h):
		a[i] = list(map(int, input().strip().split()))
	ans = []
	for i in range(h-1):
		for j in range(w):
			if a[i][j] % 2 == 1:
				a[i][j] -= 1
				a[i+1][j] += 1
				ans.append((i+1, j+1, i+2, j+1))

	for j in range(w-1):
		if a[h-1][j] % 2 == 1:
			a[h-1][j] -= 1
			a[h-1][j+1] += 1
			ans.append((h, j+1, h, j+2))
	n = len(ans)
	print(n)
	for i in range(n):
		print("{} {} {} {}".format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))
if __name__ == '__main__':
	main()

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

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(h)]
	for i in range(h):
		a[i] = list(map(int, input().strip().split()))
	ans = []
	for i in range(h-1):
		for j in range(w):
			if a[i][j] % 2 == 1:
				a[i][j] -= 1
				a[i+1][j] += 1
				ans.append((i+1, j+1, i+2, j+1))

	for j in range(w-1):
		if a[h-1][i] % 2 == 1:
			a[h-1][j] -= 1
			a[h-1][j+1] += 1
			ans.append((h, j+1, h, j+2))
	n = len(ans)
	print(n)
	for i in range(n):
		print("{} {} {} {}".format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))
if __name__ == '__main__':
	main()

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

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(w)]
	for i in range(h):
		a[i] = list(map(int, input().strip().split()))
	ans = []
	for i in range(h-1):
		for j in range(w):
			if a[i][j] % 2 == 1:
				a[i][j] -= 1
				a[i+1][j] += 1
				ans.append((i+1, j+1, i+2, j+1))

	for j in range(w-1):
		if a[h-1][i] % 2 == 1:
			a[h-1][j] -= 1
			a[h-1][j+1] += 1
			ans.append((h, j+1, h, j+2))
	n = len(ans)
	print(n)
	for i in range(n):
		print("{} {} {} {}".format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))
if __name__ == '__main__':
	main()
Problem p02657 (python)

Fixed submission:
a,b=input().split()
print(int(a)*int(b))

Buggy submission (verdict: Runtime Error):
a,b=int(input().split())
print(a*b)
Problem p02675 (python)

Fixed submission:
n=int(input())
x=["pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"]
print(x[n%10])

Buggy submission (verdict: Runtime Error):
n=int(input())
x=["pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"]
print(x[n//10])
Problem p02706 (python)

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

ans=n

for i in range(m):
    ans-=a[i]
    if ans<0:
        ans=-1
        break
print(ans)

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

ans=n

for i in range(m):
    ans-=a[m]
    if ans<0:
        ans=-1
        break
print(ans)
Problem p02760 (python)

Fixed submission:
a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[k][j]==b:
                a[k][j]=0

ans=0
for l in range(3):
    if a[l][0]==0 and a[l][1]==0 and a[l][2]==0:
        ans=1
        break
    elif a[0][l]==0 and a[1][l]==0 and a[2][l]==0:
        ans=1
        break




if ans==1:
    print("Yes")
elif a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=input()
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[i][j]==b:
                a[i][j]=0

ans=0
for l in range(3):
    if a[l][0]==0 and a[l][1]==0 and a[l][2]==0:
        ans=1
        break
    elif a[0][l]==0 and a[1][l==0 and a[2][l]==:
        ans=1
        break

if ans==1:
    print("Yes")
elif a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
    print("Yes")
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    print("Yes")
else:
    print("No")
Problem p02934 (python)

Fixed submission:
n=int(input())
a=map(int,input().split())
print("{:.16g}".format(1/sum(1/x for x in a)))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=map(int,input().split())
print({:.16g}.format(1/sum(1/x for x in a)))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
c=0
for i in range(n):
    b=int(input())
    c+=1.0/b
print(1.0/c)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
c=0
for i in range(n):
    b=int(input())
    c+=1.0/b
print(1.0/c)
Problem p02947 (python)

Fixed submission:
N=int(input())

count=0
dic=dict()

for i in range(N):
    s="".join(sorted(input()))
#    print(s)

    if s in dic:
        count+=dic[s]
#        print(dic[s])
        dic[s]+=1
    else:
        dic[s]=1
#        print(dic)

print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
LST=[]
for i in range(N):
    a=input()
    lst=[]
    for j in range(len(a)):
        lst.append(a[j])
    lst=sorted(lst)
    if lst in LST:
        count+=1
        break
    else:
        LST.append(lst)
        

print(count)
Problem p02958 (python)

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

if count==2 or count==0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range:
    if p[i]==i+1:
        count+=1

if count==2 or count==0:
    print("YES")
else:
    print("NO")
Problem p02993 (python)

Fixed submission:
s=input()

ans=0
for i in range(3):
    if s[i]==s[i+1]:
        ans=1
if ans==1:
    print("Bad")
else:
    print("Good")

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


for i in range(3):
    if s[i]==s[i+1]:
        ans=1
if ans==1:
    print("Bad")
else:
    print("Good")
Problem p02714 (python)

Fixed submission:
def calc(i, j, B1, len_b):
    extra = 0
    d = j - i

    # i < j < k
    k1 = d + j
    if k1 < len_b:
        extra += B1[k1]

    # k < i < j
    k2 = i - d
    if 0 <= k2 and k2 < len_b:
        extra += B1[k2]

    # i < k < j
    s = i + j
    if s % 2 == 0:
        k3 = s // 2
        if k3 < len_b:
            extra += B1[k3]
    return extra

def main():
    N = int(input())
    S = input()
    R, G, B = [], [], []
    num_r, num_g, num_b = 0, 0, 0
    for i in range(N):
        s = S[i]
        if s == 'R':
            R.append(i)
            num_r += 1
        elif s == 'G':
            G.append(i)
            num_g += 1
        elif s == 'B':
            B.append(i)
            num_b += 1
    if len(R) == 0 or len(G) == 0 or len(B) == 0:
        print(0)
        return
    len_b = (B[-1] + 1)
    B1 = [0]*len_b
    for b in B:
        B1[b] = 1
    # print(R, G, B)
    ans = 0
    for i in R:
        for j in G:
            ans += num_b
            if i < j:
                ans -= calc(i, j, B1, len_b)
            else:
                ans -= calc(j, i, B1, len_b)
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def calc(i, j, B1, len_b):
    extra = 0
    d = j - i

    # i < j < k
    k1 = d + j
    if k1 < len_b:
        extra += B1[k1]

    # k < i < j
    k2 = i - d
    if 0 <= k2 and k2 < len_b:
        extra += B1[k2]

    # i < k < j
    s = i + j
    if s % 2 == 0:
        k3 = s // 2
        if k3 < len_b:
            extra += B1[k3]
    return extra

def main():
    N = int(input())
    S = input()
    R, G, B = [], [], []
    num_r, num_g, num_b = 0, 0, 0
    for i in range(N):
        s = S[i]
        if s == 'R':
            R.append(i)
            num_r += 1
        elif s == 'G':
            G.append(i)
            num_g += 1
        elif s == 'B':
            B.append(i)
            num_b += 1
    len_b = (B[-1] + 1)
    B1 = [0]*len_b
    for b in B:
        B1[b] = 1
    # print(R, G, B)
    ans = 0
    for i in R:
        for j in G:
            ans += num_b
            if i < j:
                ans -= calc(i, j, B1, len_b)
            else:
                ans -= calc(j, i, B1, len_b)
    print(ans)

if __name__ == '__main__':
    main()
Problem p02803 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
S = [0]*H
for i in range(H):
    S[i] = input()
# print(H, W, S)


def is_inside(w, h, W, H):
    if w >= 0 and w < W and h >= 0 and h < H:
        return True
    return False

def solve(sh, sw):
    T = [[0]* W for h in range(H)]
    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                T[i][j] = -1
    if T[sh][sw] == -1:
        return T
    V = deque([(sh, sw)])
    T[sh][sw] = -2
    while len(V) != 0:
        v = V.popleft()
        h = v[0]
        w = v[1]
        # print(h, w)
        t = T[h][w]
        if t == -2:
            t = 0
        if is_inside(h - 1, w, H, W):
            if T[h - 1][w] == 0:
                T[h - 1][w] = t + 1
                V.append((h - 1, w))
        if is_inside(h + 1, w, H, W):
            if T[h + 1][w] == 0:
                T[h + 1][w] = t + 1
                V.append((h + 1, w))
        if is_inside(h, w - 1, H, W):
            if T[h][w - 1] == 0:
                T[h][w - 1] = t + 1
                V.append((h , w - 1))
        if is_inside(h, w + 1, H, W):
            if T[h][w + 1] == 0:
                T[h][w + 1] = t + 1
                V.append((h , w + 1))
    # print(sh, sw, T)
    return T


ans = 0

for h in range(H):
    for w in range(W):
        T = solve(h, w)
        distance = 0
        for i in range(H):
            for j in range(W):
                d = T[i][j]
                distance = max(distance, d)
        ans = max(distance, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

H, W = map(int, input().split())
S = [0]*H
for i in range(H):
    S[i] = input()
# print(H, W, S)


def is_inside(w, h, W, H):
    if w >= 0 and w < W and h >= 0 and h < H:
        return True
    return False

def solve(sh, sw):
    T = [[0]* W for h in range(H)]
    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                T[i][j] = -1
    V = deque([(sh, sw)])
    T[sh][sw] = -2
    while len(V) != 0:
        v = V.popleft()
        h = v[0]
        w = v[1]
        # print(h, w)
        t = T[h][w]
        if t == -2:
            t = 0
        if is_inside(h - 1, w, H, W):
            if T[h - 1][w] == 0:
                T[h - 1][w] = t + 1
                V.append((h - 1, w))
        if is_inside(h + 1, w, H, W):
            if T[h + 1][w] == 0:
                T[h + 1][w] = t + 1
                V.append((h + 1, w))
        if is_inside(h, w - 1, H, W):
            if T[h][w - 1] == 0:
                T[h][w - 1] = t + 1
                V.append((h , w - 1))
        if is_inside(h, w + 1, H, W):
            if T[h][w + 1] == 0:
                T[h][w + 1] = t + 1
                V.append((h , w + 1))
    # print(sh, sw, T)
    return T


ans = 0

for h in range(H):
    for w in range(W):
        T = solve(h, w)
        distance = 0
        for i in range(H):
            for j in range(H):
                d = T[i][j]
                distance = max(distance, d)
        ans = max(distance, ans)

print(ans)
Problem p02928 (python)

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

mod = 10**9 + 7
B = [0]*N
for i in range(N):
    ai = A[i]
    for j in range(i, N):
        aj = A[j]
        if ai > aj:
            B[i] += 1

C = [0]*N
for i in range(N):
    ai = A[i]
    for j in range(i+1):
        aj = A[j]
        if ai > aj:
            C[i] += 1

# print(B)
# print(C)
ans = 0
# for i in range(N):
#     ai = A[i]
#     for j in range(i + 1, N):
#         aj = A[j]
#         # print(i, j, ai, aj)
#         if ai > aj:
#             ans += 1

for i in range(N):
    ans += B[i]*K*(K+1)//2
    ans %= mod

for i in range(N):
    ans += C[i]*(K-1)*K//2
    ans %= mod

print(ans)

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

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        ret = 0
        while i > 0:
            ret += self.tree[i]
            i -= i & -i
        return ret

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

bit = Bit(N)

inter = 0
intra = 0
for i in range(len(A)):
    a = A[i]
    bit.add(a, 1)
    s_a = bit.sum(a)
    intra += i + 1 - s_a
    if a == 1:
        continue
    inter += bit.sum(a - 1)

mod = 10**9 + 7

ans = (intra * K * (K + 1) // 2) % mod
ans += inter * (K - 1) * K // 2 % mod
ans %= mod
print(ans)
Problem p02975 (python)

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

ans = list(set(A))
l = len(ans)
if l > 3:
    print('No')
    exit()

if l == 1:
    if ans[0] == 0:
        print('Yes')
    else:
        print('No')
    exit()

if l == 2:
    a0 = ans[0]
    a1 = ans[1]
    num_a0 = A.count(ans[0])
    num_a1 = A.count(ans[1])
    if a0 != 0 and a1 != 0:
        print('No')
        exit()
    num_0 = num_a0 if a0 == 0 else num_a1
    num_n0 = num_a1 if a0 == 0 else num_a0
    if num_0 * 2 == num_n0:
        print('Yes')
    else:
        print('No')
    exit()

a0 = ans[0]
a1 = ans[1]
a2 = ans[2]

if a0 ^ a1 != a2:
    print('No')
    exit()

num_a0 = A.count(ans[0])
num_a1 = A.count(ans[1])
num_a2 = A.count(ans[2])

if num_a0 != num_a1 or num_a0 != num_a2:
    print('No')
else:
    print('Yes')

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

ans = list(set(A))
if len(ans) > 3:
    print('No')
    exit()

a0 = ans[0]
a1 = ans[1]
a2 = ans[2]

if a0 ^ a1 == a2:
    print('Yes')
else:
    print('No')
Problem p02997 (python)

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

max_edges = (N - 2) * (N - 1) // 2
if max_edges < K:
    print(-1)
    exit()

remain = max_edges - K
print(N - 1 + remain)
for i in range(2, N + 1):
    print(1, i)

for i in range(2, N + 1):
    if remain <= 0:
        break
    for j in range(i + 1, N + 1):
        if remain <= 0:
            break
        print(i, j)
        remain -= 1

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
# print(N, K)

def print_simple(N, K, simple_max_edges):
    remain = simple_max_edges - K
    print(4 + remain)
    for i in range(1, N):
        print(i, i + 1)

    for i in range(1, N - 1):
        if remain == 0:
            break
        print(i, i + 2)
        remain -= 1

simple_max_edges = N - 2
if K <= simple_max_edges:
    print_simple(N, K, simple_max_edges)
    exit()

max_edges = (N - 2) * (N - 1) // 2
if max_edges < K:
    print(-1)
    exit()

print(4 + remain)
for i in range(2, N + 1):
    print(1, i)

remain = max_edges - K
for i in range(2, N + 1):
    if remain == 0:
        break
    print(i, i + 1)
    remain -= 1
Problem p02999 (python)

Fixed submission:
l = input().split()
X = int(l[0])
A = int(l[1])

if X < A:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
l = input().split()
N = int(l[0])
K = int(l[1])

l = input().split()
s = 0
A = []
for i in range(N):
    a = int(l[i])
    s += a
    A.append(a)

B = []
s1 = 0
for i in range(N):
    B.append(s - s1)
    s1 += A[i]
B.append(0)

# print(N, K, A, B)

ans = 0
for i in range(N):
    b = B[i]
    if b < K:
        break
    small = 0
    large = N
    j = (small + large)//2
    while True:
        index = N - 1 - j
        # print(i, j, b, index, B[index], B[index + 1], small, large)
        if b - B[index] < K and b - B[index + 1] >= K:
            # print(ans, i, j)
            ans += j + 1
            break
        if b - B[index] < K:
            large = j
            j = (small + large)//2
        else:
            small = j
            j = (small + large)//2

print(ans)