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

Fixed submission:
s = input()
ans_rev = ''
b = 0
for i in range(len(s)-1,-1,-1):
  if s[i] == 'B':
    b += 1
  else:
    if b > 0:
      b -= 1
    else:
      ans_rev += s[i]
for i in range(len(ans_rev)-1, -1,-1):
  print(ans_rev[i], end='')
print()

Buggy submission (verdict: Runtime Error):
s = input()
b = 0
for i in range(n-1,-1,-1):
  if s[i] == 'B':
    b += 1
  else:
    if b > 0:
      b -= 1
    else:
      print(s[i], end='')
print()
Problem p04045 (python)

Fixed submission:
n,k = map(int,input().split())
D = list(map(int,input().split()))
while True:
  dis = False
  for d in D:
    if str(d) in str(n):
      dis = True
      break
  if not dis:
    break
  n += 1
print(n)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
D = list(map(int,input().split()))
while True:
  dis = False
  for d in D:
    if d in str(n):
      dis = True
      break
  if not dis:
    break
  n += 1
print(n)
Problem p02719 (python)

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

c=abs(n-k)
d=abs(c-k)
if(c+d==k):
    if(c>d):
        print(d)
    else:
        print(c)
    exit()
if(n>=k):
    if(n%k==0):
        print(0)
        exit()
    else:
        a=n-k*(n//k)
        b=k*(n//k+1)-n
        if(a>b):
            print(b)
        else:
            print(a)
        exit()
else:
    
    while(1):
        a=abs(n-k)
        if(n>a):
            n=a
        else:
            print(n)
            exit()

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

c=abs(n-k)
d=abs(c-k)
if(c+d==k):
    if(c>d):
        print(d)
    else:
        print(c)

if(k%n==0):
    if(n>k):
        print(0)
    else:
        print(n) 
    exit()

if(n>k):
    a=n-k*(n//k)
    b=k*(n//k+1)-n
    if(a>b):
        print(b)
    else:
        print(a)

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

flag=0
if(n>k):
    flag=1
    temp=n
    n=k
    k=temp

if(k%n==0):
    if(flag==1):
        print(0)
    else:
        print(n) 
    exit()


a=int(k/n)
b=a+1
if(flag==1):
    if(k-n*a<=n*b-k):
        print(k-n*a)
    else:
        print(n*b-k)
else:
    c=abs(n-k)
    d=abs(c-k)
    if(c>d):
        print(d)
    else:
        print(c)
Problem p02732 (python)

Fixed submission:
from collections import Counter
N=int(input())
A=list(map(int,input().split()))

parent=dict()
An=set(A)
parecou=0
aaa=Counter(A)
for i in aaa.values():
    parecou+=int((i*(i-1)/2))
"""
for i in An:
    f=A.count(i)
    parent[i]=f
    parecou+=int((f*(f-1)/2))
"""


#print(parecou)
for i in range(N):
    anko=aaa[A[i]]
    print(parecou-int((anko*(anko-1)/2))+int(((anko-2)*(anko-1)/2)))
    #print(parecou-anko+1)

Buggy submission (verdict: Runtime Error):
import copy

N=int(input())

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

#print(A)

mama=dict()
papa=dict()
papa[0]=0
papa[1]=0
papa[2]=1
for i in range(3,int(N/2)):
    papa[i]=int(i*papa[i-1]/2)
for i in range(N):

    if(A[i] in mama):
        print(mama[A[i]])
        continue
    
    AA=copy.deepcopy(A)
    ai=A[i]
    del AA[i]
    #print(AA)
    Aset=set(AA)
    count=0
    
    for i in Aset:
        aa=AA.count(i)
        if(aa in papa):
            count+=papa[aa]
            continue
        #print(i,aa)
        aiu=int((aa*(aa-1))/2)
        count+=aiu
        papa[aa]=aiu
    print(count)
    mama[ai]=count

Buggy submission (verdict: Runtime Error):
import copy

N=int(input())

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

#print(A)

mama=dict()
papa=dict()
papa[0]=0
papa[1]=0
papa[2]=1
for i in range(3,N/2):
    papa[i]=int(i*papa[i-1]/2)
for i in range(N):

    if(A[i] in mama):
        print(mama[A[i]])
        continue
    
    AA=copy.deepcopy(A)
    ai=A[i]
    del AA[i]
    #print(AA)
    Aset=set(AA)
    count=0
    
    for i in Aset:
        aa=AA.count(i)
        if(aa in papa):
            count+=papa[aa]
            continue
        #print(i,aa)
        aiu=int((aa*(aa-1))/2)
        count+=aiu
        papa[aa]=aiu
    print(count)
    mama[ai]=count
Problem p02780 (python)

Fixed submission:
q1=list(map(int,input().split(" ")))
a1=list(map(int,input().split(" ")))


sum1=sum(a1[:q1[1]])
sumsum=sum1
for i in range(q1[0]-q1[1]):
    sum1=sum1+a1[i+q1[1]]-a1[i]
    if(sumsum<sum1):
        sumsum=sum1
sumsum+=q1[1]
print(sumsum/2)

Buggy submission (verdict: Runtime Error):
q1=list(map(int,input().split(" ")))
a1=list(map(int,input().split(" ")))

sumsum=0
for i in range(q[0]-q1[1]+1):
    sum1=sum(a1[i:i+q1[1]])
    if(sumsum<sum1):
        sumsum=sum1
sumsum+=q1[1]
print(sumsum/2)
Problem p02675 (python)

Fixed submission:
import sys
import numpy as np
lines = sys.stdin.readlines()
a = int(lines[0].strip())

if a%10 == 3:
  print('bon')
elif a%10 in [0,1,6,8]:
  print('pon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

i = list(map(int, input().split()))
a = i[0]
b = i[1]
h = i[2]
m = i[3]
time = h*60+m
ths = np.pi/2-(np.pi * time/(60*12))
thl = np.pi/2-(np.pi * m/30.0)
#ths = np.deg2rad(90-h*30.0)
#thl = np.deg2rad(90-m*6.0)
x1 = a*np.cos(ths)
y1 = a*np.sin(ths)
x2 = b*np.cos(thl)
y2 = b*np.sin(thl)
print(np.sqrt((x1-x2)**2+(y1-y2)**2))
Problem p02696 (python)

Fixed submission:
import numpy as np
str = input()
lst = str.split()
a = int(lst[0])
b = int(lst[1])
c = int(lst[2])
if b > c:
    print(int(a*c/b)-int(c/b)*a)
else:
    d = int(c/b)
    if d > 100:
      d = 100
    lst = np.zeros(d)
    for i in range(d):
        k = b*(i+1)-1
        lst[i] = int(a*k/b)-int(k/b)*a
    print(int(np.max(lst)))

Buggy submission (verdict: Runtime Error):
import numpy
str = input()
lst = str.split()
a = int(lst[0])
b = int(lst[1])
c = int(lst[2])
if b > c:
    print(int(a*c/b)-int(c/b)*a)
else:
    d = int(c/b)
    lst = np.zeros(d)
    for i in range(d):
        k = b*(i+1)-1
        lst[i] = int(a*k/b)-int(k/b)*a
    print(np.max(lst))
Problem p02573 (python)

Fixed submission:
def main():
    n,m=map(int,input().split())
    ab=[map(lambda x: int(x)-1,input().split()) for _ in range(m)]
    uf=UnionFind(n)
    for a,b in ab:
        uf.union(a,b)
    ans = 0
    for s in uf.roots():
        ans = max(uf.size(s),ans)
    print(ans)

class UnionFind():
    '''Union-Find'''
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def is_same(self, x, y) -> bool:
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,m=map(int,input().split())
    uf=UnionFind(n)
    for a,b in (map(lambda x: int(x)-1, input().split()) for _ in range(m)):
        uf.union(a,b)
    print(max((uf.size(x) for x in uf.roots())))
    
if __name__ == "__main__":
    main()
Problem p02606 (python)

Fixed submission:
l,r,n = map(int,input().split())
count = 0
for i in range(l,r+1):
  if i % n == 0:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
l,r,n = map(int,input())
count = 0
for i in range(l,r+1):
  if i % n == 0:
    count += 1
print(count)
Problem p02630 (python)

Fixed submission:
from collections import Counter

def main():
    n = int(input())
    a = Counter(map(int, input().split()))
    temp, a = listed(a)
    q = int(input())
    bc = [tuple(map(int, input().split())) for _ in range(q)]
    
    for b, c in bc:
        t = a[b]
        if t == 0:
            print(temp)
            continue
        a[b] = 0
        temp -= b*t
        a[c] += t
        temp += c*t
        print(temp)

def listed(a):
    x = [0] * (10**5 + 1)
    kei = 0
    for i,v in a.items():
        x[i] = v
        kei += i*v
    return kei, x

if __name__ == '__main__':
    main()

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

def main():
    n = int(input())
    a = Counter(map(int, input().split()))
    temp, a = listed(a)
    q = int(input())
    bc = [tuple(map(int, input().split())) for _ in range(q)]
    
    for b, c in bc:
        t = a[b]
        if t == 0:
            print(temp)
            continue
        a[b] = 0
        temp -= b*t
        a[c] += t
        temp += c*t
        print(temp)

def listed(a):
    x = [0] * 10**5
    kei = 0
    for i,v in a.items():
        x[i] = v
        kei += i*v
    return kei, x

if __name__ == '__main__':
    main()

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

def main():
    n = int(input())
    a = Counter(map(int, input().split()))
    temp, a = listed(a)
    q = int(input())
    bc = [tuple(map(int, input().split())) for _ in range(q)]
    
    for b, c in bc:
        t = a[b]
        if t == 0:
            print(temp)
            continue
        a[b] = 0
        temp -= b*t
        a[c] += t
        temp += c*t
        print(temp)

def listed(a):
    x = [0] * 10**5
    kei = 0
    for i,v in a.items():
        x[i] = v
        kei += i*v
    return kei, x

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

Fixed submission:
print(list(map(int,input().split())).index(0)+1)

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    pool = set()
    count = 0
    limit = 10 ** 6 // 2 +1
    for i in range(n):
        t = a[i]
        if t in pool:
            continue
        for j in range(1, limit):
            x = t*j
            if x > limit:
                break
            pool.add(x)
        if not (n > i+1 and t == a[i+1]):
            count += 1
    print(count)

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

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

Buggy submission (verdict: Runtime Error):
def main():
    _ = input()
    a = sorted(list(map(int, input().split())), reverse=True)
    if a[-1] == 0:
        print(0)
        return
    x = 1
    m = 10 ** 18
    for i in a:
        if i > m:
            print(-1)
            return
        if i < 2:
            continue
        x *= i
    print(-1 if x > 10 ** 18 else x)


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

Fixed submission:
def prime_factorize(n):
    '''引数nの因数分解結果のlistを返す。'''
    arr = []
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            arr.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        arr.append(n)
    return arr

def main():
    n = int(input())
    f = set(prime_factorize(n))
    s = set()
    for p in f:
        e = 1
        z = p ** e
        while z <= n:
            if n % z == 0:
                if z not in s:
                    n //= z
                    s.add(z)
            e += 1
            z = p ** e
    print(len(s))
        
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    f = set(prime_factorize(n))
    s = set()
    for p in f:
        e = 1
        z = p ** e
        while z <= n:
            if n % z == 0:
                if z not in s:
                    n //= z
                    s.add(z)
            e += 1
            z = p ** e
    print(len(s))
        
if __name__ == '__main__':
    main()
Problem p02687 (python)

Fixed submission:
a = input()

if a == "ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
import itertools
 
x = int(input())
 
y = itertools.combinations(range(-100,100), 2)
i = 0
for n in y:
    if (n[0]**5 - n[1]**5) == x:
        print(n[0], n[1])
        break
    elif (n[1]**5 - n[0]**5) == x:
        print(n[1], n[0])
        break

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

y = itertools.combinations(range(-50,50), 2)
i = 0
for n in y:
    if (n[0]**5 - n[1]**5) == x:
        print(n[0], n[1])
        break
    elif (n[1]**5 - n[0]**5) == x:
        print(n[1], n[0])
        break

Buggy submission (verdict: Runtime Error):
import itertools
 
x = int(input())
 
y = itertools.combinations(range(-50,50), 2)
i = 0
for n in y:
    if (n[0]**5 - n[1]**5) == x:
        print(n[0], n[1])
        break
    elif (n[1]**5 - n[0]**5) == x:
        print(n[1], n[0])
        break

Buggy submission (verdict: Runtime Error):
import itertools

x = int(input())

y = itertools.combinations(range(-80,80), 2)
for n in y:
    if (n[0]**5 - n[1]**5) == x:
        print(n[0], n[1])
        break
    elif (n[1]**5 - n[0]**5) == x:
        print(n[1], n[0])
        break

Buggy submission (verdict: Runtime Error):
import itertools

x = int(input())

y = itertools.combinations(range(-100,100), 2)
i = 0
for n in y:
    if (n[0]**5 - n[1]**5) == x:
        print("{} {}".format(n[0], n[1]))
        break
    elif (n[1]**5 - n[0]**5) == x:
        print("{} {}".format(n[1], n[0]))
        break

Buggy submission (verdict: Runtime Error):
import itertools

x = int(input())

y = itertools.combinations(range(-100,100), 2)
i = 0
for n in y:
    if (n[0]**5 - n[1]**5) == x:
        print(n[0], n[1])
        break
    elif (n[1]**5 - n[0]**5) == x:
        print(n[1], n[0])
        break
#print("miss")
Problem p02732 (python)

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * (N+1)
    for i in A:
        nums[i] += 1
    #nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        print(comb-(nums[A[k]]-1))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * N
    for i in A:
        nums[i] += 1
    #nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        #print(comb-(nums[A[k]]-1))
        t = nums[A[k]]
        print(comb - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import itertools as iter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    nums = [0] * N
    for i in A:
        nums[i] += 1
    #nums = [A.count(i) for i in range(N+1)]
    comb = sum((i*(i-1)//2 for i in nums))
    for k in range(N):
        print(comb-(nums[A[k]]-1))

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

Fixed submission:
import itertools as iter

def main():
    n, k = list(map(int, input().split()))
    p = [0]
    p.extend(list(iter.accumulate([(1+int(x))/2 for x in input().split()])))
    #print(p)
    
    s = []
    for i in range(n-k+1):
        s.append(p[i+k]-p[i])
    #print(s)
    print(max(s))
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, k = list(map(int, input().split()))
    p = list(map(int, input().split()))
    
    s = []
    for i in range(len(p)-k):
        s.append((sum(p[i:i+k])+k)/2)    
    print(max(s))
    
if __name__ == '__main__':
    main()
Problem p02924 (python)

Fixed submission:
n=int(input());print(int(n*(n-1)//2))

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    p = list(range(1,n+1))
    q = p[1:]
    q.append(p[0])
    s = 0
    for i, v in enumerate(q):
        s += (i+1) % v
    print(s)

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

Fixed submission:
def main():
    n,q=map(int,input().split())
    ab=[list(map(int,input().split())) for _ in range(n-1)]
    tree=[list() for _ in range(n)]
    score=[0]*n
    for a,b in ab:
        a,b=a-1,b-1
        tree[a].append(b)
        tree[b].append(a)
    e = [0]
    while len(e) > 0:
        i = e.pop()
        for j in tree[i]:
            tree[j].remove(i)
            e.append(j)
    px=[list(map(int,input().split())) for _ in range(q)]
    for p,x in px:
        p-=1
        score[p]+=x
    add(tree,score)
    print(*score)

def add(tree,score):
    s=tree[0][:]
    for i in s:
        score[i] += score[0]
    while len(s)>0:
        t = s.pop()
        for i in tree[t]:
            s.append(i)
            score[i] += score[t]

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,q=map(int,input().split())
    ab=[list(map(int,input().split())) for _ in range(n-1)]
    tree=[list() for _ in range(n)]
    score=[0]*n
    for a,b in ab:
        a-=1
        b-=1
        tree[a].append(b)
    px=[list(map(int,input().split())) for _ in range(q)]
    for p,x in px:
        p-=1
        add(p,x,tree,score)
    print(s)

def add(p,x,tree,score):
    score[p] += x
    s=tree[p][:]
    while len(s)>0:
        t = s.pop()
        score[t] += x
        for i in tree[t]:
            s.append(i)

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

Fixed submission:
from itertools import permutations
def main():
    a=[int(input()) for _ in range(5)]
    ans=[]
    for x in permutations(a):
        t = 0
        for y in x:
            if t % 10 != 0:
                t = (t//10 + 1) * 10
            t += y
        ans.append(t)
    print(min(ans))
            
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    x = [int(input()) for _ in range(5)]
    d = min(((i % 10, i) for i in x if i % 10 != 0), key=lambda x: x[0])
    i = x.index(d[1])
    t = 0
    for idx, v in enumerate(x):
        if idx == i or v % 10 == 0:
            t += v
        else:
            t += v + 10 - (v % 10)
        #print(idx, t)
    print(t)
    
if __name__ == "__main__":
    main()
Problem p03086 (python)

Fixed submission:
def main():
    ans = []
    s = input()
    count = 0
    for i in s:
        if i in "ATGC":
            count += 1
        else:
            ans.append(count)
            count = 0
    ans.append(count)
    print(max(ans))
        
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    ans = []
    s = input()
    count = 0
    for i in s:
        if i in "ATGC":
            count += 1
        else:
            ans.append(count)
    print(max(ans))
        
if __name__ == "__main__":
    main()
Problem p03251 (python)

Fixed submission:
n,m,X,Y=map(int,input().split())
x=max(X,max(map(int,input().split())))
y=min(Y,min(map(int,input().split())))
print(["War","No War"][x<y])

Buggy submission (verdict: Runtime Error):
n,m,X,Y=sorted(map(int,input().split()))
x=max([X],max(map(int,input().split())))
y=min([Y],min(map(int,input().split())))
print("No War" if x<y else "War")
Problem p03262 (python)

Fixed submission:
import math
def main():
    n,x=map(int,input().split())
    p=0
    for i in map(int,input().split()):
        p = math.gcd(p, i-x)
    print(p)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
def main():
    N,X=map(int,input().split())
    x=[a-X for a in sorted(map(int,input().split()), reverse=True)]
    if N == 1:
        print(x[0])
        return
    d=[]
    for i in range(N-1):
        d.append(x[i]-x[i+1])
    ans=math.gcd(d[0], d[1])
    for a in d[1:]:
        ans = math.gcd(ans, a)
    print(ans)
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
def main():
    n,x=map(int,input().split())
    x=sorted(map(int,input().split()), reverse=True)
    d=[]
    for i in range(n-1):
        d.append(x[i]-x[i+1])
    if len(d) < 1:
        print(x[0]-1)
        return
    ans=math.gcd(d[0], d[1])
    for a in d[1:]:
        ans = math.gcd(ans, a)
    print(ans)
    
if __name__ == "__main__":
    main()
Problem p03282 (python)

Fixed submission:
def main():
    s = input()
    k = int(input())
    r = '1'
    for i,v in enumerate(s):
        if v != '1':
            r = v
            break
    if i >= k:
        print(1)
    else:
        print(r)
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import Counter
def main():
    s,k = input(), int(input())
    for i,v in enumerate(s):
        if v != '1':
            r = v
            break
    if k < i:
        print(1)
    else:
        print(r)

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

Fixed submission:
n=int(input())
s=input()
a=[]
for i in range(1,n):
    s1=set(s[:i])
    s2=set(s[i:])
    a.append(len(s1&s2))
print(max(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
a=[]
for i in range(1,n-1):
    s1=set(s[:i])
    s2=set(s[i:])
    a.append(len(s1&s2))
print(max(a))
Problem p03361 (python)

Fixed submission:
def main():
    H,W=map(int,input().split())
    m=[input() for _ in range(H)]
    is_ok = True
    for h in range(H):
        for w in range(W):
            if m[h][w] == "#":
                if -1 < h-1 and m[h-1][w] == "#":
                    pass
                elif -1 < w-1 and m[h][w-1] == "#":
                    pass
                elif h+1 < H and m[h+1][w] == "#":
                    pass
                elif w+1 < W and m[h][w+1] == "#":
                    pass
                else:
                    print("No")
                    return
    print("Yes")
        
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    H,W=map(int,input().split())
    m=[input() for _ in range(H)]
    is_ok = True
    for h in range(H):
        for w in range(W):
            if m[w][h] == "#":
                if 0 < h-1 and m[w][h-1] == "#":
                    pass
                elif 0 < w-1 and m[w-1][h] == "#":
                    pass
                elif h+1 < H and m[w][h+1] == "#":
                    pass
                elif w+1 < W and m[w+1][h] == "#":
                    pass
                else:
                    print("No")
                    return
    print("Yes")
        
if __name__ == "__main__":
    main()
Problem p03475 (python)

Fixed submission:
import math
def main():
    n=int(input())
    csf=[list(map(int,input().split())) for _ in range(n-1)]
    for i in range(n):
        if i == n-1:
            print(0)
        else:
            t=0
            for c,s,f in csf[i:]:
                t = max(s,t)
                t = math.ceil(t/f)*f+c
                #print("start:", i, t)
            print(t)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    csf=[list(map(int,input().split())) for _ in range(n-1)]
    for i in range(n):
        if i == n-1:
            print(0)
        else:
            t=0
            for c,s,f in csf[i:]:
                t = max(s,t)
                t = math.ceil(t/f)*f+c
                #print("start:", i, t)
            print(t)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from itertools import product, combinations
def main():
    n=int(input())
    csf=[list(map(int,input().split())) for _ in range(n-1)]
    for i in range(n):
        if i == n-1:
            print(0)
        else:
            t=0
            for c,s,f in csf[i:]:
                t = max(s,t)
                t = lcm(t,f)+c
                #print("start:",i, t)
            print(t)

if __name__ == "__main__":
    main()