Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

pr = make_divisors(sum(a))
pr = sorted(list(set(pr)), reverse = True)
def sol(p):
    mo = []
    pl = []
    for i in a:
        if i%p != 0:
            mo += [i%p]
            pl += [p-i%p]
    mo.sort(); pl.sort()
    m = 0; c = sum(pl)
    ln = len(mo)
    for i in range(ln):
        m += mo[i]
        c -= pl[ln-i-1]
        if max(m,c) <= k and m == c:
            return True
    return False
for p in pr:
    if sol(p):
        res = p
        break
print(res)



Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse = True)
    return divisors
pr = make_divisors(sum(a))
def sol(p):
    mo = []
    pl = []
    for i in a:
        if i%p != 0:
            mo += [i%p]
            pl += [p-i%p]
    mo.sort(); pl.sort()
    m = 0; c = sum(pl)
    ln = len(mo)
    for i in range(ln):
        m += mo[i]
        c -= pl[ln-i-1]
        if max(m,c) <= k and m == c:
            return True
    return False
for p in pr:
    if sol(p):
        res = p
        break
else:
    res = 1
print(res)
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

#素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

s = inp()
fa = prime_factorize(s)
h = 1
# print(fa)
n = len(fa)
if n >= 4:
    for i in range(n//4):
        # print(i,fa[i])
        h *= fa[i]
    for i in range(n-1,n-n//4-1,-1):
        # print(i,fa[i])
        h *= fa[i]
else:
    h = fa[-1] 
w = s//h

print(0,0,w,0,0,h)






Fixed submission:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = inp()
y3 = math.ceil(s/(10**9))
x3 = 10**9*y3 - s
print(0,0,10**9,1,x3,y3)

Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

#素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

s = inp()
fa = prime_factorize(s)
h = 1
print(fa)
n = len(fa)
if n >= 4:
    for i in range(n//4):
        # print(i,fa[i])
        h *= fa[i]
    for i in range(n-1,n-n//4-1,-1):
        # print(i,fa[i])
        h *= fa[i]
else:
    h = fa[-1] 
w = s//h

print(0,0,w,0,0,h)






Fixed submission:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = inp()
y3 = math.ceil(s/(10**9))
x3 = 10**9*y3 - s
print(0,0,10**9,1,x3,y3)
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpln(n)[::-1]
q = deque([])

for i,j in enumerate(a):
  if i == 0:
    q.append(j)
    continue
  c = bisect.bisect_left(q,j)
  if c == 0:
    q.appendleft(j)
  else:
    q[c] = j
    
print(len(q))
  


Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpln(n)
q = deque([])

for i,j in enumerate(a):
  if i == 0:
    q.append(j)
    continue
  c = bisect.bisect_left(q,j)
  if c == 0:
    q.appendleft(j)
  else:
    q[c-1] = j
    
print(len(q))
Buggy python submission (verdict: Runtime Error):
from math import factorial as fa
n,k = map(int,input().split())
for i in range(1,k+1):
    r_tmp = fa(n-k+1) / (fa(i) * fa(n-k+1-i))
    b_tmp = fa(k-1) / (fa(i-1) * fa(k-i))
    print(int(r_tmp * b_tmp) % (10**9+7))

Fixed submission:
from math import factorial as fa
def con(a,b):
    if a < b:
        return 0
    elif a < 0:
        return 1
    else:
        return int(fa(a)) // int(fa(b) * fa(a-b))
    
n,k = map(int,input().split())
for i in range(1,k+1):
    r_tmp = con(n-k+1,i)
    b_tmp = con(k-1,i-1)
    if r_tmp:
        print((r_tmp * b_tmp) % (10**9+7))
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
import sys,math
W,H,x,y = map(int,input().split())
if W % x == 0 and H % y == 0 and H!=y and W!=x and H!=0 and W!=0:
    print(W*H/2,'1')
else:
    print(W*H/2,'0')


Fixed submission:
import sys,math
W,H,x,y = map(int,input().split())
if W/2 == x and H/2 == y:
    print(W*H/2,'1')
else:
    print(W*H/2,'0')

Buggy python submission (verdict: Runtime Error):
import sys,math
W,H,x,y = map(int,input().split())
if W % x == 0 and H % y == 0:
    print(W*H/2,1)
else :
    print(W*H/2,0)

Fixed submission:
import sys,math
W,H,x,y = map(int,input().split())
if W/2 == x and H/2 == y:
    print(W*H/2,'1')
else:
    print(W*H/2,'0')
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = [inpl() for _ in range(n)]
c = []
for i,(x,y) in enumerate(a):
    for j,(z,w) in enumerate(a):
        if i == j: continue
        c.append(((x-z), (y-w)))
h = Counter(c)
print(n-max(h.values()))


Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = [inpl() for i in range(n)]
a.sort(key=lambda x:x[1])
a.sort()
z = []
# pprint.pprint(a)
for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        z.append((a[i][0]-a[j][0], a[i][1]-a[j][1]))
c = Counter(z)
# pprint.pprint(c)
if n == 1:
    print(1)
else:
    print(n-c.most_common()[0][1])
# print(n-c.most_common()[0][1])

Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = [inpl() for i in range(n)]
a.sort(key=lambda x:x[1])
a.sort()
z = []
# pprint.pprint(a)
for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        z.append((a[i][0]-a[j][0], a[i][1]-a[j][1]))
c = Counter(z)
# pprint.pprint(c)
print(n-c.most_common()[0][1])



Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = [inpl() for i in range(n)]
a.sort(key=lambda x:x[1])
a.sort()
z = []
# pprint.pprint(a)
for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        z.append((a[i][0]-a[j][0], a[i][1]-a[j][1]))
c = Counter(z)
# pprint.pprint(c)
if n == 1:
    print(1)
else:
    print(n-c.most_common()[0][1])
# print(n-c.most_common()[0][1])
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = input()
def chk(i):
    if s[i] == s[i+1] == '#':
        print('No')
        quit()
    return True
def cc(i):
    if s[i] == s[i+1] == s[i+2] == '.':
        return True
    return False

if c < d:
    for i in range(b-1,d-1):
        chk(i)
    for i in range(a-1,c-1):
        chk(i)
else:
    for i in range(b-1,d):
        if cc(i):
            break
    else:
        print('No')
        quit()
    for i in range(a-1,c-1):
        chk(i)
print('Yes')

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = input()
def chk(i):
    if s[i] == s[i+1] == '#':
        print('No')
        quit()
    return True
def cc(i):
    if s[i] == s[i+1] == s[i+2] == '.':
        return True
    return False

if c < d:
    for i in range(b-1,d-1):
        chk(i)
    for i in range(a-1,c-1):
        chk(i)
else:
    for i in range(b-2,d-1):
        if cc(i):
            break
    else:
        print('No')
        quit()
    for i in range(a-1,c-1):
        chk(i)
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
res = 0
for ope in range(k+1):
    for pick in range(ope+1):
        if pick > n: continue
        for back in range(ope - pick + 1):
            for lp in range(pick+1):
                rp = pick - lp
                # print(ope,back,lp,rp)
                q = []
                for i in range(lp):
                    q.append(a[i])
                for i in range(rp):
                    q.append(a[-i-1])
                q.sort()
                q = deque(q)
                for i in range(back):
                    if not q: break
                    q.popleft()
                res = max(res, sum(q))
print(res)

Fixed submission:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
v = inpl()
m = min(n,k)
ans = 0
for a in range(m+1):
    for b in range(m+1):
        if a+b > m:
            continue
        q = deque(v)
        tmp = []
        for i in range(a):
            tmp.append(q.popleft())
        for j in range(b):
            tmp.append(q.pop())
        if k - (a + b) > 0:
            tmp.sort()
            for i in range(k-(a+b)):
                if not tmp:
                    break
                if tmp[0] < 0:
                    tmp.pop(0)
                else:
                    break
        ans = max(ans, sum(tmp))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n,m = map(int,input().split())
r = []
ans = 0
for i in range(m):
    ll,rr = map(int,input().split())
    for j in range(ll-1,rr):
        r.append(j)
cnt = collections.Counter(r)
for i in cnt.values():
    if i == m:
        ans += 1
print(ans)

Fixed submission:
import collections
n,m = map(int,input().split())
r = []
l = []
for i in range(m):
    ll,rr = map(int,input().split())
    r.append(rr)
    l.append(ll)
ans = min(r) - max(l) +1
if ans > 0:
    print(ans)
else :
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
r = []
ans = [True] * n
for i in range(m):
    ll,rr = map(int,input().split())
    a = set()
    for j in range(ll-1,rr):
        a.add(j)
    r.append(a)
for i in range(n):
    for j in range(m):
        if not i in r[j]:
            ans[i] = False
print(ans.count(True))


Fixed submission:
import collections
n,m = map(int,input().split())
r = []
l = []
for i in range(m):
    ll,rr = map(int,input().split())
    r.append(rr)
    l.append(ll)
ans = min(r) - max(l) +1
if ans > 0:
    print(ans)
else :
    print(0)
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl()
a.sort()
bc = [inpl() for _ in range(m)]
bc.sort(key=lambda x:x[1], reverse = True)
ind = -1
now = -1
cnt = 0
for i in range(n):
    if cnt == 0:
        ind += 1
        cnt, now = bc[ind]
    if a[i] >= now:
        break
    a[i] = now
    cnt -= 1
print(sum(a))

Fixed submission:
from collections import Counter,defaultdict
import sys,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n,m = inpl()
a = inpl()
sum_a = sum(a)
bc = []
for i in range(m):
    b,c = inpl()
    bc.append([b,c])
a.sort()
bc.sort(key=lambda x:x[1],reverse=True)

start = 0
flag = True
for i,q in enumerate(bc):
    end = start+q[0]
    if end >= n:
        flag = False
        end = n
    for j in range(start,end):
        if a[j] < q[1]:
            a[j] = q[1]
        else:
            flag = False
            break
    start += q[0]
    if not flag:
        break
print(sum(a))
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def dfs(x):
    for p in g[x]:
        # print(p[0])
        if color[p[0]] != -1:
            continue
        if p[1] % 2: #odd
            if color[x]: #pre=white
                color[p[0]] = 0
            else:
                color[p[0]] = 1
        else:
            if color[x]: #pre=white
                color[p[0]] = 1
            else:
                color[p[0]] = 0
        dfs(p[0])
n = inp()
g = [[] for i in range(n)]
#0:黒 1:白 -1:未訪問
color = [-1] * n

for i in range(n-1):
    u,v,w = inpl()
    g[u-1].append([v-1,w])
    g[v-1].append([u-1,w])
# print(g)
color[0] = 0
dfs(0)
for i in range(1,n):
    if color[i] != -1:
        continue
    dfs(i)
for i in range(n):
    print(color[i])

Fixed submission:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def dfs(x):
    for p in g[x]:
        # print(p[0])
        if color[p[0]] != -1:
            continue
        if p[1] % 2: #odd
            if color[x]: #pre=white
                color[p[0]] = 0
            else:
                color[p[0]] = 1
        else:
            if color[x]: #pre=white
                color[p[0]] = 1
            else:
                color[p[0]] = 0
        dfs(p[0])
n = inp()
g = [[] for i in range(n)]
#0:黒 1:白 -1:未訪問
color = [-1] * n

for i in range(n-1):
    u,v,w = inpl()
    g[u-1].append([v-1,w])
    g[v-1].append([u-1,w])
# print(g)
color[0] = 0
dfs(0)
for i in range(1,n):
    if color[i] != -1:
        continue
    dfs(i)
for i in range(n):
    print(color[i])
Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
if n == 1:
    print(0)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors
m = make_divisors(n)
res = m[:len(m)//2]
if n //(res[-1]-1) != n % (res[-1]-1):
    res[-1] = 1
print(sum(res) - len(res))

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
if n == 1:
    print(0)
    quit()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors
m = make_divisors(n)
res = m[:len(m)//2]
if n //(res[-1]-1) != n % (res[-1]-1):
    res[-1] = 1
print(sum(res) - len(res))

Buggy python submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors
m = make_divisors(n)
res = m[:len(m)//2]
if n //(res[-1]-1) != n % (res[-1]-1):
    res[-1] = 1
print(sum(res) - len(res))

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
if n == 1:
    print(0)
    quit()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors
m = make_divisors(n)
res = m[:len(m)//2]
if n //(res[-1]-1) != n % (res[-1]-1):
    res[-1] = 1
print(sum(res) - len(res))
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
S = input()
s_list = list(S)
temp_start = N+1
count_1 = 0
count_2 = 0
for i in range(N-1):
    if s_list[i] == "#":
        temp_start = i
        break
if temp_start == N+1:
    print(0)
    sys.exit()
for i in range(N)[::-1]:
    if s_list[i] != "#":
        temp_end = i
        break
for i in range(temp_start,temp_end + 1):
    if s_list[i] == "#":
        count_1 += 1
    else :
        count_2 += 1
print(min(count_1,count_2))

Fixed submission:
import fractions,math,sys
from collections import Counter
n = int(input())
s = list(input())
cnt = Counter(s)
white_l = 0
black_l = 0
min = cnt['.']
for i in range(n):
    if s[i] == '#':
        black_l += 1
        cnt['#'] -= 1
    else:
        white_l += 1
        cnt['.'] -= 1
    if black_l + cnt['.'] < min:
        min = black_l + cnt['.']
print(min)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
s_list = list(S)
count_1 = 0
count_2 = 0
for i in range(N-1):
    if s_list[i] == "#" and s_list[i+1] == ".":
        temp_start = i
        break

for i in range(N)[::-1]:
    if s_list[i] != "#":
        temp_end = i
        break

for i in range(temp_start,temp_end + 1):
    if s_list[i] == "#":
        count_1 += 1
    else :
        count_2 += 1
print(min(count_1,count_2))

Fixed submission:
import fractions,math,sys
from collections import Counter
n = int(input())
s = list(input())
cnt = Counter(s)
white_l = 0
black_l = 0
min = cnt['.']
for i in range(n):
    if s[i] == '#':
        black_l += 1
        cnt['#'] -= 1
    else:
        white_l += 1
        cnt['.'] -= 1
    if black_l + cnt['.'] < min:
        min = black_l + cnt['.']
print(min)