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

Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())
cnt = 0
def lcm(x, y):
	return (x*y) // gcd(x,y)
e = lcm(c,d)
x = b//c + b//d - b//e
y = (a-1)//c + (a-1)//d - (a-1)//e
print (b-a+1-(x-y))

Buggy submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())

def lcm(x,y):
	return (x*y)//math.gcd(x,y)
e = lcm(c,d)

f = (b//c + b//d) - b//e
g = ((a-1)//c + (a-1)//d) - (a-1)//e
print (b-a+1-(f-g))
Problem p03062 (python)

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

hu = []
sei = []
for i in a:
	if i < 0:
		hu.append(i)
	else:
		sei.append(i)
hu.sort()
sei.sort()
if len(hu)%2 == 0:
	ans = sum(sei) + (-1)*sum(hu)
else:
	if len(sei) == 0:
		ans = (-1)*sum(hu[:-1]) + hu[-1]
		print (ans)
		exit()
	else:
		b = sei[0]
	if len(hu) == 0:
		ans = sum(sei[1:] + sei[-1])
		print (ans)
		exit()
	else:
		c = hu[-1]
	if abs(b) <= abs(c):
		b *= -1
		c *= -1
	ans = sum(sei[1:]) + (-1)*sum(hu[:-1])
	ans += (b+c)
print (ans)

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

hu = []
sei = []
for i in a:
	if i < 0:
		hu.append(i)
	else:
		sei.append(i)
hu.sort()
sei.sort()
if len(hu)%2 == 0:
	ans = sum(sei) + (-1)*sum(hu)
else:
	b = sei[0]
	c = hu[-1]
	if abs(b) <= abs(c):
		b *= -1
		c *= -1
	ans = sum(sei[1:]) + (-1)*sum(hu[:-1])
	ans += (b+c)
print (ans)

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

hu = []
sei = []
for i in a:
	if i < 0:
		hu.append(i)
	else:
		sei.append(i)
hu.sort()
sei.sort()
if len(hu)%2 == 0:
	ans = sum(sei) + (-1)*sum(hu)
else:
	b = sei.pop(0)
	c = hu.pop(-1)
	if abs(b) <= abs(c):
		b *= -1
		c *= -1
	ans = sum(sei) + (-1)*sum(hu)
	ans += (b+c)
print (ans)

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

hu = []
sei = []
for i in a:
	if i < 0:
		hu.append(i)
	else:
		sei.append(i)
hu.sort()
sei.sort()
if len(hu)%2 == 0:
	ans = sum(sei) + (-1)*sum(hu)
else:
	b = sei.pop(0)
	b *= -1
	c = hu.pop(-1)
	c *= -1
	ans = sum(sei) + (-1)*sum(hu)
	ans += (b+c)
print (ans)
Problem p03076 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
p = [a, b, c, d, e]

mi = [a%10,b%10,c%10,d%10,e%10]
mm = [i for i in mi if i != 0]
mm.sort()
sum = 0
for i in range(5):
	if p[i]%10 != 0:
		sum += (p[i]//10+1)*10
	else:
		sum += p[i]//10*10
if (mm):
	sum -= 10- mm[0]
print (sum)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
p = [a, b, c, d, e]

mi = [a%10,b%10,c%10,d%10,e%10]
mm = [i for i in mi if i != 0]
mm.sort()
sum = 0
for i in range(5):
	if p[i]%10 != 0:
		sum += (p[i]//10+1)*10
	else:
		sum += p[i]//10*10
sum -= 10 - mm[0]
print (sum)
Problem p03244 (python)

Fixed submission:
import collections
n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
	print (n//2)
	exit()
a = v[1::2]
b = v[0::2]
if len(set(a)) == 1 and len(set(b)) == 1:
	print (0)
	exit()
ans = 0

aa = collections.Counter(a)
bb = collections.Counter(b)

yousoa = aa.most_common()[0][0]
maa = aa.most_common()[0][1]
yousob = bb.most_common()[0][0]
mbb = bb.most_common()[0][1]
if len(set(a)) == 1:
	ans += len(b) - mbb
	print (ans)
	exit()
if len(set(b)) == 1:
	ans += len(a) - maa
	print (ans)
	exit()
maa2 = aa.most_common()[1][1]
mbb2 = bb.most_common()[1][1]
if yousoa == yousob:
	ans = min(n//2-maa + n//2-mbb2,n//2-maa2 + n//2-mbb)
	print (ans)
else:
	print (n-maa-mbb)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
	print (n//2)
	exit()
a = v[1::2]
b = v[0::2]
if len(set(a)) == 1 and len(set(b)) == 1:
	print (0)
	exit()

aa = collections.Counter(a)
bb = collections.Counter(b)

yousoa = aa.most_common()[0][0]
maa = aa.most_common()[0][1]
yousob = bb.most_common()[0][0]
mbb = bb.most_common()[0][1]
if yousoa == yousob
	if len(a) == 1:
		ans = (len(a) - maa) + (len(b) - bb.most_common()[1][1])
	elif len(b) == 1:
		ans = (len(a) - aa.most_common()[1][1]) + (len(b)-mbb)
	else:
		ans = (len(a) - maa) + (len(b) - bb.most_common()[1][1])
else:
	ans = len(a)-maa + len(b)-mbb
print (ans)
Problem p03496 (python)

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

b = 0
by = 0
flg = 0
for i,j in enumerate(a):
	if abs(j) > abs(b):
		b = j
		by = i+1
		if j > 0:
			flg = 1
		else:
			flg = 0
ans = []
if flg == 1:
	x = min(a)
	if x < 0:
		for i in range(n):
			if a[i] != b:
				a[i] += b
				ans.append([by,i+1])
	for i in range(1,n):
		a[i] += a[i-1]
		ans.append([i,i+1])
else:
	x = max(a)
	if x > 0:
		for i in range(n-1,-1,-1):
			if a[i] != b:
				a[i] += b
				ans.append([by,i+1])
	for i in range(n-2,-1,-1):
		a[i] += a[i+1]
		ans.append([i+2,i+1])
print (len(ans))
for i in ans:
	print (*i)

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

b = 0
by = 0
flg = 0
for i,j in enumerate(a):
	if abs(i) > abs(b):
		b = j
		by = i+1
		if j > 0:
			flg = 1
		else:
			flg = 0
ans = []
if flg == 1:
	x = min(a)
	if x < 0:
		for i in range(n):
			if a[i] != b:
				a[i] += b
				ans.append([by,i+1])
	for i in range(1,n):
		a[i] += a[i-1]
		ans.append([i,i+1])
else:
	x = max(a)
	if x > 0:
		for i in range(n,-1,-1):
			if a[i] != b:
				a[i] += b
				ans.append([by,i+1])
	for i in range(n-2,-1,-1):
		a[i] += a[i+1]
		ans.append([i+2,i+1])
print (len(ans))
for i in ans:
	print (*i)
Problem p03625 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dict = {}
b = [0,0]
c = [0,0]
for i in a:
	if i in dict:
		dict[i] += 1
	else:
		dict[i] = 1
	if dict[i] == 2:
		b.append(i)
	if dict[i] == 4:
		c.append(i)
b.sort(reverse=True)
c.sort(reverse=True)
print (max(b[0] * b[1],c[0]**2))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dict = {}
b = []
c = []
for i in a:
	if i in dict:
		dict[i] += 1
	else:
		dict[i] = 1
	if dict[i] == 2:
		b.append(i)
	if dict[i] == 4:
		c.append(i)
b.sort(reverse=True)
c.sort(reverse=True)
if len(b) < 2:
	print (0)
else:
	print (max(b[0] * b[1],c[0]**2))
Problem p03645 (python)

Fixed submission:
n, m = map(int, input().split())
#2次元配列
#a=[list(map(int,input().split())) for i in range(m)]

aa = []
bb = []
for i in range (m):
	a, b = map(int, input().split())
	if(a == 1):
		aa.append(b)
	if(b == n):
		bb.append(a)

if( len(set(aa) & set(bb)) == 0):
	print ("IMPOSSIBLE")
else:
	print ("POSSIBLE")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
c = [False for i in range(199999)]
d = [False for i in range(199999)]
for i in range(m):
	a, b = map(int, input().split())
	if a == 1:
		c[b] = True
	if b == n:
		d[a] = True
for i in range(199999):
	if c[i] and d[i]:
		print ("POSSIBLE")
		exit()
print ("IMPOSSIBLE")
Problem p03696 (python)

Fixed submission:
n = int(input())
s = input()
ans = s

let = 0
let2 = ""
for i in range(n):
	if s[i] == "(":
		let += 1
	else:
		if let > 0:
			let -= 1
		else:
			let2 += "("
print (let2 + s + ")"*let)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
lef2 = s.rindex(")")
rit2 = s.index("(")

ans = s
ans += ")"*(n-(lef2+1))
ans = "("*rit2 + ans
lef = ans.count("(")
rit = ans.count(")")
if lef > rit:
	ans += ")"*(lef-rit)
	print (ans)
elif lef == rit:
	print (ans)
else:
	ans = "("*(rit-lef) + ans
	print (ans)
Problem p03844 (python)

Fixed submission:
a, op, b = map(str, input().split())
if op == "+":
	print (int(a) + int(b))
else:
	print (int(a) - int(b))

Buggy submission (verdict: Runtime Error):
import copy
n = int(input())
t = list(map(int, input().split()))
m = int(input())
c = []
for i in range(m):
	p, x = map(int, input().split())
	c = []
	c = copy.copy(t)
	c[p-1] = x
	print (sum(c))
Problem p03860 (python)

Fixed submission:
a = list(map(str, input().split()))
print ("A" + a[1][0] + "C")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a + b > 24:
	print (a+b - 24)
else:
	print (a+b)
Problem p04043 (python)

Fixed submission:
a = list(map(int, input().split()))
a.sort()
if a[0] == 5 and a[1] == 5 and a[2] == 7:
	print ("YES")
else:
	print ("NO")

Buggy submission (verdict: Runtime Error):
n, l = map(int, input().split())
a = [input() for _ in range(n)]
a.sort()
print ("".join(a))
Problem p02641 (python)

Fixed submission:
X,N = map(int, input().split())
p = list(map(int, input().split()))
dif = 1

if(X not in p):
    print(X)
else:
    while True:
        if(X-dif not in p):
            dif = dif*(-1)
            break
        elif(X+dif not in p):
            break
        else:
            dif=dif+1
    print(X+dif)

Buggy submission (verdict: Runtime Error):
X,N = map(int, input().split())
p = list(map(int, input().split()))
dif = 1

if(X not in p):
    print(X)
else:
    while True:
        if(X-dif not in p):
            dif = dif*(-1)
            break
        elif(X+dif not in p):
            break
        else:
            dif=dif+1
      print(X+dif)
Problem p02681 (python)

Fixed submission:
S = list(input())
T = list(input())
ans = 0

for i in range(0, len(S)):
    if (S[i] != T[i]):
        ans = 0
        break    
    else :
      if(len(S)+1 == len(T)):
        ans = 1
      elif(len(S)>=len(T)):
        ans = 2
      elif(len(S)+1 < len(T)):
        ans = 3

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

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


for i in range(0, len(S)-1):
    if (S[i] != T[i]):
        print('No')
    else :
		if(len(S)+1 == len(T)):
    		print('Yes')
		elif(len(S)>=len(T)):
    		print('No')
		elif(len(S)+1 < len(T)):
    		print('No')
Problem p02705 (python)

Fixed submission:
import math
math.pi

N = int(input())

print(2*N*math.pi)

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

for i in range(0, N):
    print(A.count(i+1))

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

for i in range(0, N):
    print(A.count(i+1))
Problem p04030 (python)

Fixed submission:
S = list(input())
ans = []

for i in range(len(S)):
    if(S[i] != 'B'):
        ans.append(S[i])
    elif(S[i] == 'B' and len(ans) != 0):
        ans.pop()

        
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
S = list(input())
ans = []

for i in range(len(S)):
    if(S[i] != 'B'):
        ans.append(S[i])
    elif(S[i] == 'B' and len(ans) != 0):
        ans.remove(ans[i-1])

        
print(''.join(ans))
Problem p02582 (python)

Fixed submission:
s = input()
if s == "SSS":
    print(0)
elif s == "RSS" or s == "SRS" or s == "SSR" or s == "RSR":
    print(1)
elif s == "RRR":
    print(3)
elif s == "RRS" or s == "SRR":
    print(2)

Buggy submission (verdict: Runtime Error):
s = input()
if s = "SSS":
    print(0)
elif s = "RSS" or s = "SRS" or s = "SSR" or s = "RSR":
    print(1)
elif s = "RRR":
    print(3)
elif s = "RRS" or s = "SRR":
    print(2)
Problem p02585 (python)

Fixed submission:
n , k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
loop = []
visit = [(-1,-1) for i in range(n)]
cou = -1
for i in range(n):
    if visit[i] != (-1,-1):
        continue
    cou += 1
    tyu  = [i]
    now = i
    visit[i] = (cou,0)
    t = 1
    while True:
        nex = p[now] - 1
        if nex == i:
            break
        visit[nex] = (cou,t)
        tyu.append(nex)
        now = nex
        t += 1
    loop.append(tyu)

ans = []

for i in range(n):
    p = loop[visit[i][0]][visit[i][1]:] + loop[visit[i][0]][:visit[i][1]]
    kar = [0]
    kouho = []
    losum = 0
    lokz = len(p)
    for j in p:
        losum += c[j]
        kar.append(kar[-1] + c[j])
    if losum >= 0:
        for l in range(lokz+1):
            if l > k:
                break
            cou = losum*((k-l)//lokz) + kar[l]
            kouho.append(cou)
    elif losum < 0:
        for l in range(1,lokz+1):
            if l > k:
                break
            cou = kar[l]
            kouho.append(cou)
    ans.append(max(kouho))
print(max(ans))

Buggy submission (verdict: Runtime Error):
n , k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = []
for i in range(n):
    visit = [-1 for i in range(n)]
    cou = 0
    visit[i] = 0
    kar = []
    now = i
    while True:
        cou += 1
        if cou > k:
            break
        nex = p[now] - 1
        if visit[nex] == -1:
            visit[nex] = cou
            if kar:
                kar.append(kar[-1] + c[nex])
            else:
                kar.append(c[nex])
            now = nex
        elif visit[nex] != -1:
            if kar:
                lokz = cou
                losu = kar[-1] + c[nex]
                if losu > 0:
                    kar.append(losu * (k//lokz) + max(kar[:(k%lokz)]))
                break
            else:
                if c[nex] >= 0:
                    kar.append(c[nex]*k)
                elif c[nex] < 0:
                    kar.append(c[nex])
                break
    ans.append(max(kar))
print(max(ans))
Problem p02586 (python)

Fixed submission:
R , C , K = map(int,input().split())
masu = [[0 for i in range(C)] for j in range(R)]
for i in range(K):
    r , c , v = map(int,input().split())
    masu[r-1][c-1] = v

dp0 = [[0 for i in range(C)] for j in range(R)]
dp1 = [[0 for i in range(C)] for j in range(R)]
dp2 = [[0 for i in range(C)] for j in range(R)] 
dp3 = [[0 for i in range(C)] for j in range(R)]

if masu[0][0] != 0:
    dp1[0][0] = masu[0][0]
for i in range(1,C):
    dp0[0][i] = max(dp0[0][i],dp0[0][i-1])
    dp1[0][i] = max(dp1[0][i],dp1[0][i-1])
    dp2[0][i] = max(dp2[0][i],dp2[0][i-1])
    dp3[0][i] = max(dp3[0][i],dp3[0][i-1])
    if masu[0][i] != 0:
        dp3[0][i] = max(dp3[0][i],dp2[0][i]+masu[0][i])
        dp2[0][i] = max(dp2[0][i],dp1[0][i]+masu[0][i])
        dp1[0][i] = max(dp1[0][i],dp0[0][i]+masu[0][i])




for i in range(1,R):
    for j in range(C):
        dp0[i][j] = max(dp0[i][j],dp0[i-1][j],dp1[i-1][j],dp2[i-1][j],dp3[i-1][j])
        if j != 0:
            dp0[i][j] = max(dp0[i][j],dp0[i][j-1])
            dp1[i][j] = max(dp1[i][j],dp1[i][j-1])
            dp2[i][j] = max(dp2[i][j],dp2[i][j-1])
            dp3[i][j] = max(dp3[i][j],dp3[i][j-1])
        if masu[i][j] != 0:
            dp3[i][j] = max(dp3[i][j],dp2[i][j]+masu[i][j])
            dp2[i][j] = max(dp2[i][j],dp1[i][j]+masu[i][j])
            dp1[i][j] = max(dp1[i][j],dp0[i][j]+masu[i][j])
print(max(dp0[-1][-1],dp1[-1][-1],dp2[-1][-1],dp3[-1][-1]))

Buggy submission (verdict: Runtime Error):
R , C , K = map(int,input().split())
masu = [[0 for i in range(C)] for j in range(R)]
for i in range(K):
    r , c , v = map(int,input().split())
    masu[r-1][c-1] = v

dp0 = [[0 for i in range(C)] for j in range(R)]
dp1 = [[0 for i in range(C)] for j in range(R)]
dp2 = [[0 for i in range(C)] for j in range(R)] 
dp3 = [[0 for i in range(C)] for j in range(R)]

if masu[0][0] != 0:
    dp1[0][0] = masu[0][0]
for i in range(1,C):
    dp0[0][i] = max(dp0[0][i],dp0[0][i-1])
    dp1[0][i] = max(dp1[0][i],dp1[0][i-1])
    dp2[0][i] = max(dp2[0][i],dp2[0][i-1])
    dp3[0][i] = max(dp3[0][i],dp3[0][i-1])
    if masu[0][i] != 0:
        dp3[0][i] = max(dp3[0][i],dp2[0][i]+masu[0][i])
        dp2[0][i] = max(dp2[0][i],dp1[0][i]+masu[0][i])
        dp1[0][i] = max(dp1[0][i],dp0[0][i]+masu[0][i])


if R == 1:
    print(dp[-1][-1])
    exit()

for i in range(1,R):
    for j in range(C):
        dp0[i][j] = max(dp0[i][j],dp0[i-1][j],dp1[i-1][j],dp2[i-1][j],dp3[i-1][j])
        if j != 0:
            dp0[i][j] = max(dp0[i][j],dp0[i][j-1])
            dp1[i][j] = max(dp1[i][j],dp1[i][j-1])
            dp2[i][j] = max(dp2[i][j],dp2[i][j-1])
            dp3[i][j] = max(dp3[i][j],dp3[i][j-1])
        if masu[i][j] != 0:
            dp3[i][j] = max(dp3[i][j],dp2[i][j]+masu[i][j])
            dp2[i][j] = max(dp2[i][j],dp1[i][j]+masu[i][j])
            dp1[i][j] = max(dp1[i][j],dp0[i][j]+masu[i][j])
print(max(dp0[-1][-1],dp1[-1][-1],dp2[-1][-1],dp3[-1][-1]))
Problem p02609 (python)

Fixed submission:
def popcount(u):
    t = bin(u)
    h = t.count("1")
    return u % h 

n = int(input())
x = list(input())
c = x.count("1") + 1
d = c - 2

amaric = [1 % c]
if d >= 1:
    amarid = [1 % d]
for i in range(n-1):
    amaric.append((amaric[-1]*2)%c)
    if d >= 1:
        amarid.append((amarid[-1]*2)%d)

motoc = 0
motod = 0
for i in range(n):
    if x[i] == "1":
        motoc += amaric[n-1-i]
        if d >= 1:
            motod += amarid[n-1-i]

for i in range(n):
    if x[i] == "0":
        op = motoc
        op += amaric[n-1-i]
        op %= c
    elif x[i] == "1":
        if d >= 1:
            op = motod
            op -= amarid[n-1-i]
            op %= d
        elif d == 0:
            print(0)
            continue
    cou = 1
    while True:
        if op == 0:
            break
        op = popcount(op)
        cou += 1
    print(cou)

Buggy submission (verdict: Runtime Error):
def popcount(u):
    t = bin(u)
    h = t.count("1")
    return u % h 

n = int(input())
x = list(input())
c = x.count("1") + 1
d = c - 2

amaric = [1 % c]
amarid = [1 % d]
for i in range(n-1):
    amaric.append((amaric[-1]*2)%c)
    amarid.append((amarid[-1]*2)%d)

motoc = 0
motod = 0
for i in range(n):
    if x[i] == "1":
        motoc += amaric[n-1-i]
        motod += amarid[n-1-i]

for i in range(n):
    if x[i] == "0":
        op = motoc
        op += amaric[n-1-i]
        op %= c
    elif x[i] == "1":
        op = motod
        op -= amarid[n-1-i]
        op %= d
    cou = 1
    while True:
        if op == 0:
            break
        op = popcount(op)
        cou += 1
    print(cou)

Buggy submission (verdict: Runtime Error):
def popcount(u):
    t = bin(u)
    h = t.count("1")
    return u % h 
    
n = int(input())
x = list(input())
c = x.count("1") + 1
d = c - 2
amaric = [1 % c]
amarid = [1 % d]
for i in range(n-1):
    amaric.append((amaric[-1]*2)%c)
    amarid.append((amarid[-1]*2)%d)
pri = [-1 for i in range(2*(10**5) + 1)]
pri[0] = 0
for i in range(1,2*(10**5)+1):
    if pri[i] == -1:
        now =  popcount(i)
        pri[i] = pri[now] + 1

motoc = 0
motod = 0
for i in range(n):
    if x[i] == "1":
        motoc += amaric[n-1-i]
        motod += amarid[n-1-i]
for i in range(n):
    if x[i] == "0":
        op = motoc
        op += amaric[n-1-i]
        op %= c
    elif x[i] == "1":
        op = motod
        op -= amarid[n-1-i]
        op %= d
    print(pri[op]+1)
Problem p02691 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
mae = {}
ans = 0
for i in range(n):
    mae[i+a[i]]=mae.get(i+a[i],0)+1
    ans += mae.get(i-a[i],0)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
i = 0
j = 1
ans = 0
p = 0
while True:
    if j == n:
        j = min(i+1,nextj)
        p = 0
        i += 1
    
    if p == 0 and a[i] + a[j] == j-i:
        ans += 1
        nextj = j
        p = 1
    elif p == 1 and a[i] + a[j] == j-i:
        ans += 1
    j += 1
    
    if i == n-1:
        print(ans)
        exit()
Problem p02720 (python)

Fixed submission:
import queue

q = queue.Queue()
for i in range(1,10):
    q.put(i)

k = int(input())
cou = 0
while True:
    cou += 1
    t = q.get()
    if cou == k:
        print(t)
        exit()
    if t % 10 == 0:
        q.put(t*10)
        q.put(t*10 + 1)
    elif t % 10 == 9:
        q.put(t*10 + 8)
        q.put(t*10 + 9)
    else:
        s = t % 10
        q.put(t*10 + s -1)
        q.put(t*10 + s)
        q.put(t*10 + s + 1)

Buggy submission (verdict: Runtime Error):
k = int(input())
cou = 0
while True:
    cou += 1
    t = q.get()
    if cou == k:
        print(t)
        exit()
    if t % 10 == 0:
        q.put(t*10)
        q.put(t*10 + 1)
    elif t % 10 == 9:
        q.put(t*10 + 8)
        q.put(t*10 + 9)
    else:
        s = t % 10
        q.put(t*10 + s -1)
        q.put(t*10 + s)
Problem p02761 (python)

Fixed submission:
fla = 0
ans = 0

ket , kaz = map(int,input().split())
num = [-1 for i in range(ket)]
for j in range(kaz):
    s , c = map(int,input().split())
    if num[s-1] == -1:
        num[s-1] = c
    elif num[s-1] != c:
        fla = -1
        break

if fla == 0:
    if num[0] == 0:
        if ket != 1:
            fla = -1
    elif num[0] == -1:
        if ket == 1:
            num[0] = 0
        elif ket != 1:
            num[0] = 1

if fla == 0:
    for i in range(ket-1):
        if num[i+1] == -1:
            num[i+1] = 0
            
if fla == 0:
    for h in range(ket):
        ans +=  num[h]*(10**(ket-h-1))
    print(ans)
elif fla == -1:
    print(-1)

Buggy submission (verdict: Runtime Error):
fla = 0
ans = 0

ket , kaz = map(int,input().split())
num = [-1 for i in range(ket)]
for j in range(kaz):
    s , c = map(int,input().split())
    if num[s-1] == -1:
        num[s-1] = c
    elif num[s-1] != c:
        fla = -1
        break

if fla == 0:
    if num[0] == 0:
        if ket != 1 
            fla = -1
    elif num[0] == -1:
        if ket == 1:
            num[0] = 0
        elif ket != 1:
            num[0] = 1

if fla == 0:
    for i in range(ket-1):
        if num[i+1] == -1:
            num[i+1] = 0
            
if fla == 0:
    for h in range(ket):
        ans +=  num[h]*(10**(ket-h-1))
    print(ans)
elif fla == -1:
    print(-1)
Problem p02767 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import sys

x = int(input()) 
san = list(map(int,input().split(" ")))

if x == 1:
    print("0")
    sys.exit()

sta = min(san)
goa = max(san)

if sta == goa:
    print("0")
    sys.exit()

tai = 0
ans = [] 

for i in range(sta,goa):
    tai = 0
    for j in range(x):
        tai += (i - san[j])**2
    ans.append(tai)
    
print(min(ans))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import sys

x = int(input()) 
san = list(map(int,input().split(" ")))

if x == 1:
    print("0")
    sys.exit()

sta = min(san)
goa = max(san)

tai = 0
ans = [] 

for i in range(sta,goa):
    tai = 0
    for j in range(x):
        tai += (i - san[j])**2
    ans.append(tai)
    
print(min(ans))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
x = int(input()) 
san = list(map(int,input().split(" ")))

sta = min(san)
goa = max(san)

tai = 0
ans = [] 

for i in range(sta,goa):
    tai = 0
    for j in range(x):
        tai += (i - san[j])**2
    ans.append(tai)
    
print(min(ans))
Problem p02768 (python)

Fixed submission:
#xCy=x!/y!(x-y)!
def com(x,y):
    bunb = 1
    buns = 1
    for i in range(y):
        buns = buns * (x-i) % mod
        bunb = bunb * (i+1) % mod

    bunb_inv = pow(bunb,mod-2,mod)
    d = (buns * bunb_inv) % mod
    return buns*pow(bunb,mod-2,mod)
    
n,a,b = map(int,input().split())
mod = 10**9 + 7

ans = pow(2,n,mod) - 1
ans -= com(n,a) + com(n,b)

print(ans%mod)

Buggy submission (verdict: Runtime Error):
mod = 1000000007

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

def power(s, t):
    if   t == 0     : return 1
    elif t == 1     : return x % mod
    elif t % 2 == 0 : return power(s, t/2)**2 % mod
    else            : return power(s, t/2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))
    
def cmb(a,b):
    p = 1
    q = 1
    for i in range(1,b+1):
        p = mul(p,a-i)
    for j in range(1,b+1):
        q = mul(q,j)
    return div(p,q)

x,y,z = map(int,input().split(" "))
ans = 0

for i in range(1,x+1):
    if i == y or i == z:
        continue
    else:
        ans += cmb(x,i)

print(ans)
Problem p02797 (python)

Fixed submission:
n , k , s = map(int,input().split())
l = []
for i in range(k):
    l.append(s)
if s == 1:
    t = 3
elif s == 10**9:
    t = 1
else:
    t = s + 1

for i in range(n-k):
    l.append(t)


print(' '.join(map(str, l)))

Buggy submission (verdict: Runtime Error):
n , k , s = map(int,input().split())
l = []
for i in range(k):
    l.append(s)
for i in range(n-k):
    l.append(s+1)
    
if n != 1:
    print(' '.join(map(str, l)))
elif n = 1:
    print(s)