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

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

nodes = [0 for _ in range(N)]

parents = {}
for _ in range(N-1):
  a, b = map(int, input().split())
  parents[b] = a

for _ in range(Q):
  p, x = map(int, input().split())
  nodes[p-1] += x

for i in range(N):
  if i+1 in parents:
    nodes[i] += nodes[parents[i+1]-1]

print(" ".join(map(str, nodes)))

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

def find(nodes, key):
  if len(nodes[key]) == 1:
    return [key]
  else:
    x = [key]
    for node in nodes[key]:
      if key != node:
        x.extend(find(nodes, node))
    return x

nodes = {}
nodes_p = {}
for _ in range(N-1):
  a,b = map(int, input().split())
  if a in nodes:
    nodes[a].append(b)
  else:
    nodes_p[a] = 0
    nodes[a] = [a]
    nodes[a].append(b)

  if b not in nodes:
    nodes_p[b] = 0
    nodes[b] = [b]

for key in nodes:
  nodes[key] = find(nodes, key)

for _ in range(Q):
  p, x = map(int, input().split())
  for key in nodes[p]:
    nodes_p[key] += x

print(" ".join(map(str, [ v for v in nodes_p.values()])))

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

def find(nodes, dp, key):
  if len(nodes[key]) == 1:
    return [key]
  else:
    x = [key]
    for node in nodes[key]:
      if key != node:
        if node in dp:
          x.extend(dp[node])
        else:
          x.extend(find(nodes, dp, node))
    return x

nodes = {}
nodes_p = {}
for _ in range(N-1):
  a,b = map(int, input().split())
  if a in nodes:
    nodes[a].append(b)
  else:
    nodes_p[a] = 0
    nodes[a] = [a]
    nodes[a].append(b)

  if b not in nodes:
    nodes_p[b] = 0
    nodes[b] = [b]

dp = {}
for _ in range(Q):
  p, x = map(int, input().split())
  if p in dp:
    for key in dp[p]:
      nodes_p[key] += x
  else:
    dp[p] = find(nodes, dp, p)
    for key in dp[p]:
      nodes_p[key] += x

print(" ".join(map(str, [ v for v in nodes_p.values()])))
Problem p02947 (python)

Fixed submission:
N = int(input())
s = ["".join(sorted(input())) for _ in range(N)]

mp = {}
for c in s:
    if c in mp:
        mp[c] += 1
    else:
        mp[c] = 1

ans = 0
for key in mp.keys():
    ans += mp[key]*(mp[key]-1)/2
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
s = ["".join(sorted(input())) for _ in range(N)]
cnt = 0

for c in s:
  if len(s) == 0:
    break
  amnt = len(list(filter(lambda x: x == c, s[s.index(c)+1:])))
  cnt += amnt
  cnt += (sum(range(1, amnt)))
  s = list(filter(lambda x: x != c, s))

print(cnt)
Problem p02612 (python)

Fixed submission:
a = int(input().rstrip())
n = [i for i in range(1,11) if(a <=i *1000)]
print((min(n)*1000) - a)

Buggy submission (verdict: Runtime Error):
n = int(input().rstrip())
s = [str(input().rstrip()) for i in range(n)]
print("AC ×",s.count("AC"))
print("WA ×",s.count("WA"))
print("TLE ×",s.count("TLE"))
print("RE ×",s.count("RE"))
Problem p02613 (python)

Fixed submission:
n = int(input().rstrip())
s = [str(input().rstrip()) for i in range(n)]
for v in ["AC","WA","TLE","RE"]:
         print(f"{v} x {s.count(v)}")

Buggy submission (verdict: Runtime Error):
n = int(input().rstrip())
s = [str(input().rstrip()z) for i in range(n)]
for v in ["AC","WE","TLE","RE"]
         print(f"{v} x {s.count(v)}")
Problem p02717 (python)

Fixed submission:
x,y,z =map(int,input().split())
t=0
t=x;x=y;y=t;
t=x;x=z;z=t;
print(x,y,z)

Buggy submission (verdict: Runtime Error):
x,y,z =map(int,input().splilt())
t=0
t=x;x=y;y=t;
t=x;x=z;z=t;
print(x,y,z)
Problem p03377 (python)

Fixed submission:
a,b,x = map(int,input().split())
print("YES" if a<=x and (a+b)>=x else "NO")

Buggy submission (verdict: Runtime Error):
    a,b,x = map(int,input().split())
    print("YES" if (a+b)>=x else "NO")
Problem p03415 (python)

Fixed submission:
c1 = input()
c2 = input()
c3 = input()
print(c1[0]+c2[1]+c3[2])

Buggy submission (verdict: Runtime Error):
c1 = input().split()
c2 = input().split()
c3 = input().split()
print(c1[0]+c2[1]+c3[2])

Buggy submission (verdict: Runtime Error):
c1 = input().split()
c2 = input().split()
c3 = input().split()
print(c1[0]+c2[1]+c3[3])
Problem p03447 (python)

Fixed submission:
x=int(input())
a=int(input())
b=int(input())
print((x-a)%b)

Buggy submission (verdict: Runtime Error):
x,a,b = map(int,input().split())
print((x-a)%b)
Problem p03455 (python)

Fixed submission:
a,b =map(int,input().split())
print("Odd" if (a*b)%2!=0 else "Even")

Buggy submission (verdict: Runtime Error):
a.b =map(int,input().split())
print("Odd" if (a*b)%2!=0 else "Even")
Problem p03485 (python)

Fixed submission:
a,b =map(int,input().split())
if (a+b)%2 ==0:
  print((a+b)//2)
else:
  print(((a+b)//2)+1)

Buggy submission (verdict: Runtime Error):
a,b =map(int,input().split())
if (a+b)% ==0:
  print((a+b)//2)
else:
  print(((a+b)//2)+1)
Problem p03547 (python)

Fixed submission:
a,b =input().split()
if a>b:
  print(">")
elif b>a:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
a,b =input().split()
if a.isalpha() > b.isalpha():
  print(">")
elif a.isalpha() < b.isalpha():
  print("<")
  else:
  print("=")
Problem p03555 (python)

Fixed submission:
c1 = input()
c2 = input()
print("YES" if c1==c2[-1::-1] else "NO")

Buggy submission (verdict: Runtime Error):
c1 = input()
c2 = input()
print("YES" if c1=c2[-1::-1] else "NO")
Problem p03597 (python)

Fixed submission:
n=int(input())
a = int(input())
print(n*n-a)

Buggy submission (verdict: Runtime Error):
n,a = map(int,input().split())
print(n**n-a)
Problem p03737 (python)

Fixed submission:
a,b,c =input().split()
print(a[0].upper(),b[0].upper(),c[0].upper(),sep="")

Buggy submission (verdict: Runtime Error):
a,b,c =map(input().split())
print(a[0].isupper(),b[0].isupper(),c[0].isupper(),sep="")

Buggy submission (verdict: Runtime Error):
a,b,c =map(input().split())
print(a[0],b[0],c[0],sep="")
Problem p03773 (python)

Fixed submission:
a,b = map(int,input().split())
print((a + b) % 24)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().splilt())
print((a + b) % 24)
Problem p03827 (python)

Fixed submission:
n =int(input())
s = input()
x,ans =0,0
for i in s:
  if i =="I":
    x +=1
    ans =max(x,ans)
  else:
    x-=1
    ans =max(x,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n =int(input())
s = input()
x = 0
for i in s:
  if i ="I": 
    x =max(x,x+1)
  else:
    x =max(x,x-1)
print(x)
Problem p03943 (python)

Fixed submission:
a,b,c = list(map(int,input().split()))
if a + b == c:
  print("Yes")
elif a + c == b:
  print("Yes")
elif b + c ==a:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c = int(input.split())
if a + b == c:
  print("Yes")
elif a + c == b:
  print("Yes")
elif b + c ==a:
  print("Yes")
else:
  print("No")
Problem p04011 (python)

Fixed submission:
n,k,x,y = [int(input()) for i in range(4)]
print(min(n,k) * x + max(n-k,0) * y)

Buggy submission (verdict: Runtime Error):
n,k,x,y = [int(input) for i in range(4)]
print(min(n,k) * x + max(n-k,0) * y)

Buggy submission (verdict: Runtime Error):
n = int(input())
k,x,y = [int(input()) for i in range(n)]
print(k * x + (n - k) * y) if n > k else print(k * x)
Problem p04043 (python)

Fixed submission:
a = list(map(int,input().split()))
if sum(a) == 17 and a.count(5) == 2:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a =list(map(int,input().split()))
if a+b+c ==19 and a.count("7") ==2:
  print("Yes")
else:
  print("No")
Problem p04044 (python)

Fixed submission:
n,l =map(int,input().split())
ss = [input() for _ in range(n)]
s =sorted(ss)
ans =""
for i in s:
  ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
n,l = map(int,input().split())
s =[input() for _ in range(n)]
ss = sorted(s)
print(ss[0]+ss[1]+ss[2])
Problem p02993 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(S: str):
    for i in range(len(S) - 1):
        if S[i] == S[i+1]:
            return 'Bad'
    return 'Good'


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: str
    print(solve(S))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from collections import namedtuple
import functools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    for i in range(N):
        min_length = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
        travel_time = t[i+1] - t[i]

        if min_length > travel_time:
            return NO
        elif min_length == travel_time:
            next
        elif (travel_time - min_length) % 2 == 0:
            next
        else:
            return NO

    return YES


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [int()] * (N)  # type: "List[int]" 
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        t[i] = int(next(tokens))
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    t.insert(0, 0)
    x.insert(0, 0)
    y.insert(0, 0)
    print(solve(N, t, x, y))

if __name__ == '__main__':
    main()
Problem p02995 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
import fractions

def solve(A: int, B: int, C: int, D: int):
    def can_div_by(x: int):
        return (B // x) - (A - 1) // x

    c = can_div_by(C)
    d = can_div_by(D)
    cd = can_div_by(C*D // fractions.gcd(C, D))
    return B - A + 1 - (c + d - cd)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    print(solve(A, B, C, D))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import math

def solve(A: int, B: int, C: int, D: int):
    def can_div_by(x: int):
        return (B // x) - (A - 1) // x

    c = can_div_by(C)
    d = can_div_by(D)
    cd = can_div_by(C*D // math.gcd(C, D))
    return B - A + 1 - (c + d - cd)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    print(solve(A, B, C, D))

if __name__ == '__main__':
    main()
Problem p03695 (python)

Fixed submission:
import sys

def main():
    N = int(input())
    a = list(map(int, input().split()))
    colors = [0] * 9 # 8色 + 任意の1色
    for rate in a:
        colors[min(rate // 400, 8)] += 1

    used = 0
    for c in colors[0:8]:
        if c != 0:
            used += 1

    mn = max(used, 1)
    mx = used + colors[8]
    print(mn, mx)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from functools import reduce

def solve():
    pass

def main():
    N = int(input())
    a = list(map(int, input().split()))
    colors = [0] * 9 # 8色 + 任意の1色
    for rate in a:
        colors[rate // 400] += 1

    mn = 0
    for c in colors[0:8]:
        if c != 0:
            mn += 1

    mx = mn + min(8 - mn, colors[8])
    print(mn, mx)

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

Fixed submission:
n, a, b = map(int, input().split())
print(min(n * a, b))

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
print(min(m * a, b))
Problem p03102 (python)

Fixed submission:
n, m, c = map(int, input().split())
bl = [int(i) for i in input().split()]
ans = 0
for i in range(n):
  al = [int(j) for j in input().split()]
  ans += sum([bl[j] * al[j] for j in range(m)]) + c > 0
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, c = map(int, input().split())
bl = [int(i) for i in input().split()]
ans = 0
for i in range(n):
  al = [int(j) for j in input().split()]
  ans += sum([bl[j] * al[j] for j in range(m)) + c > 0
print(ans)
Problem p03110 (python)

Fixed submission:
n = int(input())
ans = 0
d = { 'JPY': 1, 'BTC': 380000.0}
for _ in range(n):
  a, b = input().split()
  ans += float(a) * d[b]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
d = { 'JPY': 1, 'BTC': 380000.0}
for _ in range(n):
  a, b = input().split()
  ans += int(a) * d[b]
print(ans)
Problem p03125 (python)

Fixed submission:
a, b = map(int, input().split())
print((a + b) if b % a == 0 else (b - a))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict
import itertools

def solve():
    t = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    dt = {0:0, 1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

    n, m = map(int, input().split())
    al = [int(i) for i in input().split()]
    al.sort(reverse=True)
    d = defaultdict(list)
    for i in al:
        d[dt[i]].append(i)
    k = list(sorted(d.keys()))
    ans = ''
    if n % k[0] == 0:
        ans += str(d[k[0]][0]) * (n // k[0])
    else:
        p = n % k[0]
        s = []
        k1 = k[1:]
        for i in range(9, 0, -1):
            if i > len(k1):
                continue
            for j in list(itertools.combinations(k1, i)):
                l = [dt[w] for w in j]
                if p == sum(l) % k[0]:
                    s.append(list(j))
        mt, ma, mx = 10 ** 20, [0] * 5, 0
        tans = [None] * len(s)
        for idx, i in enumerate(s):
            i.sort(reverse=True)
            _tans = ''.join([str(d[w][0]) for w in i])
            _tans += str(d[k[0]][0]) * ((n - sum(i)) // k[0])
            _tans = list(_tans)
            _tans.sort(reverse=True)
            tans[idx] = (''.join(_tans))
        ans = 0
        for i in tans:
            ans = max(ans, int(i))
        ans = str(ans)
    ans = list(ans)
    ans.sort(reverse=True)
    print(''.join(ans))


if __name__=="__main__":
    solve()
Problem p03206 (python)

Fixed submission:
d = int(input())
if d == 25:
  print("Christmas")
elif d == 24:
  print("Christmas Eve")
elif d == 23:
  print("Christmas Eve Eve")
elif d == 22:
  print("Christmas Eve Eve Eve")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

al = [0, 5] + [0] * 49
bl = [0, 3] + [0] * 49


def solve2(ans, x, idx, cnt):
    if idx == 1:
        return ans + (0, 0, 1, 2, 3, 3, 3)[x] + [0, 1][cnt >= 1]
    if x == (al[idx] // 2) + 1:
        return ans + bl[idx - 1] + 1 + [0, 1][cnt >= 1]
    elif x > (al[idx] // 2) + 1:
        ans += bl[idx - 1]
        x -= (al[idx] // 2)
        cnt += 1
    return solve2(ans, x, idx - 1, cnt)


def solve():
    n, x = map(int, input().split())
    for i in range(2, n + 1):
        al[i] = al[i - 1] * 2 + 3
        bl[i] = bl[i - 1] * 2 + 1
    ans = solve2(0, x, n, 0)
    print(ans)


if __name__ == "__main__":
    solve()
Problem p03276 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import bisect


def solve():
    n, k = map(int, input().split())
    al = [int(i) for i in input().split()]

    ans = sum(abs(i) for i in al)
    flag0 = 0 in al
    if flag0:
        k -= 1
        n -= 1
        if k == 0:
            print(0)
            return
        al.remove(0)
    nc = bisect.bisect_left(al, 0)
    for i in range(n):
        if i < 0 or i + k - 1 >= n:
            break
        if al[i] < 0 and al[i + k - 1] < 0:
            t1 = abs(al[i])
        else:
            t1 = min(abs(al[i]) * 2 + abs(al[i + k - 1]),
                     abs(al[i]) + abs(al[i + k - 1]) * 2)
        if al[i] > 0 and al[i + k - 1] > 0:
            t2 = abs(al[i + k - 1])
        else:
            t2 = min(abs(al[i]) * 2 + abs(al[i + k - 1]),
                     abs(al[i]) + abs(al[i + k - 1]) * 2)
        t = min(t1, t2)
        ans = min(ans, t)
    for i in range(n - 1, -1, -1):
        if i - k + 1 < 0 or i >= n:
            break
        if al[i] < 0 and al[i - k + 1] < 0:
            t1 = abs(al[i - k + 1])
        else:
            t1 = min(abs(al[i - k + 1]) * 2 + abs(al[i]),
                     abs(al[i - k + 1]) + abs(al[i]) * 2)
        if al[i] > 0 and al[i - k + 1] > 0:
            t1 = abs(al[i])
        else:
            t2 = min(abs(al[i - k + 1]) * 2 + abs(al[i]),
                     abs(al[i - k + 1]) + abs(al[i]) * 2)
        t = min(t1, t2)
        ans = min(ans, t)
    print(ans)


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import bisect


def solve():
    n, k = map(int, input().split())
    al = [int(i) for i in input().split()]

    ans = sum(abs(i) for i in al)
    flag0 = 0 in al
    if flag0:
        k -= 1
        n -= 1
        if k == 0:
            print(0)
            return
        al.remove(0)
    nc = bisect.bisect_left(al, 0)
    for i in range(n):
        if i < 0 or i + k - 1 >= n:
            break
        if al[i] < 0 and al[i + k - 1] < 0:
            t1 = min(abs(al[i], al[i + k - 1]))
        else:
            t1 = min(abs(al[i]) * 2 + abs(al[i + k - 1]),
                     abs(al[i]) + abs(al[i + k - 1]) * 2)
        if al[i] > 0 and al[i + k - 1] > 0:
            t2 = min(abs(al[i], al[i + k - 1]))
        else:
            t2 = min(abs(al[i]) * 2 + abs(al[i + k - 1]),
                     abs(al[i]) + abs(al[i + k - 1]) * 2)
        t = min(t1, t2)
        ans = min(ans, t)
    for i in range(n - 1, -1, -1):
        if i - k + 1 < 0 or i >= n:
            break
        if al[i] < 0 and al[i - k + 1] < 0:
            t1 = abs(al[i - k + 1], al[i])
        else:
            t1 = min(abs(al[i - k + 1]) * 2 + abs(al[i]),
                     abs(al[i - k + 1]) + abs(al[i]) * 2)
        if al[i] > 0 and al[i - k + 1] > 0:
            t2 = abs(al[i - k + 1], al[i])
        else:
            t2 = min(abs(al[i - k + 1]) * 2 + abs(al[i]),
                     abs(al[i - k + 1]) + abs(al[i]) * 2)
        t = min(t1, t2)
        ans = min(ans, t)
    print(ans)


if __name__ == "__main__":
    solve()
Problem p03282 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve():
    s = input()
    n = int(input())
    idx = 0
    slen = len(s)
    while idx < slen and s[idx] == "1":
        idx += 1
        if idx == n:
            print(1)
            return
    if idx == slen:
        print(1)
    else:
        print(s[idx])


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve():
    s = input()
    n = int(input())
    idx = 0
    while s[idx] == "1":
        idx += 1
    if idx == len(s):
        print(1)
    else:
        print(s[idx])


if __name__ == "__main__":
    solve()
Problem p03304 (python)

Fixed submission:
print((lambda n, m, d: (m - 1) / (n * n) * (n if d == 0 else (2 * (n - d))))(*map(int, input().split())))

Buggy submission (verdict: Runtime Error):
print((lambda n,m,d:(m-1)/(n*n)*([n,2*(n-d))][d>0]))(*map(int,input().split())))
Problem p03308 (python)

Fixed submission:
p=input;p();a=sorted([int(i)for i in p().split()]);print(a[-1]-a[0])

Buggy submission (verdict: Runtime Error):
p=input;p();a=map(int,p().split());print(max(a)-min(a))
Problem p03316 (python)

Fixed submission:
print(*["YNeos"[(int(s)%sum(int(i)for i in s))>0::2]for s in[input()]])

Buggy submission (verdict: Runtime Error):
print(*["YNeos"[(int(s)%sum(int(i))for i in s)>0::2]for s in[input()]])

Buggy submission (verdict: Runtime Error):
print(*[["Yes","No"][int(s)%sum(int(i)for i in s)]for s in[input()]])
Problem p03337 (python)

Fixed submission:
print((lambda x:max(eval(x[0]+c+x[1])for c in"*+-"))(input().split()))

Buggy submission (verdict: Runtime Error):
print((lambda x:max(eval(x[0]+c+x[1])for c in"*+-"))(input()))
Problem p03338 (python)

Fixed submission:
p=input;n,s=int(p()),p();print(max(len(set(s[:i])&set(s[i:]))for i in range(n)))

Buggy submission (verdict: Runtime Error):
p=input;n,s=p(),p();print(max(len(set(s[:i])&set(s[i:]))for i in range(n)))
Problem p03351 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
print(["No","Yes"][abs(a-c)<=d or (abs(a-b) <= d and abs(b-c)<=d)])

Buggy submission (verdict: Runtime Error):
x,ans=int(input()),1
for i in range(int(x**0.5)+1):
  ans = max(ans, max(i**j for j in range(10) if i**j<=x))
print(ans)
Problem p03352 (python)

Fixed submission:
x,ans=int(input()),1
for i in range(int(x**0.5)+1):
  ans = max(ans, max(i**j for j in range(10) if i**j<=x))
print(ans)

Buggy submission (verdict: Runtime Error):
print(max([max(i**j for j in range(10) if i**j<=x) for i in range(x)] for x in range(int(input())**0.5+1)))
Problem p03360 (python)

Fixed submission:
p=input;a=[int(i)for i in p().split()];m=max(a);print(sum(a)-m+m*2**int(p()))

Buggy submission (verdict: Runtime Error):
p=input;a=[i for i in p().split()];print(sum(a)+max(a)*2**int(p()))

Buggy submission (verdict: Runtime Error):
p=input;a=map(int,p().split());print(sum(a)+max(a)*2**int(p()))
Problem p03361 (python)

Fixed submission:
h, w = map(int, input().split())
table = [list(input()) for _ in range(h)]
visited = [["." for _ in range(w)] for _ in range(h)]

mx = [0, 1, 0, -1]
my = [1, 0, -1, 0]
for i in range(h):
  for  j in range(w):
    if table[i][j] == "#":
      for k in range(4):
        tx, ty = j + mx[k], i + my[k]
        if 0 <= tx < w and 0 <= ty < h and table[ty][tx] == "#":
          visited[i][j] = visited[ty][tx] = "#"

for i in range(h):
  for  j in range(w):
    if table[i][j] != visited[i][j]:
      print("No")
      exit(0)
print("Yes")

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
table = [list(input()) for _ in range(h))
visited = [["." for _ in range(w)] for _ in range(h)]

mx = [0, 1, 0, -1]
my = [1, 0, -1, 0]
for i in range(h):
  for  j in range(w):
    if table[i][j] == "#":
      for k in range(4):
        tx, ty = j + mx[k], i + my[k]
        if 0 <= tx <= w and 0 <= ty <= h and table[ty][tx] == "#":
          visited[i][j] = visited[ty][tx] = "#"

for i in range(h):
  for  j in range(w):
    if table[i][j] != visited[i][j]:
      print("No")
      exit(0)
print("Yes")
Problem p03370 (python)

Fixed submission:
n, x = map(int, input().split())
l = [int(input()) for _ in range(n)]
print(n+(x-sum(l))//min(l))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = [int(i) for i in range(n)]
print(n+(x-sum(l))//min(l))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = [int(i) for i in range(n)]
print(n+((x-sum(l))//min(l))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = [int(i) for i in range(n)]
print(n+((x-sum(l))//min(l)))
Problem p03385 (python)

Fixed submission:
print(["No","Yes"]["".join(sorted(input()))=="abc"])

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
s = set()
for i in [j for j in range(a, min(b + 1, a + x))] :
  print(i)
  s.add(i)
for i in [j for j in range(max(a, b - x + 1), b + 1)] :
  if i not in s:
    print(i)

Buggy submission (verdict: Runtime Error):
print(["No","Yes"][input().sort()=="abc"])