Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = ' ' + input()
t = ' ' + input()

dp = [0] * len(t)
lcs = [''] * len(t)
for i in range(1, len(s)) :
    dp_ = [0] * len(t)
    lcs_ = [''] * len(t)
    
    for j in range(1, len(t)) :            
        if s[i] == t[j] :
            dp_[j] = dp[j-1] + 1
            lcs_[j] = lcs[j-1] + s[i]
        else :
            if dp[j] >= dp_[j-1] :
                dp_[j] = dp[j]
                lcs_[j] = lcs[j]
            else :
                dp_[j] = dp_[j-1]
                lcs_[j] = lcs_[j-1]
    dp = dp_
    lcs = lcs_

print(lcs[-1])

Fixed submission:
s = 'S' + input()
t = 'T' + input()

dp = [[0] * len(t) for _ in range(len(s))]
for i in range(len(s)) :
    for j in range(len(t)) :
        if i == 0 or j == 0 :
            continue
            
        if s[i] == t[j] :
            dp[i][j] = dp[i-1][j-1] + 1
        else :
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
ret = ''
i, j = len(s)-1, len(t)-1
while i >= 1 and j >= 1 :
    if dp[i][j] == dp[i-1][j] :
        i -= 1
    elif dp[i][j] == dp[i][j-1] :
        j -= 1
    else :
        ret += s[i]
        i -= 1
        j -= 1
        
print(ret[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = ' ' + input()
t = ' ' + input()

dp = [[0] * len(t) for _ in range(len(s))]
lcs = [[''] * len(t) for _ in range(len(s))]
for i in range(len(s)) :
    for j in range(len(t)) :
        if i == 0 or j == 0 :
            dp[i][j] = 0
            continue
            
        if s[i] == t[j] :
            dp[i][j] = dp[i-1][j-1] + 1
            lcs[i][j] = lcs[i-1][j-1] + s[i]
        else :
            if dp[i-1][j] >= dp[i][j-1] :
                dp[i][j] = dp[i-1][j]
                lcs[i][j] = lcs[i-1][j]
            else :
                dp[i][j] = dp[i][j-1]
                lcs[i][j] = lcs[i][j-1]

print(lcs[-1][-1])

Fixed submission:
s = 'S' + input()
t = 'T' + input()

dp = [[0] * len(t) for _ in range(len(s))]
for i in range(len(s)) :
    for j in range(len(t)) :
        if i == 0 or j == 0 :
            continue
            
        if s[i] == t[j] :
            dp[i][j] = dp[i-1][j-1] + 1
        else :
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
ret = ''
i, j = len(s)-1, len(t)-1
while i >= 1 and j >= 1 :
    if dp[i][j] == dp[i-1][j] :
        i -= 1
    elif dp[i][j] == dp[i][j-1] :
        j -= 1
    else :
        ret += s[i]
        i -= 1
        j -= 1
        
print(ret[::-1])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

c = Counter(A)
b = sorted(c.keys())

ret = 0

j = len(b) - 1
for j in range(N - 1, -1, -1) :
    i = 2
    while c[b[j]] > 0 and i - b[j] <= b[j] :
        if b[j] != i - b[j] :
            if c[b[j]] > 0 and c[i-b[j]] :
                M = max(c[b[j]], c[i-b[j]])
                ret += M
                c[b[j]] -= M
                c[i-b[j]] -= M
        else :
            if c[b[j]] > 1 :
                ret += c[b[j]] // 2
                c[b[j]] %= 2
        i *= 2
    
print(ret)

Fixed submission:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

c = Counter(A)
b = sorted(c.keys())

ret = 0
for j in range(len(c) - 1, -1, -1) :
    i = 2
    while c[b[j]] > 0 and i - b[j] <= b[j] :
        if b[j] != i - b[j] :
            if c[b[j]] > 0 and c[i-b[j]] > 0 :
                M = min(c[b[j]], c[i-b[j]])
                ret += M
                c[b[j]] -= M
                c[i-b[j]] -= M
        else :
            if c[b[j]] > 1 :
                ret += c[b[j]] // 2
                c[b[j]] %= 2
        i *= 2
    
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()] + [1]

# 一個前の提出は嘘解法だったてへぺろ
# 桁上げの処理はpopのときにまとめてやれば良い
def check(m) :
  rl = [[0, A[0]]]
  for i in range(1, N + 1) :
    if A[i-1] < A[i] :
      rl.append([0, A[i] - A[i-1]])

    else :
      cnt = A[i-1]
      while A[i] <= cnt :
        char, size = rl.pop()
        cnt -= size
        if char >= m and size > 1 :
          if size > 2 :
            rl.append([char, size - 2])
            cnt += size - 2
          rl.append([char + char // m, 1])
          cnt += 1
        elif char >= m and size == 1 :
          if len(rl) == 0 : 
            return False
          c, s = rl.pop()
          if s > 1 :
            rl.append([c, s - 1])
          rl.append([c + char // m, 1])
        
      if A[i] - cnt - 1 >= 1 :
        rl.append([char % m, A[i] - cnt - 1])
      rl.append([char % m + 1, 1])
      cnt = A[i]
  return True
  
ng, ok = 0, N
    
while ok - ng > 1 :
  m = (ok + ng) // 2
  
  if check(m) :
    ok = m
  else :
    ng = m
    
print(ok)

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

def check(m) :
  dp = [0] * 40
  for i in range(1, N) :
    if A[i] <= A[i-1] and A[i] < 40 :
      for j in range(A[i] + 1, 40) :
        dp[j] = 0
      dp[A[i]] += 1
      for j in range(A[i], 0, -1) :
        if dp[j] >= m :
          dp[j-1] += 1
          dp[j] %= m
      if dp[0] >= m :
        return False
        
  return True

ng, ok = 0, N
for i in range(1, N) :
  if A[i] <= A[i-1] :
    ng = 1
    
while ok - ng > 1 :
  m = (ok + ng) // 2
  
  if check(m) :
    ok = m
  else :
    ng = m
    
print(ok)
Buggy python submission (verdict: Runtime Error):
N = int(input())

xyh1 = [] # h > 0
xyh2 = [] # h = 0
for _ in range(N) :
    x, y, h = map(int, input().split())
    if h > 0 :
        xyh1.append((x, y, h))
    else :
        xyh2.append((x, y, h))

def solve() :
    for Cx in range(0, 101) :
        for Cy in range(0, 101) :
            # 特定できるからxyh1は必ず1つは要素を持つ?
            x, y, h = xyh1[0]
            H = h + abs(x-Cx) + abs(y-Cy)
            
            flag = False
            for x, y, h in xyh1[1:] :
                if H != h + abs(x-Cx) + abs(y-Cy) :
                    flag = True
                    break
                    
            if flag :
                continue
                
            for x, y, h in xyh2 :
                if h + abs(x-Cx) + abs(y-Cy) > 0 :
                    flag = True
                    break
                    
            if flag :
                continue
                
            return (Cx, Cy, H)
            
print(*solve())

Fixed submission:
N = int(input())

xyh1 = [] # h > 0
xyh2 = [] # h = 0
for _ in range(N) :
    x, y, h = map(int, input().split())
    if h > 0 :
        xyh1.append((x, y, h))
    else :
        xyh2.append((x, y, h))

def solve() :
    for Cx in range(0, 101) :
        for Cy in range(0, 101) :
            # 特定できるからxyh1は必ず1つは要素を持つ
            x, y, h = xyh1[0]
            H = h + abs(x-Cx) + abs(y-Cy)
            
            flag = False
            for x, y, h in xyh1[1:] :
                if H != h + abs(x-Cx) + abs(y-Cy) :
                    flag = True
                    break
                    
            if flag :
                continue
                
            for x, y, h in xyh2 :
                if H - abs(x-Cx) - abs(y-Cy) > 0 :
                    flag = True
                    break
                    
            if flag :
                continue
                
            return (Cx, Cy, H)
            
print(*solve())
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())

LR = [[] for _ in range(N)]
for _ in range(M) :
    L, R = map(int, input().split())
    LR[L-1].append(R-1)
for i in range(N) :
    LR[i].sort()

for _ in range(Q) :
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    ret = 0
    for i in range(p, N) :
        ret += bisect_left(LR[i], q+1)
    print(ret)

Fixed submission:
from bisect import bisect_left
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())

dp = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M) :
    L, R = map(int, input().split())
    dp[L][R] += 1

for i in range(N + 1) :
    for j in range(N + 1) :
        if 0 <= i - 1 :
            dp[i][j] += dp[i-1][j]
        if 0 <= j - 1 :
            dp[i][j] += dp[i][j-1]
        if 0 <= i - 1 and 0 <= j - 1 :
            dp[i][j] -= dp[i-1][j-1]

for _ in range(Q) :
    p, q = map(int, input().split())
    print(dp[q][q]-dp[p-1][q]-dp[q][p-1]+dp[p-1][p-1])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
mod = 10 ** 9 + 7

ret = 0
la, rc = 0, S.count('C')
lq, rq = 0, S.count('?')

fac = [1]
inv = [1]
for i in range(1, len(S) + 1) :
    fac.append(fac[-1] * i % mod)
    inv.append(pow(fac[-1], mod - 2, mod))

def comb(ac, q) :
    ret = 0
    for i in range(q + 1) :
        ret += pow(2, q - i, mod) * (ac + i) * fac[q] * inv[q-i] * inv[i] % mod
        
    return ret

for s in S :
    if s == '?' :
        rq -= 1
        ret += comb(la, lq) * comb(rc, rq)
        ret %= mod
        lq += 1
    elif s == 'A' :
        la += 1
    elif s == 'B' :
        ret += comb(la, lq) * comb(rc, rq)
        ret %= mod
    elif s == 'C' :
        rc -= 1
    
print(ret)

Fixed submission:
S = input()
mod = 10 ** 9 + 7

ret = 0
la, rc = 0, S.count('C')
lq, rq = 0, S.count('?')

def comb(ac, q) :
    if q == 0 :
        return ac * pow(3, q, mod) % mod
    else :
        p = pow(3, q - 1, mod)
        return (q * p + ac * p * 3) % mod

for s in S :
    if s == '?' :
        rq -= 1
        ret += comb(la, lq) * comb(rc, rq)
        ret %= mod
        lq += 1
    elif s == 'A' :
        la += 1
    elif s == 'B' :
        ret += comb(la, lq) * comb(rc, rq)
        ret %= mod
    elif s == 'C' :
        rc -= 1
    
print(ret)
Buggy python submission (verdict: Runtime Error):
from math import gcd

T = int(input())
ABCD = [[int(i) for i in input().split()] for _ in range(T)]

def solve(A, B, C, D) :
    if B > A or B > D :
        return 'No'
        
    a0 = A % B
    d = gcd(B, D)
    if a0 + ((C - a0) // d + 1) * d >= B :
        return 'Yes'
        
    return 'No'

for A, B, C, D in ABCD :
    print(solve(A, B, C, D))

Fixed submission:
T = int(input())
ABCD = [[int(i) for i in input().split()] for _ in range(T)]

def gcd(a, b) :
    a, b = max(a, b), min(a, b)
    while b != 0 :
        a, b = b, a % b
    return a

def solve(A, B, C, D) :
    if B > A or B > D :
        return 'No'
        
    a0 = A % B
    d = gcd(B, D)
    if a0 + ((C - a0) // d + 1) * d >= B :
        return 'Yes'
        
    return 'No'

for A, B, C, D in ABCD :
    print(solve(A, B, C, D))
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

N = int(input())
A = [int(i) for i in input().split()]

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


def check(d) :
    ifr = bisect_left(A, (s - 3 * d) // 4)
    ito = bisect_left(A, (s + 3 * d) // 4)
    for i in range(ifr, min(N, ito + 1)) :
        jfr = bisect_left(A, A[i] + (s - A[i] - 2 * d) // 3)
        jto = bisect_left(A, A[i] + (s - A[i] + 2 * d) // 3)
        for j in range(max(i + 1, jfr), min(N, jto + 1)) :
            kfr = bisect_left(A, A[j] + (s - A[j] - d) // 2)
            kto = bisect_left(A, A[j] + (s - A[j] + d) // 2)
            for k in range(max(j + 1, kfr), min(N - 1, kto + 1)) :
                cut = [A[i], A[j] - A[i], A[k] - A[j], s - A[k]]
                if max(cut) - min(cut) <= d :
                    return True
    return False

ng, ok = 0, s
while ok - ng > 1 :
    mid = (ng + ok) // 2
    
    if check(mid) :
        ok = mid
    else :
        ng = mid

print(ok)

Fixed submission:
from bisect import bisect_left

N = int(input())
A = [int(i) for i in input().split()]

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

ret = float('inf')
for b in range(1, N - 1) :
    a = bisect_left(A, A[b] / 2)
    c = bisect_left(A, A[b] + (s - A[b]) / 2)
    for i in [a - 1, a] :
        for j in [c - 1, c] :
            if not 0 <= i < b < j < N - 1 :
                continue
            cut = [A[i], A[b] - A[i], A[j] - A[b], s - A[j]]
            ret = min(ret, max(cut) - min(cut))
            
print(ret)
Buggy python submission (verdict: Runtime Error):
K = int(input())

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

v = [1]
n = [1]
for i in range(2, 1000) :
    x = i / S(i)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(i)

suf = 99
for i in range(2, 14) :
    for j in range(10, 100) :
        k =  j * (10 ** i) + suf
        x = k / S(k)
        while v[-1] > x :
            v.pop()
            n.pop()
        v.append(x)
        n.append(k)
    
    suf = suf * 10 + 9

for i in range(K) :
    print(n[i])

Fixed submission:
K = int(input())

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

L = set()
nine = ''
for i in range(16) :
    for j in range(1, 1000) :
        x = int(str(j) + nine)
        L.add(x)
    nine += '9'
    
L = list(L)
L.sort()

v = [1]
n = [1]

for l in L[1:] :
    x = l / S(l)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(l)

for i in range(K) :
    print(n[i])

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

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

v = [1]
n = [1]
for i in range(2, 1000) :
    x = i / S(i)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(i)

suf = 99
for i in range(2, 11) :
    for j in range(10, 100) :
        k =  j * (10 ** i) + suf
        x = k / S(k)
        while v[-1] > x :
            v.pop()
            n.pop()
        v.append(x)
        n.append(k)
    
    suf = suf * 10 + 9

for i in range(K) :
    print(n[i])

Fixed submission:
K = int(input())

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

L = set()
nine = ''
for i in range(16) :
    for j in range(1, 1000) :
        x = int(str(j) + nine)
        L.add(x)
    nine += '9'
    
L = list(L)
L.sort()

v = [1]
n = [1]

for l in L[1:] :
    x = l / S(l)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(l)

for i in range(K) :
    print(n[i])
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
if A > 8 or B >  :
  print(':(')
else :
  print('Yay!')


Fixed submission:
A, B = map(int, input().split())
if A > 8 or B > 8 :
  print(':(')
else :
  print('Yay!')
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B, K = map(int, input().split())
mod = 998244353

fac = [1]
inv = [1]
for i in range(1, N + 1) :
    fac.append(fac[-1] * i % mod)
    inv.append(pow(fac[-1], mod - 2, mod))

ret = 0
for na in range(N + 1) :
    if (K - na * A) % B != 0 :
        continue
        
    nb = (K - na * A) // B
    for ng in range(max(0, na + nb - N), min(na, nb) + 1) :
        ret += fac[N] * inv[na-ng] * inv[nb-ng] * inv[ng] * inv[N-na-nb+ng] % mod
        ret %= mod
        
print(ret)


Fixed submission:
N, A, B, K = map(int, input().split())
mod = 998244353

fac = [1]
inv = [1]
for i in range(1, N + 1) :
    fac.append(fac[-1] * i % mod)
    inv.append(pow(fac[-1], mod - 2, mod))

ret = 0
for na in range(N + 1) :
    if (K - na * A) % B != 0 :
        continue
        
    nb = (K - na * A) // B
    if 0 <= na <= N and 0 <= nb <= N :
        ret += fac[N] * inv[N-na] * inv[na] * fac[N] * inv[N-nb] * inv[nb]
        ret %= mod
        
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B, K = map(int, input().split())
mod = 998244353

fac = [1]
inv = [1]
for i in range(1, N + 1) :
    fac.append(fac[-1] * i % mod)
    inv.append(pow(fac[-1], mod - 2, mod))

ret = 0
for na in range(N + 1) :
    if (K - na * A) % B != 0 :
        continue
        
    nb = (K - na * A) // B
    for ng in range(min(na, nb) + 1) :
        if not 0 <= na + nb - ng <= N :
            continue
        ret += fac[N] * inv[na-ng] * inv[nb-ng] * inv[ng] * inv[N-na-nb+ng] % mod
        ret %= mod
        
print(ret)

Fixed submission:
N, A, B, K = map(int, input().split())
mod = 998244353

fac = [1]
inv = [1]
for i in range(1, N + 1) :
    fac.append(fac[-1] * i % mod)
    inv.append(pow(fac[-1], mod - 2, mod))

ret = 0
for na in range(N + 1) :
    if (K - na * A) % B != 0 :
        continue
        
    nb = (K - na * A) // B
    if 0 <= na <= N and 0 <= nb <= N :
        ret += fac[N] * inv[N-na] * inv[na] * fac[N] * inv[N-nb] * inv[nb]
        ret %= mod
        
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [list(input()) for _ in range(N)]

T = [S[i] * 2 for i in range(N)]
T = T + T

def check(i, j) :
    for x in range(N) :
        for y in range(x, N) :
            if T[i+y][j+x] != T[i+x][j+y] :
                return False
    return True

ret = 0
for i in range(N) :
    for j in range(N) :
        if check(i, j) :
            ret += 1
            
print(ret)

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

def check(a) :
    for i in range(N) :
        for j in range(i, N) :
            if S[(a+i)%N][j] != S[(a+j)%N][i] :
                return False
                
    return True

ret = 0
for a in range(N) :
    if check(a) :
        ret += N
            
print(ret)
Buggy python submission (verdict: Runtime Error):
K = int(input())
A = [int(i) for i in input().split()]

def solve() :
    A.pop()

    m, M = 2, 2
    for a in A[::-1] :
        x = (2 * M - 1) // a
        if a * x < M :
            return [-1]
        M = a * x
      
    return [M, M + A[0] - 1]
    
print(*solve())

Fixed submission:
K = int(input())
A = [int(i) for i in input().split()]

def solve() :            
    m, M = 2, 2
    for a in A[::-1] :
        if (m - 1) // a == M // a :
            return [-1]
            
        M = M // a * a + a - 1
        x = (m + a - 1) // a
        m = a * x
        
    return [m, M]
    
print(*solve())

Buggy python submission (verdict: Runtime Error):
K = int(input())
A = [int(i) for i in input().split()]

A.pop()

m, M = 2, 2
for a in A[::-1] :
    x = (2 * M - 1) // a
    M = a * x
  
if M >= 2 :
    print(M, M + A[0] - 1)
else :
    print(-1)

Fixed submission:
K = int(input())
A = [int(i) for i in input().split()]

def solve() :            
    m, M = 2, 2
    for a in A[::-1] :
        if (m - 1) // a == M // a :
            return [-1]
            
        M = M // a * a + a - 1
        x = (m + a - 1) // a
        m = a * x
        
    return [m, M]
    
print(*solve())
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A == B :
    print(C)
elif A == C :
    print(B) :
else :
    print(A)

Fixed submission:
A, B, C = map(int, input().split())
if A == B :
    print(C)
elif A == C :
    print(B)
else :
    print(A)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N, K = map(int, input().split())
AB = [[int(i) for i in input().split()] for _ in range(N)]

visited = defaultdict(lambda : False)
L = set()
def dfs(x) :
    if visited[x] :
        return 
        
    visited[x] = True
    for i in range(30) :
        if x & (1 << i) == 0 :
            continue
            
        y = x ^ (1 << i)
        if y <= K :
            L.add(y)
        else :
            dfs(y)


dfs((1 << (len(bin(K)) - 2)) - 1)
L.add(K)

ret = 0
for mask in L :
    s = 0
    for A, B in AB :
        if A & ~mask == 0 :
            s += B
    ret = max(ret, s)
    
print(ret)

Fixed submission:
N, K = map(int, input().split())
AB = [[int(i) for i in input().split()] for _ in range(N)]

ret = 0
for A, B in AB :
    if A & ~K == 0 :
        ret += B
        
for i in range(30) :
    if K & (1 << i) == 0 :
        continue
        
    k = K
    k ^= 1 << i
    k |= (1 << i) - 1
    s = 0
    for A, B in AB :
        if A & ~k == 0 :
            s += B
            
    ret = max(ret, s)
    
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
AB = [[int(i) for i in input().split()] for _ in range(N)]

def dfs(x, fr) :
    flag = True
    M = 0
    for i in range(fr, 30) :
        y = x | (1 << i)
        if y <= K :
            M = max(M, dfs(y, i + 1))
            flag = False
            
    if flag :
        s = 0
        for A, B in AB :
            if A & ~x == 0 :
                s += B
        return s
    else :
        return M
        
print(dfs(0, 0))

Fixed submission:
N, K = map(int, input().split())
AB = [[int(i) for i in input().split()] for _ in range(N)]

ret = 0
for A, B in AB :
    if A & ~K == 0 :
        ret += B
        
for i in range(30) :
    if K & (1 << i) == 0 :
        continue
        
    k = K
    k ^= 1 << i
    k |= (1 << i) - 1
    s = 0
    for A, B in AB :
        if A & ~k == 0 :
            s += B
            
    ret = max(ret, s)
    
print(ret)
Buggy python submission (verdict: Runtime Error):
H, W, h, w = map(int, input().split())

a = (10 ** 9 - 1) // (h * w - 1)
ret = [[a] * W for _ in range(H)]
for y in range(h - 1, H, h) :
  for x in range(w - 1, W, w) :
    ret[y][x] = - a * (h * w - 1) - 1

s = 0
for y in range(H) :
  s += sum(ret[y])
  
if s > 0 :
  print('Yes')
  for r in ret :
    print(*r)
else :
  print('No')

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

if h == w == 1 :
  print('No')

else :
  a = (10 ** 9 - 1) // (h * w - 1)
  ret = [[a] * W for _ in range(H)]
  for y in range(h - 1, H, h) :
    for x in range(w - 1, W, w) :
      ret[y][x] = - a * (h * w - 1) - 1

  s = 0
  for y in range(H) :
    s += sum(ret[y])
    
  if s > 0 :
    print('Yes')
    for r in ret :
      print(*r)
  else :
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)

X, Y = map(int, input().split())

def rec(x, y) :
    flg = False
    for i in range(2, x + 1, 2) :
        flg = flg or not rec(x-i, y+i//2)
    for i in range(2, y + 1, 2) :
        flg = flg or not rec(x+i//2, y-i)
        
    return flg
    
if rec(X, Y) :
    print('Alice')
else :
    print('Brown')

Fixed submission:
X, Y = map(int, input().split())

if abs(X-Y) <= 1 :
    print('Brown')
else :
    print('Alice')

Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())

def rec(x, y) :
    flg = False
    for i in range(2, x + 1, 2) :
        flg = flg or not rec(x-i, y+i//2)
    for i in range(2, y + 1, 2) :
        flg = flg or not rec(x+i//2, y-i)
        
    return flg
    
if rec(X, Y) :
    print('Alice')
else :
    print('Brown')

Fixed submission:
X, Y = map(int, input().split())

if abs(X-Y) <= 1 :
    print('Brown')
else :
    print('Alice')
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

MOD = 10 ** 9 + 7

ret = 0
for i in range(1, m) :
    for j in range(1, n) :
        ret += (x[j]-x[j-1])*(y[i]-y[i-1])*(n-j)*(m-i)*i*j%MOD
        ret %= MOD
        
print(ret)


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

x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

MOD = 10 ** 9 + 7

sx = 0
pre = 0
for i in range(1, n) :
    pre += (x[i]-x[i-1]) * i
    sx += pre
    sx %= MOD
    
sy = 0
pre = 0
for i in range(1, m) :
    pre += (y[i]-y[i-1]) * i
    sy += pre
    sy %= MOD
    
print(sx*sy%MOD)