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

Fixed submission:
# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

N, M = map(int, input().split())
S = input()
T = input()

l = lcm(N, M)

ans = {}
flag = True

for i in range(N):
    now = (l // N) * i + 1
    ans[now] = S[i]

for i in range(M):
    now = (l // M) * i + 1
    if now in ans:
        if ans[now] != T[i]:
            flag = False
            break

if flag:
    print(l)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

N, M = map(int, input().split())
S = input()
T = input()

l = lcm(N, M)

ans = ['.']*(l+1)
flag = True

for i in range(N):
    now = (l // N) * i + 1
    if ans[now] == '.':
        ans[now] = S[i]

for i in range(M):
    now = (l // M) * i + 1
    if ans[now] == '.':
        ans[now] = T[i]
    else:
        if ans[now] != T[i]:
            flag = False
            break

if flag:
    print(l)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

N, M = map(int, input().split())
S = input()
T = input()

l = lcm(N, M)

ans = ['.']*(l+1)
flag = True

for i in range(N):
    now = (l // N) * i + 1
    if ans[now] == '.':
        ans[now] = S[i]

for i in range(M):
    now = (l // M) * i + 1
    if ans[now] == '.':
        ans[now] = T[i]
    else:
        if ans[now] != T[i]:
            flag = False
            break

for i in range(1, l+1):
    if ans[i] == '.':
        ans[i] = 'a'

if flag:
    print(len("".join(ans[1:])))
else:
    print(-1)
Problem p03262 (python)

Fixed submission:
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

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

# ユークリッドの互除法
def gcd(a, b):  # a >= b
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

    
x.sort()
sa = [0]*(N)
for i in range(N):
    sa[i] = x[i+1] - x[i]
    
for i in range(1, N):
    sa[i] = gcd(sa[i-1], sa[i])

print(sa[-1])

Buggy submission (verdict: Runtime Error):
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

N, X = map(int, input().split())
x = list(map(int, input().split()))

# ユークリッドの互除法
def gcd(a, b):  # a >= b
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

    
x.sort()
sa = [0]*(N-1)
for i in range(N-1):
    sa[i] = x[i+1] - x[i]
    
for i in range(1, N-1):
    sa[i] = gcd(sa[i-1], sa[i])

print(sa[-1])
Problem p03263 (python)

Fixed submission:
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

H, W = map(int, input().split())
board = [0]*(H+1)
for i in range(1, H+1):
    board[i] = [0] + list(map(int, input().split()))

#
ans = []
for y in range(1, H+1):
    if y % 2 == 1:
        for x in range(1, W):
            now = board[y][x]
            if now % 2 != 0:
                ans.append((y, x, y, x+1))
                board[y][x+1] += 1
        if y != H:
            now = board[y][W]
            if now % 2 != 0:
                ans.append((y, W, y + 1, W))
                board[y+1][W] += 1
    else:
        for x in reversed(range(2, W+1)):
            now = board[y][x]
            if now % 2 != 0:
                ans.append((y, x, y, x-1))
                board[y][x-1] += 1
        if y != H:
            now = board[y][1]
            if now % 2 != 0:
                ans.append((y, 1, y+1, 1))
                board[y+1][1] += 1

print(len(ans))
for (a, b, c, d) in ans:
    print(str(a) + " " + str(b) + " " + str(c) + " " + str(d))

Buggy submission (verdict: Runtime Error):
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

H, W = map(int, input().split())
board = [0]*(H+1)
for i in range(1, H+1):
    board[i] = [0] + list(map(int, input().split()))

#
ans = []
for y in range(1, H+1):
    if y % 2 == 1:
        for x in range(1, W):
            now = board[y][x]
            if now % 2 != 0:
                ans.append((y, x, y, x+1))
                board[y][x+1] += 1
        if y != H:
            now = board[y][W]
            if now % 2 != 0:
                ans.append((y, W, y + 1, W))
                board[y+1][W] += 1
    else:
        for x in reversed(range(2, W+1)):
            now = board[y][x]
            if now % 2 != 0:
                ans.append((y, x, y, x-1))
                board[y][x-1] += 1
        if y != H:
            now = board[y][1]
            if now % 2 != 0:
                ans.append((y, 1, y+1, 1))
                board[y+1][1] += 1

print(len(ans))
for (a, b, c, d) in ans:
    print(f"{a} {b} {c} {d}")

Buggy submission (verdict: Runtime Error):
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

H, W = map(int, input().split())
board = [0]*(H+1)
for i in range(1, H+1):
    board[i] = [0] + list(map(int, input().split()))

#
ans = []
for y in range(1, H+1):
    if y % 2 == 1:
        for x in range(1, W):
            now = board[y][x]
            if now % 2 != 0:
                ans.append((y, x, y, x+1))
                board[y][x+1] += 1
        if y != H:
            now = board[y][W]
            if now % 2 != 0:
                ans.append((y, W, y + 1, W))
                board[y+1][W] += 1
    else:
        for x in reversed(range(2, W+1)):
            now = board[y][x]
            if now % 2 != 0:
                ans.append((y, x, y, x-1))
                board[y][x-1] += 1
        if y != H:
            now = board[y][1]
            if now % 2 != 0:
                ans.append((y, 1, y+1, 1))
                board[y+1][1] += 1

for (a, b, c, d) in ans:
    print(f"{a} {b} {c} {d}")
Problem p03352 (python)

Fixed submission:
X = int(input())
if X == 1:
    print(1)
else:
    ans = 1
    for i in range(2, X+1):
        for k in range(2, 10):
            now = i ** k
            if now <= X:
                ans = max(ans, now)
    print(ans)

Buggy submission (verdict: Runtime Error):
X = int(input())
if X == 1:
    print(1)
else:
    ans = 1
    for i in range(2, X+1):
        for k in range(2, 10):
            now = i ** k
            if now <= X:
                ans = max(ans, now)
print(ans)
Problem p03424 (python)

Fixed submission:
N = int(input())
ans = "Four" if 'Y' in list(input().split()) else "Three"
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = "Four" if 'Y' in list(map(int, input().split())) else "Three"
print(ans)
Problem p03552 (python)

Fixed submission:
N, Z, W = map(int, input().split())
a = list(map(int, input().split()))

if N == 1:
    print(abs(a[0] - W))
else:
    x = abs(a[-2] - a[-1])
    y = abs(a[-1] - W)
    
    ans = max(x, y)
    print(ans)

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

if N == 1:
    print(a[0] - W)
else:
    x = abs(a[-2] - a[-1])
    y = abs(a[-1] - W)
    z = min(abs(max(A) - A[-1]), abs(a[-2]-a[-1]))
    w = min(abs(min(A) - A[-1]), abs(a[-2]-a[-1]))
    
    ans = max(x, y)
    print(ans)
Problem p03588 (python)

Fixed submission:
n = int(input())

maxm = 0
num = -1

for i in range(n):
    a, b = map(int, input().split())
    if a > maxm:
        maxm = a
        num = b

print(maxm + num)

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

maxm = 0
num = -1

for i in range():
    a, b = map(int, input().split())
    if a > maxm:
        maxm = a
        num = b

print(maxm + num)
Problem p03644 (python)

Fixed submission:
N = int(input())
 
if N == 1:
    print(1)
else:
    ans = 2
    while ans * 2 <= N:
        ans *= 2
    print(ans)

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

if N == 1:
    print(0)
else:
    ans = 2
    while ans * 2 <= N:
        ans *= 2
print(ans)
Problem p03673 (python)

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

dp = [0]*n
for i in range(n):
    now = a[i]
    if i%2 == 0:
        dp[i//2] = now
    else:
        dp[-(i//2 + 1)] = now
print(" ".join(map(str, dp)))

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

dp = [0]*n
for i in range(n):
    now = a[i]
    if i%2 == 0:
        dp[i//2] = now
    else:
        dp[-(i//2 + 1)] = now
print(" ".join(map(str, a)))
Problem p03737 (python)

Fixed submission:
a, b, c = input().split()
ans = (a[0]+b[0]+c[0]).upper()
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
ans = (a[0]+b[0]+c[0]).upper()
print(ans)
Problem p03816 (python)

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

num = int(1e5)

dp = [0]*(num+1)

for e in A:
  dp[e] += 1

cnt = 0
for i in range(1, num+1):
  if dp[i] > 1:
    cnt += dp[i] - 1

ans = N - (cnt + (cnt%2))
print(ans)

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

num = int(1e5)

dp = [0]*(num+1)

for e in A:
  dp[e] += 1

cnt = 0
maxm = 0
for i in range(1, num+1):
  if dp[i] > 1:
    cnt += dp[i] - 1
    maxm = max(maxm, dp[i] - 1)

if maxm * 2 > N // 2:
  print(ans)
if maxm > cnt // 2:
  ans = N - (maxm-(cnt-maxm)) * 2
  if ans <= 0:
    ans = 1
else:
  ans = N - (cnt + (cnt%2)*2)
print(ans)

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

num = int(1e5)

dp = [0]*(num+1)

for e in A:
  dp[e] += 1

cnt = 0
maxm = 0
for i in range(1, num+1):
  if dp[i] > 1:
    cnt += dp[i] - 1
    maxm = max(maxm, dp[i] - 1)

if maxm * 2 > N // 2:
  print(ans)
if maxm > cnt // 2:
  ans = N - (maxm-(cnt-maxm)) * 2
  print(cnt, maxm)
  if ans <= 0:
    ans = 1
else:
  ans = N - (cnt + (cnt%2)*2)
print(ans)
Problem p03857 (python)

Fixed submission:
# 頂点 v の所属するグループを調べる
def root(v, uni):
  if uni[v] < 0:  # v が親の場合
    return v
  else:           # v が子の場合
    uni[v] = root(uni[v], uni)  # 親のrootを調べる
    return uni[v]

# 頂点 a と頂点 b をつなぐ。もともと同じグループのとき、False を返す
def connect(a, b, uni):
  # まずはそれぞれ根の番号に置き換える
  ra = root(a, uni)
  rb = root(b, uni)
  if ra == rb:  # a と b がそもそも同じグループに属しているなら即終了
    return False
	
  # ra を大きなグループにしたいので、逆であれば入れ替える
  if uni[ra] > uni[rb]: # rbの方が要素数が多ければ
    tmp = ra
    ra  = rb 
    rb  = tmp

  # ra と rb を結合し、rb の親を ra とする
  uni[ra] += uni[rb]
  uni[rb] = ra
  return True
      
##
N, K, L = map(int, input().split())

road = [-1]*(N+1)
rail = [-1]*(N+1)

for i in range(K):
  a, b = map(int, input().split())
  connect(a, b, road)

for i in range(L):
  a, b = map(int, input().split())
  connect(a, b, rail)


##
dp = [0]*(N+1)
for i in range(1, N+1):
  dp[i] = (root(i, road), root(i, rail))

dic = {}
for i in range(1, N+1):
  key = dp[i]
  if key not in dic:
    dic[key] = 1
  else:
    dic[key] += 1

for i in range(1, N+1):
  ans = dic[dp[i]]
  if i == N:
    print(ans)
  else:
    print(ans, end=" ")

Buggy submission (verdict: Runtime Error):
# 頂点 v の所属するグループを調べる
def root(v):
  if uni[v] < 0:  # v が親の場合
    return v
  else:           # v が子の場合
    uni[v] = root(uni[v])  # 親のrootを調べる
    return uni[v]

# 頂点 a と頂点 b をつなぐ。もともと同じグループのとき、False を返す
def connect(a, b):
  # まずはそれぞれ根の番号に置き換える
  ra = root(a)
  rb = root(b)
  if ra == rb:  # a と b がそもそも同じグループに属しているなら即終了
    return False
	
  # ra を大きなグループにしたいので、逆であれば入れ替える
  if uni[ra] > uni[rb]: # rbの方が要素数が多ければ
    tmp = ra
    ra  = rb 
    rb  = tmp

  # ra と rb を結合し、rb の親を ra とする
  uni[ra] += uni[rb]
  uni[rb] = ra
  return True
      
##
N, K, L = map(int, input().split())

road = [-1]*(N+1)
rail = [-1]*(N+1)

for i in range(K):
  a, b = map(int, input().split())
  connect(a, b, road)

for i in range(L):
  a, b = map(int, input().split())
  connect(a, b, rail)


##
dp = [0]*(N+1)
for i in range(1, N+1):
  dp[i] = (root(i, road), root(i, rail))

dic = {}
for i in range(1, N+1):
  key = dp[i]
  if key not in dic:
    dic[key] = 1
  else:
    dic[key] += 1

for i in range(1, N+1):
  ans = dic[dp[i]]
  if i == N:
    print(ans)
  else:
    print(ans, end=" ")
Problem p03959 (python)

Fixed submission:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()

MOD = int(1e9) + 7
n = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))

Tsa = [0]*n
Asa = [0]*n

if n == 1:
	if T[0] != A[0]:
		print(0)
	else:
		print(1)
elif T[-1] != A[0]:
	print(0)
else:
	##
	dai = T[0]
	shou = T[0]
	Tsa[0] = (shou, dai)

	for i in range(1, n):
		if T[i] == dai:
			Tsa[i] = (1, dai)
		else:
			dai = T[i]
			Tsa[i] = (dai, dai)

	##
	dai = A[-1]
	shou = A[-1]
	Asa[-1] = (shou, dai)

	for i in reversed(range(-n, -1)):
		if A[i] == dai:
			Asa[i] = (1, dai)
		else:
			dai = A[i]
			Asa[i] = (dai, dai)

	##
	ans = 1
	for i in range(n):
		d = max(Tsa[i][0], Asa[i][0])
		u = min(Tsa[i][1], Asa[i][1])

		if d > u:
			ans = 0
			break
		else:
			ans *= u - d + 1
			ans %= MOD
	print(ans)

Buggy submission (verdict: Runtime Error):
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


K, T = map(int, input().split())
hoge = list(map(int, input().split()))

a = [0]*T
for i in range(T):
	a[i] = (hoge[i], i)

if T == 1:
	print(K-1)
else:
	a.sort()
	a[-1] = (a[-1][0] - 1, a[-1][1])
	pre = a[-1][1]

	while True:
		a.sort()
		if a[-1][0] == 0:
			print(0)
			raise NameError('error')
			break
		elif a[-1][1] != pre:
			a[-1] = (a[-1][0] - 1, a[-1][1])
			pre = a[-1][1]
		else:
			if a[-2][0] == 0:
				print(a[-1][1])
				break
			else:
				a[-2] = (a[-2][0] - 1, a[-2][1])
				pre = a[-2][1]
Problem p03970 (python)

Fixed submission:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


rei = "CODEFESTIVAL2016"
s = input()

ans = 0
for i in range(len(s)):
	if rei[i] != s[i]:
		ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


rei = "CODEFESTIVAL2016"
s = input()

ans = 0
for i in range(s):
	if rei[i] != s[i]:
		ans += 1

print(ans)
Problem p03973 (python)

Fixed submission:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

N = int(input())
A = [0]*N
for i in range(N):
	A[i] = int(input())

ans = A[0] - 1
A[0] = 1

cnt = 1
# yobi = 1

for i in range(1, N):
	now = A[i]

	if now > cnt:
		if now == cnt + 1: ## 0 ni nattyau
			cnt += 1
		else: ## now >= cnt + 2
			ans += now // (cnt + 1)
			if now % (cnt + 1) == 0:
				ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

n = int(input())
A = [0]*N
for i in range(N):
	A[i] = int(input())

ans = A[0] - 1
A[0] = 1

cnt = 1
# yobi = 1

for i in range(1, N):
	now = A[i]

	if now > cnt:
		if now == cnt + 1: ## 0 ni nattyau
			cnt += 1
		else: ## now >= cnt + 2
			ans += now // (cnt + 1)
			if now % (cnt + 1) == 0:
				ans -= 1

print(ans)
Problem p03987 (python)

Fixed submission:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# a = int(input())
# b, c = map(int, input().split())
# s = input()


par = [0]*202020
size = [0]*202020

def find(x):
	if par[x] == x:
		return x
	else:
		par[x] = find(par[x])
		return par[x]

def unite(x, y):
	x = find(x)
	y = find(y)
	res = size[x] * size[y]
	size[x] += size[y]
	par[y] = x
	return res

# main
n = int(input())
for i in range(202020):
	par[i] = i
	size[i] = 1

a = [0] + list(map(int, input().split()))
b = [0]*(n+1)
for i in range(1, n+1):
	b[a[i]] = i

ans = 0
for j in reversed(range(1, n+1)):
	i = b[j]
	ans += a[i]
	if i - 1 >= 1 and a[i-1] > a[i]:
		ans += unite(i-1, i) * a[i]
	if i + 1 <= n and a[i+1] > a[i]:
		ans += unite(i+1, i) * a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# a = int(input())
# b, c = map(int, input().split())
# s = input()


par = [0]*202020
size = [0]*202020

def find(x):
	if par[x] == x:
		return x
	else:
		par[x] = find(par[x])
		return par[x]

def unite(x, y):
	x = find(x)
	y = find(y)
	res = size[x] * size[y]
	size[x] += size[y]
	par[y] = x
	return res

# main
n = int(input())
for i in range(202020):
	par[i] = i
	size[i] = 1

a = [0] + list(map(int, input().split()))
b = [0]*(n+1)
for i in range(1, n+1):
	b[a[i]] = i

ans = 0
for j in reversed(1, n+1):
	i = b[j]
	ans += a[i]
	if i - 1 >= 1 and a[i-1] > a[i]:
		ans += unite(i-1, i) * a[i]
	if i + 1 <= n and a[i+1] > a[i]:
		ans += unite(i+1, i) * a[i]
print(ans)
Problem p04001 (python)

Fixed submission:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# 


s = input()
l = len(s)

if l == 1:
	print(int(s))
else:
	ans = 0

	m = int('1'*(l-1), 2)
	for i in range(m+1):
		now = format(i, 'b').zfill(l-1)
		tmp = s[0]
		for k in range(l-1):
			if now[k] == '0':
				tmp += s[k+1]
			else:
				ans += int(tmp)
				tmp = s[k+1]
		ans += int(tmp)
	print(ans)

Buggy submission (verdict: Runtime Error):
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# 


s = input()
l = len(s)

ans = 0

m = int('1'*(l-1), 2)
for i in range(m+1):
	now = format(i, 'b').zfill(l-1)
	tmp = s[0]
	for k in range(l-1):
		if now[k] == '0':
			tmp += s[k+1]
		else:
			ans += int(tmp)
			tmp = s[k+1]
	ans += int(tmp)
print(ans)
Problem p02619 (python)

Fixed submission:
import random

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    sche = []
    for i in range(D):
        x = int(input())
        sche.append(x)
    
    last_d = [0 for i in range(26)]
    score = 0
    
    for i in range(D):
        score += s[i][sche[i]-1]
        last_d[sche[i]-1] = i+1
        score = down_score(i+1, c, last_d, score)
        print(score)
        
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])
        
    return (score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    sche = []
    for i in range(D):
        x = int(input())
        sche.append(x)
    
    last_d = [0 for i in range(26)]
    score = 0
    
    for i in range(D):
        score += s[i][sche[i]]
        last_d[sche[i]] = i+1
        score = down_score(i+1, c, last_d, score)
        print(score)
        
if __name__ == "__main__":
    main()
Problem p03450 (python)

Fixed submission:
NOT_VISIT = 10**20
N, M = map(int,input().split())
graph = [[] for i in range(N)]

for i in range(M):
	L, R, D = map(int,input().split())
	graph[L-1].append((R-1,D))
	graph[R-1].append((L-1,-D))

visited = [NOT_VISIT for i in range(N)]

def dfs(start):
	global graph, visited

	if visited[start] != NOT_VISIT:
		return True

	stack = [start]
	visited[start] = 0
	while stack:
		label = stack.pop()
		for nextnode, distance in graph[label]:
			if visited[nextnode] == NOT_VISIT:
				stack.append(nextnode)
				visited[nextnode] = visited[label] + distance
			elif visited[nextnode] != visited[label] + distance:
				return False
	return True

res = True
for i in range(N):
	res &= dfs(i)

print("Yes" if res == True else "No")

Buggy submission (verdict: Runtime Error):
def dfs(s):
	global x, G
	for t, d in G[s]:
		if x[t] is None:
			x[t] = x[s] + d
			if not dfs(t):
				return False
		else:
			if x[t] != x[s] + d:
				return False
	return True

N,M = map(int,input().split())
x = [None] * N
G = [[] for _ in range(N)]
for i in range(M):
	L, R, D = map(int,input().split())
	G[L-1].append([R-1,D])
	G[R-1].append([L-1,-D])

res = True
for i in range(N):
	if x[i] is None:
		x[i] = 0
		res &= dfs(i)

print("Yes" if res == True else "No")
Problem p03633 (python)

Fixed submission:
def gcd(x,y):
	if x < y:
		x,y = y,x
	while y > 0:
		r = x % y
		x = y
		y = r
	return x

def lcm(x,y):
	return x * y // gcd(x,y)

N=int(input())
T=[0]*N
for i in range(N):
	T[i] = int(input())

ans=1
for i in range(N):
	ans=lcm(ans,T[i])

print(int(ans))

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
	if x < y:
		x,y = y,x
	while y > 0:
		r = x % y
		x = y
		y = r
	return x

N=int(input())
T=[0]*N
for i in range(N):
	T[i] = int(input())

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

print(int(ans))

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
	if x < y:
		x,y = y,x
	while y > 0:
		r = x % y
		x = y
		y = r
	return x

N=int(input())
T=[0]*N
for i in range(N):
	T[i] = int(input())

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

print(int(ans))
Problem p02730 (python)

Fixed submission:
s = input()
n = len(s)
ss = s[:(n - 1) // 2]
sss = s[(n + 3) // 2 - 1:]
flag = True;
for i in range(len(s)//2):
    if s[i] != s[n - 1 - i]:
        flag = False
if not flag:
    print("No")
    exit()

for i in range(len(ss)//2):
    if ss[i] != ss[len(ss) - 1 - i]:
        flag = False
if not flag:
    print("No")
    exit()

for i in range(len(sss)//2):
    if sss[i] != sss[len(sss) - 1 - i]:
        flag = False
if not flag:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
print((n/3)**3)
Problem p02743 (python)

Fixed submission:
from math import sqrt
from decimal import *


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

tmp = 2 * sqrt(Decimal(a)) * sqrt(Decimal(b))
print("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No")

Buggy submission (verdict: Runtime Error):
from math import sqrt
from decimal import *

getcontext().prec = 40000

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

tmp = 2 * sqrt(Decimal(a)) * sqrt(Decimal(b))
print("Yes" if Decimal(a) ** 0.5 + Decimal(b) ** 0.5 < Decimal(c) ** 0.5 else "No")
Problem p02786 (python)

Fixed submission:
from math import log2, floor

h = int(input())
tmp = floor(log2(h)) + 1
print(2 ** tmp - 1)

Buggy submission (verdict: Runtime Error):
from math import log2, floor

h = int(input())
tmp = floor(log2(h)) + 1
print(2 ** tmp - 1)
Problem p02797 (python)

Fixed submission:
n, k , s = map(int, input().split())
ans = []
for i in range(n):
    if k != 0:
        ans.append(s)
        k -= 1
    else:
        ans.append(s+1 if s != 10**9 else s-1)
print(" ".join([str(x) for x in ans]))

Buggy submission (verdict: Runtime Error):
n, k , s = map(int, input().split())
ans = []
for i in range(n):
    if k != 0:
        ans.append(s)
        k -= 1
    else:
      	if s == 10**9:
          ans.append(s-1)
        else if s == 1:
          ans.append(s+1)
        else:
          ans.append(s+1)
print(" ".join([str(x) for x in ans]))

Buggy submission (verdict: Runtime Error):
n, k , s = map(int, input().split())
ans = []
for i in range(n):
    if k != 0:
        ans.append(s)
        k -= 1
    else:
      	if s == 10**9:
          ans.append(s-1)
        else if s == 1:
          ans.append(s+1)
		else:
          ans.append(s+1)
print(" ".join([str(x) for x in ans]))