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

Fixed submission:
# coding: utf-8
from collections import deque

n = int(input())

lw = [[] for _ in range(n+1)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    lw[u].append((v,w))
    lw[v].append((u,w))

#print(lw)

ans = [-1] * (n+1)
q = deque()
ans[1] = 0
q.append(1)
while q:
    r = q.popleft()
    prev = ans[r]
    
    for x in lw[r]:
        #print(x)
        y = x[0]
        if ans[y] >= 0:
            continue
        q.append(y)
        if x[1]%2==0:
            ans[y] = ans[r]
        else:
            ans[y] = 1 - ans[r]

for x in ans[1:]:
    print(x)

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

n = int(input())
matrix = np.zeros((n,n),dtype="int32")
for i in range(n-1):
    v,w,d = map(int,input().split())
    matrix[v-1,w-1] = d
#print(matrix)

queue = deque([0])
no_check = [i for i in range(1,n)]
ans = np.zeros((n),dtype="int32")

while queue:
    x = queue.popleft()
    #print("x:",x)
    if no_check == []:
        break
    for i in no_check:
        if matrix[x,i]!=0:
            if matrix[x,i]%2==0:
                ans[i] = ans[x]
            else:
                if ans[x]==0:
                    ans[i] = 1
                else:
                    ans[i] = 0
            no_check.remove(i)
            queue.append(i)
        
                
for i in ans:
    print(i)

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

n = int(input())
matrix = np.zeros((n,n),dtype="int32")
for i in range(n-1):
    v,w,d = map(int,input().split())
    matrix[v-1,w-1] = d
#print(matrix)

queue = deque([0])
check = [0]
ans = np.zeros((n),dtype="int32")

while queue:
    x = queue.popleft()
    #print("x:",x)
    for i in range(n):
        #print("i:",i,"check:",check)
        if i not in check:
            if matrix[x,i] != 0:
                #print("d:",matrix[x,i])
                if matrix[x,i]%2==0:
                    #print("even")
                    ans[i] = ans[x]
                else:
                    #print("odd")
                    if ans[x] == 0:
                        ans[i] = 1
                    else:
                        ans[i] = 0
                check.append(i)
                queue.append(i)
                #print("APPEND check:",check,"queue:",queue)
                
for i in ans:
    print(i)
Problem p03160 (python)

Fixed submission:
# coding: utf-8

n = int(input())
h_list = list(map(int, input().split()))

inf = float('inf')
ans_list = [inf for _ in range(n)]
# ans_list = [0, 1, 2,..., n-1]
# h_list = [0, 1, 2,..., n-1]

def cmin(a, b):
    if a<b:
        return a
    else:
        return b

ans_list[0] = 0
ans_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, n):
    ans_list[i] = cmin(ans_list[i], ans_list[i-1]+abs(h_list[i]-h_list[i-1]))
    ans_list[i] = cmin(ans_list[i], ans_list[i-2]+abs(h_list[i]-h_list[i-2]))

print(ans_list[-1])

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

n = int(input())
h_list = list(map(int, input().split()))

inf = math.inf
ans_list = [inf for _ in range(n)]
# ans_list = [0, 1, 2,..., n-1]
# h_list = [0, 1, 2,..., n-1]

def cmin(a, b):
    if a<b:
        return a
    else:
        return b

ans_list[0] = 0
ans_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, n):
    ans_list[i] = cmin(ans_list[i], ans_list[i-1]+abs(h_list[i]-h_list[i-1]))
    ans_list[i] = cmin(ans_list[i], ans_list[i-2]+abs(h_list[i]-h_list[i-2]))

print(ans_list[-1])
Problem p03163 (python)

Fixed submission:
def main():
    N, W = map(int, input().split())
 
    dp = [-1] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] == -1:
                continue
            if dp[i + w] < dp[i] + v:
                dp[i + w] = dp[i] + v
    print(max(dp))
 
 
main()

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np

N, W = map(int, sys.stdin.buffer.readline().split())
   
dp = np.zeros((N+1, W+1), dtype=int)

for i in range(1, N+1):
    w, v = map(int, sys.stdin.buffer.readline().split())
    for j in range(W+1):
        if j-w[i] >= 0:
            dp[i,j] = max(dp[i,j], dp[i-1,j-w[i]]+v[i])
        dp[i,j] = max(dp[i,j], dp[i-1,j])

# for i in range(N+1):
#     print(dp[i])

print(dp[N,W])
Problem p03164 (python)

Fixed submission:
import numpy as np
N, W = map(int, input().split())
 
items = [tuple(map(int, input().split())) for _ in range(N)]
 
dp = np.full(N*1000 +1, W+1) #横軸を価値の値に変換する
dp[0] = 0
 
for i, (w, v) in enumerate(items):
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
 
print(np.max(np.where(dp <= W)))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import numpy as np

def main():
    N, W = map(int, input().split())
    V = 10**3 * 100
    
    dp = np.full(V, V+100)
    # print(len(dp))
    dp[0] = 0
    
    for _ in range(N):
        w, v = map(int, input().split())
        dp[v:] = np.minimum(dp[v:], dp[:-v]+w)

# print(dp)
print(np.max(np.where(dp<=W)))
    
if __name__ == "__main__":
    main()
Problem p03161 (python)

Fixed submission:
import sys
n,k = list(map(int,input().split()))
arr = list(map(int,input().split()))

dp = [sys.maxsize for i in range(n)]
dp[0] = 0
for i in range(n):
	for j in range(i+1,i+k+1):
		if j<n:
			dp[j] = min(dp[j],dp[i]+abs(arr[i]-arr[j]))
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
n,k = list(map(int,sys.stdin.readline().split()))
arr = list(map(int,sys.stdin.readline().split()))

dp = [sys.maxsize for i in range(n)]
dp[0] = 0
for i in range(n):
	for j in range(i+1,i+k+1):
		if j<n:
			dp[j] = min(dp[j],dp[i]+abs(arr[i]-arr[j]))
sys.stdout.write(str(dp[-1]+'\n'))

Buggy submission (verdict: Runtime Error):
import sys
n,k = list(map(int,input().split()))
arr = list(map(int,input().split()))

dp = [sys.maxsize for i in range(n)]
dp[0] = [0]
for i in range(n):
	for j in range(i+1,i+k+1):
		if j<n:
			dp[j] = min(dp[j],dp[i]+abs(arr[i]-arr[j]))
print(dp[-1])
Problem p02641 (python)

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

table = [0 for i in range(102)]
for i in p:
    table[i] = 1

mx = 10000
ans = mx
dis = mx
for i in range(len(table)):
    idx = 101-i
    if (table[idx] == 0) and (dis >= abs(idx-x)):
        ans = idx
        dis = abs(idx-x)
print(ans)

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

table = [0 for i in range(100)]
for i in p:
    table[i-1] = 1

mx = 10000
ans = mx
dis = mx
for i in range(len(table)):
    idx = 99-i
    if (table[idx] == 0) and (dis >= abs(idx+1-x)):
        ans = idx+1
        dis = abs(idx+1-x)
if ans == mx:
    if 50 >= x
        print(0)
    else:
        print(101)
else:
    print(ans)
Problem p02683 (python)

Fixed submission:
n, m, x = map(int, input().split())
prace = []
know = []
for i in range(n):
    acc = list(map(int, input().split()))
    prace.append(acc[0])
    know.append(acc[1:])

ans = 10**10
for i in range(2**n):
    und = [0 for i in range(m)]
    f = "{:b}".format(i)
    s = f.zfill(n)
    mm = 0
    for j in range(len(s)):
        if s[j] == '1':
            for k in range(m):
                und[k] += know[j][k]
            mm += prace[j]
    for j in range(m):
        if und[j] < x:
            break
    else:
        ans = min(ans, mm)
if ans == 10**10:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
prace = []
know = []
for i in range(n):
    acc = list(map(int, input().split()))
    prace.append(acc[0])
    know.append(acc[1:])

ans = 10**10
for i in range(2**n):
    und = [0 for i in range(m)]
    f = "{:b}".format(i)
    s = f.zfill(m)
    mm = 0
    for j in range(len(s)):
        if s[j] == '1':
            for k in range(m):
                und[k] += know[j][k]
            mm += prace[j]
    for j in range(m):
        if und[j] < x:
            break
    else:
        ans = min(ans, mm)
if ans == 10**10:
    print(-1)
else:
    print(ans)
Problem p02717 (python)

Fixed submission:
x, y, z = input().split()
print(z, x, y)

Buggy submission (verdict: Runtime Error):
x, y, z = input().split()
print(f"{z} {x} {y}")
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
i = 10**(n-1)
if n==1:
    i = 0
no = False
while i<10**n:
    for j in range(m):
        if int(str(i)[sc[j][0]-1])==sc[j][1]:
            pass
        else:
            no = True
    if no == False:
        print(i)
        break
    else:
        i+=1
    no = False
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))
i = 10**(n-1)
if n==1:
    i = 0
while i<10**n:
    for j in range(m):
        if int(str(i)[sc[j][0]-1])==sc[j][1]:
            pass
        else:
            no = True
    if no == False:
        print(i)
        break
    else:
        i+=1
    no = False
else:
    print(-1)
Problem p02866 (python)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
lis = [0 for i in range(10**5+100)]
ans = 1
mx = -1
for i in d:
    lis[i] += 1
    if i > mx:
        mx = i
if lis[0] != 1 or d[0] != 0:
    print(0)
else:
    for i in range(1, mx+1):
        ans *= lis[i-1]**lis[i]
    print(ans%998244353)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int, input().split()))
lis = [0 for i in range(10*5+100)]
ans = 1
mx = -1
for i in d:
    lis[i] += 1
    if i > mx:
        mx = i
if lis[0] != 1 or d[0] != 0:
    print(0)
for i in range(1, mx+1):
    for j in range(lis[i]):
        ans *= lis[i-1]
print(ans%998244353)

Buggy submission (verdict: Runtime Error):
import heapq

n = int(input())
d = list(map(int, input().split()))
heapq.heapify(d)
if d[0] != 0:
    print(0)
else:
    pre = -1
    num = 0
    ans = 1
    for i in range(len(d)):
        if d[0] == 0:
            if i > 0:
                print(0)
                break
            else:
                pre = 0
                heapq.heappop(d)
                continue
        if d[0] == pre:
            num += 1
            if i == n-1:
                ans *= d[i]**num
            heapq.heappop(d)
        elif d[0] - pre > 1:
            print(0)
            break
        else:
            if i == 1:
                num = 1
                pre = d[0]
                heapq.heappop(d)
                continue
            ans *= pre**num
            pre = d[0]
            if i == n-1:
                ans *= pre
            num = 1
            heapq.heappop(d)
    else:
        print(ans)
Problem p02900 (python)

Fixed submission:
a, b = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
n = gcd(a, b)
ndiv = n
if n == 1:
    print(1)
else:
    i = 1
    primecount = 0
    divisor = False
    while True:
        i += 1
        while ndiv%i == 0:
            ndiv = ndiv//i
            divisor = True
        if divisor:
            primecount += 1
            divisor = False
            if ndiv == 1:
                break
        if ndiv != 1 and i*i > n:
            primecount += 1
            break
    print(primecount+1)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
def gcd(x, y):
    if y == 0:
        return x
    else:
        gcd(y, x%y)
n = gcd(a, b)
ndiv = n
i = 2
primecount = 0
divisor = False
while i*i <= n:
    while ndiv%i == 0:
        ndiv = ndiv//i
        divisor = True
    if divisor:
        primecount += 1
        divisor = False
    i += 1

print(primecount+1)
Problem p02923 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
count = 0
max_list = []
for i in range(len(h)-1):
    if h[i] >= h[i+1]:
        count += 1
        if i == len(h)-2:
            max_list.append(count)
    else:
        max_list.append(count)
        count = 0
if n == 1:
    print(0)
else:        
    print(max(max_list))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
count = 0
max_list = []
for i in range(len(h)-1):
    if h[i] >= h[i+1]:
        count += 1
        if i == len(h)-2:
            max_list.append(count)
    else:
        max_list.append(count)
        count = 0
print(max(max_list))
Problem p02971 (python)

Fixed submission:
n = int(input())
a = []
max_num = -1
for i in range(n):
    ipt = int(input())
    if ipt > max_num:
        max_num = max(ipt, max_num)
        idx = i
    a.append(ipt)
a = sorted(a)
if a[-1] == a[-2]:
    for i in range(n):
        print(max_num)
else:
    for i in range(n):
        if i == idx:
            print(a[-2])
        else:
            print(max_num)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
max_num = -1
for i range(n):
    ipt = int(input())
    if ipt > max_num:
        max_num = max(ipt, max_num)
        idx = i
    a.append(ipt)
a = sorted(a)
if a[-1] == a[-2]:
    for i in range(n):
        print(max_num)
else:
    for i in range(n):
        if i == idx:
            print(a[-2])
        else:
            print(max_num)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
max_num = -1
mode_max = False
for i in range(n):
    ipt = int(input())
    if ipt == max_num:
        mode_max = True
    else:
        max_num = max(ipt, max_num)
        a.append(ipt)
if mode_max:
    for i in range(n):
        print(max_num)
else:
    a_copy = a[:]
    idx = a.index(max_num)
    a_copy.remove(max_num)
    sub_max = max(a_copy)
    for i in range(n):
        if i == idx:
            print(sub_max)
        else:
            print(max_nums)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = []
max_num = 0
sub_max = 0
all_max = False
if n == 2:
    a_list.append(int(input))
    print(a_list[1])
    print(a_list[0])
else:
    for i in range(n):
        a = int(input())
        a_list.append(a)
        if sub_max < a:
            if max_num < a:
                sub_max = max_num
                max_num = a
                idx = i
            else:
                sub_max = a
        elif max_num == a:
            max_num = a
            all_max = True
    if all_max:
        for i in range(n):
            print(max_num)
    else:
        for i in range(n):
            if i == idx:
                print(sub_max)
            else:
                print(max_num)
Problem p02995 (python)

Fixed submission:
from fractions import gcd

a, b, c, d = map(int, input().split())
cx = b//c - (a-1)//c
dx = b//d - (a-1)//d
lcm = (c * d) // gcd(c, d)
lcmx = b//lcm - (a-1)//lcm
print(b-a+1-cx-dx+lcmx)

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

a, b, c, d = map(int, input().split())
cx = b//c - (a-1)//c
dx = b//d - (a-1)//d
lcm = (c * d) // gcd(c, d)
lcmx = b//lcm - (a-1)//lcm
print(b-a+1-cx-dx+lcmx)
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
s = 0
for i in range(n):
    s += l[i]
    if s > x:
        print(i+1)
        break
else:
    print(n+1)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
i = 0
while d <= x:
    d += l[i]
    i += 1
    if i == x:
        break
print(i)
Problem p03006 (python)

Fixed submission:
from collections import Counter

n = int(input())
q_list = []
a_list = []
for i in range(n):
    q = []
    x, y = map(int, input().split())
    q.append(x)
    q.append(y)
    q_list.append(q)
    if i != 0:
        for j in range(i):
            difx1 = q_list[j][0] - q_list[i][0]
            dify1 = q_list[j][1] - q_list[i][1]
            difx2 = q_list[i][0] - q_list[j][0]
            dify2 = q_list[i][1] - q_list[j][1]
            a_list.append(str(difx1)+str(dify1))
            a_list.append(str(difx2)+str(dify2))
if n != 1:
    zero = Counter(a_list).most_common()[0][1]
    print(n-zero)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
q_list = []
a_list = []
for i in range(n):
    q = []
    x, y = map(int, input().split())
    q.append(x)
    q.append(y)
    q_list.append(q)
    if i != 0:
        for j in range(i):
            difx1 = q_list[j][0] - q_list[i][0]
            dify1 = q_list[j][1] - q_list[i][1]
            difx2 = q_list[i][0] - q_list[j][0]
            dify2 = q_list[i][1] - q_list[j][1]
            a_list.append(f"{difx1}{dify1}")
            a_list.append(f"{difx2}{dify2}")
if n != 1:
    c = collections.Counter(a_list)
    zero = c.most_common()[0][1]
    print(n-zero)
else:
    print(1)

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

n = int(input())
q_list = []
a_list = []
for i in range(n):
    q = []
    x, y = map(int, input().split())
    q.append(x)
    q.append(y)
    q_list.append(q)
    if i != 0:
        for j in range(i):
            difx1 = q_list[j][0] - q_list[i][0]
            dify1 = q_list[j][1] - q_list[i][1]
            difx2 = q_list[i][0] - q_list[j][0]
            dify2 = q_list[i][1] - q_list[j][1]
            a_list.append(f"{difx1}{dify1}")
            a_list.append(f"{difx2}{dify2}")
if n != 1:
    zero = Counter(a_list).most_common()[0][1]
    print(n-zero)
else:
    print(1)
Problem p03067 (python)

Fixed submission:
a = input()
b = list(map(int, a.split()))
if b[0] <= b[2] <= b[1]:
  print('Yes')
  
elif b[1] <= b[2] <= b[0]:
  print('Yes')
  
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a = input()
b = a.split()
N = int(b[0])
S = list(b[1])
K = int(b[2])
lit = S[K-1]
for i in range(N):
    if S[i] != lit:
        S[i] = "*"
        
print("".join(S))

Buggy submission (verdict: Runtime Error):
a = input()
b = a.split()
N = int(b[0])
S = list(b[1])
K = int(b[2])
lit = S[K-1]
for i in range(N):
    if S[i] != lit:
        S[i] = '*'
print(''.join(S))
Problem p03068 (python)

Fixed submission:
N = int(input())
S = list(input())
K = int(input())
lit = S[K-1]
for i in range(N):
  if S[i] != lit:
    S[i] = '*'

print(''.join(S))

Buggy submission (verdict: Runtime Error):
a = input()
b = a.splitlines()
N = int(b[0])
S = list(b[1])
K = int(b[2])
lit = S[K-1]
for i in range(N):
  if S[i] != lit:
    S[i] = '*'

print(''.join(S))

Buggy submission (verdict: Runtime Error):
a = input()
b = a.split()
N = int(b[0])
S = list(b[1])
K = int(b[2])
lit = S[K-1]
for i in range(N):
  if S[i] != lit:
    S[i] = '*'

print(''.join(S))

Buggy submission (verdict: Runtime Error):
a = input()
b = a.split()
N = int(b[0])
S = list(b[1])
K = int(b[2])
lit = S[K-1]
for i in range(N):
  if S[i] != lit:
    S[i] = '*'

print(''.join(S))

Buggy submission (verdict: Runtime Error):
a = input()
b = a.split()
N = int(b[0])
S = list(b[1])
K = int(b[2])
lit = S[K-1]
for i in range(N):
  if S[i] != lit:
    S[i] = '*'
print(''.join(S))
Problem p03069 (python)

Fixed submission:
N = int(input())
S = list(input())

num = S.count('.')

anslist = [num]
for i in range(N):
  if S[i] == '#':
    num += 1
    anslist.append(num)
  else:
    num -= 1
    anslist.append(num)

print(min(anslist))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
x = 0
w = 0
b = 0
while S[x] == ".":
  x += 1
  if x == N:
    break
for j in range(N):
  if S[j] == ".":
    w += 1
  else:
    b += 1
if y - w <= b:
  print(y - w)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
x = 0
w = 0
b = 0
while S[x] == ".":
  x += 1
  if x == N:
    break
for j in range(N):
  if S[j] == ".":
    w += 1
  else:
    b += 1
if y - w <= b:
  print(y - w)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
a = input()
b = a.split()
N = int(b[0])
S = b[1]
stone = list(S)
x = 0
y = 0 
while stone[x] == ".":
  x += 1
  if x == N:
    break
for j in range(N):
  if stone[j] == ".":
    y += 1
print(y - x)
Problem p03284 (python)

Fixed submission:
n, k = map(int, input().split())
if n%k:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input())
if n%k:
    print(0)
else:
    print(1)
Problem p03574 (python)

Fixed submission:
mine = []
h, w = map(int, input().split())
for i in range(h):
    mine.append(list(input()[:]))
ans = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if mine[i][j] == '#':
            if i != 0:
                ans[i-1][j] += 1
            if j != 0:
                ans[i][j-1] += 1
            if i != h-1:
                ans[i+1][j] += 1
            if j != w-1:
                ans[i][j+1] += 1
            if i != 0 and j != 0:
                ans[i-1][j-1] += 1
            if i != 0 and j != w-1:
                ans[i-1][j+1] += 1
            if i != h-1 and j != 0:
                ans[i+1][j-1] += 1
            if i != h-1 and j != w-1:
                ans[i+1][j+1] += 1

for i in range(h):
    for j in range(w):
        if mine[i][j] == "#":
            print("#", end="")
        else:
            print(ans[i][j], end="")
    print()

Buggy submission (verdict: Runtime Error):
mine = []
h, w = map(int, input().split())
for i in range(h):
    mine.append(list(input()[:]))
ans = [[0 for i in range(w)] for j in range(w)]
for i in range(h):
    for j in range(w):
        if mine[i][j] == '#':
            if i != 0:
                ans[i-1][j] += 1
            if j != 0:
                ans[i][j-1] += 1
            if i != h-1:
                ans[i+1][j] += 1
            if j != w-1:
                ans[i][j+1] += 1
            if i != 0 and j != 0:
                ans[i-1][j-1] += 1
            if i != 0 and j != w-1:
                ans[i-1][j+1] += 1
            if i != h-1 and j != 0:
                ans[i+1][j-1] += 1
            if i != h-1 and j != w-1:
                ans[i+1][j+1] += 1

for i in range(h):
    for j in range(w):
        if mine[i][j] == "#":
            print("#", end="")
        else:
            print(ans[i][j], end="")
    print()
Problem p03937 (python)

Fixed submission:
h, w = map(int, input().split())
table = []
for i in range(h):
    table.append(list(input()))
poss = True
for i in range(h-1):
    for j in range(w-1):
        if table[i][j] == "#":
            if (table[i+1][j]=="#" and table[i][j+1]=="#") or (table[i+1][j]=="." and table[i][j+1]=="."):
                poss = False
for i in range(1, h):
    if table[i][w-2]=="#" and table[i-1][w-1]=="#":
        poss = False
for i in range(1, w):
    if table[h-1][i-1]=="#" and table[h-2][i]=="#":
        poss = False

if poss:
    print("Possible")
else:
    print("Impossible")

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
table = []
for i in range(h):
    table.append(list(input()))
poss = True
for i in range(h-1):
    for j in range(w-1):
        if table[i][j] == "#":
            if (table[i+1][j]=="#" and table[i][j+1]=="#") or (table[i+1][j]=="." and table[i][j+1]=="."):
                poss = False
for i in range(1, h):
    if table[i][w-1]=="#" and table[i-1][w]=="#":
        poss = False
for i in range(1, w):
    if table[h][i-1]=="#" and table[h-1][i]=="#":
        poss = False

if poss:
    print("Possible")
else:
    print("Impossible")
Problem p02582 (python)

Fixed submission:
S=input()
if S=='SSS':
  print(0)
if S=='RSS' or S=='SRS' or S=='SSR' or S=='RSR':
  print(1)
if S=='RRS' or S=='SRR':
  print(2)
if S=='RRR':
  print(3)

Buggy submission (verdict: Runtime Error):
if S=='SSS':
  print(0)
if S=='RSS' or S=='SRS' or S=='SSR' or S=='RSR':
  print(1)
if S=='RRS' or S=='SRR':
  print(2)
if S=='RRR':
  print(3)