Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
ud = False
ud_count = 0
for i in range(q):
    query = list(input().split())
    if int(query[0]) == 1:
        ud = not(ud)
        ud_count += 1
    else:
        if (int(query[1])==1 and ud==False) or (int(query[1])==2 and ud==True):
            s = query[2] + s
        else:
            s += query[2]
if ud_count%2:
    print(s[::-1])
else:
    print(s)


Fixed submission:
s = input()
q = int(input())
ud = False
ud_count = 0
sub_s = ""
for i in range(q):
    query = list(input().split())
    if int(query[0]) == 1:
        ud = not(ud)
        ud_count += 1
    else:
        if (int(query[1])==1 and ud==False) or (int(query[1])==2 and ud==True):
            sub_s += query[2]
        else:
            s += query[2]
s = sub_s[::-1] + s
if ud_count%2:
    print(s[::-1])
else:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
ud = False
ud_count = 0
for i in range(q):
    query = list(input().split())
    if int(query[0]) == 1:
        ud = not(ud)
        ud_count += 1
    else:
        if (int(query[1])==1 and ud==False) or (int(query[1])==2 and ud==True):
            s = query[2] + s
        else:
            s += query[2]
if ud_count%2:
    print(s[::-1])
else:
    print(s)


Fixed submission:
s = input()
q = int(input())
ud = False
ud_count = 0
sub_s = ""
for i in range(q):
    query = list(input().split())
    if int(query[0]) == 1:
        ud = not(ud)
        ud_count += 1
    else:
        if (int(query[1])==1 and ud==False) or (int(query[1])==2 and ud==True):
            sub_s += query[2]
        else:
            s += query[2]
s = sub_s[::-1] + s
if ud_count%2:
    print(s[::-1])
else:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    query = list(input().split())
    if int(query[0]) == 1:
        s = s[::-1]
    else:
        if int(query[1]) == 1:
            s = query[2] + s
        else:
            s += query[2]
print(s)


Fixed submission:
s = input()
q = int(input())
ud = False
ud_count = 0
sub_s = ""
for i in range(q):
    query = list(input().split())
    if int(query[0]) == 1:
        ud = not(ud)
        ud_count += 1
    else:
        if (int(query[1])==1 and ud==False) or (int(query[1])==2 and ud==True):
            sub_s += query[2]
        else:
            s += query[2]
s = sub_s[::-1] + s
if ud_count%2:
    print(s[::-1])
else:
    print(s)
Buggy python 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)



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 python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
m = []
m_sum = 0
for i in range(n-k+1):
    p_sum = sum(p[i:i+k])
    if p_sum > m_sum:
        m_sum = p_sum
print((m_sum+k)/2)



Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
m = []
m_sum = 0
for i in range(n-k+1):
    if i == 0:
        p_sum = sum(p[:k])
    else:
        p_sum -= p[i-1]
        p_sum += p[i+k-1]
    if p_sum > m_sum:
        m_sum = p_sum
print((m_sum+k)/2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
new_s = input()
# new_s = ""
# for i in range(len(s)):
#    if i<3:
#        new_s+=s[i]
#     else:
#         if s[i-1] == s[i] and s[i-2] == s[i]:
#             pass
#         else:
#             new_s+=s[i]
pas = -1
ans = 0
lens = len(new_s)
for i in range(1000):
    ott = 0
    pas = int(pas)+1
    if pas < 10:
        pas = "00"+str(pas)
    elif pas < 100:
        pas = "0"+str(pas)
    pas = str(pas)
    idx = -1
    while idx < lens-1:
        idx += 1
        if ott == 0:
            if pas[0] == new_s[idx]:
                ott += 1
        elif ott == 1:
            if pas[1] == new_s[idx]:
                ott += 1
        elif ott == 2:
            if pas[2] == new_s[idx]:
                ott += 1
                ans += 1
        if ott == 3:
            break
print(ans)



Fixed submission:
n = int(input())
new_s = input()
pas = -1

ans = 0
lens = len(new_s)
for i in range(1000):
    ott = 0
    pas = int(pas)+1
    if pas < 10:
        pas = "00"+str(pas)
    elif pas < 100:
        pas = "0"+str(pas)
    pas = str(pas)
    idx = -1
    while idx < lens-1:
        idx += 1
        if ott == 0:
            if pas[0] == new_s[idx]:
                ott += 1
        elif ott == 1:
            if pas[1] == new_s[idx]:
                ott += 1
        elif ott == 2:
            if pas[2] == new_s[idx]:
                ott += 1
                ans += 1
        if ott == 3:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
new_s = input()
# new_s = ""
# for i in range(len(s)):
#    if i<3:
#        new_s+=s[i]
#     else:
#         if s[i-1] == s[i] and s[i-2] == s[i]:
#             pass
#         else:
#             new_s+=s[i]
pas = -1
ans = 0
for i in range(1000):
    ott = 0
    pas = int(pas)+1
    if pas < 10:
        pas = "00"+str(pas)
    elif pas < 100:
        pas = "0"+str(pas)
    pas = str(pas)
    idx = -1
    while idx < len(new_s)-1:
        idx += 1
        if ott == 0:
            if pas[0] == new_s[idx]:
                ott += 1
        elif ott == 1:
            if pas[1] == new_s[idx]:
                ott += 1
        elif ott == 2:
            if pas[2] == new_s[idx]:
                ott += 1
                ans += 1
        if ott == 3:
            break
print(ans)



Fixed submission:
n = int(input())
new_s = input()
pas = -1

ans = 0
lens = len(new_s)
for i in range(1000):
    ott = 0
    pas = int(pas)+1
    if pas < 10:
        pas = "00"+str(pas)
    elif pas < 100:
        pas = "0"+str(pas)
    pas = str(pas)
    idx = -1
    while idx < lens-1:
        idx += 1
        if ott == 0:
            if pas[0] == new_s[idx]:
                ott += 1
        elif ott == 1:
            if pas[1] == new_s[idx]:
                ott += 1
        elif ott == 2:
            if pas[2] == new_s[idx]:
                ott += 1
                ans += 1
        if ott == 3:
            break
print(ans)
Buggy python 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)


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 python 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)


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 python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
jyunban = []
for i in range(n):
    jyunban.append(a.index(i+1)+1)
for i in range(n):
    print(jyunban[i], end = " ")

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
jyunban = [0 for i in range(n)]
for i in range(n):
    jyunban[a[i]-1] += i+1
for i in range(n):
    print(jyunban[i], end = " ")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    max_idx = a.index(max(a))
    a[max_idx] = a[max_idx] // 2
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*-1, a))
heapq.heapify(a)
for i in range(m):
    tar = heapq.heappop(a)
    ins = ((tar*-1) // 2)*-1
    heapq.heappush(a, ins)
a = list(map(lambda x: x*-1, a))
print(sum(a))
Buggy python 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))

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 python 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)

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 python 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)

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 python 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)


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 python 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)

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 python 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)

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 python 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)

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 python 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)

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 python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
table = []
for i in range(m):
    nest_table = []
    l, r = map(int, input().split())
    nest_table.append(l)
    nest_table.append(r)
    table.append(nest_table)

ans = 0 
for j in range(n):
    for k in range(m):
        frag = 0
        if j+1 >= table[k][0] and j+1 <= table[k][1]:
            pass
        else:
            frag += 1
            break
    if frag == 0:
        ans += 1
print(ans)   

Fixed submission:
n, m = map(int, input().split())
lower = 1
upper = 100000
for i in range(m):
    l, r = map(int, input().split())
    if l >= lower:
        lower = l
    if r <= upper:
        upper = r
        
if lower > upper:
    print(0)
else:    
    if n < upper:
        upper = n
    print(upper - lower + 1)
Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
r_num = n // r
g_num = n // g
b_num = n // b
count = 0
for i in range(r_num+1):
    r_remain = n - r * i
    if r_remain == 0:
        count += 1
    else:
        for j in range(g_num+1):
            g_remain = r_remain - g * j
            if g_remain == 0:
                count += 1
            elif g_remain > 0:
                if g_remain % b == 0:
                    count += 1
print(count)

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

Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
r_num = n // r
g_num = n // g
b_num = n // b
count = 0
for i in range(r_num+1):
    r_r_remain = n - r * i
    if r_r_remain == 0:
        count += 1
    else:
        for j in range(g_num+1):
            r_g_remain = r_r_remain - g * j
            if r_g_remain >= 0:
                if r_g_remain == 0:
                    count += 1
                else:
                    if r_g_remain % b == 0:
                        count += 1
print(count)

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

Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
r_num = n // r
g_num = n // g
b_num = n // b
count = 0
for i in range(r_num+1):
    r_r_remain = n - r * i
    if r_r_remain == 0:
        count += 1
    else:
        for j in range(g_num+1):
            r_g_remain = r_r_remain - g * j
            if r_g_remain == 0:
                count += 1
            else:
                for k in range(b_num+1):
                    if r_g_remain - b * k == 0:
                        count += 1
print(count)

Fixed submission:
r, g, b, n = map(int, input().split())
count = 0
for i in range(0, n+1, r):
    rem = n-i
    for j in range(0, rem+1, g):
        if (rem-j)%b==0:
            count += 1
print(count)
Buggy python 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)) 

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 python 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)) 

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 python 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))

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 python 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))

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 python 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))

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 python 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))  

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 python 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)

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 python 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)

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 python 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)

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 python submission (verdict: Runtime Error):
n, k = map(int, input())
if n%k:
    print(0)
else:
    print(1)


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