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

Fixed submission:
# -*- coding: utf-8 -*-
H, W = map(int, raw_input().split())
c = [[0 for i in range(10)] for j in range(10)]
A = [[0 for i in range(W)] for j in range(H)]
for i in range(10):
    n = map(int, raw_input().split())
    for j in range(10):
        c[i][j] = n[j]
for i in range(H):
    n = map(int, raw_input().split())
    for j in range(W):
        A[i][j] = n[j]
        
def getDistance(start):
    if start == 1:
        return 0
    d = [1001 for i in range(10)]
    d[start] = 0
    prev = [-1 for i in range(10)]
    Q = set()
    for i in range(10):
        Q.add(i)
    while len(Q) != 0:
        min = 1001
        for i in range(10):
            if d[i] < min and i in Q:
                min = d[i]
                u = i
        Q.remove(u)
        for v in range(10):
            if d[v] > d[u] + c[u][v]:
                d[v] = d[u] + c[u][v]
                prev[v] = u
    return(d[1])



if __name__ == '__main__':
    D = [0 for i in range(10)]
    for i in range(10):
        D[i] = getDistance(i)
    ans = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] != -1:
                ans += D[A[i][j]]
    print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
H, W = map(int, raw_input().split())
c = [[0 for i in range(10)] for j in range(10)]
A = [[0 for i in range(W)] for j in range(H)]
for i in range(10):
    n = map(int, raw_input().split())
    for j in range(10):
        c[i][j] = n[j]
for i in range(H):
    n = map(int, raw_input().split())
    for j in range(W):
        A[i][j] = n[j]
def getDistance(start):
    if start == 1:
        return 0
    d = [1000 for i in range(10)]
    d[start] = 0
    prev = [-1 for i in range(10)]
    Q = set()
    for i in range(10):
        Q.add(i)
    while len(Q) != 0:
        min = 1000
        for i in range(10):
            if d[i] < min and i in Q:
                min = d[i]
                u = i
        Q.remove(u)
        for v in range(10):
            if d[v] > d[u] + c[u][v]:
                d[v] = d[u] + c[u][v]
                prev[v] = u
    return(d[1])



if __name__ == '__main__':
    D = [0 for i in range(10)]
    for i in range(10):
        D[i] = getDistance(i)
    ans = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] != -1:
                ans += D[A[i][j]]
    print(ans)
Problem p03567 (python)

Fixed submission:
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！
if __name__ == '__main__':
    S = raw_input()
    flg = True
    for index in range(len(S) - 1):
        if S[index]+S[index+1] == 'AC':
            print 'Yes'
            flg = False
            break
    if flg:
        print 'No'

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
if __name__ == '__main__':
    N = raw_input()
    A = map(int, raw_input().split())
    c_total = 1
    c_odd = 1
    for a in A:
        if a != 1 or a != 100:
            c_total *= 3
        else:
            c_total *= 2
        if a % 2 == 0 and a != 100:
            c_odd *= 2
    print c_total - c_odd

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！
if __name__ == '__main__':
    S = input()
    flg = True
    for index in range(len(S) - 1):
        if S[index]+S[index+1] == 'AC':
            print 'Yes'
            flg = False
            break
    if flg:
        print 'No'

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！
if __name__ == '__main__':
    S = input()
    if 'AC' in S:
        print 'Yes'
    else:
        print 'No'
Problem p03568 (python)

Fixed submission:
# -*- coding: utf-8 -*-
if __name__ == '__main__':
    N = raw_input()
    A = map(int, raw_input().split())
    c_total = 1
    c_odd = 1
    for a in A:
        c_total *= 3
        if a % 2 == 0:
            c_odd *= 2
    print c_total - c_odd

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
if __name__ == '__main__':
    N = raw_input()
    A = map(int, raw_input().split())
    c_total = 1
    c_odd = 1
    for a in A:
            c_total *= 3
        if a % 2 == 0 and a != 100:
            c_odd *= 2
    print c_total - c_odd
Problem p03573 (python)

Fixed submission:
# -*- coding: utf-8 -*-
A,B,C = map(int, raw_input().split())
if A == B:
    print(C)
if A == C:
    print(B)
if B == C:
    print(A)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A,B,C = map(int, raw_input().split())
if A == B:
    print(C):
if A == C:
    print(B)
if B == C:
    print(A)
Problem p03997 (python)

Fixed submission:
if __name__ == '__main__':
    a = input()
    b = input()
    h = input()
    print ((a + b) * h / 2)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    a = raw_input()
    b = raw_input()
    h = raw_input()
    print ((a + b) * h / 2)
Problem p02999 (python)

Fixed submission:
ina = input()
ina = ina.split()
X = ina[0]
A = ina[1]
if X<A:
  print("0")
else:
  print("10")

Buggy submission (verdict: Runtime Error):
import numpy as np

ina = input()
N = int(ina)
x_list = []
y_list = []
dx_list = []
dy_list = []
for i in range(N):
  x,y,d = input().split()
  x_list.append(float(x))
  y_list.append(float(y))
  if d == 'L':
  	dx_list.append(-1)
  	dy_list.append(0)
  elif d == 'R':
  	dx_list.append(1)
  	dy_list.append(0)
  elif d == 'D':
  	dy_list.append(-1)
  	dx_list.append(0)
  elif d == 'U':
  	dy_list.append(1)
  	dx_list.append(0)


x = np.array(x_list)
y = np.array(y_list)
dx = np.array(dx_list)
dy = np.array(dy_list)

min_obj = (max(x)-min(x)) * (max(y)-min(y))

t = 0
t_min = 0
for t in range(1, 10000):
  x = x + dx*0.1
  y = y + dy*0.1
  obj = (max(x)-min(x)) * (max(y)-min(y))
  if obj < min_obj:
    min_obj = obj
    t_min = t
  if t_min + 500 < t:
    break
print(min_obj)

Buggy submission (verdict: Runtime Error):
ina = input()
inb = input()
N, K = ina.split()
N = int(N)
K = int(K)

a = inb.split()
a = [int(elem) for elem in a]

total = 0
for i in range(len(a)):
  for j in range(i+1, len(a)+1):
    if sum(a[i:j]) >= K:
      total += 1 + len(a)-j
      break
print(total)
Problem p03359 (python)

Fixed submission:
if __name__ == "__main__":

    date = input().replace("　", " ").split(" ")

    if date[0] <= date[1]:
        print(date[0])
    else:
        print(int(date[0])-1)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":

    date = input().replace("　", " ").split(" ")

    if date[0] <= date[1]:
        print(date[0])
    else:
        print(date[0]-1)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    date = input().split(" ")
    if date[0] <= date[1]:
        print(date[0])
    else:
        print(date[0]-1)
Problem p03360 (python)

Fixed submission:
if __name__ == "__main__":
    abc = input().replace("　", " ").split(" ")
    abc = [int(x) for x in abc]
    abc.sort(reverse=True)
    k = int(input())
    print(abc[0] * (2**k) + abc[1] + abc[2])

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    abc = input().replace("　", " ").split(" ")
    import pdb;pdb.set_trace()
    abc = [int(x) for x in abc]
    abc.sort(reverse=True)
    k = int(input())
    print(abc[0] * (2**k) + abc[1] + abc[2])

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    abc = input().replace("　", " ").split(" ")
    abc = [int(x) for x in abc].sort(reverse=True)
    k = int(input())
    print(abc[0] * (2**k)
Problem p03006 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from itertools import product
from collections import Counter

def main():
    N = II()
    if N == 1:
        return 1
    XY = []
    for _ in range(N):
        XY.append(LI())
    cnt = Counter()
    for p0, p1 in product(XY, repeat=2):
        dx, dy = p1[0] - p0[0], p1[1] - p0[1]
        if dx != 0 or dy != 0:
            cnt[(dx, dy)] += 1
    ans = N - max(cnt.values())
    return ans

print(main())

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from itertools import product
from collections import Counter

def main():
    N = II()
    XY = []
    for _ in range(N):
        XY.append(LI())
    cnt = Counter()
    for p0, p1 in product(XY, repeat=2):
        dx, dy = p1[0] - p0[0], p1[1] - p0[1]
        if dx != 0 or dy != 0:
            cnt[(dx, dy)] += 1
    ans = N - max(cnt.values())
    return ans

print(main())
Problem p03025 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

# factorials
_nfact = 2 * (10 ** 5) + 10
facts = [0] * _nfact
facts[0] = 1
for i in range(1, _nfact):
    facts[i] = (facts[i - 1] * i) % MOD

def binomial(m, n):
    return DIV(facts[m], facts[n] * facts[m - n])

def main():
    N, A, B, C = LI()
    D = DIV(100, 100 - C)
    ans = 0
    ap, bp, abp = [1], [1], [POW(A + B, N)]
    for _ in range(0, N + 1):
        ap.append(ap[-1] * A % MOD)
        bp.append(bp[-1] * B % MOD)
        abp.append(abp[-1] * (A + B) % MOD)
    for m in range(N, 2 * N):
        x = binomial(m - 1, N - 1) * DIV(
            ap[N] * bp[m - N] + ap[m - N] * bp[N],
            abp[m - N]) % MOD
        y = (m * D) % MOD
        ans = (ans + (x * y) % MOD) % MOD
    return ans

print(main())

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

# factorials
_nfact = 10 ** 5 + 10
facts = [0] * _nfact
ifacts = [0] * _nfact
facts[0] = 1
ifacts[0] = 1
for i in range(1, _nfact):
    facts[i] = (facts[i - 1] * i) % MOD
    ifacts[i] = INV(facts[i])

def binomial(m, n):
    return facts[m] * ifacts[n] * ifacts[m - n]

def main():
    N, A, B, C = LI()
    D = DIV(100, 100 - C)
    ans = 0
    for m in range(N, 2 * N):
        x = binomial(m - 1, N - 1) * DIV(
            POW(A, N) * POW(B, m - N) + POW(A, m - N) * POW(B, N),
            POW(A + B, m)) % MOD
        y = (m * D) % MOD
        ans += (x * y) % MOD
    return ans

print(main())
Problem p03078 (python)

Fixed submission:
x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
import heapq
q = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
def val(i, j, k):
  return -(A[i] + B[j] + C[k])
heapq.heappush(q, (val(0,0,0), 0,0,0))
visited = set((0,0,0))
for _ in range(k):
  v, aa, bb, cc = heapq.heappop(q)
  print(-v)
  if aa + 1 < len(A) and (aa+1, bb, cc) not in visited:
    visited.add((aa+1, bb, cc))
    heapq.heappush(q, (val(aa+1, bb, cc), aa+1, bb, cc))
  if bb + 1 < len(B) and (aa, bb+1, cc) not in visited:
    visited.add((aa, bb+1, cc))
    heapq.heappush(q, (val(aa, bb+1, cc), aa, bb+1, cc))
  if cc + 1 < len(C) and (aa, bb, cc+1) not in visited:
    visited.add((aa, bb, cc+1))
    heapq.heappush(q, (val(aa, bb, cc+1), aa, bb, cc+1))

Buggy submission (verdict: Runtime Error):
x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
import heapq
q = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
def val(i, j, k):
  return -(A[i] + B[j] + C[k])
heapq.heappush(q, (val(0,0,0), 0,0,0))
for _ in range(k):
  v, aa, bb, cc = heapq.heappop(q)
  print(-v)
  heapq.heappush(q, (val(aa+1, bb, cc), aa+1, bb, cc))
  heapq.heappush(q, (val(aa, bb+1, cc), aa, bb+1, cc))
  heapq.heappush(q, (val(aa, bb, cc+1), aa, bb, cc+1))
Problem p03081 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    N, Q = LI()
    s = SI()
    TD = []
    for _ in range(Q):
        TD.append(LS())
    rev = TD[::-1]
    l, r = -1, N
    for t, d in rev:
        if t == s[l + 1] and d == 'L':
            l += 1
        elif t == s[r - 1] and d == 'R':
            r -= 1
        if l > -1 and t == s[l] and d == 'R':
            l -= 1
        elif r < N and t == s[r] and d == 'L':
            r += 1
        if r == 0 or l == N - 1:
            break
    ans = max(0, r - l - 1)
    return ans

print(main())

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    N, Q = LI()
    s = SI()
    TD = []
    for _ in range(Q):
        TD.append(LS())
    rev = TD[::-1]
    l, r = -1, N
    for t, d in rev:
        if t == s[l + 1] and d == 'L':
            l += 1
        elif t == s[r - 1] and d == 'R':
            r -= 1
        if l > -1 and t == s[l] and d == 'R':
            l -= 1
        elif r < N and t == s[r] and d == 'L':
            r += 1
        if r <= l:
            break
    ans = max(0, r - l - 1)
    return ans

print(main())

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    N, Q = LI()
    s = SI()
    TD = []
    for _ in range(Q):
        TD.append(LS())
    rev = TD[::-1]
    l, r = -1, N
    for t, d in rev:
        if t == s[l + 1] and d == 'L':
            l += 1
        elif t == s[r - 1] and d == 'R':
            r -= 1
        if l > -1 and t == s[l] and d == 'R':
            l -= 1
        elif r < N and t == s[r] and d == 'L':
            r += 1
    ans = max(0, r - l - 1)
    return ans

print(main())
Problem p03087 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from itertools import accumulate

def main():
    N, Q = LI()
    S = SI()
    LR = []
    for _ in range(Q):
        LR.append(LI_())

    AC = [0] * (N + 1)
    for i in range(N - 1):
        if S[i:i + 2] == 'AC':
            AC[i] = 1
    acc = [0] + list(accumulate(AC))
    for l, r in LR:
        print(acc[r] - acc[l])

    return 0

main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from itertools import product

def main():
    N = II()
    A, G, C, T = range(4)
    def code(c0, c1, c2):
        return c0 + 4 * c1 + 16 * c2
    dp = [0] * 64
    dp[code(T, T, T)] = 1
    for _ in range(N):
        tmp = [0] * 64
        for p1, p2, p3 in product(range(4), repeat=3):
            for cur in range(4):
                if (p2, p1, cur) == (A, G, C):
                    continue
                if (p2, p1, cur) == (A, C, G):
                    continue
                if (p2, p1, cur) == (G, A, C):
                    continue
                if (p3, p1, cur) == (A, G, C):
                    continue
                if (p3, p2, cur) == (A, G, C):
                    continue
                tmp[code(cur, p1, p2)] += dp[code(p1, p2, p3)]
                tmp[code(cur, p1, p2)] %= MOD
        dp = tmp
    ans = sum(dp)

    return ans % MOD

print(main())
Problem p03111 (python)

Fixed submission:
n, a, b, c = list(map(int, input().split()))
goals = [a, b, c]
bamboos = []
for _ in range(n):
    bamboos.append(int(input()))

def get_best(li, goal):
    bam_mp_lis = {0: (-10, tuple())}
    li.sort()
    for i, v in enumerate(li):
        tmp = bam_mp_lis.copy()
        for bam, (mp, lis) in tmp.items():
            b0 = bam + v
            m0 = mp + 10
            l0 = lis + (i,)
            if b0 not in bam_mp_lis or m0 < bam_mp_lis[b0][0]:
                bam_mp_lis[b0] = (m0, l0)
    del bam_mp_lis[0]
    best = 10 ** 9
    for bam, (mp, lis) in bam_mp_lis.items():
        cost = mp + abs(goal - bam)
        if cost < best:
            best = cost
            beslis = lis
    return best, beslis

ans = 10 ** 9
from itertools import permutations
for junjo in permutations(goals):
    tmp = 0
    bambooo = bamboos.copy()
    for ju in junjo:
        if len(bambooo) == 0:
            tmp = 10 ** 9
            break
        be, beli = get_best(bambooo, ju)
        beli = sorted(beli, reverse=True)
        for beli0 in beli:
            del bambooo[beli0]
        tmp += be
    if tmp < ans:
        ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b, c = list(map(int, input().split()))
goals = [a, b, c]
bamboos = []
for _ in range(n):
    bamboos.append(int(input()))

def get_best(li, goal):
    bam_mp_lis = {0: (-10, tuple())}
    li.sort()
    for i, v in enumerate(li):
        tmp = bam_mp_lis.copy()
        for bam, (mp, lis) in tmp.items():
            b0 = bam + v
            m0 = mp + 10
            l0 = lis + (i,)
            if b0 not in bam_mp_lis or m0 < bam_mp_lis[b0][0]:
                bam_mp_lis[b0] = (m0, l0)
    del bam_mp_lis[0]
    best = 10 ** 9
    for bam, (mp, lis) in bam_mp_lis.items():
        cost = mp + abs(goal - bam)
        if cost < best:
            best = cost
            beslis = lis
    return best, beslis

ans = 10 ** 9
from itertools import permutations
for junjo in permutations(goals):
    tmp = 0
    bambooo = bamboos.copy()
    for ju in junjo:
        be, beli = get_best(bambooo, ju)
        beli = sorted(beli, reverse=True)
        for beli0 in beli:
            del bambooo[beli0]
        tmp += be
    if tmp < ans:
        ans = tmp

print(ans)
Problem p03112 (python)

Fixed submission:
import bisect
A, B, Q = list(map(int, input().split()))
S, T, X = [], [], []
for _ in range(A):
    S.append(int(input()))
for _ in range(B):
    T.append(int(input()))
for _ in range(Q):
    X.append(int(input()))
INF = 10 ** 12
S = [-INF] + S + [INF]
T = [-INF] + T + [INF]

for x in X:
    ans = INF
    sr = bisect.bisect_right(S, x)
    tr = bisect.bisect_right(T, x)
    for s in S[sr-1: sr+1]:
        for t in T[tr-1: tr+1]:
            ans = min(ans, abs(s-x) + abs(s-t), abs(t-x) + abs(s-t))
    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
A, B, Q = list(map(int, input().split()))
S, T, X = [-INF], [-INF], []
for _ in range(A):
    S.append(int(input()))
for _ in range(B):
    T.append(int(input()))
for _ in range(Q):
    X.append(int(input()))
INF = 10 ** 12
S.append(INF)
T.append(INF)

for x in X:
    ans = INF
    sr = bisect.bisect_right(S, x)
    tr = bisect.bisect_right(T, x)
    for s in S[sr-1: sr+1]:
        for t in T[tr-1: tr+1]:
            ans = min(ans, abs(s-x) + abs(s-t), abs(t-x) + abs(s-t))
    print(ans)

Buggy submission (verdict: Runtime Error):
a, b, q = list(map(int, input().split()))
ss, tt, xx = [], [], []
for _ in range(a):
    ss.append(int(input()))
for _ in range(b):
    tt.append(int(input()))
for _ in range(q):
    xx.append(int(input()))

ss.sort()
tt.sort()

import bisect
def get_left(aa, bb, pos):
    a1 = bisect.bisect_left(aa, pos)
    b1 = bisect.bisect_left(bb, pos)
    if a1 == b1 == 0:
        return 10 ** 9
    if a1 == 0 or (b1 > 0 and bb[b1 - 1] > aa[a1 - 1]):
        dists = [10 ** 9]
        if a1 < len(aa):
            dists.append(pos - bb[b1 - 1] + aa[a1] - bb[b1 - 1])
        if a1 > 0:
            dists.append(pos - aa[a1 - 1])
        return min(dists)
    dists = [10 ** 9]
    if b1 < len(bb):
        dists.append(pos - aa[a1 - 1] + bb[b1] - aa[a1 - 1])
    if b1 > 0:
        dists.append(pos - bb[b1 - 1])
    return min(dists)

def get_right(aa, bb, pos):
    a1 = bisect.bisect_left(aa, pos)
    b1 = bisect.bisect_left(bb, pos)
    if a1 == len(aa) and b1 == len(bb):
        return 10 ** 9
    if a1 == len(aa) or (b1 < len(bb) and bb[b1] < aa[a1]):
        dists = [10 ** 9]
        if a1 > 0:
            dists.append(- pos + bb[b1] - aa[a1 - 1] + bb[b1])
        if a1 < len(aa):
            dists.append(aa[a1] - pos)
        return min(dists)
    dists = [10 ** 9]
    if b1 > 0:
        dists.append(- pos + aa[a1] - bb[b1 - 1] + aa[a1])
    if b1 > 0:
        dists.append(bb[b1] - pos)
    return min(dists)

for x in xx:
    print(min(get_left(ss, tt, x), get_right(ss, tt, x)))
Problem p03418 (python)

Fixed submission:
n, k = list(map(int, input().split()))

ans = 0
if k == 0:
    ans = n * n
else:
    for b in range(k + 1, n + 1):
        ans += n // b * (b - k)
        ans += max(0, (n - (n // b * b)) - k + 1)

print(ans)

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

ans = 0
if k = 0:
    ans = n * n
else:
    for b in range(k + 1, n + 1):
        ans += n // b * (b - k)
        ans += max(0, (n - (n // b * b)) - k + 1)

print(ans)
Problem p03469 (python)

Fixed submission:
s = input()
s = s.replace('2017', '2018')
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
s[3] = '8'
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
s[3] = 8
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
s[3] = [8]
print(s)
Problem p03550 (python)

Fixed submission:
n, z, w = list(map(int, input().split()))
li = list(map(int, input().split()))

ans = abs(w - li[-1])
if len(li) > 1:
    ans = max(ans, abs(li[-1] - li[-2]))

print(ans)

Buggy submission (verdict: Runtime Error):
n, z, w = list(map(int, input().split()))
li = list(map(int, input().split()))

ans = max(abs(w - li[-1]), abs(li[-1] - li[-2]))

print(ans)