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

Fixed submission:
n = int(input())
l = [input().split()+[i+1] for i in range(n)]
for i in range(n):
    l[i][1] = int(l[i][1])
l = sorted(l, key=lambda x : x[1], reverse=True)
l = sorted(l, key=lambda x : x[0])
for i in range(n):
    print(l[i][2])

Buggy submission (verdict: Runtime Error):
n = int(input())
book=[]
for i in range(n):
    a,b=input().split()
    temp=[a,int(b),i+1]
    book.append(temp)

book.reverse(key = lambda x:x[1])
book.sort(key = lambda x:x[0])

for j in range(len(book)):
    print(book[j][2])

Buggy submission (verdict: Runtime Error):
n = int(input())
book=[]
for i in range(n):
    a,b=input().split()
    temp=[a,int(b),i+1]
    book.append(temp)

book.reverse(key = lambda x:x[1])
book.sort(key = lambda x:x[0])

for j in range(len(book)):
    print(book[j][2])

Buggy submission (verdict: Runtime Error):
n = int(input())
book=[]
for i in range(n):
    a,b=input().split()
    temp=[a,int(b),i+1]
    book.append(temp)

book.sort(key = lambda x:x[1], reverce = True)
book.sort(key = lambda x:x[0])

for j in range(len(book)):
    print(book[j][2])

Buggy submission (verdict: Runtime Error):
n = int(input())
book=[]
for i in range(n):
    a,b=input().split()
    temp=[a,int(b),i+1]
    book.append(temp)

book.sort(key = lambda x:x[1])
book.sort(key = lambda x:x[0])

for j in range(len(book)):
    print(book[j][3])

Buggy submission (verdict: Runtime Error):
n = int(input())
book=[]
for i in range(n):
    a,b=input().split()
    temp=[a,int(b),i+1]
    book.append(temp)

book.sort(key=lambda x:x[0])
book.sort(key=lambda x:x[1])

for j in range[len(book)]:
    print(book[j][3])

Buggy submission (verdict: Runtime Error):
n = int(input())
book=[]
for i in range(n):
    a,b=input().split()
    temp=[a,int(b),i+1]
    book.append(temp)

book.sort(key=lambda x:x[0])
book.sort(key=lambda x:x[1])

for j in range[len(book)]:
    print(book[j][3])
Problem p03049 (python)

Fixed submission:
import sys
N = int(sys.stdin.readline())
S = list(map(str,sys.stdin.read().rstrip().split("\n")))

ans = 0
A = 0
B = 0
BA = 0
for s in S:
	ans += s.count('AB')
	if  s[0] == 'B' and s[-1] == 'A':
		BA += 1
		continue
	elif s[0] == 'B':
		B += 1
	elif s[-1] == 'A':
		A += 1

if BA == 0:
	ans += min(A,B)
else:
	if A+B > 0:
		ans += BA + min(A,B)
	else:
		ans += BA-1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N = int(sys.stdin.readline())
S = list(map(str,sys.stdin.read().rstrip().split("\n")))

ans = 0
A = 0
B = 0
BA = 0
for s in S:
	ans += s.count('AB')
	if  s[0] == 'B' and s[-1] == 'A':
		BA += 1
	elif s[0] == 'B':
		B += 1
	elif s[-1] == 'A':
		A += 1


if A+B >= BA:
	ans += BA
	BA = 0
else:
	ans += A+B
	BA -= A+B

if A >= B:
	ans += B
	C = A - B
else:
	ans += A
	C = B - A

if BA > 0:
	if C >= BA:
		ans += BA
	else:
		s,t = divmod(BA,C)
		ans += s*C
		ans += t//2


print(ans)
Problem p03061 (python)

Fixed submission:
import math

N = int(input())
A = sorted(list(map(int, input().split())))

def division_enumeration(num):
	ans = []
	d = math.floor(float(num)**(1/2))
	for i in range(1,d+1):
		if num % i == 0:
			ans.append(i)
			ans.append(num//i)

	return ans

trgs = sorted(set(division_enumeration(A[0]) + division_enumeration(A[1])), reverse = True)

for trg in trgs:
	cnt = 0
	cond = True
	for i in range(N):
		if A[i] % trg != 0:
			cnt += 1
			if cnt > 1:
				cond = False
				break
	if not cond:
		continue
	
	ans = trg
	break

print(ans)

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


def check(num):
	cnt = 0
	cond = True

	for i in range(N):
		if A[i] % num != 0:
			cnt += 1
		if cnt > 1:
			cond = False
			break

	return cond

def BinarySearch(s,l):
	if s == l:
		return s
	if s+1 == l:
		if check(l):
			return l
		elif check(s):
			return s

	center = s + (l-s)//2
	
	if check(center):
		return BinarySearch(center, l)
	else:
		return BinarySearch(s, center-1)

print(BinarySearch(0, max(A))
Problem p03101 (python)

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())

print((H - h) * (W - w))

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

print(s[:k-1] + s[k-1].lower() + s[k:n])
Problem p03145 (python)

Fixed submission:
a, b, c = map(int, input().split())

print((a*b)//2)

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

print(int((a*b)/2))

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

print((a*b)//2)
Problem p03150 (python)

Fixed submission:
s = input()
l = len(s)
cond = False
for i in range(8):
	if s[:i] + s[-(7-i):] == "keyence":
		cond = True

if cond:
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
import sys

s = input()
A = "keyence"

ind = 100

for i in range(len(s)):
	if i == 0:
		if s[i] == A[i]:
			continue
		else:
			ind = -1
			break

	if i == 6:
		if s[i] == A[i]:
			print("YES")
			sys.exit()

	else:
		if s[i] == A[i]:
			continue
		else:
			ind == i
			break

if ind == -1:
	print("NO")
	sys.exit()

ind_back = 100

for i in range(1,8):
	if i == 1:
		if s[-i] == A[-i]:
			continue
		else:
			ind_back == -1
			break

	if i == 7:
		if s[-i] == A[-i]:
			print("YES")
			sys.exit()

	else:
		if s[-i] == A[-i]:
			continue
		else:
			ind_back == 7-i+1

if ind == ind_back:
	print("YES")
else:
	print("NO")
Problem p03210 (python)

Fixed submission:
x = int(input())

if x == 7 or x == 5 or x == 3:
    print("YES")
else:
    print("NO")

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

print(min([abs(int(s[i]+s[i+1]+s[i+2])-753) for i in range(len(s)-3)]))
Problem p03229 (python)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

l = A.pop()
r = A.pop(0)
ans = abs(l-r)
while A:
	tmp = [abs(l-A[0]),abs(l-A[-1]),abs(r-A[0]),abs(r-A[-1])]
	cond = tmp.index(max(tmp))

	if cond == 0:
		ans += tmp[0]
		l = A.pop(0)
	elif cond == 1:
		ans += tmp[1]
		l = A.pop()
	elif cond == 2:
		ans += tmp[2]
		r = A.pop(0)
	else:
		ans += tmp[3]
		r = A.pop()

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

c = A.pop(0)
l = A.pop()
r = A.pop()
ans = (l-c) + (r-c)

cond = 0
while A:
	if cond % 4 == 0:
		tmp = A.pop(0)
		ans += l - tmp
		l = tmp
		cond += 1 
	elif cond % 4 == 1:
		tmp = A.pop(0)
		ans += r - tmp
		r = tmp
		cond += 1
	elif cond % 4 == 2:
		tmp = A.pop()
		ans += tmp - l
		l = tmp
		cond += 1
	else:
		tmp = A.pop()
		ans += tmp - r
		r = tmp
		cond += 1

print(ans)
Problem p03231 (python)

Fixed submission:
import math
import sys

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


n,m = map(int, input().split())
s = input()
t = input()

if s[0] != t[0]:
	print(-1)
	sys.exit()

GCD = gcd(n,m)

if GCD == 1:
	print(n*m)
	sys.exit()

LCM = n*m//GCD


s_k = LCM//m
t_k = LCM//n
for i in range(GCD):
	if s[i*s_k] != t[i*t_k]:
		print(-1)
		sys.exit()

print(LCM)

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

n,m = map(int, input().split())
s = input()
t = input()

if s[0] != t[0]:
	print(-1)
	sys.exit()

GCD = math.gcd(n,m)

if GCD == 1:
	print(n*m)
	sys.exit()

LCM = n*m//GCD


s_k = LCM//m
t_k = LCM//n
for i in range(GCD):
	if s[i*s_k] != t[i*t_k]:
		print(-1)
		sys.exit()

print(LCM)

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

n,m = map(int, input().split())
s = input()
t = input()

if s[0] != t[0]:
	print(-1)
	sys.exit()

GCD = math.gcd(n,m)

if GCD == 1:
	print(n*m)
	sys.exit()

LCM = n*m//GCD


s_k = LCM//m
t_k = LCM//n
for i in range(GCD):
	if s[i*s_k] != t[i*t_k]:
		print(-1)
		sys.exit()

print(LCM)
Problem p03238 (python)

Fixed submission:
n = int(input())

if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)

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

if n == 1:
    print("Hello World")
else:
    a, b = map(int,input().split())
    print(a+b)
Problem p03251 (python)

Fixed submission:
n,m,x,y = map(int, input().split())
x_city = sorted(list(map(int, input().split())))
y_city = sorted(list(map(int, input().split())))

if x_city[len(x_city)-1] < y_city[0] and (x < y_city[0] <= y):
    print("No War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
n,m,x,y = map(int, input().split())
x_city = sorted(list(map(int, input().split())))
y_city = sorted(list(map(int, input().split())))

if x_city[len(x_city)-1] < y_city[0] and (x < y_city[0] <= y)
    print("No War")
else:
    print("War")
Problem p03262 (python)

Fixed submission:
import sys

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


n, X = map(int,input().split())
x = sorted(list(map(int, input().split())) + [X])

if len(x) == 2:
    print(x[1]- x[0])
    sys.exit()

xx = [x[i+1] -x[i] for i in range(len(x)-1)]

g = gcd(xx[0],xx[1])

if len(xx) >= 3:
    for i in range(2,n):
        g = gcd(g,xx[i])

print(g)

Buggy submission (verdict: Runtime Error):
import sys

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


n, X = map(int,input().split())
x = sorted(list(map(int, input().split())) + [X])

if len(x) == 2:
    print(x[1]- x[0])
    sys.exit()

xx = [x[i+1] -x[i] for i in range(len(x)-1)]

g = gcd(xx[0],xx[1])

if len(xx) >= 3:
    for i in range(2,n-1):
        g = gcd(g,xx[n])

print(g)

Buggy submission (verdict: Runtime Error):
n, X = map(int,input().split())
x = sorted(list(map(int, input().split())) + [X])

xx = [x[i+1] -x[i] for i in range(len(x)-1)]

import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(xx))
Problem p03284 (python)

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

if n % k == 0:
    print(0)
else:
    print(1)

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

if n % K == 0:
    print(0)
else:
    print(1)
Problem p03288 (python)

Fixed submission:
a = int(input())

if a < 1200:
    print("ABC")
elif a < 2800:
    print("ARC")
else:
    print("AGC")

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

if a < 1200:
    print("ABC")
elif a < 2800:
    print("ARC")
else:
    print("AGC")
Problem p03290 (python)

Fixed submission:
D, G = map(int, input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

p = []
c = []
for _ in range(D):
	p_tmp, c_tmp = map(int,input().split())
	p.append(p_tmp)
	c.append(c_tmp)
t = [(i+1)*100*p[i] + c[i] for i in range(D)]

ans = float("inf")

for i in range(2**D):
	flg = list(map(int, Base_10_to_n(i,2).rjust(D,"0")))
	tmp_score = sum([t[j] for j in range(D) if flg[j] == 1])
	cnt = sum([p[j] for j in range(D) if flg[j] == 1])

	if tmp_score < G:

		rst_max_q = max([j for j in range(D) if flg[j] == 0])

		rst_q_num = 0
		while rst_q_num < p[rst_max_q]:
			tmp_score += 100*(rst_max_q+1)
			rst_q_num += 1
			cnt += 1
			if tmp_score >= G:
				break

		if tmp_score < G:
			continue

	ans = min(ans, cnt)


print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

D,G = map(int, input().split())
PC = [list(map(int, input().split())) for _ in range(D)]

P_list = list(range(D))
cnt = float('inf')

for i in range(D):
	for bonus in itertools.combinations(P_list, i):

		tmp_cnt = 0
		score = 0

		for j in bonus:
			score += PC[j][0] * 100 * (j+1) + PC[j][1]
			tmp_cnt += PC[j][0]

		res_max_p = max([k for k in range(D) if k not in bonus])
		res_score = G - score
		if res_score > 0:
			t = (-res_score//((res_max_p+1)*100)) * (-1) 
			if t < PC[res_max_p][0]:
				tmp_cnt += t
			else:
				continue

		cnt = min(cnt, tmp_cnt)

if cnt == float('inf'):
	cnt = sum([PC[j][0] for j in rnage(D)])

print(cnt)

Buggy submission (verdict: Runtime Error):
D, G = map(int,input().split())
num_q = []
bonus = []
for _ in range(D):
	pp,cc = map(int,input().split())
	num_q.append(pp)
	bonus.append(cc)

cnt = [0] * D
ans = float("inf")

def dfs(cnt, i, score):
	global ans

	if sum(cnt) >= ans:
		return True

	if cnt[i] == num_q[i]:
		score += bonus[i]

	if cnt[D-1] == num_q[D-1]:
		if score >= G:
			ans = min([ans,sum(cnt)])
			return True
		else:
			return True

	if score >= G:
		ans = min([ans,sum(cnt)])
		return True
	
	
	for j in range(i,D):
		if cnt[j] < num_q[j]:
			cnt[j] += 1
			dfs(cnt, j, score+(100*(j+1)))
			cnt[j] -= 1

dfs(cnt,0,0)
print(ans)
Problem p03292 (python)

Fixed submission:
data = sorted(list(map(int, input().split())))

print(data[2] - data[0])

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
cnt = 1
for _ in range(len(s)):
    a = s[len(s)-1]
    b = [s[i] for i in range(len(s)-1)]
    bb = "".join(b)
    s = a+bb
    if s == t:
        cnt *= 0

print("No") if cnt else print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
for _ in range(len(s)):
    a = s[len(s)-1]
    b = [s[i] for i in range(len(s)-1)]
    bb = "".join(b)
    s = a+bb
    if s == t:
        print("Yes")
        exit()
print("No")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
for _ in range(len(s)):
    s = s[len(s)-1]+"".join([s[i] for i in range(len(s)-1)])
    if s == t:
        print("Yes")
        exit()
        
print("No")
Problem p03293 (python)

Fixed submission:
s = input()
t = input()
cnt = 1
for _ in range(len(s)):
    a = s[len(s)-1]
    b = [s[i] for i in range(len(s)-1)]
    bb = "".join(b)
    s = a+bb
    if s == t:
        cnt *= 0

print("No") if cnt else print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
for _ in range(len(s)):
    s = s[len(s)-1]+"".join[s[i] for i in range(len(s)-1)]
    if s == t:
        print("Yes")
        exit()
        
print("No")
Problem p03386 (python)

Fixed submission:
a, b, k = map(int,input().split())
if b-a+1 >= 2*k:
    aa = [a+i for i in range(k)]
    bb = [b-i for i in range(k)]
    cc = sorted(aa+bb)
    for s in cc:
        print(s)
else:
    for s in range(a,b+1):
        print(s)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
s = list(range(a,b+1))
ans = [s[i] for i in range(len(s)) if i < k or i > (len(s) - k -1)]
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
nums=list(range(a,b+1))
start=nums[:k]
end=nums[len(nums)-k:]
ans=start+end
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
nums = list(range(a,b+1))
ans = [nums[i] for i in range(len(nums)) if i < k or i > (len(nums) - k - 1)]
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
nums = list(range(a,b+1))
ans = [nums[i] for i in range(len(nums)) if i < k or i > (len(nums) - k - 1)]
for i in ans:
    print(i)
Problem p03399 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min([a,b]) + min([c,d]))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min[a,b] + min[c,d])
Problem p03436 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

H, W = map(int, input().split())
S = [list(map(str, input())) for _ in range(H)]

tmp = 0
for i in range(H):
	tmp += S[i].count("#")

w_count = (H*W) - tmp

def bfs(field, dp, q):
	cp = q.pop(0)
	np = [[cp[0]+1,cp[1]], [cp[0]-1,cp[1]], [cp[0],cp[1]+1], [cp[0],cp[1]-1]]

	for n in np:
		if 0 <= n[0] <= H-1 and 0 <= n[1] <= W-1:
			if field[n[0]][n[1]] == "." and dp[n[0]][n[1]] == inf:
				q.append(n)
				dp[n[0]][n[1]] = dp[cp[0]][cp[1]] + 1
			if n == [H-1,W-1]:
				return dp[n[0]][n[1]]

	if len(q) == 0:
		return -1

	return bfs(field, dp, q)

inf = float("inf")
dp = [[inf for _ in range(W)] for _ in range(H)]
dp[0][0] = 0
nes = bfs(S, dp, [[0,0]])
if nes == -1:
	print(-1)
else:
	print(w_count-nes-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
H, W = map(int, input().split())
grid = np.array([list(map(str, input())) for _ in range(H)])

X = np.where(grid == '#')
A = np.zeros([H,W])
A[X] = 1
orig_black = np.count_nonzero(grid=='#')

q = [[0,0,0]]
while q:
	cx,cy,cd = q.pop(0)
	if cx == H-1 and cy == W-1:
		shortest = cd
		break
	elif A[cx,cy] == -1:
		continue

	A[cx,cy] = -1

	for nx,ny in [[cx+1,cy],[cx-1,cy],[cx,cy+1],[cx,cy-1]]:
		if 0 <= nx < H and 0 <= ny < W:
			if A[nx][ny] == 0:
				q.append([nx,ny,cd+1])

print((H*W)-shortest-orig_black-1)
Problem p03501 (python)

Fixed submission:
n, a, b = map(int, input().split())
print(min([n*a,b]))

Buggy submission (verdict: Runtime Error):
n,a,b = map(int, input().split())
print(min([a*n,b])
Problem p03524 (python)

Fixed submission:
import collections as c
import sys
s = input()
l = len(s)

if l == 1:
	print("YES")
else:
	S = c.Counter(list(map(str,s)))
	if len(S.keys()) == 1:
		print("NO")
		sys.exit()
	elif len(S.keys()) == 2:
		if l == 2:
			print("YES")
		else:
			print("NO")
		sys.exit()

	cnt = set(list(S.values()))

	if len(cnt) == 3:
		print("NO")
	elif len(cnt) == 2:
		a,b = cnt
		if abs(a-b) <= 1:
			print("YES")
		else:
			print("NO")
	else:
		print("YES")

Buggy submission (verdict: Runtime Error):
import collections as c
import sys
s = input()
l = len(s)

if l == 1:
	print("YES")
else:
	S = c.Counter(list(map(str,s)))
	if len(S.key()) == 1:
		print("NO")
		sys.exit()
	elif len(S.keys()) == 2:
		if l == 2:
			print("YES")
		else:
			print("NO")
		sys.exit()

	cnt = set(list(S.values()))

	if len(cnt) == 3:
		print("NO")
	elif len(cnt) == 2:
		a,b = cnt
		if abs(a-b) <= 1:
			print("YES")
		else:
			print("NO")
	else:
		print("YES")

Buggy submission (verdict: Runtime Error):
import collections as c
import sys
s = input()
l = len(s)

if l == 1:
	print("NO")
else:
	S = c.Counter(list(map(str,s)))

	if len(S.keys()) <= 2:
		if l == 2:
			print("YES")
		else:
			print("NO")
		sys.eixt()

	cnt = set(list(S.values()))

	if len(cnt) == 3:
		print("NO")
	elif len(cnt) == 2:
		a,b = cnt
		if abs(a-b) <= 1:
			print("YES")
		else:
			print("NO")
	else:
		print("YES")
Problem p03544 (python)

Fixed submission:
n = int(input())
l2 = 2
l1 = 1
if n == 1:
    print(1)
    exit()
    
for i in range(2,n+1):
    l = l2+l1
    l2=l1
    l1=l
print(l)

Buggy submission (verdict: Runtime Error):
n = int(input())
l2 = 2
l1 = 1
for i in range(2,n+1):
    l = l2+l1
    l2=l1
    l1=l
print(l)
Problem p03547 (python)

Fixed submission:
x, y = input().split()
if x > y:
    print(">")
elif x < y:
    print("<")
else:
    print("=")

Buggy submission (verdict: Runtime Error):
k = {"A":1,"B":2,"C":3,"D":4,"E":5,"F":6}
x, y = input().split()
xx = '"'+x+'"'
yy = '"'+y+'"'

if k[xx] > k[yy]:
    print(">")
elif k[xx] < k[yy]:
    print("<")
else:
    print("=")
Problem p03565 (python)

Fixed submission:
SS = input()
T = input()
ans = "z"*(len(SS)+1)

for i in range(len(SS) - len(T) + 1):
	temp = "?"*i + T + "?"*(len(SS)-i-len(T))
	cond = True
	for i in range(len(SS)):
		if SS[i] == "?" or temp[i] == "?":
			continue
		else:
			if SS[i] != temp[i]:
				cond = False
	if cond:
		temp_2 = []
		for i in range(len(SS)):
			if SS[i] == "?" and temp[i] == "?":
				temp_2.append("a")
			elif SS[i] == "?" and temp[i] != "?":
				temp_2.append(temp[i])
			else:
				temp_2.append(SS[i])
		temp_3 = "".join(temp_2)
		if temp_3 <= ans:
			ans = temp_3

if ans == "z"*(len(SS)+1):
	print("UNRESTORABLE")
else:
	print(ans)

Buggy submission (verdict: Runtime Error):
SS = input()
T = input()

L_S = len(SS)
L_T = len(T)

COND = 0
for i in range(L_S-L_T+1):
	cond = 1
	t = ('?' * i) + T + ('?' * (L_S-L_T-i))

	ans = ''
	for j in range(L_S):
		if SS[j] == '?' and t[j] == '?':
			ans += 'a'
			
		elif SS[j] == '?' and t[j] != '?':
			ans += t[j]
		elif SS[j] != '?' and t[j] == '?':
			ans += SS[j]
		else:
			if SS[j] != t[j]:
				cond = 0
				ans = ''
				break
			else:
				ans += t[j]

	if cond == 0:
		continue
	else:
		break

if ans == '':
	print('UNRESTORABLE')
else:
	print(ans)

Buggy submission (verdict: Runtime Error):
SS = input()
T = input()

L_S = len(SS)
L_T = len(T)

COND = 0
for i in range(L_S-L_T+1):
	cond = 1
	t = ('?' * i) + T + ('?' * (L_S-L_T-i))

	ans = ''
	for j in range(L_S):
		if SS[j] == '?' and t[j] == '?':
			ans += 'a'
			
		elif SS[j] == '?' and t[j] != '?':
			ans += t[j]
		elif SS[j] != '?' and t[j] == '?':
			ans += SS[j]
		else:
			if SS[j] != t[j]:
				cond = 0
				ans = ''
				break

	if cond == 0:
		continue
	else:
		break

if ans == '':
	print('UNRESTORABLE')
else:
	print(ans)
Problem p03573 (python)

Fixed submission:
a,b,c=input().split()

if a==b:
    print(c)
elif a==c:
    print(b)
else:
    print(a)

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()

if a==b:
    print(c)
    break
elif a==c:
    print(b)
    break
else:
    print(a)
Problem p03632 (python)

Fixed submission:
a,b,c,d = list(map(int,input().split()))
if c<=a<=d<=b:
    print(d-a)
elif c<=a<=b<=d:
    print(b-a)
elif a<=c<=d<=b:
    print(d-c)
elif a<=c<=b<=d:
    print(b-c)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b,c,d = list(map(int,input().split()))
if c<=a<=d<=b:
    print(d-a)
elif c<=a<=b<=d:
    print(b-a)
elif a<=c<=d<=b:
    pirnt(d-c)
elif a<=c<=b<=d:
    print(b-c)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b,c,d = list(map(int,input().split()))
if c<a<d<b:
    print(d-a)
elif c<a<b<d:
    print(b-a)
elif a<c<d<b:
    pirnt(d-c)
elif a<c<b<d:
    print(b-c)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b,c,d = list(map(int,input().split()))
if c<=a<=d<=b:
    print(d-a)
elif c<=a<=b<=d:
    print(b-a)
elif a<=c<=d<=b:
    pirnt(d-c)
elif a<=c<=b<=d:
    print(b-c)
else:
    print(0)
Problem p03633 (python)

Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]

def Eucrid(a,b):
	if b == 0:
		return a
	return Eucrid(b,a%b)


ans = 1
for i in range(N):
	ans = (ans * T[i]) // Eucrid(ans, T[i])

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
if N == 1:
	print(T[0])
	sys.exit()
def GCD(a,b):
	if b == 0:
		return a
	return GCD(b,a%b)

N = int(input())
T = [int(input()) for _ in range(N)]

def SKS(a,b):
	return (a*b)//GCD(a,b)

for i in range(1,N):
	if i == 1:
		temp = SKS(T[0], T[1])
		continue

	temp = SKS(temp, T[i])

print(temp)

Buggy submission (verdict: Runtime Error):
import math

def GCD(a,b):
	if b == 0:
		return a
	return GCD(b,a%b)

N = int(input())
T = [int(input()) for _ in range(N)]

def SKS(a,b):
	return (a*b)//GCD(a,b)

for i in range(1,N):
	if i == 1:
		temp = SKS(T[0], T[1])
		continue

	temp = SKS(temp, T[i])

print(temp)
Problem p03640 (python)

Fixed submission:
import numpy as np
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
B = np.zeros([H,W], np.int64)
ind = 0
for i in range(H):
    for j in range(W):
        if A[ind] == 0:
            ind += 1
        B[i,j] = ind+1
        A[ind] -= 1

for i in range(H):
    if i % 2 == 0:
        print(*B[i])
    else:
        print(*B[i][::-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
s = ''
for i in range(N):
    s += str(i+1) * A[i]
B = np.array(list(map(int, s)), np.int64).reshape([H,W])

for i in range(H):
    if i % 2 == 0:
        print(*B[i])
    else:
        print(*B[i][::-1])
Problem p03651 (python)

Fixed submission:
import sys

N, K = map(int, input().split())
A = list(map(int, input().split()))
maxA = max(A)
if K > maxA:
	print("IMPOSSIBLE")
	sys.exit()

if K in A:
	print("POSSIBLE")
	sys.exit()

def GCD(a,b):
	if b == 0:
		return a
	return GCD(b,a%b)

for i in range(1,N):
	if i == 1:
		temp = GCD(A[0],A[1])
	else:
		temp = GCD(temp, A[i])

if K % temp == 0:
	ans = "POSSIBLE"
else:
	ans = "IMPOSSIBLE"
print(ans)

Buggy submission (verdict: Runtime Error):
import sys

N, K = map(int, input().split())
A = list(map(int, input().split()))
maxA = max(A)
if K > maxA:
	print("IMPOSSIBLE")
	sys.exit()

def GCD(a,b):
	if b == 0:
		return a
	return GCD(b,a%b)

for i in range(1,N):
	if i == 1:
		temp = GCD(A[0],A[1])
	else:
		temp = GCD(temp, A[i])

if temp == 1:
	ans = "POSSIBLE"
else:
	if K//temp == 0:
		ans = "POSSIBLE"
	else:
		ans = "IMPOSSIBLE"

print(ans)