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

Fixed submission:
s = int(input())

e = 10**9
if s == e**2:
    print(0, 0, e, 1, 0, e)
else:
    y = s//e + 1
    x = y*e - s
    print(0, 0, e, 1, x, y)

Buggy submission (verdict: Runtime Error):
while True:
    if s >= 10e9:
        for i in range(min(int(s**0.5), 10e9), 0, -1):
            if s % i == 0 and i <= 10e9 and s / i <= 10e9:
                x2 = i
                y3 = s//i
                break
    else:
        for i in range(1, min(int(s**0.5), 10e9) + 1):
            if s % i == 0 and i <= 10e9 and s / i <= 10e9:
                x2 = i - x1
                y3 = s//i
                break

    if x2 == 0 and y3 == 0:
        y2 = -1
        x3 += 1
        s -= x3
        continue
    break

print(x1, y1, x2, y2, x3, y3)

Buggy submission (verdict: Runtime Error):
s = int(input())
start = 1

if s >= 10e9:
    start = s//2

for i in range(start, int(s**0.5)+1):
    if s % i == 0:
        if i <= 10e9 and s % i <= 10e9:
            x2 = i
            y3 = s//i
print("0 0 {} 0 0 {}".format(x2, y3))

Buggy submission (verdict: Runtime Error):
s = int(input())
start = 1

if s >= 10e9:
    start = s/2

for i in range(start, int(s**0.5)+1):
    if s % i == 0:
        if i <= 10e9 and s % i <= 10e9:
            x2 = i
            y3 = s//i
print("0 0 {} 0 0 {}".format(x2, y3))
Problem p02975 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
setA = set(A)
listSetA = list(setA)

if A == [0 for i in range(n)]:
    print("Yes")
elif len(setA) == 2 and listSetA[0] == 0 and 2*A.count(0) == A.count(listSetA[1]):
    print("Yes")
elif len(setA) == 3 and listSetA[0] ^ listSetA[1] == listSetA[2] and A.count(listSetA[0]) == A.count(listSetA[1]) == A.count(listSetA[2]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
setA = set(A)
listSetA = list(setA)

if A == [0 for i in range(n)]:
    print("Yes")
elif len(setA) == 2 and listSetA[0] == 0 and 2*A.count(0) == A.count(listSetA[1])
elif len(setA) == 3 and listSetA[0] ^ listSetA[1] == listSetA[2] and A.count(listSetA[0]) == A.count(listSetA[1]) == A.count(listSetA[2]):
    print("Yes")
else:
    print("No")
Problem p02983 (python)

Fixed submission:
l, r = map(int, input().split())

if r-l+1 >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j) % 2019)
            if ans == 0:
                break
        if ans == 0:
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())

if r-l+1 >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j) % 2019)
            if ans == 0:
                break
        if ans == 0:
            break

print(ans)
Problem p03023 (python)

Fixed submission:
print(180*(int(input())-2))

Buggy submission (verdict: Runtime Error):
print(180*(int(input()-2)))
Problem p03061 (python)

Fixed submission:
import fractions

n = int(input())
A = list(map(int, input().split()))
n = len(A)

L = [0]
R = [0]
ans_list = []

for i in range(n-1):
    L.append(fractions.gcd(L[i], A[i]))
    R.append(fractions.gcd(R[i], A[n-1-i]))

for j in range(n):
    ans_list.append(fractions.gcd(L[j], R[-j-1]))

print(max(ans_list))

Buggy submission (verdict: Runtime Error):
import fraction  # python3.5以降ではmath


def seekGcd(A, n):
    ans = A[0]
    for i in range(1, n):
        ans = fraction.gcd(ans, A[i])  # python3.5以降ではmath.gcd
    ans_list.append(ans)


n = int(input())
A = list(map(int, input().split()))
ans_list = []

for i in range(n):
    p = A.pop(0)
    seekGcd(A, n-1)
    A.append(p)

print(max(ans_list))

Buggy submission (verdict: Runtime Error):
import math


def seekGcd(A, n):
    ans = A[0]
    for i in range(1, n):
        ans = math.gcd(ans, A[i])
    ans_list.append(ans)


n = int(input())
A = list(map(int, input().split()))
ans_list = []

seekGcd(A, n)

for i in range(n):
    p = A.pop(0)
    seekGcd(A, n-1)
    A.append(p)

print(max(ans_list))

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
A = list(map(int, input().split()))
ans_list = []

for i in range(n):
    p = A.pop(0)
    ans = A[0]
    for j in range(1, n-1):
        ans = math.gcd(ans, A[j])
    ans_list.append(ans)
    A.append(p)

print(max(ans_list))
Problem p03109 (python)

Fixed submission:
s = int(input().replace('/', ''))
print("Heisei" if s <= 20190430 else "TBD")

Buggy submission (verdict: Runtime Error):
s = map(int, input().split('/'))
print("Heisei" if s <= 20190430 else "TBD")
Problem p03131 (python)

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

if k > a and a+2 <= b:
    print(max((k-a-1) // 2 * (b-a) + b + (k-a-1) % 2, k+1))
else:
    print(k+1)

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

if a+2 <= b:
    print(max(max((k-a-1) // 2, 0) * (b-a) + b + (k-a-1) % 2), k+1)
else:
    print(k+1)
Problem p03197 (python)

Fixed submission:
n = int(input())
A = [int(input()) for i in range(n)]

print('second' if all(A[i] % 2 == 0 for i in range(n)) else 'first')

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

print('second' if all(A[i] % 2 == 0 for i in range(n)) else 'first')
Problem p03227 (python)

Fixed submission:
s = input()

if len(s) == 2:
    print(s)
else:
    print(s[::-1])

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

ans = ''
for i in range(0, len(s), w):
    ans += s[i]
print(ans)
Problem p03231 (python)

Fixed submission:
import fractions

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

l = n*m//fractions.gcd(n, m)

s_dic = {i * l//n + 1: s[i] for i in range(n)}
t_dic = {i * l//m + 1: t[i] for i in range(m)}

dup_idx = set(s_dic.keys()) & set(t_dic.keys())

for d in dup_idx:
    if s_dic[d] != t_dic[d]:
        print(-1)
        break
else:
    print(l)

Buggy submission (verdict: Runtime Error):
import fractions

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

l = n*m//fractions.gcd(n, m)

s_dic = {i * l//n + 1: s[i] for i in range(n)}
t_dic = {i * l//m + 1: t[i] for i in range(m)}

dup_idx = set(s_dic.keys) & set(t_dic.keys)

for d in dup_idx:
    if s_dic[d] != t_dic[d]:
        print(-1)
        break
else:
    print(l)
Problem p03282 (python)

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

if S[0] == '1':
    cnt = 0
    for s in S:
        if s == '1':
            cnt += 1
        else:
            not1 = s
            break
    if k <= cnt:
        print(1)
    else:
        print(not1)
else:
    print(S[0])

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

if S[0] == '1':
    cnt = 0
    for s in S:
        if s == '1':
            cnt += 1
        else:
            not1 = s
            break
    if k <= cnt:
        print(1)
    else:
        print(not1)
else:
    print(S[0])
Problem p03393 (python)

Fixed submission:
S = list(input())

if len(S) < 26:
    W = list('abcdefghijklmnopqrstuvwxyz')
    for s in S:
        W.remove(s)
    S += W[0]
    print(*S, sep='')
else:
    s_last = S[-1]
    idx = -1
    for i in range(24, -1, -1):
        s = S[i]
        if s > s_last:
            s_last = s
        else:
            idx = i
            break
    if idx == -1:
        print(-1)
    else:
        res = []
        for s in S[idx+1:]:
            if s > S[idx]:
                res.append(s)
        res.sort()
        print(*(S[:idx] + [res[0]]), sep='')

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

W = list('abcdefghijklmnopqrstuvwxyz')

if len(S) < 26:
    for s in S:
        W.remove(s)
    S += W[0]
    print(*S, sep='')
else:
    s_last = S[-1]
    for i in range(24, -1, -1):
        s = S[i]
        if s > s_last:
            s_last = s
        else:
            idx = i
            break
    if idx == 0:
        print(-1)
    else:
        res = []
        for s in S[idx+1:]:
            if s > S[idx]:
                res.append(s)
        res.sort()
        print(*(S[:idx] + [res[0]]), sep='')

Buggy submission (verdict: Runtime Error):
S = list(input())
n = len(S)
W = list('abcdefghijklmnopqrstuvwxyz')

ans = []
if S == list('zyxwvutsrqponmlkjihgfedcba'):
    print(-1)
elif n == 26:
    for i in range(n):
        if S[i] == W[i]:
            ans.append(W[i])
        else:
            ans.pop(-1)
            ans.append(W[i])
            break
    print(*ans, sep='')
else:
    for s in S:
        W.remove(s)
        ans.append(s)
    ans.append(W[0])
    print(*ans, sep='')
Problem p03424 (python)

Fixed submission:
n = input()
s = list(input().split())

if 'Y' in s:
    print('Four')
else:
    print('Three')

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

if 'Y' in s:
    print('Four')
else:
    print('Three')
Problem p03943 (python)

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

if P[0] + P[1] == P[2]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#include <iostream>
using namespace std;

int main()
{
    int a, b, c, ab;
    cin >> a >> b >> c;
    ab = max(a, b);

    if (max(ab, c) == (a + b + c) / 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}
Problem p02684 (python)

Fixed submission:
from collections import deque

n, k = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))

loop = []
visited = set()
s = set([1])
loop_creating = False
last = 1

while True:
  if loop_creating and len(visited) == 0:
    break
  
  if k == len(s) - 1:
    print(last)
    exit(0)

  nex = a[last - 1]

  if nex in visited:
    visited.remove(nex)
    loop.append(nex)
    loop_creating = True
  elif nex in s:
    visited.add(nex)
  else:
    s.add(nex)

  last = nex

rem = k - len(s)
print(loop[rem % len(loop)])

Buggy submission (verdict: Runtime Error):
from collections import deque

n, k = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))

loop = []
visited = set()
s = set([1])
seq_s = [1]
loop_creating = False
last = 1

while True:
  if loop_creating and len(visited) == 0:
    break

  nex = a[last - 1]

  if nex in visited:
    visited.remove(nex)
    loop.append(nex)
    loop_creating = True
  elif nex in s:
    visited.add(nex)
  else:
    s.add(nex)
    seq_s.append(nex)

  last = nex

if k <= len(s):
  print(seq_s[k])
elif k > len(s):
  rem = k - len(s)
  print(loop[rem % len(loop)])

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

loop = []
visited = set()
stack = [1]
loop_creating = False
last = 1

while True:
  if loop_creating and len(visited) == 0:
    break

  nex = a[last - 1]

  if nex in visited:
    visited.remove(nex)
    loop.append(nex)
    loop_creating = True
  elif nex in stack:
    visited.add(nex)
  else:
    stack.append(nex)

  last = nex

if k <= len(stack):
  print(stack[k])
elif k > len(stack):
  rem = k - len(stack)
  print(loop[rem % len(loop)])
Problem p02713 (python)

Fixed submission:
import math

k = int(input())

sum = 0

for a in range(1, k+1):
  for b in range(1, k+1):
    for c in range(1, k+1):
      tmp = math.gcd(a, b)
      sum += math.gcd(tmp, c)

print(sum)

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

m = {'R': 0, 'G': 0, 'B': 0}

for i, c in enumerate(s):
  if c == 'R':
    m['R'] += 1
  elif c == 'G':
    m['G'] += 1
  else:
    m['B'] += 1

result = m['R'] * m['G'] * m['B']

for i in range(1, n - 1):
  for j in range(i + 1, n):
    k = 2 * j - i

    if k > n or not (s[i - 1] != s[j - 1] and s[j - 1] != s[k - 1] and s[k - 1] != s[i - 1]):
      continue
    result -= 1

print(result)
Problem p02720 (python)

Fixed submission:
from collections import deque

k = int(input())

a = deque([9,8,7,6,5,4,3,2,1])
current_num = 0

for i in range(k):
  current_num = a.pop()
  current_str = str(current_num)
  current_last = int(current_str[-1])

  up = ""  
  mid = current_str + str(current_last)
  down = ""

  if current_last >= 0 and current_last <= 8:
    up = current_str + str(current_last + 1)

  if current_last >= 1 and current_last <= 9:
    down = current_str + str(current_last - 1)
  
  if len(down) != 0:
    a.appendleft(down)

  a.appendleft(mid)

  if len(up) != 0:
    a.appendleft(up)

print(current_num)

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

a = [9,8,7,6,5,4,3,2,1]
current_str = ''

for i in range(k):
  current_str = str(a.pop())
  current = list(current_str)
  candidates = []

  if current[-1] == "0":
    cp = current.copy()
    cp1 = current.copy()
    
    cp.append("0")
    cp1.append("1")

    candidates.append(int(''.join(cp)))
    candidates.append(int(''.join(cp1)))
  elif current[-1] == "9":
    cp = current.copy()
    cp1 = current.copy()
    
    cp.append("8")
    cp1.append("9")

    candidates.append(int(''.join(cp)))
    candidates.append(int(''.join(cp1)))
  else:
    cp = current.copy()
    cp1 = current.copy()
    cp2 = current.copy()

    cp.append(str(int(current[-1]) - 1))
    cp1.append(str(int(current[-1])))
    cp2.append(str(int(current[-1]) + 1))

    candidates.append(''.join(cp))
    candidates.append(''.join(cp1))
    candidates.append(''.join(cp2))
    

  for c in candidates:
    a.insert(0, int(c))

print(current_str)
Problem p03597 (python)

Fixed submission:
n = int(input())
a = int(input())
ans = n ** 2 - a
print(ans)

Buggy submission (verdict: Runtime Error):
l = input().split()
n = int(l[0])
a = int(l[1])
ans = n ** 2 - a
print(ans)
Problem p02714 (python)

Fixed submission:
from bisect import bisect_left, bisect_right
n = int(input()) # 入力が1つ
s = input()
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字
r = []
g = []
b = []
for i in range(n):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    else:
        b.append(i)
ans = 0

def bs(nums, target):
    l = 0
    r = len(nums) - 1
    while l <= r:
        mid = (l + r) // 2
        if nums[mid] == target:
            return True
        elif nums[mid] < target:
            l = mid + 1
        else:
            r = mid - 1
    return False

def solution(t1, t2, t3):
    ans = 0
    if len(t1) < 1 or len(t2) < 1 or len(t3) < 1:
        return ans
    for i in range(len(t2)):
        num = t2[i]
        left = bisect_left(t1, num)
        right = bisect_right(t3, num)
        ans += left * (len(t3) - right)

    for i in t1:
        for j in t3:
            if i < j:
                if (i + j) % 2 == 0 and bs(t2, (i + j) // 2):
                    ans -= 1
    return ans

ans = 0
ans += solution(r, g, b)
ans += solution(r, b, g)
ans += solution(g, r, b)
ans += solution(g, b, r)
ans += solution(b, r, g)
ans += solution(b, g, r)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from bisect import bisect_left, bisect_right
n = int(input()) # 入力が1つ
s = input()
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字
# n = 4
# s = 'RRGB'
r = []
g = []
b = []
for i in range(n):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    else:
        b.append(i)
ans = 0
for i in range(len(r)):
    j = bisect_left(g, r[i])
    k = bisect_left(b, g[j])
    ans += (len(g) - j) * (len(b) - k)

def bs(nums, target):
    l = 0
    r = len(nums) - 1
    while l <= r:
        mid = (l + r) // 2
        if nums[mid] == target:
            return True
        elif nums[mid] < target:
            l = mid + 1
        else:
            r = mid - 1
    return False

def solution(t1, t2, t3):
    ans = 0
    if len(t1) < 1 or len(t2) < 1 or len(t3) < 1:
        return ans
    for i in range(len(t2)):
        num = t2[i]
        left = bisect_left(t1, num)
        right = bisect_right(t3, num)
        ans += left * (len(t3) - right)

    for i in t1:
        for j in t3:
            if i < j:
                if (i + j) % 2 == 0 and bs(t2, (i + j) // 2):
                    ans -= 1
    return ans

ans = 0
ans += solution(r, g, b)
ans += solution(r, b, g)
ans += solution(g, r, b)
ans += solution(g, b, r)
ans += solution(b, r, g)
ans += solution(b, g, r)
print(ans)
Problem p02727 (python)

Fixed submission:
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
x, y, a, b, c = map(int, input().split()) # 入力が複数

reds = sorted([int(i) for i in input().split()], reverse=True)
greens = sorted([int(i) for i in input().split()], reverse=True)
whites = sorted([int(i) for i in input().split()], reverse=True)

reds = reds[:x]
greens = greens[:y]

apples = sorted(reds + greens + whites, reverse=True)
ans = sum(apples[:x + y])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
x, y, a, b, c = map(int, input().split()) # 入力が複数

reds = sorted([int(i) for i in input().split()], reverse=True)
greens = sorted([int(i) for i in input().split()], reverse=True)
whites = sorted([int(i) for i in input().split()], reverse=True)

reds = reds[:x] + [-float('inf')]
greens = greens[:y] + [-float('inf')]
whites.append(-float('inf'))

ans = 0
num = 0
r = g = w = 0
while num != x + y:
    red = reds[r]
    green = greens[g]
    white = whites[w]
    if red > green and red > white:
        r += 1
        ans += red
    elif green > red and green > white:
        g += 1
        ans += green
    else:
        w += 1
        ans += white
    num += 1
print(ans)
Problem p02788 (python)

Fixed submission:
from collections import deque

def updiv(a,b):
    if a % b == 0:
        return a // b
    else:
        return a // b + 1

N,D,A = map(int,input().split())

XH = []

for i in range(N):

    x,h = map(int,input().split())
    XH.append([x,h])

XH.sort()

q = deque([])
qs = 0
ans = 0

for i in range(N):

    X = XH[i][0]
    H = XH[i][1]

 
    while len(q) > 0 and q[0][0] < X-D:
        po = q.popleft()
        qs -= po[1] * A

    if H - qs <= 0:
        continue
        
    else:
        pl = updiv(H-qs,A)
        qs += pl * A
        ans += pl
        q.append([X+D,pl])

print (ans)

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

monsters = []
for _ in range(n):
    x, h = map(int, input().split())
    monsters.append((x, h))
monsters.sort(key=lambda x: x[0])
attack = 0

left_m, left_hp = monsters[0]
MAX_HP = left_hp
attacked = [False] * len(monsters)
for i in range(len(monsters)):
    cur_m, cur_hp = monsters[i]
    if cur_m - left_m <= d:
        MAX_HP = max(MAX_HP, cur_hp)
    else:
        attacked[:i + d] = [True] * (i + d)
        if MAX_HP % a == 0:
            attack += MAX_HP // a
        else:
            attack += MAX_HP // a + 1
        left_m, left_hp = monsters[i]

if not attacked[-1]:
    hp = monsters[-1][1]
    if hp % a == 0:
        attack += hp // a
    else:
        attack += hp // a + 1
print(attack)
Problem p02803 (python)

Fixed submission:
from collections import deque
h, w = map(int, input().split())
maze = []
for _ in range(h):
    maze.append(list(input()))

def clear_maze(sx, sy, maze):
    INF = -float('infinity')
    field_x_length = len(maze)
    field_y_length = len(maze[0])
    distance = [[INF for i in range(field_y_length)] for j in range(field_x_length)]

    queue = deque([(sx, sy)])
    distance[sx][sy] = 0
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    while queue:
        x, y = queue.pop()
        # if x == gx and y == gy:
        #     break
        for i in range(0, 4):
            nx, ny = x + dx[i], y + dy[i]
            if (0 <= nx < field_x_length) and (0 <= ny < field_y_length):
                if maze[nx][ny] != '#' and distance[nx][ny] == INF:
                    queue.appendleft((nx, ny))
                    distance[nx][ny] = distance[x][y] + 1
    MAX = 0
    for row in range(field_x_length):
        for col in range(field_y_length):
            MAX = max(MAX, distance[row][col])
    return MAX
    # return distance[gx][gy]

pairs = []
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            pairs.append([i, j])

MAX = 0
for sx, sy in pairs:
    r = clear_maze(sx, sy, maze)
    MAX = max(MAX, r)
print(MAX)

Buggy submission (verdict: Runtime Error):
from collections import deque
h, w = map(int, input().split())
maze = []
for _ in range(h):
    maze.append(list(input()))

def clear_maze(sx, sy, maze):
    INF = -float('infinity')
    field_x_length = len(maze)
    field_y_length = len(maze[0])
    distance = [[INF for i in range(field_y_length)] for j in range(field_x_length)]

    queue = deque([(sx, sy)])
    distance[sx][sy] = 0
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    while queue:
        x, y = queue.pop()
        # if x == gx and y == gy:
        #     break
        for i in range(0, 4):
            nx, ny = x + dx[i], y + dy[i]
            if (0 <= nx < field_x_length) and (0 <= ny < field_y_length):
                if maze[nx][ny] != '#' and distance[nx][ny] == INF:
                    queue.appendleft((nx, ny))
                    distance[nx][ny] = distance[x][y] + 1
    MAX = 0
    for row in range(len(distance)):
        for col in range(len(distance)):
            MAX = max(MAX, distance[row][col])
    return MAX
    # return distance[gx][gy]

pairs = []
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            pairs.append([i, j])

MAX = 0
for sx, sy in pairs:
    r = clear_maze(sx, sy, maze)
    MAX = max(MAX, r)
print(MAX)
Problem p02855 (python)

Fixed submission:
h,w,k=map(int,input().split())
s=[list(input())for _ in range(h)]
g=1
for i in range(h):
    for j in range(w):
        if s[i][j]!='#':continue
        s[i][j]=g
        k=j-1
        while k>=0 and s[i][k]=='.':
            s[i][k]=g
            k-=1
        k=j+1
        while k<w and s[i][k]=='.':
            s[i][k]=g
            k+=1
        g+=1
for i in range(h-2,-1,-1):
    if s[i][0]=='.':
        for j in range(w):
            s[i][j]=s[i+1][j]
for i in range(h):
    if s[i][0]=='.':
        for j in range(w):
            s[i][j]=s[i-1][j]
for t in s:
    print(*t)

Buggy submission (verdict: Runtime Error):
h, w, k=map(int,input().split())
s = [list(input()) for _ in range(h)]
g = 1
for i in range(h):
    for j in range(w):
        if s[i][j] != '#':
            continue
        s[i][j] = g
        k = j-1
        while k >= 0 and s[i][k]=='.':
            s[i][k] = g
            k -= 1
        k = j + 1
        while k < w and s[i][k] == '.':
            s[i][k] = g
            k += 1
        g += 1
for i in range(h)[::-1]:
    if s[i][0]=='.':
        for j in range(w):
            s[i][j] = s[i+1][j]
for i in range(h):
    if s[i][0] == '.':
        for j in range(w):
            s[i][j] = s[i-1][j]
for t in s:
    print(*t)
Problem p02866 (python)

Fixed submission:
# https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_b
# まず、本当に木を構築するモノではないだろう
from collections import Counter
n = int(input())
nums = [int(i) for i in input().split()]
mod = 998244353
MAX = max(nums)

c = Counter(nums)
if nums[0] != 0 or nums.count(0) != 1:
    ans = 0
else:
    ans = 1
    for i in range(1, MAX + 1):
        ans = ans * pow(c.get(i - 1, 0), c.get(i, 0), mod) % mod
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_b
# まず、本当に木を構築するモノではないだろう
from collections import Counter
n = int(input())
nums = [int(i) for i in input().split()]
mod = 998244353
MAX = max(nums)

c = Counter(nums)
if nums[0] != 0 or nums.count(0) != 1:
    ans = 0
else:
    ans = 1
    for i in range(1, MAX + 1):
        ans = ans * pow(c.get(i - 1), c.get(i), mod) % mod
    ans %= mod
print(ans)
Problem p02939 (python)

Fixed submission:
# https://atcoder.jp/contests/agc037/tasks/agc037_a

s = input()

ans = 0
pre = ''
cur = ''
for i in range(len(s)):
    pre += s[i]
    if pre != cur:
        ans += 1
        cur = pre
        pre = ''
print(ans)

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/agc037/tasks/agc037_a

s = input()

ans = 0
pre = s[0]
i = 0
while i < len(s):
    cur = s[i]
    if pre == cur:
        pre = s[i] + s[i + 1]
        i += 2
    else:
        pre = cur
        i += 1
    ans += 1
print(ans)