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

Fixed submission:
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint


INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

H, W = [int(x) for x in input().split()]
A = []
BQ = deque()
for _ in range(H):
    L = list(input())
    A.append(L)

bCnt = 0
for x in range(W):
    for y in range(H):
        if A[y][x] == '#':
            BQ.append((x, y))
            bCnt += 1


def check(a):
    a2 = sum(a, [])
    cnt = a2.count('.')
    return cnt == 0


def ok(x, y, W, H):
    if x >= 0 and x < W and y >= 0 and y < H:
        return True
    return False


# X,Y座標
DX = [1, -1, 0, 0]
DY = [0, 0, 1, -1]

cnt = 0

while bCnt != H * W:
    newBQ = deque()
    for (x, y) in BQ:
        for (dx, dy) in zip(DX, DY):
            X = x + dx
            Y = y + dy
            if ok(X, Y, W, H) and A[Y][X] == '.':
                A[Y][X] = '#'
                newBQ.append((X, Y))
                bCnt += 1

    cnt += 1

    # print("len:{}".format(len(newBQ)))
    # for a in A:
    #     print(a)
    # print("---")

    BQ = newBQ

print(cnt)

Buggy submission (verdict: Runtime Error):
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint


INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

H, W = [int(x) for x in input().split()]
A = []
BQ = deque()
for _ in range(H):
    L = list(input())
    A.append(L)

for x in range(W):
    for y in range(H):
        if A[x][y] == '#':
            BQ.append((x, y))


def check(a):
    a2 = sum(a, [])
    cnt = a2.count('.')
    return cnt == 0


def ok(x, y, W, H):
    if x >= 0 and x < W and y >= 0 and y < H:
        return True
    return False


# X,Y座標
DX = [1, -1, 0, 0, 0]
DY = [0, 0, 1, -1, 0]

cnt = 0
while check(A) == False:
    newBQ = deque()
    for (x, y) in BQ:
        for (dx, dy) in zip(DX, DY):
            X = x + dx
            Y = y + dy
            if ok(X, Y, W, H) and A[X][Y] == '.':
                A[X][Y] = '#'
                newBQ.append((X, Y))
    cnt += 1
    BQ = newBQ

    # for a in A:
    #     print(a)
    # print("---")

print(cnt)
Problem p03075 (python)

Fixed submission:
A = [int(input())  for _  in range(5)]
k = int(input())

if A[4] - A[0] <= k:
    print("Yay!"  )
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
A = [int(input())  for _  in range(5)]
k = int(input())

if A[4] - A[0] <= k
    print("Yay!"  )
else:
    print(":(")
Problem p03272 (python)

Fixed submission:
N, i = [int(x) for x in input().split()]

print(N - i + 1)

Buggy submission (verdict: Runtime Error):
import sys

N, K = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]

r = 0
for idx, xi in enumerate(x):
    r = idx


list = []

S = r - K
if x[r] == 0:
    S += 1
S = max(S, 0)

for s in range(S, r+1):
    e = s + K - 1
    if len(x) <= e:
        break
    list.append(abs(x[e] - x[s]) + abs(x[s]))
    list.append(abs(x[e] - x[s]) + abs(x[e]))

print(min(list))

sys.exit(0)
Problem p03775 (python)

Fixed submission:
N = int(input())


def countDigits(n):
    return len(str(n))


ans = countDigits(N)
A = 1
while A * A <= N:
    if(N % A != 0):
        A += 1
        continue
    B = N // A

    cur = max(countDigits(A), countDigits(B))
    if (ans > cur):
        ans = cur
    A += 1
print(ans)

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

divList = []

n = N

while n != 1:
    if n % 2 == 0:
        n = n // 2
        divList.append(2)
        continue
    if n % 3 == 0:
        n = n // 3
        divList.append(3)
        continue

    newN = n
    isFind = False
    for i in range(6, (n**(1/2)) + 1, 6):
        if n % (i - 1) == 0:
            divList.append(i - 1)
            newN = newN // (i - 1)
            isFind = True
        if n % (i + 1) == 0:
            divList.append(i + 1)
            newN = newN // (i + 1)
            isFind = True

        if isFind == True:
            break

    if isFind == False:
        divList.append(n)
        newN = 1
    n = newN

    # print(divList)

# print(divList)

t = [([1], [1])]

for d in divList:
    newT = []
    for ab in t:
        a, b = ab[0], ab[1]
        a_add = a[:]
        a_add.append(d)
        b_add = b[:]
        b_add.append(d)

        newT.append((a, b_add))
        newT.append((a_add, b))
    t = newT

# print(t)

from functools import reduce

a1 = [(reduce(lambda a, b:a * b, ab[0]), reduce(lambda a, b:a * b, ab[1]))
      for ab in t]
# print(a1)


a2 = set([(len(str(ab[0])), len(str(ab[1]))) for ab in a1])

# print(a2)

a3 = [max(ab[0], ab[1]) for ab in a2]

# print(a3)

print(min(a3))
Problem p03272 (python)

Fixed submission:
N, i = (int(i) for i in input().split(" "))
print(N - i + 1)

Buggy submission (verdict: Runtime Error):
N, i = input().split(" ")
print(N - i + 1)
Problem p03315 (python)

Fixed submission:
S=input()
for i in range(len(S)):
  S=S[:2*i+1]+"1"+S[2*i+1:]
print(eval("0"+S))

Buggy submission (verdict: Runtime Error):
S=input()
for i in S.len():
  S[:2*i+1]+"1"+S[2*i+1:]
print(eval(S))
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()

if(len(S)<=K):
    print(S)
else:
    print(S[0:K] + "...")

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()

if(len(S)<=K):
    print(S)
else:
    print(S[0:k-1] + "...")
Problem p02699 (python)

Fixed submission:
a, b = map(int, input().split())
if a <= b:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
count = 0
while True:
    if count % 2 == 0:
        C -= B
    else:
        A -= D
    count += 1
    if A <= 0:
        print("No")
        break
    elif C <= 0:
        print("Yes")
        break
Problem p02701 (python)

Fixed submission:
N = int(input())
l = [input() for i in range(N)]
print(len(set(l)))

Buggy submission (verdict: Runtime Error):
N = int(input())
l = []
for i in range(N):
    l.append(int(input()))
print(len(set(l)))
Problem p02693 (python)

Fixed submission:
k = int(input())
list = input().split()

if int(list[0])//k != int(list[1])//k:
  print("OK")
elif int(list[0])%k == 0:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
k = int(input())
list = input().split()

if int(list[0])//k != int(list[1])//k:
  print("OK")
else if int(list[0])%k == 0:
  print("OK")
else:
  print("NG")
Problem p03803 (python)

Fixed submission:
a,b=map(int,input().split())
     
if a==b:
  print("Draw")
elif a==1:
  print("Alice")
elif b==1:
  print("Bob")
elif a>b:
  print("Alice")
else:
  print("Bob")

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

if a==b
  print("Draw")
elif a==1:
  print("Alice")
elif b==1:
  print("Bob")
elif a>b:
  print("Alice")
else:
  print("Bob")
Problem p03835 (python)

Fixed submission:
k,s=map(int,input().split())
c=0
for i in range(k+1):
  for i2 in range(k+1):
      if i+i2>s:
        break
      elif s-(i+i2) <=k: 
        c+=1
print(c)

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())
c=0
for i in range(k+1):
  for i2 in range(k+1):
    for i3 in range(k+1):
      if i+i2+i3i==s:
        c+=1
print(c)
Problem p02729 (python)

Fixed submission:
from math import factorial
n,m = map(int,input().split())

if n == 0:
   N = 0
elif n == 1:
    N = 0
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
elif m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))

Buggy submission (verdict: Runtime Error):
from math import factorial
n,m = map(int,input().split())

if n == 0:
   N = 0
if n == 1:
    N = 0
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
if m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))

Buggy submission (verdict: Runtime Error):
from math import factorial
n,m = map(int,input().split())

if n == 0:
   N = 0
if n == 1:
    N = 1
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
if m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))

Buggy submission (verdict: Runtime Error):
from math import factorial
n,m = map(int,input().split())

if n == 0:
   M = 0
if n == 1:
    M = 1
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
if m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))

Buggy submission (verdict: Runtime Error):
from math import factorial
n,m = map(int,input().split())

N = factorial(n)/factorial(2)/factorial(n-2)
M = factorial(m)/factorial(2)/factorial(m-2)

print(N+M)

Buggy submission (verdict: Runtime Error):
from math import factorial
n,m = map(int,input().split())

N = factorial(n)/factorial(2)/factorial(n-2)
M = factorial(M)/factorial(2)/factorial(m-2)

print(N+M)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

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

ans = comb(n,2,exact=True) + comb(m,2,exact=True)

Buggy submission (verdict: Runtime Error):
from scipy.special import import comb

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

ans = comb(n,2,exact=True) + comb(m,2,exact=True)
Problem p02729 (python)

Fixed submission:
#Contest 159
x = input()
N = int(x[:x.index(" ")])
M = int(x[x.index(" ")+1:])
def factorial(number):
	if number>2:
		return number*factorial(number-1)
	elif not number==0:
		return number
	else:
		return 1
def choose2(number):
	if number>=2:
		return factorial(number)/(2*factorial(number-2))
	else:
		return 0

print(int(choose2(N)+choose2(M)))

Buggy submission (verdict: Runtime Error):
				
def factorial(number):
	if number>2:
		return number*factorial(number-1)
	elif not number==0:
		return number
	else:
		return 1
def choose2(number):
	if number>=2:
		return number*(number-1)/2
	else:
		return 0
N = int(input())
klist = input()
k = []
for x in range(N-1):
	k.append(int(klist[:klist.index(" ")]))
	klist = klist[klist.index(" ")+1:]
k.append(int(klist))
valArr = list(set(k))
occurence = []
for i in range(len(valArr)):
	occurence.append(0)
for j in range(N):
	for x in range(len(valArr)):
		if k[j]==valArr[x]:
			occurence[x]+=1
for ball in range(len(k)):
	ans = 0
	kArray = occurence[:len(occurence)]
	for index in range(len(valArr)):
		if valArr[index]==k[ball]:
			kArray[index]-=1
			break;
	for time in kArray:
		ans+=choose2(time)
	print(int(ans))
Problem p02990 (python)

Fixed submission:
from math import factorial

def cmb(n, r):
  return factorial(n) // (factorial(n - r) * factorial(r))

N, K = map(int, input().split())

for i in range(1, K + 1):
  try:
    print((cmb(N - K + 1, i) * cmb(K - 1, i - 1)) % (10 ** 9 + 7))
  except:
    print(0)

Buggy submission (verdict: Runtime Error):
from math import factorial

def cmb(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

N, K = map(int, input().split())

for i in range(1, K + 1):
  print((cmb(N - K + 1, i) * cmb(K - 1, i - 1)) % (10 ** 9 + 7))
Problem p03045 (python)

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

class UnionFind():
  def __init__(self, n):
    self.par = [i for i in range(n)]

  def root(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  
  def unite(self, x, y):
    x = self.root(x)
    y = self.root(y)
    self.par[y] = x

  def same(self, x, y):
    return self.root(x) == self.root(y)

N, M = map(int, input().split())
uf = UnionFind(N)

for i in range(M):
  x, y, z = map(int, input().split())
  uf.unite(x-1, y-1)

ans = set()
for i in range(N):
  ans.add(uf.root(i))
print(len(ans))

Buggy submission (verdict: Runtime Error):
class UnionFind():
  def __init__(self, n):
    self.par = [i for i in range(n)]

  def root(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  
  def unite(self, x, y):
    x = self.root(x)
    y = self.root(y)
    self.par[y] = x

  def same(self, x, y):
    return self.root(x) == self.root(y)

N, M = map(int, input().split())
uf = UnionFind(N)

for i in range(M):
  x, y, z = map(int, input().split())
  uf.unite(x-1, y-1)

ans = set()
for i in range(N):
  ans.add(uf.root(i))
print(len(ans))
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
cy = [1] * N
city = []

for i in range(M):
  p, y = map(int, input().split())
  city.append((y, p, i))
city.sort()

ans = [""] * M

for y, p, i in city:
  ans[i] = ("000000" + str(p))[-6:] + ("000000" + str(cy[p-1]))[-6:]
  cy[p-1] += 1

print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
cy = [1] * M
city = []

for i in range(M):
  p, y = map(int, input().split())
  city.append((y, p, i))
city.sort()

ans = [""] * M

for y, p, i in city:
  ans[i] = ("000000" + str(p))[-6:] + ("000000" + str(cy[p-1]))[-6:]
  cy[p-1] += 1

print(*ans, sep="\n")
Problem p03253 (python)

Fixed submission:
N, M = map(int, input().split())
p = 10**9 + 7

fac = [0] * (N + 33)
inv = [0] * (N + 33)
finv = [0] * (N + 33)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

for i in range(2, N+33):
  fac[i] = fac[i-1] * i % p
  inv[i] = p - inv[p%i] * (p // i) % p
  finv[i] = finv[i-1] * inv[i] % p

primes = {}
i = 2
while(M > 1):
  if(M % i == 0):
    primes[i] = primes.get(i, 0) + 1
    M //= i
  else:
    i += 2 - (i + 1) % 2
r = 1
for v in primes.values():
  r = r * fac[N+v-1] * finv[N-1] * finv[v] % p
print(r)

Buggy submission (verdict: Runtime Error):
N = int(input())
p = 10**9 + 7

fac = [0] * (N + 33)
inv = [0] * (N + 33)
finv = [0] * (N + 33)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

for i in range(2, N+34):
  fac[i] = fac[i-1] * i % p
  inv[i] = p - inv[p%i] * (p // i) % p
  finv[i] = finv[i-1] * inv[i] % p

primes = {}
i = 2
n = N
while(n > 1):
  if(n % i == 0):
    primes[i] = primes.get(i, 0) + 1
    n //= i
  else:
    i += 2 - (n + 1) % 2

r = 1
for v in primes.value():
  r = r * fac[N+v-1] * finv[N-1] * finv[v] % p
print(r)
Problem p02676 (python)

Fixed submission:
k = int(input())
s = input()
 
if len(str(s)) <= k:
  print(s)
else:
  print(s[:k] + '...')

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

if s > len(str(k)):
  print(s)
else:
  print(s[k:] + '...')
Problem p02682 (python)

Fixed submission:
a, b, c, k = map(int, input().split())
out = 0
if k < a:
  out = k
elif k >= a:
  out = a
if k > (a + b):
  out += (k - a - b) * (-1)
print(out)

Buggy submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())
if k < a:
  out = k
elif k > a:
  out = a
if k > (a + b):
  out += (k - a - b) * (-1)
print(out)
Problem p02829 (python)

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

ans = [1, 2, 3]

ans.remove(a)
ans.remove(b)

print(ans[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
 
now = 1
ans = 0
match = 0
chuumoku = 0
for i in range(n):
    if a[chuumoku] != now:
        ans += 1
        a.pop(chuumoku)
    else:
        match += 1
        chuumoku += 1
        now += 1
 
    if chuumoku == len(a) and match == 0:
        print(-1)
        exit(0)
 
print(ans)
Problem p02835 (python)

Fixed submission:
A = list(map(int, input().split()))
a1, a2, a3 = A
if a1 + a2 + a3 >= 22:
  print('bust')
else:
  print('win')

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
    a1, a2, a3 = A
    if a1 + a2 + a3 >= 22:
        print('bust')
    else:
        print('win')
Problem p02847 (python)

Fixed submission:
s = input()
if s == 'SUN':
  print(7)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
 print(3)
elif s == 'FRI':
  print(2)
else:
  print(1)

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

if s == 'SUN':
  return 7
elif s == 'MON':
  return 6
elif s == 'TUE':
  return 5
elif s == 'WED':
  return 4
elif s == 'THU':
  return 3
elif s == 'FRI':
  return 2
else s == 'SAT':
  return 1
Problem p03127 (python)

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


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


ans = gcd(a[0], a[1])

for i in range(2, len(a)):
    ans = gcd(ans, a[i])

print(ans)

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

if len(set(a)) == 1:
    print(a[0])
else:
    a.sort()
    for i in range(1, 10 ^ 9+1):
        count = i
        for i in range(1, len(a)):
            x = a[i] + count
            for j in range(i):
                x = x % a[i-1-j]
        if x == 0:
            break

    print(count)
Problem p02759 (python)

Fixed submission:
import math

n = int(input())

if n%2 == 0:
    print(n//2)
else:
    print(math.floor(n//2)+1)

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

if n%2 == 0:
    print(n/2)
else:
    print(math.floor(n/2)+1)

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

if n%2 == 0:
    print(n/2)
else:
    print(math.floor(n/2)+1)
Problem p02759 (python)

Fixed submission:
n=int(input())
if n%2==0:
    print(n//2)
else:
    print(n//2+1)

Buggy submission (verdict: Runtime Error):
n=input()
if n%2==0:
    print(n//2)
else:
    print(n//2+1)

Buggy submission (verdict: Runtime Error):
s=input()
if s%2==0:
    print(s//2)
else:
    print(s//2+1)

Buggy submission (verdict: Runtime Error):
s=input()
if s%2==0:
    print(s//2)
else:
    print(s//2+1)

Buggy submission (verdict: Runtime Error):
s=input()
if s%2==0:
    print(s//2)
else:
    print(s//2+1)
Problem p02682 (python)

Fixed submission:
a,b,c,k = (int(x) for x in input().split())
answer = 0
answer += min(a,k)
k = k - min(a,k)
k = k - min(b,k)
answer -= min(c,k)
print(answer)

Buggy submission (verdict: Runtime Error):
a,b,c,k = (int(x) for x in input().split())
answer = 0
answer += min(a,k)
k = k - min(a,k)
k = k - min(b-k)
answer -= min(c,k)
print(answer)
Problem p03252 (python)

Fixed submission:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F551C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    S = read_str()
    T = read_str()
    n = len(S)
    res = 'Yes'
    A = [0] * n
    B = [0] * n
    vu = {}
    for i in range(n):
        if S[i] in vu:
            A[i] = vu[S[i]]
        else:
            vu[S[i]] = i
            A[i] = vu[S[i]]

    vu = {}
    for i in range(n):
        if T[i] in vu:
            B[i] = vu[T[i]]
        else:
            vu[T[i]] = i
            B[i] = vu[T[i]]

    if A != B:
        res = 'No'

    # for i in range(n):
    #     for j in range(n):
    #         if S[i] != S[j] and T[i] == T[j]:
    #             res = 'No'
    #         if S[i] == S[j] and T[i] != T[j]:
    #             res = 'No'
    print(res)


main()

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

hostname = socket.gethostname()

if hostname == 'F551C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    S = read_str()
    T = read_str()
    n = len(S)
    res = 'Yes'
    A = [0] * n
    B = [0] * n
    vu = {}
    for i in range(n):
        if S[i] in vu:
            A[i] = vu[S[i]]
        else:
            vu[S[i]] = i
            A[i] = vu[S[i]]

    vu = {}
    for i in range(n):
        if T[i] in vu:
            T[i] = vu[T[i]]
        else:
            vu[T[i]] = i
            B[i] = vu[T[i]]

    if A != B:
        res = 'No'

    # for i in range(n):
    #     for j in range(n):
    #         if S[i] != S[j] and T[i] == T[j]:
    #             res = 'No'
    #         if S[i] == S[j] and T[i] != T[j]:
    #             res = 'No'
    print(res)


main()
Problem p03631 (python)

Fixed submission:
import sys

# sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    if str(n)[0] == str(n)[-1]:
        res = 'Yes'
    else:
        res = 'No'
    print(res)


main()

Buggy submission (verdict: Runtime Error):
import sys


# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    inf = 10 ** 20
    n = read_int()
    adj = [[] for u in range(n)]
    for i in range(n - 1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append((b, c))
        adj[b].append((a, c))

    q, k = read_int_list()
    k -= 1
    d = [inf for u in range(n)]

    d[k] = 0
    Q = [(k, -1)]
    while Q:
        u, parent = Q.pop(0)
        for v, w in adj[u]:
            if v == parent:
                continue
            d[v] = d[u] + w
        Q.extend([(v, u) for v, w in adj[u] if v != parent])

    res = [0] * q
    for i in range(q):
        x, y = map(int, input().split())
        res[i] = d[x-1] + d[y-1]
    print(*res, sep='\n')


main()
Problem p02676 (python)

Fixed submission:
k = int(input())
s = input()
if len(s) > k:
  print(s[:k] + '...')
else:
  print(s)

Buggy submission (verdict: Runtime Error):
k = int(input())
s = int(input())
if len(s) > k:
  print(s[:k])
else:
  print(s)
Problem p02693 (python)

Fixed submission:
k = int(input())
a, b = [int(i) for i in input().split()]

if b-a >= k-1:
  print('OK')
elif a % k - b % k > 0 or a % k == 0:
  print('OK')
else:
  print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input())
a, b = [int(i) for i in input().split]

if a % k == 0 or (a % k - b % k) >= 0:
  print('OK')
else:
  print('NG')

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

if a % k == 0 or (a % k - b % k) >= 0:
  print('OK')
else:
  print('NG')
Problem p02676 (python)

Fixed submission:
K=int(input())
S=input()
if len(S) <= K:
  print(S)
else:
  print(S[:K]+"...")

Buggy submission (verdict: Runtime Error):
K=input()
S=input()
if len(S) <= K:
  print(S)
else:
  print(S[:K]+"...")