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

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

A.sort()
flag = False
for count in range(0,len(A)-1):
    if A[count] == A[count+1]:
        flag = True
        break

if flag == False:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

A.sort()
flag = False
for count in range(0,len(A-1)):
    if A[count] == A[count+1]:
        flag = True
        break

if flag == False:
    print("YES")
else:
    print("NO")
Problem p02790 (python)

Fixed submission:
A,B = map(int,input().split())

ansA = ""
ansB = ""
for countA in range(B):
    ansA = ansA + str(A)
for countB in range(A):
    ansB = ansB + str(B)

list = [str(ansA),str(ansB)]
list.sort()

print(list[0])

Buggy submission (verdict: Runtime Error):

input = list(map(int, input().split()))
A = input[0]
B = input[1]
output = []
 
output.append(str(B) * A)

output.append(str(A) * B)

output.sort

print(output[0])
Problem p02819 (python)

Fixed submission:

inputA = int(input())

flag = 0
for count in range(inputA,300000):

    for mod in range(2,200000):
        if count % mod == 0:
            flag = mod
            break
        mod += 1
    if count == flag:
        print(count)
        break
    elif flag == 0:
        print(inputA)
    else:
        count += 1

Buggy submission (verdict: Runtime Error):

inputA = map(int, input())

flag = 0
for count in range(inputA+1,300000):
    for mod in range(2,10000):
        if count % mod == 0:
            flag = mod
            break
        mod += 1
    if count == flag:
        print(count)
        break
    else:
        count += 1
Problem p02831 (python)

Fixed submission:
import fractions

a,b = map(int,input().split())

print((a * b) // fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math

a,b = map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02879 (python)

Fixed submission:
A,B = map(int,input().split())
if A > 9:
    print(-1)
elif B > 9:
    print(-1)
else:
    print(A*B)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().splite())

if A > 9:
    print(-1)
elif B > 9:
    print(-1)
else:
    print(A*B)
Problem p02881 (python)

Fixed submission:
import math

N = int(input())

result1 = 0
result2 = 0
ans = float("inf")
for count in range(1,int(math.sqrt(N))+1):
    if N % count == 0:
        ans = min(ans,count + N // count -2)


print(ans)

Buggy submission (verdict: Runtime Error):

N = int(input())

result1 = 0
result2 = 0

for count in range(2,N // 2):
    if N % count == 0:
        result1 = count


print(result1+ N // result1 -2)
Problem p02915 (python)

Fixed submission:
N = int(input())

print(N*N*N)

Buggy 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()))
sumc = 0

for count in range(N-1):
    if A[count+1] - A[count] == 1:
        sumc = sumc + C[A[count]-1]

print(sumc + sum(B))
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
sumc = 0

for count in range(N-1):
    if A[count+1] - A[count] == 1:
        sumc = sumc + C[A[count]-1]

print(sumc + sum(B))

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())

sumc = 0
ans = 0
for count in range(1,22):
    sumc = A * count 
    if sumc-count + 1 >= B:
        ans = count 
        break
print(ans)

Buggy submission (verdict: Runtime Error):
4
2 3 4 1
13 5 8 24
45 9 15
Problem p02951 (python)

Fixed submission:
A,B,C = map(int,input().split())

if C-(A-B) > 0:
    print(C-(A-B))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
A.B.C = map(int,input().split())

print(C-(A-B))
Problem p02712 (python)

Fixed submission:
N = int(input())
list = []

for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        "FizzBuzz"
    elif i % 3 == 0:
        "Fizz"
    elif i % 5 == 0:
        "Buzz"
    else:
        list.append(i)
print(sum(list))

Buggy submission (verdict: Runtime Error):
n = int(input())
sum = 0

if(1 <= N <= 10 ** 6):

 for i in range(1 , n + 1 ):
    if (i % 3 == 0) and (i % 5 == 0):
        n = "FizzBuzz"
    elif (i % 3 == 0):
        n = "Fizz"
    elif (i % 5 == 0):
        n = "ZBuzz"
    else:
        sum += 1

print(sum)
Problem p02753 (python)

Fixed submission:
S = str(input())
if S[0] == S[1] and S[1] == S[2]:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
S = str(input())
if S[1] + S[2] == 'A':
    print('Yes')
elif S[2] + S[3] == 'B':
    print('Yes')
else:
    print('No')
Problem p03011 (python)

Fixed submission:
p, q, r = map(int, input().split())
time = [p, q, r]

print(sum(time) - max(time))

Buggy submission (verdict: Runtime Error):
p, q, r = map(int, input().split())

print(sum[p, q, r] - max[p, q, r])
Problem p03207 (python)

Fixed submission:
import math
N = int(input())
p = []

for i in range(N):
    p.append(int(input()))

total_price = max(p) / 2 + sum(p) - max(p)

print(math.floor(total_price))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
p = []

for i in range(N):
    p.append(int(input()))

total_price = max(N) / 2 + sum(N) - max(N)

print(math.floor(total_price))

Buggy submission (verdict: Runtime Error):
N = int(input())
p = []

for i in range(N):
    p.append(int(input()))

total_price = max(N) / 2 + sum(N) - max(N)

print(total_price)

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))

total_price = (max(N) / 2) + (sum(N) - max(N))

print(total_price)
Problem p02753 (python)

Fixed submission:
s = input()

if s[0]==s[1] and s[0]==s[2]:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n,p = map(int,input().split())
s = input()
count = 0

if p == 2 or p == 5:
    for i in range(n):
        if int(s[i])%p == 0:
            count += i+1
else:
    u = [0]*p
    u[0] += 1
    for i in range(n):
        u[int(s[i:])%p] += 1
    
    for i in u:
        count += i*(i-1)//2
    
print(count)
Problem p02763 (python)

Fixed submission:
import bisect

n = int(input())
s = list(input())
q = int(input())

alpha_map = {chr(i):[] for i in range(97,123)}
for i,c in enumerate(s):
    bisect.insort(alpha_map[c],i+1)
    
for _ in range(q):
    x,y,z = map(str,input().split())
    if int(x) == 1:
        y = int(y)
        bef = s[y-1]
        if bef == z:
            continue
        alpha_map[bef].pop(bisect.bisect_left(alpha_map[bef],y))
        bisect.insort(alpha_map[z],y)
        s[y-1] = z
    else:
        count = 0
        for i,j in alpha_map.items():
            idx = bisect.bisect_left(j,int(y))
            if idx < len(j) and j[idx] <= int(z):
                    count += 1
        print(count)

Buggy submission (verdict: Runtime Error):
import bisect

n = int(input())
s = input()
q = int(input())

alpha_map = {i:[] for i in alpha}
for i,c in enumerate(s):
    bisect.insort(alpha_map[c],i+1)
    
for _ in range(q):
    x,y,z = map(str,input().split())
    if int(x) == 1:
        y = int(y)
        bef = s[y-1]
        if bef == z:
            continue
        alpha_map[bef].pop(bisect.bisect_left(alpha_map[bef],y))
        bisect.insort(alpha_map[z],y)
        s = s[:y-1]+z+s[y:]
    else:
        count = 0
        for i,j in alpha_map.items():
            idx = bisect.bisect_left(j,int(y))
            if idx < len(j) and j[idx] <= int(z):
                    count += 1
        print(count)
Problem p02771 (python)

Fixed submission:
A, B, C = map(int, input().split())

if A == B:
  if A == C:
    print('No')
  else:
    print('Yes')
elif A == C:
  print('Yes')
elif B == C:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = map(int,input().split())
a = np.array(input().split(),np.int64)
a = np.sort(a)
zero = a[a==0]
pos = a[a>0]
neg = a[a<0]

def f(x):
    count = 0
    c = x // pos
    count += np.searchsorted(a, c, side='right').sum()
    count += N*len(zero) if x >= 0 else 0
    c = -(-x // neg)
    count += (N - np.searchsorted(a, c, side='left')).sum()
    count -= a[a*a <= x].size
    count //= 2
    return count

right = 10**18
left = -10**18
while right-left>1:
    mid = (right + left)//2
    if f(mid)<K:
        left = mid
    else:
        right = mid
        
print(int(right))
Problem p02773 (python)

Fixed submission:
import collections

N = int(input())
s = [input() for i in range(N)]

c = collections.Counter(s)
max_num = max(c.values())
d = []
for key,value in c.items():
  if value == max_num:
    d.append(key)

for i in sorted(d):
  print(i)

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
s = [input() for i in range(N)]

c = collections.Counter(s)
max_num = list(c.values())[0]
d = []
for key,value in c:
  if value == max_num:
    d.append(key)
  else:
    break
    
for i in sorted(d):
  print(i)

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
s = list(input().split())

c = collections.Counter(s)
max_num = list(c.values())[0]
d = []
for key,value in c:
  if value == max_num:
    d.append(key)
  else:
    break
    
for i in sorted(d):
  print(i)

Buggy submission (verdict: Runtime Error):
import collections

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

c = collections.Counter(s)
max_num = list(c.values())[0]
d = []
for key,value in c.items():
  if value == max_num:
    d.append(key)
  else:
    break
    
for i in sorted(d):
  print(i)

Buggy submission (verdict: Runtime Error):
import collections

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

c = collections.Counter(s)
max_num = list(c.values())[0]
d = []
for key,value in c:
  if value == max_num:
    d.append(key)
  else:
    break
    
for i in sorted(d):
  print(i)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [input() for i in range(N)]

n = N
max_num = 0
t = []
while n >= max_num:
    word = s[0]
	count = 0
    for i in s:
      if i == word:
        count += 1
        
    if count > max_num:
      max_num = count
      t = [s[0]]
    elif count == max_num:
      t = t.append(s[0])
      
    s = [i for i in s if i != word]
    n = len(s)

t = sorted(t)
for i in range(t):
  print(i)
Problem p02781 (python)

Fixed submission:
n = input()
k = int(input())
n_len = len(n)
dp0 = [[0]*k for i in range(n_len)]
dp1 = [[0]*k for i in range(n_len)]
for i in range(k):
    if i == 0:
        dp0[0][i]=int(n[0])-1
        dp1[0][i]=1
    else:
        dp0[0][i]=0
        dp1[0][i]=0

for i in range(1,n_len):
    for j in range(k):
        if j == 0:
            dp0[i][j]=9 + dp0[i-1][0] + dp1[i-1][0]*min(1,int(n[i]))
            dp1[i][j]=dp1[i-1][0] if int(n[i]) == 0 else 0
        else:
            dp0[i][j]=dp0[i-1][j-1]*9 + dp1[i-1][j-1]*max(0,int(n[i])-1) + dp0[i-1][j] + dp1[i-1][j]*min(1,int(n[i]))
            dp1[i][j]=dp1[i-1][j-1] if int(n[i]) != 0 else dp1[i-1][j]
            
print(dp0[n_len-1][k-1]+dp1[n_len-1][k-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
n_len = len(str(n))

x = [1]*(n_len)
for i in range(n_len-1):
    x[i+1] = x[i]*(i+1)

def calc(i,j):
    return x[i]/x[j]/x[i-j]*9**(j)
    
count = 0
non_zero = 0
for ind,i in enumerate(str(n)):
    if i != '0':
        non_zero += 1
        if n_len-ind-1 > k-non_zero:
            count += calc(n_len-ind-1,k-non_zero+1)
        if non_zero < k:
            count += calc(n_len-ind-1,k-non_zero)*(int(i)-1)
        elif non_zero == k:
            count += int(i)
            break
    
print(int(count))
Problem p02711 (python)

Fixed submission:
A = list(map(int, input()))

if A[0] == 7 or A[1] == 7 or A[2] == 7:
  print('Yes')

else:
  print('No')

Buggy submission (verdict: Runtime Error):
A = list(int(input()))

if A[0] == 7 or A[1] == 7 or A[2] == 7:
  print('Yes')
  
else:
  print('No')
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split())
AB = A + B

if N >= AB:
    iters, div = divmod(N, AB)
    if div <= A:
        print((A*iters + div))
    else:
        print((A*(iters + 1)))
elif N >= A:
    print(A)
else:
    print(N)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

if N >= AB:
    iters, div = divmod(N, (A +B))
    print((A*iters + div))
else:
    print(A)
Problem p02831 (python)

Fixed submission:
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b= b, a%b
    return a
def lcm(a, b):
    return (a * b) // gcd(a, b)
print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B = map(int, input().split())
print(lcm(A, B))
Problem p03265 (python)

Fixed submission:
Ax, Ay, Bx, By = map(int, input().split())
x = Ax - Bx
y = Ay - By

print(Bx + y, By - x, Ax + y, Ay - x)

Buggy submission (verdict: Runtime Error):
length = int(input())
s = input()

if s[:length // 2] == s[length // 2:]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
length = int(input())
s = input()

if s[:length // 2] == s[length // 2:]:
    print("Yes")
else:
    print("No")
Problem p02679 (python)

Fixed submission:
from collections import defaultdict

def gcd(x, y):
    r = x % y
    while r:
        x, y, r = y, r, y%r
    return y
    
def main():
    n = int(input())
    al = defaultdict(lambda: 0)
    All = 0
    mod = 1000000007
    goods = dict()
    for i in range(n):
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            All += 1
        elif b == 0:
            al["inf"] += 1
            goods["inf"] = "0"
        elif a == 0:
            al["0"] += 1
            goods["0"] = "inf"
        else:
            g = gcd(b, a)
            a_key = f"{a//g},{b//g}"
            if b//g < 0:
                good = f"{-b//g},{a//g}"
            else:
                good = f"{b//g},{-a//g}"
            goods[a_key] = good
            al[a_key] += 1
    ans = 1
    al = dict(al)
    done = set()
    ok = 0
    for k, v in al.items():
        if k in done:
            continue
        num = al.get(goods[k])
        done.add(goods[k])
        if num:
            ans *= pow(2, num, mod)+pow(2, v, mod)-1
            ans %= mod
        else:
            ok += v
    ans *= pow(2, ok, mod)
    ans += All - 1
    ans %= mod
    print(ans)
        
        
            
    

if __name__ == "__main__":
    main()

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

def gcd(x, y):
    if x < 0:
        x, y = y, x
    r = x % y
    while r:
        x, y, r = y, r, y%r
    return y
    
def main():
    n = int(input())
    mod = 1000000007
    p = defaultdict(lambda: 0)
    bad = dict()
    zeros = 0
    for _ in range(n):
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            zeros += 1
        else:
            if a == 0:
                p["0"] += 1
                bad["0"] = "INF"
            elif b == 0:
                p["INF"] += 1
                bad["INF"] = "0"
            else:
                g = gcd(a, b)
                a //= g
                b //= g
                sp = f"{a}_{b}"
                if b < 0:
                    b *= -1
                    a *= -1
                sm = f"{b}_{-a}"
                p[sp] += 1
                bad[sp] = sm
    done = set()
    good = 0
    for key, num in p.items():
        if key in done:
            continue
        b = a[bad[key]]
        done.add(bad[key])
        if b > 0:
            ans *= pow(2, b, mod)*pow(2, num, mod)-1
            ans %= mod
        else:
            good += num
    ans *= pow(2, good, mod)
    ans += zeros
    ans -= 1
    ans %= mod
    print(ans)
        
        

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

Fixed submission:
import sys
input = sys.stdin.readline
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 2* 10 ** 5+2  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def solve():
  n,k = (int(i) for i in input().split())
  mod = 10**9+7
  if n-k <= 1:
    #任意の部屋に移動可能
    comba = 1
    inva = 1
    for i in range(1,n+1):
      comba *= (n+i-1)
      inva *= i
      comba %= mod
      inva %= mod
    comba *= pow(inva,10**9+5,mod)
    comba %= mod
    print(comba)
  else:
    #n <= 2**10^5
    #k <= 2**10^5
    ans = 0
    
    
    
    for i in range(0,k+1):
      ans += cmb(n,i,mod)*cmb(n-1,i,mod)
      ans %= mod
    
    print(ans)
  
solve()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 5+15  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def solve():
  n,k = (int(i) for i in input().split())
  mod = 10**9+7
  if n-k <= 1:
    #任意の部屋に移動可能
    comba = 1
    inva = 1
    for i in range(1,n+1):
      comba *= (n+i-1)
      inva *= i
      comba %= mod
      inva %= mod
    comba *= pow(inva,10**9+5,mod)
    comba %= mod
    print(comba)
  else:
    #n <= 2**10^5
    #k <= 2**10^5
    ans = 0
    
    
    
    for i in range(0,k+1):
      ans += cmb(n,i,mod)*cmb(n-1,i,mod)
      ans %= mod
    
    print(ans)
  
solve()
Problem p02984 (python)

Fixed submission:
from collections import deque
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  x1 = 0
  for i in range(n):
    if i%2 == 0:
      x1  += a[i]
    else:
      x1  -= a[i]
  query = deque([x1])
  x = x1
  for i in range(n-1):
    tmp = a[i]-x//2
    tmp *= 2
    query.append(tmp)
    x  = tmp
  print(*query)
solve()

Buggy submission (verdict: Runtime Error):
def solve():
  l,r = (int(i) for i in input().split())
  mod = 2019
  l %= mod
  r %= mod
  ans = 10**15
  if l > r :
    print(0)
    exit()
  elif l == 0 or r == 0:
    print(0)
    exit()
  else:
    for i in range(l,r):
      for j in range(l+1,r+1):
        if i<j:
         ans = min(ans,(i*j)%mod)
  print(ans%mod)

solve()
Problem p02990 (python)

Fixed submission:
def solve():
  n,k = (int(i) for i in input().split())
  mod = 10**9+7
  fact = [1]*(n+5)
  inv = [1]*(n+5)
  finv = [1]*(n+5)
  fact[0] = fact[1] = 1
  finv[0] = finv[1] = 1
  inv[1]  = 1
  for i in range(2,n+4):
   fact[i] = (fact[i-1]*i)%mod
   inv[i] = mod-inv[mod%i]*(mod//i)%mod
   finv[i]= finv[i-1]*inv[i]%mod

  
  blue = k
  red  = n-k
  blueplace = red+1
  
  for i in range(1,k+1):
    if (n-k+1)>= i:
     tmp = fact[n-k+1]*(finv[i]*finv[n-k+1-i]%mod)%mod
     tmp *= fact[k-1]*(finv[i-1]*finv[k-i]%mod)%mod
     print(tmp%mod)
    else:
      print(0)
solve()

Buggy submission (verdict: Runtime Error):
from math import factorial
def P(n, r):
     mod = 10**9+7
     return (factorial(n)//factorial(n-r))%mod

def ncr(n, r):
     mod = 10**9+7
     return (P(n, r)//factorial(r))%mod

def solve():
  n,k = (int(i) for i in input().split())
  mod = 10**9+7
  blue = k
  red  = n-k
  blueplace = red+1
  
  for i in range(1,k+1):
    tmp = ncr(k-1,i-1)*ncr(blueplace,i)%mod
    print(tmp%mod)
solve()

Buggy submission (verdict: Runtime Error):
from math import factorial
def ncr(n,r):
 if r <= 0:
  return 1
 if not n == r:
  return (factorial(n)) // factorial(r) // factorial(n - r)
 else:
    return 1

def solve():
  n,k = (int(i) for i in input().split())
  mod = 10**9+7
  blue = k
  red  = n-k
  blueplace = red+1
  
  for i in range(1,k+1):
    print(ncr(blueplace,i)*ncr(k-1,i-1)%mod)
solve()
Problem p03053 (python)

Fixed submission:

from collections import deque
def solve():
  h,w = (int(i) for i in input().split())
  maze = ["0"*(w+2)]
  for i in range(h):
    maze.append("0"+input()+"0")
  maze.append("0"*(w+2))
  black = deque([])
  count = 0
  visit = [[False]*(w+2) for _ in range(h+2)]
  
  for i in range(h+2):
    for j in range(w+2):
      if maze[i][j] == "#":
        black.append((0,i,j)) #move,h,w

  d = [(0,1),(1,0),(-1,0),(0,-1)]
  ans = 0
  
  while count != h*w:
    move,y,x = black.popleft()
    #print(move,y,x)
    if visit[y][x]:
      continue
    else:
      visit[y][x] = True
      count += 1
      for dy,dx in d:
        ny,nx = y+dy,x+dx
        if visit[ny][nx]:
          continue
        elif maze[ny][nx] ==".":
          black.append((move+1,ny,nx))
  print(move)
          

    
solve()

Buggy submission (verdict: Runtime Error):
def solve():
  h,w = (int(i) for i in input().split())
  maze = [input() for _ in range(h)]
  visit = [[False]*w for i in range(h)]
  count = h*w
  ans = 0
  
  white = []
  for i in range(h):
    for j in range(w):
      if maze[i][j] == "#":
        white.append((i,j))
        count -= 1
        visit[i][j] = True
        
  d = [(1,0),(0,1),(-1,0),(0,-1)]
  while count > 0:
   ans += 1
   newwhite = []
   while white:
      x,y = white.pop(0)
      for dx,dy in d:
        nx,ny = x+dx,y+dy
        if nx < 0 or nx >= h or ny < 0 or ny >=w :
         continue 
        elif visit[nx][ny]:continue
          
        if maze[nx][ny] == ".":
          count -= 1
          str_list = list(maze[nx])
          str_list[ny] = "#"
          maze[nx] = "".join(str_list)          
          newwhite.append((nx,ny))
          visit[nx][ny] =True
   white = newwhite
    
  print(ans)
solve()
Problem p03127 (python)

Fixed submission:
import fractions
n = int(input())
a = list(int(i) for i in input().split())
ans = fractions.gcd(a[1], a[0])
for i in range(n-1):
  ans = fractions.gcd(a[i+1], ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n = int(input())
a = list(int(i) for i in input().split())
a.sort()
flag = 1
sa = [1]*(n-1)
for i in range(n-1):
  sa[i] = a[i+1]-a[i]
  if sa[i] != 0: flag = 0
if flag == 1: 
  print(min(a))
  exit()
else:
 for i in range(n):
  if a[i]%(min(sa))!= 0:
   a[i] = a[i]%(min(sa))
 
print(min(a))
Problem p03265 (python)

Fixed submission:
import heapq
def solve():
  x1,y1,x2,y2 = (int(i) for i in input().split())
  x = x2-x1
  y = y2-y1
  print(x2-y,y2+x,x1-y,y1+x)
 	
solve()

Buggy submission (verdict: Runtime Error):
import heapq
def solve():
  x1,y1,x2,y2 = (int(i) for i in input().split())
  
  que = []
  que2 = []
  for i in range(-300,300):
    for j in range(-300,300):
      if (x2-x1)**2+(y2-y1)**2 == (i-x1)**2+(j-y1)**2:
        if (i,j) != (x1,y1) and  (i,j) != (x2,y2):
          que.append((i,j))
      if (x2-x1)**2+(y2-y1)**2 == (i-x2)**2+(j-y2)**2:
        if  (i,j) != (x1,y1) and  (i,j) != (x2,y2):
         que2.append((i,j))
        
  #define x3,y3
  while que2:
    (x3,y3) = heapq.heappop(que2)
    for i in range(len(que)):
      x4,y4 = que[i]
      if (x3-x2)**2+(y3-y2)**2 == (x4-x1)**2+(y4-y1)**2:
       if (x3-x4)**2+(y3-y4)**2 == (x2-x1)**2+(y2-y1)**2:
        if (x3-x1)**2+(y3-y1)**2 == (x2-x4)**2+(y2-y4)**2:
           print(x3,y3,x4,y4)
            exit()
  #print(que)
 #print(que2)			
solve()
Problem p03705 (python)

Fixed submission:
n,a,b = (int(i) for i in input().split())
if a >b:
  print(0)
  exit()
elif n == 1 and a!=b:
  print(0)
  exit()
if n<= 2:
  print(1)
else:
  mi = a*(n-1)+b
  ma = a+(n-1)*b
  print(ma-mi+1)

Buggy submission (verdict: Runtime Error):
1 3 3