Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
a = list(map(int,input().split()))
a = np.array(a,dtype=np.int64)
point = 0
mod = 10**9+7

b = [((a>>i)&1).sum() for i in range(61)]
c = [n-b[i] for i in range(61)]
d = [c[i]*b[i]%mod for i in range(61)]

point = 0
for i in range(61):
    point += (2**i)*d[i]%mod

point %= mod

print(point)

Fixed submission:
from sys import stdin
n,k = map(int,stdin.readline().rstrip().split())
li = list(map(int,stdin.readline().rstrip().split()))
nai = 0
ato = 0
point = 0
for i in range(n):
    for s in range(i+1,n):
        if li[i] > li[s]:
            nai += 1
    for v in range(n):
        if li[i] > li[v]:
            ato += 1
point += (nai*k)+(ato*k*(k-1)//2)
print(point%(10**9+7))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from math import factorial
n,k = map(int,stdin.readline().rstrip().split())
li = list(map(int,stdin.readline().rstrip().split()))
nai = 0
ato = 0
point = 0
for i in range(n):
    for s in range(i+1,n):
        if li[i] > li[s]:
            nai += 1
    for v in range(n):
        if li[i] > li[v]:
            ato += 1
def combinations_count(j,r):
    return factorial(j) // (factorial(j - r) * factorial(r))
point += (nai*k)+(ato*combinations_count(k,2))
print(point%(10**9+7))

Fixed submission:
from sys import stdin
n,k = map(int,stdin.readline().rstrip().split())
li = list(map(int,stdin.readline().rstrip().split()))
nai = 0
ato = 0
point = 0
for i in range(n):
    for s in range(i+1,n):
        if li[i] > li[s]:
            nai += 1
    for v in range(n):
        if li[i] > li[v]:
            ato += 1
point += (nai*k)+(ato*k*(k-1)//2)
print(point%(10**9+7))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from math import factorial
n,k = map(int,stdin.readline().rstrip().split())
li = list(map(int,stdin.readline().rstrip().split()))
li_to = li*2
nai = 0
ato = 0
for i in range(len(li)):
    for s in range(i+1,len(li)):
        if li[i] > li[s]:
            nai += 1
    for p in range(len(li),len(li_to)):
        if li[i] > li_to[p]:
            ato += 1
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
point = 0
point += (nai*k)+(ato*combinations_count(k,2))
print(point%(10**9+7))

Fixed submission:
from sys import stdin
n,k = map(int,stdin.readline().rstrip().split())
li = list(map(int,stdin.readline().rstrip().split()))
nai = 0
ato = 0
point = 0
for i in range(n):
    for s in range(i+1,n):
        if li[i] > li[s]:
            nai += 1
    for v in range(n):
        if li[i] > li[v]:
            ato += 1
point += (nai*k)+(ato*k*(k-1)//2)
print(point%(10**9+7))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rsprit())
s = stdin.readline().rstrip()

if n >= 3200:
    print(s)
else:
    print("red")

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

if n >= 3200:
    print(s)
else:
    print("red")
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rsprit())
li = list(map(int,stdin.readline().rstrip().split()))
s = 0
for i in range(n):
    s += 1/li[i]
print(1/s)

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
s = 0
for i in range(n):
    s += 1/li[i]
print(1/s)
Buggy python submission (verdict: Runtime Error):
import heapq
from sys import stdin

n,m = map(int,stdin.readline().rstrip().split())
jobs = [[] for i in range(m)]

for i in range(n):
    tmp,tmp2 = map(int,stdin.readline().rstrip().split())
    if(tmp>m):
        continue
    jobs[m-tmp].append(tmp2)
print(jobs)
ans = 0
h=[]
for i in range(m-1,-1,-1):
    for b in jobs[i]:
        heapq.heappush(h,-b)
    print(h)
    if(len(h)!=0):
        a = -heapq.heappop(h)
        ans += a
print(ans)

Fixed submission:
import heapq
from sys import stdin

n,m = map(int,stdin.readline().rstrip().split())
jobs = [[] for i in range(m)]

for i in range(n):
    tmp,tmp2 = map(int,stdin.readline().rstrip().split())
    if(tmp>m):
        continue
    jobs[m-tmp].append(tmp2)
ans = 0
h=[]
for i in range(m-1,-1,-1):
    for b in jobs[i]:
        heapq.heappush(h,-b)
    if(len(h)!=0):
        a = -heapq.heappop(h)
        ans += a
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())
A = list(map(int,stdin.readline().rstrip().split()))
B = list(map(int,stdin.readline().rstrip().split()))
point = 0
fa = min(A[0],B[0])
fb = min(A[1],B[0]-f00)
point += fb
point += fa
for i in range(1,n):
    fc = min(A[i]-fb,B[i])
    point += fc
    fb = min(A[i+1],B[i]-fc)
    point += fb
print(point)

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
A = list(map(int,stdin.readline().rstrip().split()))
B = list(map(int,stdin.readline().rstrip().split()))
point = 0
fa = min(A[0],B[0])
fb = min(A[1],B[0]-fa)
point += fb
point += fa
for i in range(1,n):
    fc = min(A[i]-fb,B[i])
    point += fc
    fb = min(A[i+1],B[i]-fc)
    point += fb
print(point)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())
A = list(map(int,stdin.readline().rstrip().split()))
B = list(map(int,stdin.readline().rstrip().split()))
point = 0
f00 = min(A[0],B[0])
f12 = min(A[1],B[0]-f00)
point += f12
point += f0
for i in range(1,n):
    f11 = min(A[i]-f12,B[i])
    point += f11
    f12 = min(A[i+1],B[i]-f11)
    point += f12
print(point)

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
A = list(map(int,stdin.readline().rstrip().split()))
B = list(map(int,stdin.readline().rstrip().split()))
point = 0
fa = min(A[0],B[0])
fb = min(A[1],B[0]-fa)
point += fb
point += fa
for i in range(1,n):
    fc = min(A[i]-fb,B[i])
    point += fc
    fb = min(A[i+1],B[i]-fc)
    point += fb
print(point)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())
A = list(map(int,stdin.readline().rstrip().split()))
B = list(map(int,stdin.readline().rstrip().split()))
point = 0
f00 = min(A[0],B[0])
f12 = min(A[1],B[0]-f00)
point += f12
point += f0
for i in range(1,n):
    f11 = min(A[i]-f12,B[i])
    point += f11
    f12 = min(A[i+1],B[i]-f11)
    point += f12
print(point)

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
A = list(map(int,stdin.readline().rstrip().split()))
B = list(map(int,stdin.readline().rstrip().split()))
point = 0
fa = min(A[0],B[0])
fb = min(A[1],B[0]-fa)
point += fb
point += fa
for i in range(1,n):
    fc = min(A[i]-fb,B[i])
    point += fc
    fb = min(A[i+1],B[i]-fc)
    point += fb
print(point)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
S = len(s)

mod = 10**9+7

#全ての余りを確認する
dp = [[0 for i in range(13)]for j in range(S)]

if s[0] == "?":
    for i in range(10):
        dp[0][i%13] += 1
else:
    dp[0][int(s[0])%13] += 1

for i in range(1,S):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i][(10*k+j)%13] += dp[i-1][k]%mod
    else:
        for k in range(13):
            dp[i][(10*k+int(s[i]))%13] += dp[i-1][k]%mod
            
print(dp[-1][5]%mod)

Fixed submission:
s = input()
S = len(s)

mod = 10**9+7

#全ての余りを確認する
dp = [[0 for i in range(13)]for j in range(S)]

if s[0] == "?":
    for i in range(10):
        dp[0][i%13] += 1
else:
    dp[0][int(s[0])%13] += 1

for i in range(1,S):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i][(10*k+j)%13] += dp[i-1][k]%mod
    else:
        for k in range(13):
            dp[i][(10*k+int(s[i]))%13] += dp[i-1][k]%mod
            
print(dp[-1][5]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
S = len(s)

mod = 10**9+7

#全ての余りを確認する
dp = [[0 for i in range(13)]for j in range(S)]

if s[0] == "?":
    for i in range(10):
        dp[0][i%13] += 1
else:
    dp[0][int(s[0])%13] += 1

for i in range(1,S):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i][(10*k+j)%13] += dp[i-1][k]
    else:
        for k in range(13):
            dp[i][(10*k+int(s[i]))%13] += dp[i-1][k]

print(dp[-1][5]%mod)

Fixed submission:
s = input()
S = len(s)

mod = 10**9+7

#全ての余りを確認する
dp = [[0 for i in range(13)]for j in range(S)]

if s[0] == "?":
    for i in range(10):
        dp[0][i%13] += 1
else:
    dp[0][int(s[0])%13] += 1

for i in range(1,S):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i][(10*k+j)%13] += dp[i-1][k]%mod
    else:
        for k in range(13):
            dp[i][(10*k+int(s[i]))%13] += dp[i-1][k]%mod
            
print(dp[-1][5]%mod)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())
li = list(int(stdin.readline().rstrip()) for _ in range(n))
li_to = sorted(li)
one = li_to[-1]
two = li_to[-2]
for i in range(n):
    if max(li) == li[i]:
        print(two)
    else:
        print(one)

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
print(3*n**2)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

point = 0
lin = []

for i in range(n,0,-1):
    score = 0
    for j in range(i+1,n+1):
        if j % i == 0:
            score += li[j-1]
    if li[i-1] != score%2:
        point += 1
        lin.append(i)

print(point)
for i in lin:
    print(i)

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = [0]*(n+1)
point = 0
lis = []

for i in range(n,0,-1):
    su = sum(lin[i::i])%2
    if li[i] != su:
        lin[i] = 1
        point += 1
        lis.append(i)
    
print(point)
lis.sort()

for i in lis:
    print(i)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
li = list(map(int,stdin.readline().rstrip.split()))
if li[1] > li[2]:
    print(li[0]*li[1])
else:
    print(li[0]*li[2])

Fixed submission:
from sys import stdin
li = list(map(int,stdin.readline().rstrip().split()))
if li[1]*li[0] > li[2]:
    print(li[2])
else:
    print(li[0]*li[1])

Buggy python submission (verdict: Runtime Error):
from sys import stdin

li = list(map(int,stdin.readline().rstrip.split()))

if li[1] > li[2]:
    print(li[0]*li[1])
else:
    print(li[0]*li[2])
    

Fixed submission:
from sys import stdin
li = list(map(int,stdin.readline().rstrip().split()))
if li[1]*li[0] > li[2]:
    print(li[2])
else:
    print(li[0]*li[1])
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import itertools

l,r = [int(x) for x in stdin.readline().rstrip().split()]


li = [x for x in range(l,r+1)]
m = 2020
for i in range(len(li)-1):
    for j in range(i+1,len(li)):
        if li[i]*li[j]%2019 == 0:
            print(0)
            exit()
        else:
            if m >= li[i]*li[j]%2019:
                m = li[i]*li[j]%2019
print(m)

Fixed submission:
from sys import stdin

l,r = [int(x) for x in stdin.readline().rstrip().split()]
m = 2020
if r - l > 2018:
    print(0)
    exit()
for i in range(l,r):
    for j in range(i+1,r+1):
        if i*j%2019 == 0:
            print(0)
            exit()
        else:
            m = min(m,i*j%2019)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import itertools

l,r = [int(x) for x in stdin.readline().rstrip().split()]


li = [x for x in range(l,r+1)]
m = 2020
for i in range(len(li)-1):
    for j in range(i+1,len(li)):
        if li[i]*li[j]%2019 == 0:
            print(0)
            exit()
        else:
            m = min(m,li[i]*li[j]%2019)
print(m)

Fixed submission:
from sys import stdin

l,r = [int(x) for x in stdin.readline().rstrip().split()]
m = 2020
if r - l > 2018:
    print(0)
    exit()
for i in range(l,r):
    for j in range(i+1,r+1):
        if i*j%2019 == 0:
            print(0)
            exit()
        else:
            m = min(m,i*j%2019)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import itertools

l,r = [int(x) for x in stdin.readline().rstrip().split()]


li = [x%2019 for x in range(l,r+1)]
m = 2020
for i in range(len(li)-1):
    for j in range(i+1,len(li)):
        if li[i]*li[j]%2019 == 0:
            print(0)
            exit()
        else:
            m = min(m,li[i]*li[j]%2019)
print(m)

Fixed submission:
from sys import stdin

l,r = [int(x) for x in stdin.readline().rstrip().split()]
m = 2020
if r - l > 2018:
    print(0)
    exit()
for i in range(l,r):
    for j in range(i+1,r+1):
        if i*j%2019 == 0:
            print(0)
            exit()
        else:
            m = min(m,i*j%2019)
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from numpy.linalg import solve

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = [[0 for _ in range(n)]for _ in range(n)]
point = 0
for i in range(n-1):
    lin[i][i] = 0.5
    lin[i][i+1] = 0.5
lin[-1][0] = 0.5
lin[-1][-1] = 0.5
lis = solve(lin,li)
liv = []
for i in lis:
    liv.append(int(i))
print(*liv)

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
point = 0
for i in range(n):
    if i%2 == 0:
        point += li[i]
    else:
        point -= li[i]
lin = [point]
for i in range(n-1):
    lin.append((li[i]-lin[i]//2)*2)
print(*lin)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)
n,k = map(int,input().split())
li = [[] for _ in range(n+1)]
mod = 10**9+7
ans = k
perm = [1]*(n)# 組み合わせ(k-2)P(要素)

for i in range(n-1):
    a,b = map(int,input().split())
    li[a].append(b)
    li[b].append(a)
    perm[i+1] = (perm[i]*(k-2-i))%mod

def dfs(now,before):
    point = 1
    ret = 1
    if now == 1:
        ko = len(li[1])
        for i in range(ko):
            ret *= k-1-i
            ret %= mod
    else:
        ko = len(li[now])-1
        ret= perm[ko]%mod
    
    for i in li[now]:
        if i==before:
            continue
        ret = ret*dfs(i,a)%mod
    return ret

ans *= dfs(1,0)
print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n,k = map(int,input().split())
li = [[] for _ in range(n+1)]
mod = 10**9+7
ans = k
perm = [1]*(n)# 組み合わせ(k-2)P(要素)

for i in range(n-1):
    a,b = map(int,input().split())
    li[a].append(b)
    li[b].append(a)
    perm[i+1] = (perm[i]*(k-2-i))%mod

def dfs(now,before):
    point = 1
    if now == 1:
        ret = 1
        ko = len(li[1])
        for i in range(ko):
            ret *= k-1-i
            ret %= mod
    else:
        ko = len(li[now])-1
        ret= perm[ko]%mod
    
    for i in li[now]:
        if i==before:
            continue
        ret = ret*dfs(i,now)%mod
    return ret

ans *= dfs(1,0)

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
kouyaku = math.gcd(c, d)
koubai = c * d // math.gcd(c, d)
b_s = b - b//c - b//d + b//koubai
a_s = a-1 - (a-1)//c - (a-1)//d + (a-1)//koubai
print(b_s - a_s)

Fixed submission:
from sys import stdin
import fractions
a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
kouyaku = fractions.gcd(c, d)
koubai = c * d // fractions.gcd(c, d)
b_s = b - b//c - b//d + b//koubai
a_s = a-1 - (a-1)//c - (a-1)//d + (a-1)//koubai
print(b_s - a_s)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
kouyaku = math.gcd(c, d)
koubai = (c * d // kouyaku)
b_s = (b - b//c - b//d + b//koubai)
a_s = (a-1 - (a-1)//c - (a-1)//d + (a-1)//koubai)
print(b_s - a_s)

Fixed submission:
from sys import stdin
import fractions
a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
kouyaku = fractions.gcd(c, d)
koubai = c * d // fractions.gcd(c, d)
b_s = b - b//c - b//d + b//koubai
a_s = a-1 - (a-1)//c - (a-1)//d + (a-1)//koubai
print(b_s - a_s)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
kouyaku = math.gcd(c, d)
koubai = c * d // kouyaku
b_s = b - b//c - b//d + b//koubai
a_s = a-1 - (a-1)//c - (a-1)//d + (a-1)//koubai
print(b_s - a_s)

Fixed submission:
from sys import stdin
import fractions
a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
kouyaku = fractions.gcd(c, d)
koubai = c * d // fractions.gcd(c, d)
b_s = b - b//c - b//d + b//koubai
a_s = a-1 - (a-1)//c - (a-1)//d + (a-1)//koubai
print(b_s - a_s)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
s = stdin.readline().rstrip()
point = 0
while True:
    if "ABC" not in s:
        break
    else:
        point += s.count("ABC")
        s = s.replace("ABC","BCA")
print(point)

Fixed submission:
from sys import stdin
s = stdin.readline().rstrip()
s = s.replace("BC","D")
point = 0
count = 0
for i in s:
    if i == "A":
        count += 1
    elif i == "D":
        point += count
    else:
        count = 0
print(point)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    point = 0
    r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
    for i in range(n//r+1):
        for j in range(n//g+1):
            if n-r*i-g*j >= 0:
                if (n-r*i-g*j)%b == 0:
                    point += 1
    print(point)

if __name__ == "__main__":
    main()

Fixed submission:
from sys import stdin
import math

point = 0

r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(n//r+1):
    for j in range(n//g+1):
        if n-r*i-g*j >= 0:
            if (n-r*i-g*j)%b == 0:
                point += 1

print(point)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    point = 0
    r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
    for i in range(n//r+1):
        for j in range(n//g+1):
            if n-r*i-g*j >= 0:
                if (n-r*i-g*j)%b == 0:
                    point += 1
    print(point)

main()

Fixed submission:
from sys import stdin
import math

point = 0

r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(n//r+1):
    for j in range(n//g+1):
        if n-r*i-g*j >= 0:
            if (n-r*i-g*j)%b == 0:
                point += 1

print(point)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import math

point = 0

r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(n//r+1):
    for j in range(n//g+1):
        if n-r*i-g*j >= 0:
            if (n-r*i-g*j)%b == 0:
                point += 1

print(point)

Fixed submission:
from sys import stdin
import math

point = 0

r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(n//r+1):
    for j in range(n//g+1):
        if n-r*i-g*j >= 0:
            if (n-r*i-g*j)%b == 0:
                point += 1

print(point)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
n = int(stdin.readline().rstrip())
point = 0
for i in range(1,n+1):
    if n%i == n//i:
        point += i
print(point)

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
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
li = make_divisors(n)
point = 0
for i in li:
    minashi = i-1
    if minashi == 0:
        continue
    elif n%minashi == n//minashi:
        point += minashi
print(point)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
inf = 10**10
h,w = map(int,stdin.readline().rstrip().split())
li = [stdin.readline().rstrip() for _ in range(h)]
visited = [[0 for i in range(w)]for j in range(h)]
q = []
for i in range(h):
    for j in range(w):
        if li[i][j] == ".":
            continue
        q.append((i,j))
        visited[i][j] = 1
dx = [1,0,-1,0]
dy = [0,1,0,-1]
ans = -1
while q:
    qq = []
    ans += 1
    for y,x in q:
        for i,j in zip(dy,dx):
            ny,nx = i+y,j+x
            if ny < 0 or ny >= h or nx < 0 or nx >= w:
                continue
            elif li[ny][nx] == "#":
                continue
            elif visited[ny][nx] == 0:
                visited[ny][nx] = 1
                qq.append((ny,nx))
    q = qq
print(ans)

Fixed submission:
from sys import stdin
inf = 10**10
h,w = map(int,stdin.readline().rstrip().split())
li = [stdin.readline().rstrip() for _ in range(h)]
visited = [[0 for i in range(w)]for j in range(h)]
q = []
for i in range(h):
    for j in range(w):
        if li[i][j] == ".":
            continue
        q.append((i,j))
        visited[i][j] = 1
dx = [1,0,-1,0]
dy = [0,1,0,-1]
ans = -1
while q:
    qq = []
    ans += 1
    for y,x in q:
        for i,j in zip(dy,dx):
            ny,nx = i+y,j+x
            if ny < 0 or ny >= h or nx < 0 or nx >= w:
                continue
            elif li[ny][nx] == "#":
                continue
            elif visited[ny][nx] == 0:
                visited[ny][nx] = 1
                qq.append((ny,nx))
    q = qq
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from fractions import gcd
#from math import gcd

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

def gcd_all(list):
    return gcd_all([gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]

ma = -50
for i in range(n):
    lin = [li[s] for s in range(n) if s != i]
    ma = max(ma,gcd_all(lin))

print(ma)

Fixed submission:
from fractions import gcd

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

M = [0]*N

#漸化式を作る
L = [0]*N
R = [0]*N

for i in range(1,N):
    L[i] = gcd(L[i-1],A[i-1])
    R[N-1-i] = gcd(R[N-i],A[N-i])

for j in range(N):
    M[j] = gcd(L[j],R[j])

print(max(M))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import fractions

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

def gcd_all(list):
    return gcd_all([fractions.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]

ma = 0
for i in range(n):
    lin = [li[s] for s in range(n) if s != i]
    ma = max(ma,gcd_all(lin))

print(ma)

Fixed submission:
from fractions import gcd

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

M = [0]*N

#漸化式を作る
L = [0]*N
R = [0]*N

for i in range(1,N):
    L[i] = gcd(L[i-1],A[i-1])
    R[N-1-i] = gcd(R[N-i],A[N-i])

for j in range(N):
    M[j] = gcd(L[j],R[j])

print(max(M))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

def gcd_all(list):
    return gcd_all([math.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]

ma = 0
for i in range(n):
    lin = [li[s] for s in range(n) if s != i]
    ma = max(ma,gcd_all(lin))

print(ma)

Fixed submission:
from fractions import gcd

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

M = [0]*N

#漸化式を作る
L = [0]*N
R = [0]*N

for i in range(1,N):
    L[i] = gcd(L[i-1],A[i-1])
    R[N-1-i] = gcd(R[N-i],A[N-i])

for j in range(N):
    M[j] = gcd(L[j],R[j])

print(max(M))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())
s = "."+stdin.readline().rstrip()
kuro = s.count("#")
shiro = n-kuro
mi = shiro
k = 0
sh = shiro
for i in range(n):
    if s[i] == "#":
        k += 1
    else:
        sh -= 1
    mi = min(mi,k+s)
print(mi)

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
kuro = s.count("#")
shiro = n-kuro
mi = shiro
k = 0
sh = shiro
for i in range(n):
    if s[i] == "#":
        k += 1
    else:
        sh -= 1
    mi = min(mi,k+sh)
print(mi)