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

Fixed submission:

import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

class Graph:
    def __init__(self, node_count, edge_count):
        self.node_count = node_count
        self.lst = [-1 for _ in range(node_count)]
        self.nxt = [0 for _ in range(edge_count)]
        self.to = [0 for _ in range(edge_count)]
        self.m = 0

    def add_edge(self, u, v, w):  # bidirection weight
        m = self.m
        self.nxt[m], self.lst[u], self.to[m] = self.lst[u], m, (v, w)
        self.m += 1

    def traverse(self, u):
        m = self.lst[u]
        while m != -1:
            yield self.to[m]
            m = self.nxt[m]


n,q=getints()
values = [0]*n
gr = Graph(n,2*n)

for _ in range(n-1):
    a,b=getints()
    a,b=a-1,b-1
    gr.add_edge(a,b,1)
    gr.add_edge(b,a,1)

for _ in range(q):
    u, p=getints()
    values[u-1] += p

def distribute(u, par, prev):
    stk = []
    stk.append((u, par, 0))
    while stk:
        u,par,prev=stk[-1]
        stk.pop()
        values[u] += prev
        for v, _ in gr.traverse(u):
            if v == par: continue
            stk.append((v,u,values[u]))

distribute(0, -1, 0)
print(" ".join(map(str, values)))

Buggy submission (verdict: Runtime Error):

import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

class Graph:
    def __init__(self, node_count, edge_count):
        self.node_count = node_count
        self.lst = [-1 for _ in range(node_count)]
        self.nxt = [0 for _ in range(edge_count)]
        self.to = [0 for _ in range(edge_count)]
        self.m = 0

    def add_edge(self, u, v, w):  # bidirection weight
        m = self.m
        self.nxt[m], self.lst[u], self.to[m] = self.lst[u], m, (v, w)
        self.m += 1

    def traverse(self, u):
        m = self.lst[u]
        while m != -1:
            yield self.to[m]
            m = self.nxt[m]


n,q=getints()
values = [0]*n
gr = Graph(n,2*n)

for _ in range(n-1):
    a,b=getints()
    a,b=a-1,b-1
    gr.add_edge(a,b,1)
    gr.add_edge(b,a,1)

for _ in range(q):
    u, p=getints()
    values[u-1] += p

def distribute(u, par, prev):
    values[u] += prev
    for v, _ in gr.traverse(u):
        if v == par: continue
        distribute(v, u, values[u])

distribute(0, -1, 0)
print(" ".join(map(str, values)))
Problem p02960 (python)

Fixed submission:
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = input()
n = len(s)
mod = 10 ** 9 + 7

dp = [[0]*13 for _ in range(n+1)]
dp[0][0]=1

for i in range(n):
    c = -1 if s[i] == '?' else ord(s[i]) - ord('0')
    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i+1][(ki*10+j)%13] += dp[i][ki]
    for j in range(13):
        dp[i+1][j] %= mod

res = dp[n][5]

print(res)

Buggy submission (verdict: Runtime Error):
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = list(reversed(input()))
n = len(s)
mod = 10 ** 9 + 7
digits=[0]*n

for i in range(n):
    digits[i] = (10 ** i) % 13


cache = [[-1]*13 for _ in range(n+1)]

def solve(pos, now):
    if pos >= n:
        return 1 if now == 5 else 0
    res = cache[pos][now]
    if res >= 0:
        return res
    res = 0
    if s[pos] == '?':
        for i in range(10):
            m = (now + i * digits[pos]) % 13
            res += solve(pos + 1, m)
    else:
        d = ord(s[pos]) - ord('0')
        m = (now + d * digits[pos]) % 13
        res += solve(pos + 1, m)
    res %= mod
    cache[pos][now] = res

    return res

for i in range(n-1,0,-1):
    solve(0,0)

print(solve(0, 0))

Buggy submission (verdict: Runtime Error):
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = list(reversed(input()))
n = len(s)
mod = 10 ** 9 + 7
digits=[0]*n

for i in range(n):
    digits[i] = (10 ** i) % 13


cache = [[-1]*13 for _ in range(n+1)]

def solve(pos, now):
    if pos >= n:
        return 1 if now == 5 else 0
    res = cache[pos][now]
    if res >= 0:
        return res
    res = 0
    if s[pos] == '?':
        for i in range(10):
            m = (now + i * digits[pos]) % 13
            res += solve(pos + 1, m)
    else:
        d = ord(s[pos]) - ord('0')
        m = (now + d * digits[pos]) % 13
        res += solve(pos + 1, m)
    res %= mod
    cache[pos][now] = res

    return res

for i in range(n-1,0,-1):
    solve(0,0)

print(solve(0, 0))
Problem p02988 (python)

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

def count(ps):
    if len(ps) <= 2:
        return 0
    qs = sorted(ps[0:3])
    res = 1 if qs[1] == ps[1] else 0
    return res + count(ps[1:])

print(count(ps))

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

def count(ps):
    if len(ps) <= 2:
        return 0
    qs = sorted(ps[0:3])
    res = 1 if qs[1] == ps[1] else 0
    return res + count(ps[1:])

print(count(ps))
Problem p02994 (python)

Fixed submission:

N, L = map(int, input().split())

t = list(map(lambda i: L + i, range(N)))

targ = sum(t)
m = 10000000000000
res = 0
for c in t:
    now = targ - c
    if m > abs(targ - now):
        m = abs(targ - now)
        res = now

print(res)

Buggy submission (verdict: Runtime Error):

N, L = map(int, input())

t = map(lambda i: L + i, range(N))

targ = sum(t)
res = 0
for c in t:
    now = targ - c
    if m > abs(targ - now):
        m = abs(targ - now)
        res = now

print(res)
Problem p02995 (python)

Fixed submission:

def gcd(x, y):
    while x % y > 0:
        x, y = y, x % y
    return y

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

cd = c * d // gcd(c, d)

res_b = b - b // c - b // d + b // cd
a -= 1
res_a = a - a // c - a // d + a // cd

print(res_b - res_a)

Buggy submission (verdict: Runtime Error):

import math

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

cd = c * d // math.gcd(c, d)

res_b = b - b // c - b // d + b // cd
a -= 1
res_a = a - a // c - a // d + a // cd


print(res_b - res_a)
Problem p03032 (python)

Fixed submission:


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,k = getints()
vs = getints()

res = 0
for take_operation in range(0, k + 1):
    sute_operation = k - take_operation
    if take_operation > n:
        continue
    for take_from_left in range(0, take_operation+1):
        take_from_right = take_operation - take_from_left
        item_values = []
        for i in range(0, take_from_left):
            item_values.append(vs[i])
        for i in range(0, take_from_right):
            item_values.append(vs[n - 1 - i])
        item_values = list(sorted(item_values, reverse=True))
        for i in range(sute_operation):
            if item_values and item_values[-1] < 0:
                item_values.pop()
        tmp = 0 if not item_values else sum(item_values)
        res = max(res, tmp)
print(res)

Buggy submission (verdict: Runtime Error):


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,k = getints()
vs = getints()

res = 0
for take in range(0, k + 1):
    sute = k - take
    for from_left in range(0, take+1):
        from_right = k - from_left
        value = []
        for i in range(0, from_left):
            value.append(vs[i])
        for i in range(-1, -from_right, -1):
            value.append(vs[i])
        value = list(sorted(value, reverse=True))
        for i in range(sute):
            if value and value[-1] < 0:
                value.pop()
        tmp = 0 if not value else sum(value)
        res = max(res, tmp)
print(res)

Buggy submission (verdict: Runtime Error):


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,k = getints()
vs = getints()

res = 0
for take in range(0, k + 1):
    sute = k - take
    for from_left in range(0, take+1):
        from_right = k - from_left
        value = []
        for i in range(0, from_left):
            value.append(vs[i])
        for i in range(-1, -from_right, -1):
            value.append(vs[i])
        value = list(sorted(value, reverse=True))
        for i in range(sute):
            if value and value[-1] < 0:
                value.pop()
        tmp = 0 if not value else sum(value)
        res = max(res, tmp)
print(res)
Problem p03044 (python)

Fixed submission:

import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

##* graph
##pre graph
m,lst,nxt,to=0,[],[],[]

def init_graph(node_count, edge_count):
    global lst,nxt,to
    lst = [-1 for _ in range(node_count)]
    nxt = [0  for _ in range(edge_count)]
    to  = [0  for _ in range(edge_count)]

# bidirection
def add_edge(u, v):
    global m
    nxt[m], lst[u], to[m], m = lst[u], m, v, m + 1
    nxt[m], lst[v], to[m], m = lst[v], m, u, m + 1

# bidirection weight
def add_edge(u, v, w):
    global m
    nxt[m], lst[u], to[m], m = lst[u], m, (v, w), m + 1
    nxt[m], lst[v], to[m], m = lst[v], m, (u, w), m + 1

def traverse(u):
    m = lst[u]
    while m != -1:
        yield m
        m = nxt[m]


n = getint()
init_graph(n, 2 * n)

for _ in range(n - 1):
    u, v, w = getints()
    add_edge(u - 1, v - 1, w)

def get_distance(u, dist):
    dist[u] = 0
    stk = [(u, 0)]
    while stk:
        v, d = stk[-1]
        stk.pop()
        for m in traverse(v):
            vv, w = to[m]
            if dist[vv] >= 0:
                continue
            dist[vv] = d + w
            stk.append((vv, d + w))


dist = [-1]*n
get_distance(0, dist)

# print(dist)


for i in range(n):
    print(dist[i] % 2)

Buggy submission (verdict: Runtime Error):

import collections
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

##* graph
##pre graph
m,lst,nxt,to=0,[],[],[]

def init_graph(node_count, edge_count):
    global lst,nxt,to
    lst = [-1 for _ in range(node_count)]
    nxt = [0  for _ in range(edge_count)]
    to  = [0  for _ in range(edge_count)]

# bidirection
def add_edge(u, v):
    global m
    nxt[m], lst[u], to[m], m = lst[u], m, v, m + 1
    nxt[m], lst[v], to[m], m = lst[v], m, u, m + 1

# bidirection weight
def add_edge(u, v, w):
    global m
    nxt[m], lst[u], to[m], m = lst[u], m, (v, w), m + 1
    nxt[m], lst[v], to[m], m = lst[v], m, (u, w), m + 1

def traverse(u):
    m = lst[u]
    while m != -1:
        yield m
        m = nxt[m]


n = getint()
init_graph(n, 2 * n)

for _ in range(n - 1):
    u, v, w = getints()
    add_edge(u - 1, v - 1, w)

def get_distance(u, dist, d):
    dist[u] = d
    for m in traverse(u):
        v, w = to[m]
        if dist[v] >= 0:
            continue
        get_distance(v, dist, d + w)

dist = [-1]*n
get_distance(0, dist, 0)


for i in range(n):
    print(dist[i] % 2)
Problem p03059 (python)

Fixed submission:

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

res = 0
t = t + 1
for k in range(1,10000):
    now = k * a
    if now < t:
        res += b

print(res)

Buggy submission (verdict: Runtime Error):

a,b,t=map(int,input())

res = 0
for k in range(1,10000):
    now = k * a
    if now < t:
        res += b

print(res)
Problem p03062 (python)

Fixed submission:
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n=getint()
a=getints()
inf = 1 << 60

cache=[[-inf] * 2 for _ in range(n)]

def solve(pos, minus):
    if pos == n - 1:
        return -a[pos] if minus else a[pos]
    res = cache[pos][minus]
    if res > -inf:
        return res
    now = a[pos] if minus == 0 else -a[pos]
    res1 =  now + solve(pos + 1, 0)
    res2 = -now + solve(pos + 1, 1)
    res  = max(res1, res2)
    cache[pos][minus] = res
    return res

for i in range(n-1,-1,-1):
    solve(i, 0)
    solve(i, 1)

res = solve(0, 0)
print(res)

Buggy submission (verdict: Runtime Error):
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n=getint()
a=getints()
inf = 1 << 60

cache=[[-inf] * 2 for _ in range(n)]

def solve(pos, minus):
    if pos == n - 1:
        return -a[pos] if minus else a[pos]
    res = cache[pos][minus]
    if res > -inf:
        return res
    now = a[pos] if minus == 0 else -a[pos]
    res1 =  now + solve(pos + 1, 0)
    res2 = -now + solve(pos + 1, 1)
    res  = max(res1, res2)
    cache[pos][minus] = res
    return res

res = solve(0, 0)
print(res)
Problem p03071 (python)

Fixed submission:

but=list(map(int,input().split()))
but = sorted(but)
res = but[-1]
but[-1] -= 1
but = sorted(but)
res += but[-1]
print(res)

Buggy submission (verdict: Runtime Error):

but=list(map(int,input()))
but = sorted(but)
res = but[-1]
but = sorted(but)
res += but[-1]
print(res)

Buggy submission (verdict: Runtime Error):

but=map(int,input())
but = sorted(but)
res = but[-1]
but = sorted(but)
res = but[-1]
print(res)
Problem p03106 (python)

Fixed submission:
a,b,k=map(int,input().split())

cnt = 0
for i in range(max(a,b)+1, 0, -1):
    if (a % i == 0) and (b % i == 0):
        cnt += 1
    if cnt == k:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input())

cnt = 0
for i in range(1, max(a,b)+1):
    if a % i == 0 and b % i == 0:
        cnt += 1
    if cnt == k:
        print(i)
        break
Problem p03109 (python)

Fixed submission:

y,m,d=map(int, input().split('/'))


heisei = False
heisei = heisei or y < 2019
heisei = heisei or y == 2019 and m < 4
heisei = heisei or y == 2019 and m == 4 and d <= 30

print("Heisei" if heisei else "TBD")

Buggy submission (verdict: Runtime Error):

y,m,d=map(int, input().split())


heisei = False
heisei = heisei or y < 2019
heisei = heisei or y == 2019 and m < 4
heisei = heisei or y == 2019 and m == 4 and d <= 30

print("Heisei" if heisei else "TBD")

Buggy submission (verdict: Runtime Error):

y,m,d=input().split()

heisei = False:
heisei = heisei or y < 2019:
heisei = heisei or y == 2019 and m < 4
heisei = heisei or y == 2019 and m == 4 and d <= 30:

print("Heisei" if heisei else "TBD")
Problem p03110 (python)

Fixed submission:

n=int(input())
s=[input().split() for _ in range(n)]
res = 0.0
for v, c in s:
    v = float(v)
    v = v if c == 'JPY' else v * 380000.0
    res += v
print(res)

Buggy submission (verdict: Runtime Error):

n=int(input())
s=[input().split() for _ in range(n)]
res = 0.0
for v, c in s:
    v = v if c == 'JPY' else v * 380000.0
    res += v
print(res)
Problem p03220 (python)

Fixed submission:

n=int(input())
temp,a=map(int,input().split())
hs=map(int,input().split())

t=list(map(lambda h: temp-h*0.006, hs))
t=list(enumerate(t,1))

def solve(best,a,t):
    if not t:
        return best[0]
    if abs(best[1] - a) < abs(t[0][1] - a):
        return solve(best, a, t[1:])
    else:
        return solve(t[0],a,t[1:])

min_diff = 100000000
res = 0
for i in range(len(t)):
    if min_diff > abs(t[i][1] - a):
        min_diff = abs(t[i][1] - a)
        res = i + 1


print(res)

Buggy submission (verdict: Runtime Error):

n=int(input())
temp,a=map(int,input().split())
hs=map(int,input().split())

t=list(map(lambda h: temp-h*0.006, hs))
t=list(enumerate(t,1))

def solve(best,a,t):
    if not t:
        return best[0]
    if abs(best[1] - a) < abs(t[0][1] - a):
        return solve(best, a, t[1:])
    else:
        return solve(t[0],a,t[1:])

print(solve(t[0],a,t[1:]))

Buggy submission (verdict: Runtime Error):

n=int(input())
t,a=map(int,input().split())
hs=map(int,input().split())

t=list(map(lambda h: t-h*0.006, hs))
t=list(enumerate(t,1))

def solve(best,a,t):
    if not t:
        return best[0]
    if abs(best[1] - a) < abs(t[0][1] - a):
        return solve(best, a, t[1:])
    else:
        return solve(t[0],a,t[1:])

print(solve(t[0],a,t[1:]))
Problem p03243 (python)

Fixed submission:

n=int(input())
for x in range(n, 1000):
    if len(set(list(str(x)))) == 1:
        print(x)
        break

Buggy submission (verdict: Runtime Error):

n=int(input())
for x in range(n, 1000):
    if set(list(x)) == 1:
        print(x)
        break
Problem p03280 (python)

Fixed submission:

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

s = a * b - a - b + 1
print(s)

Buggy submission (verdict: Runtime Error):

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

s = a*b - a - b
print(s)
Problem p03281 (python)

Fixed submission:


n = int(input())

def count(x):
    res = 0
    for i in range(1, x + 1):
        if x % i == 0:
            res += 1
    return res

res = 0
for x in range(1, n+1, 2):
    if count(x) == 8:
        res += 1

print(res)

Buggy submission (verdict: Runtime Error):


n = map(int,input().split())

def count(x):
    res = 0
    for i in range(1, x + 1):
        if x % i == 0:
            res += 1
    return res

res = 0
for x in range(1, n+1, 2):
    if count(x) == 8:
        res += 1

print(res)
Problem p03282 (python)

Fixed submission:


import collections
import itertools
import sys


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = input()
k = getint() - 1

t = list(itertools.takewhile(lambda s: s == '1', s))

if len(t) > k:
    print(1)
else:
    i = len(t)
    print(s[i])

Buggy submission (verdict: Runtime Error):


import collections
import itertools
import sys


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = input()
k = getint()

t = list(itertools.takewhile(lambda s: s == '1', s))

if len(t) > k:
    print(1)
else:
    i = len(t)
    print(s[i])
Problem p03359 (python)

Fixed submission:


endday = [31] * 13
endday[2] = 28
for i in [4,6,9,11]:
    endday[i] = 30

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

res = 0
done = False
for m in range(1, 13):
    if done:
        break
    for d in range(1, endday[m] + 1):
        if m == d:
            res += 1
        if m == a and d == b:
            done = True
            break

print(res)

Buggy submission (verdict: Runtime Error):


endday = [31] * 12
endday[2] = 28
for i in [4,6,9,11]:
    endday[i] = 30

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

res = 0
done = False
for m in range(1, 13):
    if done:
        break
    for d in range(1, endday[m] + 1):
        if m == d:
            res += 1
        if m == a and d == b:
            done = True
            break

print(res)
Problem p03399 (python)

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

print(min(a, b) + min(c, d))

Buggy submission (verdict: Runtime Error):
x, y = map(int, raw_input().split())
print(x + y / 2)

Buggy submission (verdict: Runtime Error):
x, y = map(int, raw_input().split())
print(x + y / 2)
Problem p03408 (python)

Fixed submission:

n = int(input())
ss = [input() for _ in range(n)]
m = int(input())
tt = [input() for _ in range(m)]

res = 0
for u in ss:
    tmp = ss.count(u) - tt.count(u)
    res = max(res, tmp)
print(res)

Buggy submission (verdict: Runtime Error):

n = int(input())
ss = [input() for _ in range(n)]
m = int(input())
tt = [input() for _ in range(n)]

res = 0
for u in ss:
    tmp = ss.count(u) - tt.count(u)
    res = max(res, tmp)
print(res)
Problem p03434 (python)

Fixed submission:
n = int(input())
cards = list(sorted(map(int, input().split()), reverse=True))

a = sum(cards[0::2])
b = sum(cards[1::2])

print(a - b)

Buggy submission (verdict: Runtime Error):
n = int(input())
cards = list(sorted(map(int, input()), reverse=True))

a = sum(cards[0::2])
b = sum(cards[1::2])

print(a - b)
Problem p03473 (python)

Fixed submission:
print(48 - int(input()))

Buggy submission (verdict: Runtime Error):

xs = sorted(map(int, input().split()))

if xs[0] != xs[1]:
    print(xs[0])
if xs[1] != xs[2]:
    print(xs[2])

Buggy submission (verdict: Runtime Error):

xs = sorted(map(int, input().split()))

if xs[0] != xs[1]:
    print(xs[0])
if xs[1] != xs[2]:
    print(xs[2])

Buggy submission (verdict: Runtime Error):

xs = sorted(map(int, input().split()))

if xs[0] != xs[1]:
    print(xs[0])
if xs[1] != xs[2]:
    print(xs[2])

Buggy submission (verdict: Runtime Error):

xs = sorted(map(int, raw_input().split()))

if xs[0] != xs[1]:
    print(xs[0])
if xs[1] != xs[2]:
    print(xs[2])
Problem p03609 (python)

Fixed submission:


X, t = map(int, input().split())
Y = max(0, X - t)
print(Y)

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


possibles = set()
for x in xs:
    possibles.add(x - 1)
    possibles.add(x)
    possibles.add(x + 1)


res = 0
for p in possibles:
    d = 0
    for x in xs:
        c = abs(x - p)
        if c <= 1: d += 1
    if res < d: res = d

print(res)
Problem p03644 (python)

Fixed submission:

n = int(input())

def cnt(a):
    if a == 1:
        return 0
    return 1 + cnt(a//2)

res, maxcount = 0, -1
for a in range(1, n + 1):
    if maxcount < cnt(a):
        maxcount, res = cnt(a), a
print(res)

Buggy submission (verdict: Runtime Error):

n = int(input())

def cnt(a):
    if a == 1:
        return 0:
    return cnt(a//2)

res = 0
for a in range(1, n + 1):
    res = max(res, cnt(a))
print(res)
Problem p03729 (python)

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


if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

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


if A[-1] == B[0] && B[-1] == C[0]:
    print('YES')
else:
    print('NO')
Problem p03759 (python)

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

if xs[1] - xs[0] == xs[2] - xs[1]:
    print('YES')
else:
    print('NO')

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

if xs[1] - xs[0] and xs[2] - xs[1]:
    print('YES')
else:
    print('NO')
Problem p03814 (python)

Fixed submission:

s = input()

while True:
    if s[0] != 'A':
        s = s[1:]
        continue
    if s[-1] != 'Z':
        s = s[:-1]
        continue
    break

print(len(s))

Buggy submission (verdict: Runtime Error):


s = input()

def drop(s):
    if s[0] != 'A':
        return drop(s[1:])
    if s[-1] != 'Z':
        return drop(s[:-1])
    return s

print(len(drop(s)))
Problem p04043 (python)

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

if [A, B, C].count(5) == 2 and [A, B, C].count(7) == 1:
    print 'YES'
else:
    print 'NO'

Buggy submission (verdict: Runtime Error):

N, K = raw_input().split()
D = raw_input().split()
candi = [str(i) for i in xrange(10)]
for d in D:
    candi.remove(d)

def decide(i):
    if i >= len(N):
        return ''
    for c in candi:
        if N[i] == c:
            return c + decide(i + 1)
        elif N[i] < c:
            return c + candi[0] * (len(N) - i - 1)

if candi[-1] * len(N) >= N:
    print decide(0)
else:
    print (candi[0] if candi[0] != '0' else candi[1]) + candi[0] * len(N)