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

Fixed submission:
N = int(input())
a = [int(n) for n in input().split()]
print(sum(a)-N)

Buggy submission (verdict: Runtime Error):
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
i = 0
Mb = B[0]
while Mb > Ma:
  i += 1
  if i == N:
    Mb = 0
    B = B[:i]
  else:
    Mb = B[i]
H -= sum(B)
print(i+int(-(-H//Ma)))

Buggy submission (verdict: Runtime Error):
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
C = 0
i = 0
while i < len(B) and B[i] > Ma:
  i += 1
H -= sum(B[:i])
print(i+int(-(-H//Ma)))
Problem p03415 (python)

Fixed submission:
x = input()
y = input()
z = input()

print(x[0] + y[1] + z[2])

Buggy submission (verdict: Runtime Error):
x = input()
y = input()
z = input()

print(x[1] + y[2] + z[3])
Problem p03485 (python)

Fixed submission:
a,b = map(int,input().split())
print(-int((-a-b)//2))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
print(-int((-a-b)//2)
Problem p03495 (python)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
import collections
c = collections.Counter(A)
print(N - sum([pair[1] for pair in c.most_common(K)]))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
import collections
c = collections.Counter(A)
ans = N
for k in range(K):
    n = c.most_common()[k][0]
    ans -= c[n]
print(ans)
Problem p03555 (python)

Fixed submission:
C1 = list(input())
C2 = list(input())
C2.reverse()
if C1 == C2:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
C1 = input()
C2 = input()
C2.reverse()
if C1 == C2:
  print('YES')
else:
  print('NO')
Problem p02730 (python)

Fixed submission:
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    S = get_input()

    def is_palindrome(s):
        if len(s) == 1:
            return True
        else:
            first = s[:len(s)//2]
            last = s[len(s)//2 + 1:]
            return s == s[::-1] and first == first[::-1] and last == last[::-1]

    if is_palindrome(S):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    S = get_input()

    def is_palindrome(s):
        if len(s) == 1:
            return True
        else:
            return s == s[::-1] and is_palindrome(s[:len(s)//2]) and is_palindrome(s[len(s)//2 + 1:])

    if is_palindrome(S):
        print("Yes")
    else:
        print("No")


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

Fixed submission:
import numpy as np
import copy
from collections import defaultdict
from heapq import heappush, heappop


def djkstra(adj_mat, src):
    dist = defaultdict(lambda: np.inf)
    dist[src] = 0

    prev = defaultdict(lambda: None)

    queue = []
    heappush(queue, (dist[src], src))

    while len(queue) > 0:
        dist_u, u = heappop(queue)
        vs = np.argwhere(adj_mat[u] > 0).flatten()
        for v in vs:
            weight = adj_mat[u, v]
            alt = dist_u + weight
            if alt < dist[v]:
                dist[v] = alt
                prev[v] = u
                heappush(queue, (alt, v))
    visited_edges = np.zeros_like(adj_mat, dtype=np.int32)

    for v in range(adj_mat.shape[0]):
        u = prev[v]
        if u is not None:
            visited_edges[u, v] = 1
            visited_edges[v, u] = 1

    return visited_edges


def main():
    N, M = map(int, input().split())
    adj_mat = np.zeros((N, N), dtype=np.int32)
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        adj_mat[a, b] = c
        adj_mat[b, a] = c

    visited_edge_count = np.sum(
        np.concatenate([djkstra(adj_mat, src)[np.newaxis, :, :] for src in range(N)], axis=0), axis=0)
    out = np.sum(np.logical_and(adj_mat > 0, visited_edge_count == 0)) // 2
    print(out)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import copy
from collections import defaultdict
from heapq import heappush, heappop


def djkstra(adj_mat, src):
    dist = defaultdict(lambda: np.inf)
    dist[src] = 0

    prev = defaultdict(lambda: None)

    queue = []
    heappush(queue, (dist[src], src))

    while len(queue) > 0:
        dist_u, u = heappop(queue)
        vs = np.argwhere(adj_mat[u] > 0).flatten()
        for v in vs:
            weight = adj_mat[u, v]
            alt = dist_u + weight
            if alt < dist[v]:
                dist[v] = alt
                prev[v] = u
                heappush(queue, (alt, v))
    visited_edges = np.zeros_like(adj_mat, dtype=np.int32)

    for v in range(adj_mat.shape[0]):
        u = prev[v]
        if u is not None:
            visited_edges[u, v] = 1
            visited_edges[v, u] = 1

    return visited_edges


def main():
    N, M = map(int, input().split())
    adj_mat = np.zeros((N, N), dtype=np.int32)
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        adj_mat[a, b] = c
        adj_mat[b, a] = c

    visited_edge_count = np.sum(
        np.stack([djkstra(adj_mat, src)[np.newaxis, :, :] for src in range(N)], axis=0), axis=0)
    out = np.sum(np.logical_and(adj_mat > 0, visited_edge_count == 0)) // 2
    print(out)


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

Fixed submission:
n,m,x=map(int,input().split())
from itertools import combinations
l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
l1=[]
for i in range(n):
    l1.append(i)
l2=[]
for i in range(1,n+1):
    lx=[0]*i
    lyy=[0]*m
    for lx in combinations(l1,i):
        ly=lyy.copy()
        a=0
        for p in range(1,m+1):
            for k in lx:
                ly[p-1]+=l[k][p]
        for k in lx:
            a+=l[k][0]
        for j in ly:
            if j<x:
                a=0
                break
        if a!=0:
            l2.append(a)
if len(l2)!=0:
    print(min(l2))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
from itertools import combinations
l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
l1=[]
for i in range(m):
    l1.append(i)
l2=[]
for i in range(1,m+1):
    lx=[0]*i
    a=0
    for lx in combinations(l1,i):
        ly=[0]*m
        for p in range(1,m+1):
            for k in lx:
                ly[p-1]+=l[k][p]
        for k in lx:
            a+=l[k][0]
        for j in ly:
            if j<x:
                a=0
                break
        if a!=0:
            l2.append(a)
print(min(l2))
Problem p02700 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
ans=0
while a>0 and c>0:
    c-=b
    ans+=1
    if c<=0:
        break
    a-=d
    ans+=1
    if a<=0:
        break
if ans%2==0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if max(a)>max(b):
    print('Yes')
elif max(a)==max(b):
    if a+b>=c+d:
        print('Yes')
    else:
        print('No')
else:
    if min(a,b)>=min(c,d):
        print('Yes')
    else:
        print('No')
Problem p03160 (python)

Fixed submission:
n=input()
from sys import stdin,stdout
l=list(map(int,stdin.readline().split()))
l1=[0,abs(l[1]-l[0])]
for i in range(2,n):
    l1.append(min(abs(l[i-1]-l[i])+l1[-1],abs(l[i-2]-l[i])+l1[-2]))
stdout.write(str(l1[-1])+'\n')

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
a=[0]*(w+1)
for i in range(n):
    b=a.copy()
    x,y=map(int,input().split())
    for j in range(min(x,w),w+1):
        b[j]=max(a[j-x]+y,a[j])
    a=b.copy()
print(max(a))
Problem p03163 (python)

Fixed submission:
n,w=map(int,input().split())
from copy import copy
a=[0]*(w+1)
for i in range(n):
    b=copy(a)
    x,y=map(int,input().split())
    for j in range(min(x,w),w+1):
        b[j]=max(a[j-x]+y,a[j])
    a=copy(b)
print(max(a))

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
a=[0]*(w+1)
for i in range(n):
    b=a.copy()
    x,y=map(int,input().split())
    for j in range(min(x,w),w+1):
        b[j]=max(a[j-x]+y,a[j])
    a=b.copy()
print(max(b))

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
a=[0]*(w+1)
for i in range(n):
    b=a.copy()
    x,y=map(int,input().split())
    for j in range(min(x,w),w+1):
        b[j]=max(a[j-x]+y,a[j])
    a=b.copy()
print(max(a))
Problem p03759 (python)

Fixed submission:
a, b, c = [ int(i) for i in input().split() ]
middle = (a + c)/2
 
if b == middle:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, raw_input().split)
middle = (a + c)/2

if b == middle:
  print("YES")
else:
  print("NO")
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())
print(W * H / 2, 1 if x != 0 and y != 0 and W / x == 2 and H / y == 2 else 0)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
print(W * H / 2, 1 if W / x == 2 and H / y == 2 else 0)
Problem p03076 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

if len([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0]) > 0:
    m = min([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0])
else:
    m = 10

print((a // 10 + (1 if a % 10 != 0 else 0)) * 10 + (b // 10 + (1 if b % 10 != 0 else 0)) * 10 + (c // 10 + (1 if c % 10 != 0 else 0)) * 10 + (d // 10 + (1 if d % 10 != 0 else 0)) * 10 + (e // 10 + (1 if e % 10 != 0 else 0)) * 10 - 10 + m)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

m = min([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0])

print((a // 10 + (1 if a % 10 != 0 else 0)) * 10 + (b // 10 + (1 if b % 10 != 0 else 0)) * 10 + (c // 10 + (1 if c % 10 != 0 else 0)) * 10 + (d // 10 + (1 if d % 10 != 0 else 0)) * 10 + (e // 10 + (1 if e % 10 != 0 else 0)) * 10 - 10 + m)
Problem p03525 (python)

Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()

l = {i: 0 for i in range(13)}

for d in D:
    l[d] += 1

possible_lists = [[]]

for k, v in l.items():
    if v > 2:
        possible_lists = [[0]]
        break
    elif v > 1:
        new = [[0]] + [pl + [k, 24-k] for pl in possible_lists]
        # new = [pl + [k, k] for pl in possible_lists] + [pl + [24-k, 24-k] for pl in possible_lists] + [pl + [k, 24-k] for pl in possible_lists]
        possible_lists = new
    elif v > 0:
        new = [pl + [k] for pl in possible_lists] + [pl + [24-k] for pl in possible_lists]
        possible_lists = new

Max = -1
for pl in possible_lists:
    Min = 13
    pl.sort()
    for i in range(len(pl)):
        if i == 0:
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        elif i == len(pl)-1:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        else:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
    Max = max(Min, Max)

print(Max)

Buggy submission (verdict: Runtime Error):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()

l = {i: 0 for i in range(13)}

for d in D:
    l[d] += 1

possible_lists = [[]]

for k, v in l.items():
    if v > 2:
        possible_lists = [0]
        break
    elif v > 1:
        new = [[0]] + [pl + [k, 24-k] for pl in possible_lists]
        # new = [pl + [k, k] for pl in possible_lists] + [pl + [24-k, 24-k] for pl in possible_lists] + [pl + [k, 24-k] for pl in possible_lists]
        possible_lists = new
    elif v > 0:
        new = [pl + [k] for pl in possible_lists] + [pl + [24-k] for pl in possible_lists]
        possible_lists = new

Max = -1
for pl in possible_lists:
    Min = 13
    pl.sort()
    for i in range(len(pl)):
        if i == 0:
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        elif i == len(pl)-1:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        else:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
    Max = max(Min, Max)

print(Max)
Problem p03633 (python)

Fixed submission:
import sys
import fractions

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

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

N = ir()
start = ir()
next = 0
for n in range(1, N):
    next = ir()
    start = lcm(start, next)

print(start)

Buggy submission (verdict: Runtime Error):
import sys
import math

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

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

N = ir()
start = ir()
next = 0
for n in range(1, N):
    next = ir()
    start = lcm(start, next)

print(start)
Problem p03645 (python)

Fixed submission:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
E = {i+1: set() for i in range(N)}
first = set()
for m in range(M):
    a, b = lr()
    if b == N:
        first.add(a)
    E[a].add(b)
if not first.isdisjoint(E[1]):
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")

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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
E = {i+1: [] for i in range(M)}
first = []
for m in range(M):
    a, b = lr()
    if b == N:
        first.append(a)
    E[a].append(b)
for f in first:
    if f in E[1]:
        print("POSSIBLE")
        exit(0)
print("IMPOSSIBLE")
Problem p02696 (python)

Fixed submission:
import math

def calc(x):
    return (math.floor(A*x/B) - A*math.floor(x/B))

A, B, N = map(int, input().split())
print(calc(min(B-1, N)))

Buggy submission (verdict: Runtime Error):
import math

def bisearch(function, ok, ng):
    tmp = 0
    while abs(ok-ng) > 1:
        mid = (ok + ng)//2
        ans = function(mid)
        if ans > tmp:
            ok = mid
        else:
            ng = mid
        print("mid:{}".format(mid))
        tmp = ans
    return ok

def calc(x):
    return (math.floor(A*x/B) - A*math.floor(x/B))

A, B, N = map(int, input().split())
ok = N
ng = 0

# print(bisearch(calc, ok, ng))
ans = []
tmp = calc(1)
for i in range(1, min(N+1)):
    a = calc(i)
    ans.append(a)
    if tmp > a:
        break
    tmp = a

print(max(ans))
Problem p02719 (python)

Fixed submission:
N, K = map(int, input().split())
ans = min(K-(N%K), N%K)
print(ans)

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

if K != 1:
    ans = N%(abs(N-K))
else:
    ans = 0
print(ans)
Problem p02727 (python)

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

anslist = p[:x] + q[:y]
anslist.sort()
for i, num in enumerate(r):
    if i >= x+y:
        break
    if num > anslist[i]:
        anslist[i] = num

print(sum(anslist))

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

anslist = p[:x] + q[:y]
anslist.sort()
for i, x in enumerate(r):
    if x > anslist[i]:
        anslist[i] = x

print(sum(anslist))
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
query = [list(input().split()) for _ in range(M)]
ans = -1
for num in range(10**N):
    if len(str(num)) != N:
        continue
    else:
        cnt = 0
        s = str(num)
        for sc in query:
            if s[int(sc[0])-1] == sc[1]:
                cnt += 1
        if cnt == M:
            ans = num
            break
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
query = [list(input().split()) for _ in range(M)]

for num in range(10**N):
    if len(str(num)) != N:
        continue
    else:
        cnt = 0
        s = str(num)
        for sc in query:
            if s[int(sc[0])-1] == sc[1]:
                cnt += 1
        if cnt == M:
            ans = num
            break
print(ans)
Problem p02953 (python)

Fixed submission:
#!/usr/bin/env python
import sys
n = int(input())
h = list(map(int, input().split()))
tmp = h[0]
for i in range(1, n):
    if h[i] - tmp == 0:
        tmp = h[i]
        continue
    elif h[i] - tmp >= 1:
        tmp = h[i] - 1
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys
n = int(input())
h = list(map(int, input().split()))
tmp = h[0]
for i in range(1, n):
    if h[i] - tmp == 0:
        tmp = h[i]
        continue
    elif h[i] - tmp >= 1:
        tmp = h[i] - 1
        continue
    else:
        print("No")
        sys.exit(1)
print("Yes")
Problem p03106 (python)

Fixed submission:
a, b, k = map(int, input().split())
devisors = [1]
for i in range(2, min(a, b)+1):
    if a%i == 0 and b%i == 0:
        devisors.append(i)
print(devisors[-k])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
devisors = [1]
for i in range(2, max(a, b)):
    if a%i == 0 and b%i == 0:
        devisors.append(i)
print(devisors[-k])
Problem p03130 (python)

Fixed submission:
x = []
f  = 1
for _ in range(3):
    x.extend(list(map(int,input().split())))
cnt = [0]*4
for i in range(6):
    cnt[x[i]-1] += 1
for a in cnt:
    if a > 2:
        f = 0
if f:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
import sys

x = []
for _ in range(3):
    x.extend(list(map(int,input().split())))
cnt = [0]*4
for i in range(6):
    cnt[x[i]-1] += 1
for a in cnt:
    if a > 2:
        print("NO")
        sys.exit(1)
print("YES")

Buggy submission (verdict: Runtime Error):
import sys

x = []
for _ in range(3):
    x.extend(list(map(int,input().split())))
a = b = c = d = 0
for i in range(6):
    if x[i] == 1:
        a += 1
    if x[i] == 2:
        b += 1
    if x[i] == 3:
        c += 1
    if x[i] == 4:
        d += 1
if a == 3:
    print("NO")
    sys.exit(1)
if b == 3:
    print("NO")
    sys.exit(1)
if c == 3:
    print("NO")
    sys.exit(1)
if d == 3:
    print("NO")
    sys.exit(1)
print("YES")

Buggy submission (verdict: Runtime Error):
import sys

x = []

for _ in range(3):
    x.extend(list(map(int,input().split())))
x.sort()
a = b = c = d = 0
for i in range(6):
    if x[i] == 1:
        a += 1
    elif x[i] == 2:
        b += 1
    elif x[i] == 3:
        c += 1
    else:
        d += 1
if a > 2 or a < 0:
    print("NO")
    sys.exit(1)
elif b > 2 or b < 0:
    print("NO")
    sys.exit(1)
elif c > 2 or c < 0:
    print("NO")
    sys.exit(1)
elif d > 2 or d < 0:
    print("NO")
    sys.exit(1)
print("YES")
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
ans  = True
for i in range(k):
    if s[i] != '1':
        print(s[i])
        ans = False
        break
if ans:
    print(1)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
cnt  = 0
ans  = False
for i in range(k):
    if s[i] != '1':
        print(s[i])
        ans = True
if ans:
    print(1)

Buggy submission (verdict: Runtime Error):
import sys

s = input()
k = int(input())
cnt  = 0
ans  = 0
while True:
    if cnt == len(s)-1:
        print("1")
        sys.exit(1)
    if s[cnt] != '1':
        print("{}".format(s[cnt]))
        sys.exit(1)
    cnt += 1

Buggy submission (verdict: Runtime Error):
import sys

s = input()
k = int(input())
cnt  = 0
ans  = 0
while True:
    if cnt == len(s):
        print("1")
        sys.exit(1)
    if s[cnt] != '1':
        print(s[cnt])
        sys.exit(1)
    cnt += 1

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
cnt  = 0
ans  = 0
while True:
    if cnt == len(s)-1:
        print("1")
        exit(1)
    if s[cnt] != '1':
        print(s[cnt])
        exit(1)
    cnt += 1

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
cnt  = 0
ans  = 0
while True:
    if cnt == len(s):
        print("1")
        exit(1)
    if s[cnt] != '1':
        print(s[cnt])
        exit(1)
    cnt += 1
Problem p03292 (python)

Fixed submission:
a = list(map(int,input().split()))
Min = min(a)
Max = max(a)
Mid = sum(a) - Max - Min
 
ans = Mid-Min + Max-Mid
print(ans)

Buggy submission (verdict: Runtime Error):
a = map(int,input().split())
Min = min(a)
Max = max(a)
Mid = sum(a) - Max - Min

ans = Mid-Min + Max-Mid
print(ans)
Problem p03424 (python)

Fixed submission:
n = input()
if len(set(input().split())) == 3:
	print("Three")
else:
	print("Four")

Buggy submission (verdict: Runtime Error):
n = input()
print(len(set(input().split()))
Problem p03564 (python)

Fixed submission:
n = int(input())
k = int(input())

ans = 1
for i in range(n):
    if ans*2 > ans + k:
        ans += k
    else:
        ans *= 2
print(ans)

Buggy submission (verdict: Runtime Error):
def check(arr, x, y):
    d = ((0, -1), (0, 1), (1, -1), (1, 0), (1, 1), (-1, -1), (-1, 0), (-1, 1))

    if arr[x][y] == '#':
        return -1
    else:
        cnt = 0
        for dx, dy in d:
            try:
                if (x+dx) >=0 and (y+dy) >= 0:
                    if arr[x + dx][y + dy] == '#':
                        cnt += 1
            except:
                pass
    return cnt    

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
ans = []
for x in range(h):
    for y in range(w):
        val = check(s, x, y)
        if val == -1:
            ans.append('#')
        else:
            ans.append(val)

for i in range(h*w):
    print(ans[i], end="")
    if (i+1)%w == 0:
        print()