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

Fixed submission:
a = int(input())
#a = 118
l = [int(x) for x in list(str(a))]
flag = False

for x in l:
	if x == 7:
		flag = True

if flag == True:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n = long(input())
#n = 1000000
#a = []
sum = 0

for x in range(n):
	if x % 5 != 0 and x % 3 != 0:
		sum += x

print(long(sum))
Problem p02829 (python)

Fixed submission:
A = int(input())
B = int(input())
SUM = 6

print(SUM-A-B)

Buggy submission (verdict: Runtime Error):
N = int(input())
S,T = input().split()
ans = ""

for i in range(N):
    ans = ans + S[i] + T[i]

print(ans)
Problem p02725 (python)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int,input().split()))
for i in range(N):
  A.append(A[i]+K)
d = [0]*(N)
max_d, max_i = 0, -1
for i in range(N):
  d[i] = A[i+1] - A[i]
  if d[i] > max_d:
    max_d = d[i]
    max_i = i + 1
ans = 0
for i in range(N-1):
  ans += A[i+max_i+1] - A[i+max_i]
print(ans)

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int,input().split()))
A.append(A[0]+K)
A.append(A[1]+K)
A.append(A[2]+K)
d = 0; ans = float("INF")
for i in range(N):
  d = 0
  for j in range(N-1):
    d += A[i+j+1] - A[i+j]
  ans = min(ans, d)
print(ans)
Problem p02862 (python)

Fixed submission:
X, Y = map(int, input().split())
mod = pow(10, 9) + 7

m = (2*Y - X)/3
n = (2*X - Y)/3

if m.is_integer() == False or n.is_integer() == False:
  print(0)
  exit()
if m < 0 or n < 0:
  print(0)
  exit()

def comb(n, k):
  if k > n - k:
    return comb(n, n - k)
  mul, div = 1, 1
  for i in range(k):
    mul = mul * (n - i) % mod
    div = div * (k - i) % mod
  return mul * pow(div, mod-2, mod) % mod

ans = comb(int(n+m), int(n))
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())
mod = pow(10, 9) + 7

m = (2*Y - X)/3
n = (2*X - Y)/3

if m.is_integer() == False or n.is_integer() == False:
  print(0)
  exit()
if m < 0 or n < 0:
  print(0)
  exit()

def comb(n, k):
  if k > n - k:
    comb(n, n - k)
    return
  mul, div = 1, 1
  for i in range(k):
    mul = mul * (n - i) % mod
    div = div * (k - i) % mod
  return mul * pow(div, mod-2, mod)

ans = comb(int(n+m), int(n)) % mod
print(ans)
Problem p03038 (python)

Fixed submission:
N, M = map(int,input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]
li = []
cnt = 0
for b, c in sorted(BC, key=lambda x:x[1], reverse=True):
  cnt += b
  for _ in range(b):
    li.append(c)
  if cnt >= N:
    break
for i in range(min(N,cnt)):
  if A[i] < li[i]:
    A[i] = li[i]
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]
li = []
cnt = 0
for b, c in sorted(BC, key=lambda x:x[1], reverse=True):
  cnt += b
  if cnt >= N:
    break
  for _ in range(b):
    li.append(c)
for i in range(min(N,cnt)):
  if A[i] < li[i]:
    A[i] = li[i]
print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]
s = ""
cnt = 0
for b, c in sorted(BC, key=lambda x:x[1], reverse=True):
  s += str(c) * b
  cnt += b
li = list(s)
for i in range(min(N, cnt)):
  if A[i] < int(li[i]):
    A[i] = int(li[i])
  else:
    break
print(sum(A))
Problem p03075 (python)

Fixed submission:
a = [int(input()) for _ in range(5)]
k = int(input())
for i in range(4):
  if a[i+1] - a[0] > k:
    print(":(")
    exit()
print("Yay!")

Buggy submission (verdict: Runtime Error):
a = [int(input()) for _ in range(5)]
k = int(input())
for i in range(4):
  if a[i+1] - a[i] > k
    print(":(")
    exit()
print("Yay!")
Problem p03077 (python)

Fixed submission:
from math import ceil
N = int(input())
T = [int(input()) for _ in range(5)]
print(4 + ceil(N / min(T)))

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for _ in range(5)]
print(5 + ceil(N // min(T)))
Problem p02625 (python)

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

nA = 1

for i in range(N):
  nA *= M - i
  nA %= mod_

dp = [0 for i in range(N+1)]
dp[1] = M-N
if N == 1:
  print( nA * dp[N] % mod_ )  
else:
  dp[2] = M - N + 1 + (M - N)*(M - N)
  dp[1] %= mod_
  dp[2] %= mod_
  for i in range(3, N+1):
    dp[i] = dp[i-1] * (M - N + i - 1) + dp[i-2] * (i-1)
    dp[i] %= mod_
  print( nA * dp[N] % mod_ )

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
mod_ = 10 ** 9 + 7

nA = 1

for i in range(N):
  nA *= M - i
  nA %= mod_

dp = [0 for i in range(N+1)]
dp[1] = M - N
dp[2] = M - N + 1 + (M - N)*(M - N)
dp[1] %= mod_
dp[2] %= mod_
for i in range(3, N+1):
  dp[i] = dp[i-1] * (M - N + i - 1) + dp[i-2] * (i-1)
  dp[i] %= mod_
  
print( nA * dp[N] % mod_ )
Problem p02688 (python)

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

L = [0 for i in range(N+1)]

for i in range(K):
  d = int(input())
  LL = list(map(int, input().split()))
  for j in range( len(LL) ):
    L[ LL[j] ] += 1

ans = 0
for i in range(1,N+1):
  if L[i] == 0:
    ans += 1
print(ans)

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

L = [0 for i in range(N+1)]

for i in range(K):
  d = int(input())
  for j in range(d):
    s = int(input())
    L[s] += 1

ans = 0
for i in range(1,N+1):
  if L[i] == 0:
    ans += 1
print(ans)
Problem p02689 (python)

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

L = [0 for i in range(N+1)]

for q in range(M):
  A, B = map(int, input().split())
  if H[A-1] < H[B-1]:
    L[A] += 1
  elif H[A-1] > H[B-1]:
    L[B] += 1
  else:
    L[A] += 1
    L[B] += 1
    
ans = 0
for i in range(1,N+1):
  if L[i] == 0:
    ans += 1
print(ans)

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

L = [0 for in range(N+1)]

for q in range(M):
  A, B = map(int, input().split())
  if H[A] < H[B]:
    L[A] += 1
  elif H[A] > H[B]:
    L[B] += 1
  else:
    L[A] += 1
    L[B] += 1
    
ans = 0
for i in range(1,N+1):
  if L[i] == 0:
    ans += 1
print(ans)
Problem p02725 (python)

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

m = K - A[N-1] + A[0]

for i in range(N-1):
  m = max(m, A[i+1] - A[i])

print(K - m)

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

m = K - A[N-1] + A[0]

for i in range(N):
  m = min(m, A[i+1] - A[i])

print(K - m)
Problem p02753 (python)

Fixed submission:
S = input()

if S == "AAA" or S == "BBB":
  print("No")
else:
  print("Yes")

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

if S == "AAA" or S = "BBB":
  print("No")
else:
  print("Yes")
Problem p02759 (python)

Fixed submission:
N = int(input())

print(N//2) if N%2==0 else print(N//2 +1)

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

print(N//2) if N%2==0 else print(N//2 +1)
Problem p02773 (python)

Fixed submission:
N = int(input())

dict = {}
L = []

for i in range(N):
  s = input()
  if s in dict:
    dict[s] = dict[s] + 1
  else:
    dict[s]=1
    L.append(s)

L.sort()

M = 0
for i in dict:
  M = max(M, dict[i])

for i in L:
  if dict[i] == M:
    print(i)

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

L = []
S = set()
for i in ragne(N):
  s = input()
  L.appened(s)
  S.insert(s)
L.sorted()

for i in S:
  M = max(M, L.count(i))
  
for i in S:
  if L.count(i) == M:
    print(i)
Problem p02779 (python)

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

B = set()
for i in A_list:
  B.add(i)

if len(B) == N:
  print("YES")
else:
  print("NO")

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

B = {}
for i in A_list:
  B.add(i)

if len(B) == N:
  print("YES")
else:
  print("NO")
Problem p02785 (python)

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

A.sort()

ans = 0

for i in range( H - K ):
  ans += A[i]
  
print(ans)

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

A.sort()

ans = 0

for i in range( N - K ):
  ans += A[i]
  
print(ans)
Problem p02819 (python)

Fixed submission:
X = int(input())

def is_Prime(x):
  for i in range(2, x+1):
    if i * i + 1 > x:
      return True
    if x % i == 0:
      return False

for i in range(X, 2*X+1):
  if is_Prime(i):
    print(i)
    break

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

def is_Prime(x):
  for i in range(2, x+1):
    if i * i + 1 > x:
      return True
    if x % i == 0:
      return False

for i in range(X+1, 2X+1):
  if is_Prime(i):
    print(i)
    break
Problem p02847 (python)

Fixed submission:
s = input()
r = ['SUN','MON','TUE','WED','THU','FRI','SAT']

for i in range(len(r)):
  if s == r[i]:
    print(7-i)

Buggy submission (verdict: Runtime Error):
s = input()
r = ['SUN','MON','TUE','WED','THU','FRI','SAT']

for i in len(r):
  if s == r[i]:
    print(7-i)
Problem p03012 (python)

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

ans = sum(W)
s = ans
t = 0
for i in W:
  s -= i
  t += i
  ans = min(abs(s-t), ans)
  
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
W = [int(i) for i in input().split()]

ans = sum(W)
s = ans
t = 0
for i in range(N):
  s -= W[i]
  t += W[i]
  ans = min(abs(s-t))
  
print(ans)
Problem p03250 (python)

Fixed submission:
A = sorted( list(map(int, input().split() ) ) )
print( A[0] + A[1] + 10*A[2] )

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split() ) ).sort()
print( A[0] + A[1] + 10*A[2] )
Problem p02989 (python)

Fixed submission:
n=int(input())
readints = lambda: map(int,input().split(' '))
a=list(readints())
a.sort()
mid = n//2
x=a[mid-1]
y=a[mid]
print(y-x)

Buggy submission (verdict: Runtime Error):
n=int(input())
readints = lambda: map(int,input().split(' '))
a=list(readints())
a.sort()
mid = n//2
x=a[mid]
y=a[mid+1]
print(y-x)

Buggy submission (verdict: Runtime Error):
n=int(input())
readints = lambda: list(map(int,input().split(' ')))
a=readints()
a.sort()
mid = n//2
x=a[mid]
y=a[mid+1]
print(y-x)
Problem p02695 (python)

Fixed submission:
N,M,Q = map(int,(input().split()))
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
    a[i],b[i],c[i],d[i] = map(int,(input().split()))

lun = [0]*N
l = []

def make(n):
    if len(n) > N:
        return 0
    if int(n) > 3234566667:
        return 0
    else:

        p = []
        for i in range(int(n[-1]),M):
            p.append(str(i))

        lun.append(n)
        for i in p:
            lun.append(n)
            if len(n) == N:
                l.append(n)
            make(n+i)
        return 0
for i in range(M):
    make(str(i))

l = list(set(l))

nax = 0
for x in l:
    score = 0
    for i in range(Q):
        if int(x[b[i]-1]) - int(x[a[i]-1]) == c[i]:
            score += d[i]
    nax = max(nax,score)

print(nax)

Buggy submission (verdict: Runtime Error):
import itertools

N,M,Q = map(int,(input().split()))
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
    a[i],b[i],c[i],d[i] = map(int,(input().split()))

l = list(itertools.combinations_with_areplacement(range(1,M+1), N))

nax = 0
for x in l:
    score = 0
    for i in range(Q):
        if int(x[b[i]-1]) - int(x[a[i]-1]) == c[i]:
            score += d[i]
    nax = max(nax,score)

print(nax)
Problem p02831 (python)

Fixed submission:
import fractions

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

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

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

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

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

print(lcm(a, b))
Problem p03011 (python)

Fixed submission:
p,q,r = map(int,input().split())
print(min(p+q,q+r,r+p))

Buggy submission (verdict: Runtime Error):
p,q,r = map(int,input().split())
print(min(p+q,q+r,r+s))
Problem p03038 (python)

Fixed submission:
import heapq

N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for i in range(M)]

B.sort(key=lambda B:B[1],reverse=True)
heapq.heapify(A)

c = 0
for i in range(M):
    for j in range(B[i][0]):
        c += 1
        if c > N:
            break
        if A[0] < B[i][1]:
            heapq.heappop(A)
            heapq.heappush(A,B[i][1])
            #print(A)
        else:
            break
    else:
        continue
    break
    
print(sum(A))

Buggy submission (verdict: Runtime Error):
import heapq

N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for i in range(M)]

B.sort(key=lambda B:B[1],reverse=True)
heapq.heapify(A)

for i in range(M):
    for j in range(B[i][0]):
        c += 1
        if c > N:
            break
        if A[0] < B[i][1]:
            heapq.heappop(A)
            heapq.heappush(A,B[i][1])
            print(A)
        else:
            break
    else:
        continue
    break
    
print(sum(A))
Problem p03426 (python)

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

A = [[] for _ in range(H)]
for i in range(H):
    A[i] = list(map(int,(input().split())))

d = {}
for i in range(H):
    for j in range(W):
        d[A[i][j]] = (i,j)

s = [[] for _ in range(D+1)]
for i in range(1,D+1):
    cost = 0
    s[i].append(0)
    for j in range(i,H*W-D+1,D):
        cost += abs(d[j][0] - d[j+D][0]) + abs(d[j][1] - d[j+D][1])
        s[i].append(cost)

Q = int(input())
for i in range(Q):
    L,R = map(int,(input().split()))
    r = L%D
    if r == 0:
        r = D
    ans = s[r][(R-r)//D]-s[r][(L-r)//D]
    print(ans)

Buggy submission (verdict: Runtime Error):
H,W,D = map(int,(input().split()))

A = [[] for _ in range(H)]
for i in range(H):
    A[i] = list(map(int,(input().split())))

d = {}
for i in range(H):
    for j in range(W):
        d[A[i][j]] = (i,j)

m = [0]*(H*W)
for i in range(1,H*W):
    if i+D <= H*W:
        m[i] = abs(d[i][0] - d[i+D][0]) + abs(d[i][1] - d[i+D][1])
s = [[] for _ in range(D+1)]
for i in range(1,D+1):
    cost = 0
    for j in range(i,H*W-D+1,D):
        cost += abs(d[j][0] - d[j+D][0]) + abs(d[j][1] - d[j+D][1])
        s[i].append(cost)

Q = int(input())
for i in range(Q):
    L,R = map(int,(input().split()))
    r = L%D
    if r == 0:
        r = D
    ans = s[r][(R-1)//D-1]-s[r][(L-1)//D-1]
    print(ans)
Problem p03634 (python)

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

N = int(input())
tree = [[] for _ in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    tree[a-1].append((b-1,c))
    tree[b-1].append((a-1,c))

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

dis = [-1]*N
dis[K-1] = 0
def dfs(v,d):
    for i in tree[v]:
        d = dis[v]
        next,c = i
        if dis[next] == -1:
            d += c
            dis[next] = d
            dfs(next,d)
dfs(K-1,0)

for i in range(Q):
    x,y = map(int,(input().split()))
    print(dis[x-1]+dis[y-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
tree = [[] for _ in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    tree[a-1].append((b-1,c))
    tree[b-1].append((a-1,c))

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

dis = [-1]*N
dis[K-1] = 0
def dfs(v,d):
    for i in tree[v]:
        d = dis[v]
        next,c = i
        if dis[next] == -1:
            d += c
            dis[next] = d
            dfs(next,d)
dfs(K-1,0)

for i in range(Q):
    x,y = map(int,(input().split()))
    print(dis[x-1]+dis[y-1])
Problem p02557 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import Counter
INF = 1e12


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    lA = Counter(A)
    lB = Counter(B)
    if max(Counter(A+B).values()) > N:
        print('No')
        exit()

    C = [0] * (N + 1)
    D = [0] * (N + 1)
    for i in range(N):
        C[i + 1] = lA[i + 1] + C[i]
        D[i + 1] = lB[i + 1] + D[i]
    shift = - INF
    for i in range(1, N + 1):
        shift = max(shift, C[i] - D[i - 1])
    print('Yes')
    ans = (B + B + B)[N-shift:2*N-shift]
    print(' '.join([str(a) for a in ans]))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import Counter
INF = 1e12


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    lA = Counter(A)
    lB = Counter(B)
    if max(Counter(A+B).values()) > N:
        print('No')
        exit(1)

    C = [0] * (N + 1)
    D = [0] * (N + 1)
    for i in range(N):
        C[i + 1] = lA[i + 1] + C[i]
        D[i + 1] = lB[i + 1] + D[i]
    shift = - INF
    for i in range(1, N + 1):
        shift = max(shift, C[i] - D[i - 1])
    print('Yes')
    ans = (B + B + B)[shift + N:shift + 2*N]
    print(' '.join([str(a) for a in ans]))


if __name__ == "__main__":
    main()
Problem p02598 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate
import math

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if K == 0:
        print(max(A))
        exit()
    
    # 二分探索で答えxを求める
    MIN = 0
    MAX = max(A)

    while MAX - MIN > 1:
        MID = (MIN + MAX)//2
        cnt = 0
        for i in range(N):
            cnt += (A[i]-1)//MID
        if cnt <= K:
            MAX = MID
        else:
            MIN = MID
    print(MAX)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    q = []
    for i in range(N):
        heappush(q,(-A[i],0))

    for i in range(K):
        l, c = heappop(q)
        heappush(q,(l*(c+1)/(c+2),c+1))
    
    ans = 0
    while q:
        l,c = heappop(q)
        ans = max(ans,-l)
    print(math.ceil(ans))

if __name__ == "__main__":
    main()
Problem p02781 (python)

Fixed submission:
#!/usr/bin/env python3

def main():
    N = input()
    l = len(N)
    K = int(input())

    ans = 0
    # 最上位K桁が0の場合
    # l-K_C_K * 9^K
    if K == 1:
        ans += (l-1) * 9
    elif K == 2:
        ans += (l-1) * (l-2) * 81 // 2
    else:
        ans += (l-1) * (l-2) * (l-3) * 729 // 6

    if K == 1:
        # 最上位の数以外0
        ans += int(N[0])
    elif K == 2:
        # 最上位1桁が0ではなく,残りl-1桁中1桁だけ0以外（Nより大きくならないように注意）
        if l >= 2:
            # ans += int(N[0]) * (l-1) * 9 - (9 - int(N[1]))
            for a in range(1,int(N[0])+1):
                for b in range(l-1):
                    for p in range(1,10):
                        tmp = a * 10**(l-1) + p * 10**b
                        if tmp <= int(N):
                            ans += 1
    else:
        # 最上位1桁が0ではなく,残りl-1桁中2桁だけ0以外（Nより大きくならないように注意）
        if l >= 3:
            NN = int(N)
            N0 = int(N[0])
            L = 10**(l-1)

            ans += (N0-1) * (l-1) * (l-2) * 81 // 2

            for p in range(1,10):
                for q in range(1,10):
                    for b in range(l-1):
                        for c in range(b+1,l-1):
                            tmp = N0 * L + p * 10**b + q * 10**c
                            if tmp <= NN:
                                ans += 1
                            else:
                                break
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N = input()
    l = len(N)
    K = int(input())

    ans = 0
    # 最上位K桁が0の場合
    # l-K_C_K * 9^K
    if K == 1:
        ans += (l-1) * 9
    elif K == 2:
        ans += (l-1) * (l-2) * 81 // 2
    else:
        ans += (l-1) * (l-2) * (l-3) * 729 // 6

    if K == 1:
        # 最上位の数以外0
        ans += int(N[0])
    elif K == 2:
        # 最上位1桁が0ではなく,残りl-1桁中1桁だけ0以外（Nより大きくならないように注意）
        ans += int(N[0]) * (l-1) * 9 - (9 - int(N[1]))
    else:
        # 最上位1桁が0ではなく,残りl-1桁中2桁だけ0以外（Nより大きくならないように注意）
        ans += int(N[0]) * (l-1) * (l-2) * 81 // 2 - (99 - int(N[1:3]))
    print(ans)

if __name__ == "__main__":
    main()
Problem p02790 (python)

Fixed submission:
a,b=map(int,input().split());print(str(min(a,b))*max(a,b))

Buggy submission (verdict: Runtime Error):
a,b=map(int,open(0));print(str(min(a,b))*max(a,b))
Problem p02831 (python)

Fixed submission:
a,b = map(int,input().split())
import fractions
print(a*b//fractions.gcd(a,b))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
import math
print(a*b//math.gcd(a,b))
Problem p02862 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def main():
    X, Y = map(int, input().split())
    if (X + Y) % 3 != 0:
        print(0)
        exit()
    n = (X+Y) // 3
    if X < n or Y < n:
        print(0)
        exit()
    r = X - n

    # nCrを計算する
    a = [None] * (n+1)
    inva = [None] * (n+1)
    a[0] = 1
    inva[0] = 1
    p = 10**9 + 7

    for i in range(1, n+1):
        a[i] = i * a[i-1] % p
        inva[i] = pow(i, p-2, p) * inva[i-1] % p

    ans = (a[n] * inva[r] % p) * inva[n-r] % p
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def main():
    X, Y = map(int, input().split())
    if (X + Y) % 3 != 0:
        print(0)
        exit()
    n = (X+Y) // 3
    if X < 2 or Y < 2:
        print(0)
        exit()
    r = X - n

    # nCrを計算する
    a = [None] * (n+1)
    inva = [None] * (n+1)
    a[0] = 1
    inva[0] = 1
    p = 10**9 + 7

    for i in range(1, n+1):
        a[i] = i * a[i-1] % p
        inva[i] = pow(i, p-2, p) * inva[i-1] % p

    ans = (a[n] * inva[r] % p) * inva[n-r] % p
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def main():
    X, Y = map(int, input().split())
    if (X + Y) % 3 != 0:
        print(0)
        exit()
    n = (X+Y) // 3
    r = X - n

    # nCrを計算する
    a = [None] * (n+1)
    inva = [None] * (n+1)
    a[0] = 1
    inva[0] = 1
    p = 10**9 + 7

    for i in range(1, n+1):
        a[i] = i * a[i-1] % p
        inva[i] = pow(i, p-2, p) * inva[i-1] % p

    ans = (a[n] * inva[r] % p) * inva[n-r] % p
    print(ans)


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

Fixed submission:
S = list(input())
N = len(S)
K = int(input())
  
if len(set(S)) == 1:
  print((N*K)//2)
  exit()

ans = 0
i = 0
while i < N-1:
  if S[i] == S[i+1]:
    ans += 1
    i += 1
  i += 1

if S[0] != S[N-1]:
  print(ans*K)
  exit()

a = 1
while S[0] == S[a]:
  a += 1

b = 1
while S[N-1] == S[N-1-b]:
  b += 1
print(ans*K - (K-1)*(a//2 + b//2 - (a+b)//2))

Buggy submission (verdict: Runtime Error):
S = list(input())
N = len(S)
K = int(input())
if N == 1:
    print(K//2)
    exit()

cnt = 0
tmpS = S[:]
for i in range(N-1):
    if tmpS[i] == tmpS[i+1]:
        cnt += 1
        tmpS[i+1] = '!'

if S[N-1] == S[0]:
    a = 1
    while S[a-1] == S[a] and a <= N-1:
        a += 1
    b = 1
    while S[N-b] == S[N-b-1] and b <= N-1:
        b += 1
    print(cnt*K+a//2+b//2 - (a+b)//2 * (K-1))
else:
    print(cnt*K)

Buggy submission (verdict: Runtime Error):
S = list(input())
flag = False
if S[0] == S[1]:
    flag = True
N = len(S)
K = int(input())
cnt = 0

for i in range(N-1):
    if S[i] == S[i+1]:
        cnt += 1
        S[i+1] = '!'

if S[N-1] == S[0]:
    if flag:
        print(cnt*K)
    else:
        print(cnt*K+(K-1))
else:
    print(cnt*K)