Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import copy
n,m = map(int,input().split())
ht = [x for x in input().split()]
hl = {x + 1 : int(ht[x]) for x in range(len(ht))}
mx = {h:0 for h in hl}
for i in range(m):
    l,r = map(int,input().split())
    mx[l] = max(mx[l],hl[r])
    mx[r] = max(mx[r],hl[l])
cnt = 0
for h in hl:
    if mx[h] < hl[h]:
        cnt += 1
print(cnt)

Fixed submission:
s = input()
ret = ""
if s=="ARC":
    ret = "ABC"
elif s=="ABC":
    ret = "ARC"
print(ret)
Buggy python submission (verdict: Runtime Error):
import copy
n,m = map(int,input().split())
ht = [x for x in input().split()]
hl = {ht.index(x) + 1 : int(x) for x in ht}
p = []
for i in range(m):
    p.append([int(x) for x in input().split()])
hl2 = copy.copy(hl)
p2 = copy.copy(p)
g = []
for h in hl:
    if not (h in hl2):
        continue
    c = False
    for pt in p2:
        if not (h in pt):
            continue
        gp = copy.copy(pt)
        l = gp.pop(pt.index(h))
        lh = hl[l]
        r = gp.pop()
        rh = hl[r]
        if lh <= rh:
            c = True
            break
        if r in hl2:
            hl2.pop(r)
    if not c:
        g.append(h)
print(len(g))

Fixed submission:
import copy
n,m = map(int,input().split())
ht = [x for x in input().split()]
hl = {x + 1 : int(ht[x]) for x in range(len(ht))}
mx = {h:0 for h in hl}
for i in range(m):
    l,r = map(int,input().split())
    mx[l] = max(mx[l],hl[r])
    mx[r] = max(mx[r],hl[l])
cnt = 0
for h in hl:
    if mx[h] < hl[h]:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n,m = map(int,input().split())
h = [int(x) for x in input().split()]
p = []
for i in range(m):
    p.append([int(x) for x in input().split()])
h2 = copy.copy(h)
p2 = copy.copy(p)
g = []
for i in range(len(h)):
    j = i + 1
    c = False
    for pt in p2:
        if not (j in pt):
            continue
        gp = copy.copy(pt)
        lh = h[gp.pop(pt.index(j)) - 1]
        rh = h[gp.pop() - 1]
        if lh <= rh:
            c = True
            break
    if not c:
        g.append(j)
print(len(g))

Fixed submission:
import copy
n,m = map(int,input().split())
ht = [x for x in input().split()]
hl = {x + 1 : int(ht[x]) for x in range(len(ht))}
mx = {h:0 for h in hl}
for i in range(m):
    l,r = map(int,input().split())
    mx[l] = max(mx[l],hl[r])
    mx[r] = max(mx[r],hl[l])
cnt = 0
for h in hl:
    if mx[h] < hl[h]:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
c = 0
for i in range(n):
    for j in range(i - 1):
        if i - j == a[i] + a[j]:
            c += 1
print(c)


Fixed submission:
n = int(input())
l = {}
r = {}
xc = 0
for x in input().split():
    xi = int(x)
    lx = xc + xi
    if lx in l:
        l[lx] += 1
    else:
        l[lx] = 1
    rx = xc - xi
    if rx in r:
        r[rx] += 1
    else:
        r[rx] = 1
    xc += 1
c = 0
for x in l:
    if x in r:
        c += l[x] * r[x]
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]
c = 0
for i in range(n):
    for j in range(i - 1):
        if i - j == abs(a[i] + a[j]):
            c += 1
print(c)


Fixed submission:
n = int(input())
l = {}
r = {}
xc = 0
for x in input().split():
    xi = int(x)
    lx = xc + xi
    if lx in l:
        l[lx] += 1
    else:
        l[lx] = 1
    rx = xc - xi
    if rx in r:
        r[rx] += 1
    else:
        r[rx] = 1
    xc += 1
c = 0
for x in l:
    if x in r:
        c += l[x] * r[x]
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(n) for n in input().split()]

for n in range(0, N):
    cnt = 0
    i = 0
    for a in A[i:]:
        i = i + 1
        if n + 1 == a:
            cnt = cnt + 1
        elif n + 1 < a:
            break
    print(A.count(n + 1))

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

d = defaultdict(int)
for i in A:
    d[i-1] += 1
for n in range(N):
    print(d[n])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(n) for n in input().split()]

for n in range(0, N):
    print(A.count(n + 1))

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

d = defaultdict(int)
for i in A:
    d[i-1] += 1
for n in range(N):
    print(d[n])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(n) for n in input().split()]

for n in range(0, N):
    cnt = 0
    for a in A:
        if n + 1 == a:
            cnt = cnt + 1
    print(cnt)

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

d = defaultdict(int)
for i in A:
    d[i-1] += 1
for n in range(N):
    print(d[n])
Buggy python submission (verdict: Runtime Error):
# 入力N:3桁の整数
N = input()
print("Yes" if str(N).index("7") != -1 else "No")

Fixed submission:
# 入力N:3桁の整数
N = input()
print("Yes" if str(N).count("7") != 0 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
#import itertools
N = int(input())
S = input()
ans = 0
#cnt = 0

for i in range(0, N):
    for j in range(i+1, N-1):
        if S[i] == S[j]:
            continue
        for k in range(j+1, N):
            #cnt += 1
            if j - i == k - j:
                continue
            if S[i] == S[j] or S[i] == S[k] or S[j] == S[k]:
                continue
            ans += 1
            #print(f"i={i},j={j},k={k}")
#print(cnt)
print(ans)


Fixed submission:
N = int(input())
S = input()
total = S.count('R') * S.count('G') * S.count('B')
cnt = 0

for i in range(0, N-2):
    for j in range(i+1, N-1):
        if S[i] == S[j]:
            continue
        k = 2 * j - i
        if k > N - 1:
            break
        if S[i] == S[k] or S[j] == S[k]:
            continue
        cnt += 1
print(total - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
#import itertools
N = int(input())
S = input()
ans = 0

for i in range(0, N):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if j - i == k - j:
                continue
            if S[i] == S[j] or S[i] == S[k] or S[j] == S[k]:
                continue
            ans += 1
            #print(f"i={i},j={j},k={k}")
print(ans)

Fixed submission:
N = int(input())
S = input()
total = S.count('R') * S.count('G') * S.count('B')
cnt = 0

for i in range(0, N-2):
    for j in range(i+1, N-1):
        if S[i] == S[j]:
            continue
        k = 2 * j - i
        if k > N - 1:
            break
        if S[i] == S[k] or S[j] == S[k]:
            continue
        cnt += 1
print(total - cnt)
Buggy python submission (verdict: Runtime Error):
X = input().split(" ")
print(f"{X[2]} {X[0]} {X[1]}")

Fixed submission:
a, b, c = input().split()
print(c, a, b)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
while True:
    c-=b
    if c<=0:
		print('Yes')
		break
    a-=d
    if a<=0:
		print('No')
		break

Fixed submission:
a,b,c,d=map(int,input().split())
x=(a+d-1)//d
y=(c+b-1)//b
if x>=y:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d=map(int,input().split())
while True:
    c-b
    if c<=0:
        print('Yes')
        break
    a-d
    if a<=0:
        print('No')
        break


Fixed submission:
a,b,c,d=map(int,input().split())
x=(a+d-1)//d
y=(c+b-1)//b
if x>=y:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d=map(int,input().split())
while True:
    c-b
    if c<=0:
        print('Yes')
        break
    a-d
    if a<=0:
        print('No')
        break


Fixed submission:
a,b,c,d=map(int,input().split())
x=(a+d-1)//d
y=(c+b-1)//b
if x>=y:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
S,T=input().split
print(T+S)

Fixed submission:
S,T=input().split()
print(T+S)

Buggy python submission (verdict: Runtime Error):
S,T=input()
print(T+S)

Fixed submission:
S,T=input().split()
print(T+S)
Buggy python submission (verdict: Runtime Error):
r=int(input())
if r<1200:
    print('ABC')
elif　r<2800:
    print('ARC')
else:
    print('AGC')


Fixed submission:
r=int(input())
if r<1200:
    print('ABC')
elif r<2800:
    print('ARC')
else:
    print('AGC')

Buggy python submission (verdict: Runtime Error):
r=int(input())
if r<1200:
  print('ABC')
elif　r<2800:
  print('ARC')
else:
  print('AGC')


Fixed submission:
r=int(input())
if r<1200:
    print('ABC')
elif r<2800:
    print('ARC')
else:
    print('AGC')

Buggy python submission (verdict: Runtime Error):
r=int(input())
if r<1200:
  print('ABC')
elif　1200<=r<2800:
  print('ARC')
else:
  print('AGC')

Fixed submission:
r=int(input())
if r<1200:
    print('ABC')
elif r<2800:
    print('ARC')
else:
    print('AGC')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a+b==15:
    print('+')
elif a*b=15:
    print('*')
else:
    print('x')

Fixed submission:
a,b=map(int,input().split())
if a+b==15:
    print('+')
elif a*b==15:
    print('*')
else:
    print('x')

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a+b=15:
    print('+')
elif a*b=15:
    print('*')
else:
    print('x')


Fixed submission:
a,b=map(int,input().split())
if a+b==15:
    print('+')
elif a*b==15:
    print('*')
else:
    print('x')

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input()split())
if a+b=15:
    print('+')
elif a*b=15:
    print('*')
else:
    print('x')

Fixed submission:
a,b=map(int,input().split())
if a+b==15:
    print('+')
elif a*b==15:
    print('*')
else:
    print('x')
Buggy python submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
y=abs(x-a)
z=abs(b-x)
    if y<z:
        print('A')
    else:
        print('B')


Fixed submission:
x,a,b=map(int,input().split())
y=abs(x-a)
z=abs(b-x)
if y<z:
    print('A')
else:
    print('B')

Buggy python submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
    if abs(x-a)<abs(b-x):
        print('A')
    else:
        print('B')


Fixed submission:
x,a,b=map(int,input().split())
y=abs(x-a)
z=abs(b-x)
if y<z:
    print('A')
else:
    print('B')
Buggy python submission (verdict: Runtime Error):
a,b,h=map(int,input())
print((a+b)*h//2)


Fixed submission:
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)

Buggy python submission (verdict: Runtime Error):
a,b,h=map(int,input().split())
print((a+b)*h//2)


Fixed submission:
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n > 10:
    print(n)
else:
    R = 100*(10 - n)
    print(R)

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

if a >= 10:
    print(b)
else:
    print(b + 100*(10 - a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
m = int(input())

if n == m:
  print("Yes")
else:
  print("No")

Fixed submission:
N,M = map(int, input().split())

if N == M:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = input()
m = input()

if n == m:
  print("Yes")
else:
  print("No")

Fixed submission:
N,M = map(int, input().split())

if N == M:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
C = input()

print(chr(ord(C)+1)

Fixed submission:
C = input()

print(chr(ord(C)+1))

Buggy python submission (verdict: Runtime Error):
C = input()

print(chr(ord(C)+1)

Fixed submission:
C = input()

print(chr(ord(C)+1))
Buggy python submission (verdict: Runtime Error):
s = input()
res = 0
for i in range(len(s)//2):
	if s[i] != s[len(s)-1-i]:
    	res += 1
print(res)

Fixed submission:
s = input()
res = 0
for i in range(len(s) // 2):
    if s[i] != s[len(s)-1-i]:
        res += 1
print(res)

Buggy python submission (verdict: Runtime Error):
s = input()
res = 0
for i in range(len(s)//2):
	if s[i] != s[len(s)-1-i]:
        res += 1
print(res)

Fixed submission:
s = input()
res = 0
for i in range(len(s) // 2):
    if s[i] != s[len(s)-1-i]:
        res += 1
print(res)

Buggy python submission (verdict: Runtime Error):
s = input()
res = 0
for i in range(len(s)//2):
	if s[i] != s[len(s)-1-i]:
    	res += 1
print(res)

Fixed submission:
s = input()
res = 0
for i in range(len(s) // 2):
    if s[i] != s[len(s)-1-i]:
        res += 1
print(res)
Buggy python submission (verdict: Runtime Error):
kkk

Fixed submission:
print(int(input()) ** 2)

Buggy python submission (verdict: Runtime Error):
hhh

Fixed submission:
print(int(input()) ** 2)

Buggy python submission (verdict: Runtime Error):
print(int(input() ** 2)

Fixed submission:
print(int(input()) ** 2)
Buggy python submission (verdict: Runtime Error):
aaaaaaaaaaaaaaaaaaaa

Fixed submission:
n = int(input())
s = input()
h = n // 2
if s[:h] == s[h:]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = 1
res = n
while x * x <= n:
  if n % x == 0:
    res = min(res, x + n // x)
print(res)

Fixed submission:
n = int(input())
i = 1
res = n
while i * i <= n:
  if n % i == 0:
    res = min(res, i + n//i - 2)
  i += 1
print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
int x = 1
res = n
while x * x <= n:
  if n % x == 0:
    res = min(res, x + n // x)
print(res)

Fixed submission:
n = int(input())
i = 1
res = n
while i * i <= n:
  if n % i == 0:
    res = min(res, i + n//i - 2)
  i += 1
print(res)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max(0, a - 2 * b)

Fixed submission:
a, b = map(int, input().split())
print(max(0, a - 2 * b))
Buggy python submission (verdict: Time Limit Exceeded):
def lower_bound(a, x):
  l = -1
  r = len(a)
  while r - l > 1:
    h = (l + r) // 2
    if a[h] < x:
      r = h
    else:
      l = h
  return l
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
res = 0
for i in range(n):
  for j in range(i+1, n):
    lb = lower_bound(l[j+1:], l[i]-l[j]+1)
    res += lb + 1
print(res)

Fixed submission:
def lower_bound(a, x):
  l = -1
  r = len(a)
  while r - l > 1:
    h = (l + r) // 2
    if a[h] < x:
      r = h
    else:
      l = h
  return l
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
res = 0
for i in range(n):
  for j in range(i+1, n):
    lb = lower_bound(l[j+1:], l[i]-l[j]+1)
    res += lb + 1
print(res)
Buggy python submission (verdict: Runtime Error):
n = int(inpuit())
print((n // 2) / n)

Fixed submission:
n = int(input())
print(((n + 1) // 2) / n)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))
print(len(filter(lambda x: x >= k, h)))


Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
print(len(list(filter(lambda x: x >= k, h))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = sum(b)
for i in range(len(a) - 1):
  if a[i+1] == a[i] + 1:
    res += c[a[i]]
print(res)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = sum(b)
for i in range(len(a) - 1):
  if a[i+1] == a[i] + 1:
    res += c[a[i] - 1]
print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = sum(b)
for i in range(len(a) - 1):
  if a[i+1] = a[i] + 1:
    res += c[i]
print(res)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = sum(b)
for i in range(len(a) - 1):
  if a[i+1] == a[i] + 1:
    res += c[a[i] - 1]
print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = sum(b)
for i in len(range(a)) - 1:
  if a[i+1] = a[i] + 1:
    res += c[i]
print(res)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
res = sum(b)
for i in range(len(a) - 1):
  if a[i+1] == a[i] + 1:
    res += c[a[i] - 1]
print(res)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
l = s.count('L')
r = s.count('R')
now = 0
for i in range(len(s)-1):
  if s[i] == 'R' and s[i+1] == 'L':
    now += 1
print(min(now + K, min(l, r)))

Fixed submission:
n, k = map(int, input().split())
s = input()
grp = 0
now = ""
for c in s:
  if c != now:
    grp += 1
    now = c
hap = 0
for i in range(n):
  if (i>0 and s[i]=='L' and s[i-1]=='L') or (i<n-1 and s[i]=='R' and s[i+1]=='R'):
    hap += 1
p_2 = (grp - 1) // 2
p_1 = (grp + 1) % 2
print(hap + 2 * min(k, p_2) + int(k > p_2) * p_1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
k = int(input())
s = input()
l = s.count('L')
r = s.count('R')
now = 0
for i in range(len(s)-1):
  if s[i] == 'R' and s[i+1] == 'L':
    now += 1
print(min(now + K, min(l, r)))

Fixed submission:
n, k = map(int, input().split())
s = input()
grp = 0
now = ""
for c in s:
  if c != now:
    grp += 1
    now = c
hap = 0
for i in range(n):
  if (i>0 and s[i]=='L' and s[i-1]=='L') or (i<n-1 and s[i]=='R' and s[i+1]=='R'):
    hap += 1
p_2 = (grp - 1) // 2
p_1 = (grp + 1) % 2
print(hap + 2 * min(k, p_2) + int(k > p_2) * p_1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
k = int(input())
s = input()
l = s.count('L')
r = s.count('R')
now = 0
for i in range(len(s)-1):
  if s[i] == 'R' and s[i+1] == 'L':
    res += 1
print(min(now + K, min(l, r)))

Fixed submission:
n, k = map(int, input().split())
s = input()
grp = 0
now = ""
for c in s:
  if c != now:
    grp += 1
    now = c
hap = 0
for i in range(n):
  if (i>0 and s[i]=='L' and s[i-1]=='L') or (i<n-1 and s[i]=='R' and s[i+1]=='R'):
    hap += 1
p_2 = (grp - 1) // 2
p_1 = (grp + 1) % 2
print(hap + 2 * min(k, p_2) + int(k > p_2) * p_1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
k = int(input())
s = input()
l = s.count('L')
r = s.count('R')
now = 0
for i in range(len(s)):
  if s[i] == 'R' and s[i+1] == 'L':
    res += 1
print(min(now + K, min(l, r)))

Fixed submission:
n, k = map(int, input().split())
s = input()
grp = 0
now = ""
for c in s:
  if c != now:
    grp += 1
    now = c
hap = 0
for i in range(n):
  if (i>0 and s[i]=='L' and s[i-1]=='L') or (i<n-1 and s[i]=='R' and s[i+1]=='R'):
    hap += 1
p_2 = (grp - 1) // 2
p_1 = (grp + 1) % 2
print(hap + 2 * min(k, p_2) + int(k > p_2) * p_1)
Buggy python submission (verdict: Time Limit Exceeded):
print(sum(range(int(input()))))

Fixed submission:
n = int(input())
print(n * (n-1) // 2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [1 / int(input()) for _ in range(n)]
print(1 / sum(a))
  

Fixed submission:
n = int(input())
a = [1 / int(x) for x in input().split()]
print(1 / sum(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
res = 0
keta = 1
for i in range(1, n+1):
  if i % (10 ** keta) == 0:
    keta += 1
  if keta % 2 == 1:
    res += 1
print(res)

Fixed submission:
a, b, c = map(int, input().split())
print(max(0, c-(a-b)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt = dict()
xy = [tuple(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(1)
for x1, y1 in xy:
    for x2, y2 in xy:
        if x1 == x2 and y1 == y2:
            continue
        dx = x1 - x2
        dy = y1 - y2
        if (dx, dy) not in cnt:
            cnt[(dx, dy)] = 1
        else:
            cnt[(dx,dy)] += 1
print(n - max(cnt.values()))


Fixed submission:
n = int(input())
cnt = dict()
xy = [tuple(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(1)
    exit()
for x1, y1 in xy:
    for x2, y2 in xy:
        if x1 == x2 and y1 == y2:
            continue
        dx = x1 - x2
        dy = y1 - y2
        if (dx, dy) not in cnt:
            cnt[(dx, dy)] = 1
        else:
            cnt[(dx,dy)] += 1
print(n - max(cnt.values()))

Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt = dict()
xy = [tuple(map(int, input().split())) for _ in range(n)]
for x1, y1 in xy:
    for x2, y2 in xy:
        if x1 == x2 and y1 == y2:
            continue
        dx = x1 - x2
        dy = y1 - y2
        if (dx, dy) not in cnt:
            cnt[(dx, dy)] = 1
        else:
            cnt[(dx,dy)] += 1
print(n - max(cnt.values()))


Fixed submission:
n = int(input())
cnt = dict()
xy = [tuple(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(1)
    exit()
for x1, y1 in xy:
    for x2, y2 in xy:
        if x1 == x2 and y1 == y2:
            continue
        dx = x1 - x2
        dy = y1 - y2
        if (dx, dy) not in cnt:
            cnt[(dx, dy)] = 1
        else:
            cnt[(dx,dy)] += 1
print(n - max(cnt.values()))
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
s = [input() for _ in range(h)]
hor = [[0] * w for _ in range(h)]
ver = [[0] * w for _ in range(h)]

for i in range(h):
    now = 0
    for j in range(w):
        if s[i][j] == '#':
            now = 0
        else:
            now += 1
            hor[i][j] = now

for j in range(w):
    now = 0
    for i in range(h):
        if s[i][j] == '#':
            now = 0
        else:
            now += 1
            ver[i][j] = now

for i in range(h-1, -1, -1):
    now = 0
    for j in range(w-1, -1, -1):
        if s[i][j] == '#':
            now = 0
        else:
            now = max(now, hor[i][j])
            hor[i][j] = now

for j in range(w-1, -1, -1):
    now = 0
    for i in range(h-1, -1, -1):
        if s[i][j] == '#':
            now = 0
        else:
            now = max(now, ver[i][j])
            ver[i][j] = now

res = 0
for i in range(h):
    for j in range(w):
        res = max(hor[i][j] + ver[i][j] - 1, res)
print(res)


Fixed submission:
h, w = map(int, input().split())
s = [input() for _ in range(h)]
hor = [[0] * w for _ in range(h)]
ver = [[0] * w for _ in range(h)]

for i in range(h):
    now = 0
    for j in range(w):
        if s[i][j] == '#':
            now = 0
        else:
            now += 1
            hor[i][j] = now

for j in range(w):
    now = 0
    for i in range(h):
        if s[i][j] == '#':
            now = 0
        else:
            now += 1
            ver[i][j] = now

for i in range(h-1, -1, -1):
    now = 0
    for j in range(w-1, -1, -1):
        if s[i][j] == '#':
            now = 0
        else:
            now = max(now, hor[i][j])
            hor[i][j] = now

for j in range(w-1, -1, -1):
    now = 0
    for i in range(h-1, -1, -1):
        if s[i][j] == '#':
            now = 0
        else:
            now = max(now, ver[i][j])
            ver[i][j] = now

res = 0
for i in range(h):
    for j in range(w):
        res = max(hor[i][j] + ver[i][j] - 1, res)
print(res)