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

Fixed submission:
#!/usr/bin/env python

x=0
y=0
n=int(raw_input().strip())
x=800*n
y=n/15*200
print x-y

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

n,m=map(int,raw_input().split())

if m<=2*n:
    print n+(m-2*n)/4
else:
    print m/2

Buggy submission (verdict: Runtime Error):
800*N-15%N*200
Problem p03087 (python)

Fixed submission:
N,Q = map(int, input().split())
S = input()
count = [0]*N
ans = []
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1]=='AC' : count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    ans.append(count[r-1]-count[l-1])
for i in  ans:
    print(i)

Buggy submission (verdict: Runtime Error):
N,Q = map(int, input().split())
S = input()
count = [0]*8
ans = []
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1]=='AC' : count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    ans.append(count[r-1]-count[l-1])
for i in  ans:
    print(i)

Buggy submission (verdict: Runtime Error):
N,Q = map(int, input().split())
S = input()
count = [0]*8
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1]=='AC' : count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    print(count[r-1]-count[l-1])
Problem p03102 (python)

Fixed submission:
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
count=0
for i in range(N):
    A = list(map(int, input().split()))
    SUM=0
    for j in range(M):
        SUM += A[j]*B[j]
    if SUM+C > 0:count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
B=np.array(b)
count=0
for i in range(n):
    A=np.array(list(map(int,input().split())))
    S=np.dot(B,A) + c
    if(S>0):
        count+=1
print(count)
Problem p03145 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print(int(a*b/2)
Problem p03220 (python)

Fixed submission:
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
z=[abs(t-x*0.006-a) for x in h]
print(z.index(min(z))+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))
z = [abs(T-h*0.006-a) for h in H]
print( z.index(min(z)) +1 )

Buggy submission (verdict: Runtime Error):
n = int(input())
T,A = map(int, input().split())
H = list(map(int, input().split()))
z = [abs(a - (t - h*0.006)) for h in H]
print( z.index(min(z)) +1 )

Buggy submission (verdict: Runtime Error):
n = int(input())
T,A = map(int, input().split())
H = map(int, input().split())
z = [abs(a - (t - h*0.006)) for h in H]
print( z.index(min(z)) +1 )

Buggy submission (verdict: Runtime Error):
n = int(input())
T,A = map(int, input().split())
H = map(int, input().split())
z = [abs(a - t - h*0.006) for h in H]
print( z.index(min(z)) +1 )
Problem p03239 (python)

Fixed submission:
N,T = map(int,input().split())
m = 1001
for i in range(N) :
    c,t = map( int, input().split() )
    if t<=T:
        m = min(m,c)
print('TLE' if m==1001 else m)

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
t = 1001
for i in range(N) :
    c,t = map( int, input().split() )
    if t<=T:
        m = min(m,c)
    print('TLF' if m==1001 else m)
Problem p03352 (python)

Fixed submission:
X = int(input())
c=1
for b in range(1,X):
    for p in range(2,X):
        if b**p<=X:c=max(c,b**p)
        else:break
print(c)

Buggy submission (verdict: Runtime Error):
X = int(input())
c=1
for b in range(1,X):
    for p in range(2,X):
        if b**p<=x:c=max(c,b**p)
        else:break
print(c)
Problem p03408 (python)

Fixed submission:
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
l=list( set(s) )
maxbox=[]
for i in range( len(l) ):
    maxbox.append( int( s.count(l[i])-t.count(l[i]) ) ) 
maxbox.append(0)
print(max(maxbox))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
l=list( set(s) )
maxbox=[]
for i in range( len(l) ):
    maxbox.append( int( s.count(l[i])-t.count(l[i]) ) ) 
print(max(maxbox,0))

Buggy submission (verdict: Runtime Error):
例
n=[input() for _ in range(int(input()))]
m=[input() for _ in range(int(input()))]
l=list(set(n))
print(max(0,max(n.count(l[i])-m.count(l[i]) for i in range(len(l)))))
Problem p03447 (python)

Fixed submission:
x,a,b = [int(input()) for i in range(3)]
print( (x-a)%b )

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

Fixed submission:
list = input()
print(list[0]+str(len(list)-2)+list[-1])

Buggy submission (verdict: Runtime Error):
s = input()
print(s)s=input()
out = s[0] + str(len(s)-2) + s[-1]
print(out)
Problem p04011 (python)

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

Buggy submission (verdict: Runtime Error):
n,k,x,y = map( int,input().split() )
print(n*x if k>=n else k*x + (n-k)*y)
Problem p02969 (python)

Fixed submission:
n = int(input())
print(3*n*n)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in range(0, n):
    a.append(int(input()))
first = max(a)
second_1 = sorted(a)
second = second_1[-2]
for i in range(0, n):
    if a[i] == first:
        print(second)
    else:
        print(first)
Problem p03136 (python)

Fixed submission:
n = int(input())
b = list(map(int, input().rstrip().split()))
c = max(b)
d = 0
for i in b:
  d +=i
d -= c
if c < d:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().rstrip().split()))
c = max(b)
d = 0
for i in b:
  d +=i
d -= c
if c < d:
  print(Yes)
else:
  print(No)

Buggy submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().rstirip().split()))
c = max(b)
d = 0
for i in b:
  d +=i
d -= c
if c < d:
  print(Yes)
else:
  print(No)
Problem p03323 (python)

Fixed submission:
a, b = list(map(int, input().rstrip().split()))
if a<= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a, b = list(map(int(input().rstrip())))
if a<=8 and b<= 8:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a, b = list(map(int(input().rstrip())))
if a<8 and b< 8:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a, b = int(input())
if a<8 and b< 8:
  print("Yay!")
else:
  print(":(")
Problem p03407 (python)

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

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

Fixed submission:
n = int(input())
c = []
for i in range(n):
    c.append(input())
d = []
m = int(input())
for i in range(m):
    d.append(input())

scores = []
for i in c:
    score = 0
    for j in range(n):
        if i == c[j]:
            score += 1
    for j in range(m):
        if i == d[j]:
            score -= 1
    scores.append(score)
if max(scores) >= 0:
    print(max(scores))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
c = []
for i in range(n):
    c.append(input())
d = []
m = int(input())
for i in range(m):
    d.append(input())

scores = []
for i in c:
    score = 0
    for j in range(n):
        if i == c[j]:
            score += 1
    for j in range(m):
        if i == d[j]:
            score -= 1
    scores.append(score)
if max(scores) >= 0:
    print(max(scores))
else:
    print(0)n = int(input())
c = []
for i in range(n):
    c.append(input())
d = []
m = int(input())
for i in range(m):
    d.append(input())

scores = []
for i in c:
    score = 0
    for j in range(n):
        if i == c[j]:
            score += 1
    for j in range(m):
        if i == d[j]:
            score -= 1
    scores.append(score)
print(max(scores))
Problem p03455 (python)

Fixed submission:
x, y = map(int, input().split())
if x * y % 2:
  print('Odd')
else:
  print('Even')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
a, b = map(int, input().split())
if (a*b)%2 == 0:
  print("even")
else:
  print("odd")

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

if (a*b)%2 = 0:
  print("Even")
else:
  print("Odds")

Buggy submission (verdict: Runtime Error):
int main() {
    int a, b;
    cin >> a >> b;
    int c = a * b;
    if (c % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}
Problem p03456 (python)

Fixed submission:
a, b = map(int, input().split())
c = str(a) + str(b)
c = int(c)
d = c**(1/2)

if d.is_integer():
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
c = str(a) + str(b)
c = int(c)
d ** 2 = c
if isinstance(d, int):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
retu = ""
retu += str(a) + str(b)
c**2 = int(retu)
def koro(n):
  if isinstance(n, int):
  	return True
  else:
    return False
koro(c)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
retu = ""
retu += str(a) + str(b)
c**2 = int(retu)
if isinstance(c, int):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
retu = ""
retu += str(a) + str(b)
if int(retu) == int(c)**2:
  print("Yes")
else:
  print("No")
Problem p03493 (python)

Fixed submission:
a = input()
b = int(a[0])+int(a[1])+int(a[2])
print(b)

Buggy submission (verdict: Runtime Error):
a = input()
a = int(a)

b = a[0]+a[1]+a[2]
print(b)
Problem p02898 (python)

Fixed submission:
d, e = map(int, input().strip().split())
g = list(map(int, input().strip().split()))
#print(d, e)
#print(g)
total = 0
for i in g:
    if i >= e:
        total += 1
print(total)

Buggy submission (verdict: Runtime Error):
d, e = map(int, input().strip().split())
g = list(map(int, input().strip().split()))
print(d, e)
#print(g)
#total = 0
for i in g:
    if i >= e:
        total += 1
print(total)
Problem p03109 (python)

Fixed submission:
S = input()
print('Heisei' if S <= '2019/04/30' else 'TBD')

Buggy submission (verdict: Runtime Error):
 s=input()
 if s<='2019/4/30':
 	print("Heisei")
 else:
 	print("TBD")
Problem p03280 (python)

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

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

Fixed submission:
import sys
def solve():
    readline = sys.stdin.readline
    write = sys.stdout.write
    MOD = 998244353

    N = int(readline())
    P = [list(map(int, readline().split())) for i in range(N)]

    P.sort()

    Y = [y for x, y in P]

    def compress(X):
        *XS, = set(X)
        XS.sort()
        return list(map({e: i for i, e in enumerate(XS)}.__getitem__, X))
    Y = compress(Y)

    data = [0]*(N+1)
    def add(k, x):
        while k <= N:
            data[k] += x
            k += k & -k
    def get(k):
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    def gen(add, get):
        pow2 = [1]*N
        r = 1
        for i in range(1, N):
            pow2[i] = r = r * 2 % MOD

        for i, y in enumerate(Y):
            v1 = get(y+1); v0 = y - v1
            w1 = i - v1; w0 = (N - y - 1) - w1
            add(y+1, 1)
            p1 = pow2[v1]; p0 = pow2[v0]
            q1 = pow2[w1]; q0 = pow2[w0]
            yield (2 * (p1*p0 % MOD)*(q1*q0 % MOD) % MOD) - (1 - p0 - p1 - q0 - q1 + (p0 + q1) * (p1 + q0)) % MOD
    write("%d\n" % (sum(gen(add, get)) % MOD))
solve()

Buggy submission (verdict: Runtime Error):
import sys
def solve():
    readline = sys.stdin.readline
    N = int(readline())
    P = [list(map(int, readline().split())) for i in range(N)]

    P.sort()

    Y = [y for x, y in P]

    def compress(X):
        *XS, = set(X)
        XS.sort()
        return list(map({e: i for i, e in enumerate(XS)}.__getitem__, X))
    Y = compress(Y)

    data = [0]*(N+1)
    def add(k, x):
        while k <= N:
            data[k] += x
            k += k & -k
    def get(k):
        s = 0
        while k:
            s += data[k]
            k -= k & -k
        return s

    def gen(add, get):
        MOD = 998244353
        pow2 = [1]*N
        r = 1
        for i in range(1, N):
            pow2[i] = r = r * 2 % MOD

        for i, y in enumerate(Y):
            v1 = get(y+1); v0 = y - v1
            w1 = i - v1; w0 = (N - y - 1) - w1
            add(y+1, 1)
            p1 = pow2[v1] - 1; p0 = pow2[v0] - 1
            q1 = pow2[w1] - 1; q0 = pow2[w0] - 1
            yield (2 * ((p1+1)*(p0+1) % MOD)*((q1+1)*(q0+1) % MOD) % MOD) - (1 + p0 + p1 + q0 + q1 + p0 * (p1 + q0) + (p1 + q0) * q1) % MOD
    print(sum(gen(add, get)) % MOD)
solve()
Problem p03046 (python)

Fixed submission:
M, K = map(int, input().split())
if 2**M <= K:
    print(-1)
    exit(0)
if M == 1:
    if K == 1:
        print(-1)
    else:
        print("0 0 1 1")
else:
    R = [i for i in range(2**M) if i != K]
    *S, = reversed(R)
    ans = [K] + R + [K] + S
    print(*ans)

Buggy submission (verdict: Runtime Error):
M, K = map(int, input().split())
if 2**M <= K:
    print(-1)
    exit(0)
if M == 1:
    if K == 1:
        print(-1)
    else:
        print("0 0 1 1")
else:
    *R, = [i for i in range(2**M) if i != K]
    print(K, *R, K, *reversed(R))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
def root(x):
    if x == p[x]:
        return x
    p[x] = y = root(p[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px < py:
        p[py] = px
    else:
        p[px] = py
*p, = range(N)

for i in range(M):
    x, y, z = map(int, input().split())
    unite(x-1, y-1)
ans = 0
for i in range(N):
    if root(i) == i:
        ans += 1
print(ans)
Problem p03148 (python)

Fixed submission:
from collections import defaultdict
N, K = map(int, input().split())
T = defaultdict(list)
for i in range(N):
    t, d = map(int, input().split())
    T[t].append(d)
S = []; U = []
for k, v in T.items():
    v.sort(reverse=1)
    U.append((v[0], k))
    for w in v[1:]:
        S.append((w, k))
S.sort(reverse=1)
U.sort(reverse=1)
D = defaultdict(int)
t = cnt = 0
res = 0
for w, k in S:
    D[k] += 1
    if D[k] == 1:
        t += 1
    cnt += 1
    res += w
ans = 0
can = 1
for v, k in U:
    D[k] += 1
    if D[k] == 1:
        t += 1
    cnt += 1
    res += v
    while cnt > K:
        if not S:
            can = 0
            break
        cnt -= 1
        w, l = S.pop()
        D[l] -= 1
        if D[l] == 0:
            t -= 1
        res -= w
    if not can:
        break
    ans = max(ans, t*t + res)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N, K = map(int, input().split())
T = defaultdict(list)
for i in range(N):
    t, d = map(int, input().split())
    T[t].append(d)
S = []
U = []
for k, v in T.items():
    v.sort(reverse=1)
    U.append((v[0], k))
    for w in v[1:]:
        S.append((w, k))
S.sort(reverse=1)
U.sort(reverse=1)
D = defaultdict(int)
cnt = 0
D[U[0][1]] += 1
t = 1
cnt += 1
res = U[0][0]
S = S[:K-1]
for w, k in S:
    D[k] += 1
    if D[k] == 1:
        t += 1
    cnt += 1
    res += w
ans = 0
for v, k in U[1:]:
    D[k] += 1
    if D[k] == 1:
        t += 1
    cnt += 1
    res += v
    while cnt > K:
        cnt -= 1
        w, l = S.pop()
        D[l] -= 1
        if D[l] == 0:
            t -= 1
        res -= w
    print(t, res, cnt)
    ans = max(ans, t*t + res)
print(ans)
Problem p03165 (python)

Fixed submission:
*S, = map(ord, input())
*T, = map(ord, input())
LS = len(S); LT = len(T)

dp = [[-1]*(LT+1) for i in range(LS+1)]
for i in range(LS-1, -1, -1):
    for j in range(LT-1, -1, -1):
        if S[i] == T[j]:
            dp[i][j] = max(dp[i+1][j+1] + 1, dp[i+1][j], dp[i][j+1])
        else:
            dp[i][j] = max(dp[i+1][j], dp[i][j+1])
i = j = 0
ans = []
while i < LS and j < LT:
    if S[i] == T[j]:
        if dp[i][j] == dp[i+1][j+1] + 1:
            ans.append(S[i])
            i += 1; j += 1
        elif dp[i][j] == dp[i+1][j]:
            i += 1
        else:
            j += 1
    else:
        if dp[i][j] == dp[i+1][j]:
            i += 1
        else:
            j += 1
print(*map(chr, ans), sep='')

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
LS = len(S); LT = len(T)

memo = [[-1]*LT for i in range(LS)]
nxt = [[(0, None, None)]*(LT+1) for i in range(LS+1)]
def dfs(i, j):
    if i == LS or j == LT:
        return 0
    if memo[i][j] != -1:
        return memo[i][j]
    r0 = dfs(i+1, j); r1 = dfs(i, j+1)
    r = max(r0, r1)
    x = (0, i, j+1) if r0 < r1 else (0, i+1, j)
    if S[i] == T[j]:
        r2 = dfs(i+1, j+1) + 1
        if r < r2:
            r = r2
            x = (1, i+1, j+1)
    memo[i][j] = r
    nxt[i][j] = x
    return r

dfs(0, 0)
i = j = 0
ans = []
while i is not None:
    m, i0, j = nxt[i][j]
    if m:
        ans.append(S[i])
    i = i0
print(*ans, sep='')
Problem p03178 (python)

Fixed submission:
MOD = 10**9 + 7
K = input()
N = len(K)
D = int(input())

S = [[0, 0] for i in range(D)]
S[0][0] = 1
for i in range(N):
    c = int(K[i])
    T = [[0, 0] for i in range(D)]
    for d in range(D):
        w0, w1 = S[d]
        w0 %= MOD
        w = S[d][0] % MOD
        for v in range(c):
            T[(d+v)%D][1] += w0
        T[(d+c)%D][0] += w0

        w1 %= MOD
        for v in range(10):
            T[(d+v)%D][1] += w1
    S = T
print((sum(S[0])-1) % MOD)

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
K = input()
N = len(K)
D = int(input())
S = [[0, 0] for i in range(D)]
S[0][0] = 1
for i in range(N):
    c = int(K[i])
    T = [[0, 0] for i in range(D)]
    for d in range(D):
        w0, w1 = S[d]
        w0 %= MOD
        w = S[d][0] % MOD
        for v in range(c):
            T[d+v-D][1] += w0
        T[d+c-D][0] += w0

        w1 %= MOD
        for v in range(10):
            T[d+v-D][1] += w1
    S = T
print((sum(S[0])-1) % MOD)
Problem p03181 (python)

Fixed submission:
import sys
from collections import deque

readline = sys.stdin.readline

N, M = map(int, readline().split())
G = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, readline().split())
    G[x-1].append((y-1, 2*i))
    G[y-1].append((x-1, 2*i+1))

G0 = [None]*N
V = [(0, -1)]
used = [0]*N
used[0] = 1
que = deque([0])
while que:
    v = que.popleft()
    g = []
    for e in G[v]:
        w, d = e
        if used[w]:
            continue
        g.append(e)
        V.append(e)
        used[w] = 1
        que.append(w)
    G0[v] = g

memo = [0]*(2*N+1)
for v, e in reversed(V):
    r = 1
    for w, d in G0[v]:
        r = r * (1 + memo[d]) % M
    memo[e] = r

lv = [0]*(2*N); rv = [0]*(2*N)
for v, e in V:
    s = 1 + memo[e ^ 1]
    for w, d in G0[v]:
        lv[d] = s
        s = s * (1 + memo[d]) % M
    s = 1
    for w, d in reversed(G0[v]):
        rv[d] = s
        s = s * (1 + memo[d]) % M
    for w, d in G0[v]:
        memo[d ^ 1] = lv[d] * rv[d] % M

ans = []
for v in range(N):
    r = 1
    for w, d in G[v]:
        r = r * (1 + memo[d]) % M
    ans.append("%d\n" % r)
sys.stdout.writelines(ans)

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque

readline = sys.stdin.readline

N, M = map(int, readline().split())
G = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, readline().split())
    G[x-1].append((y-1, 2*i))
    G[y-1].append((x-1, 2*i+1))
G0 = [None]*N
used = [0]*N
used[0] = 1
que = deque([0])
while que:
    v = que.popleft()
    g = []
    for e in G[v]:
        w, d = e
        if used[w]:
            continue
        g.append(e)
        used[w] = 1
        que.append(w)
    G0[v] = g
G = G0

memo = [0]*(2*N+1)
def dfs0(v, p, e):
    r = 1
    for w, d in G[v]:
        r = r * (1 + dfs0(w, v, d)) % M
    memo[e] = r
    return r


lv = [0]*(2*N); rv = [0]*(2*N)
ans = [None]*N
def dfs1(v, p, par):
    s = 1 + par
    for w, d in G[v]:
        lv[d] = s
        s = s * (1 + memo[d]) % M
    s = 1
    for w, d in reversed(G[v]):
        rv[d] = s
        s = s * (1 + memo[d]) % M
    for w, d in G[v]:
        memo[d ^ 1] = x = lv[d] * rv[d] % M
        dfs1(w, v, x)


dfs0(0, -1, 2*N)
dfs1(0, -1, 0)
ans = []
for v in range(N):
    r = 1
    for w, d in G[v]:
        r = r * (1 + memo[d]) % M
    ans.append("%d\n" % r)
sys.stdout.writelines(ans)
Problem p03240 (python)

Fixed submission:
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]

i = 0
while 1:
    if P[i][2] > 0:
        break
    i += 1
x0, y0, h0 = P[i]
for cy in range(101):
    for cx in range(101):
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for x, y, h1 in P:
            if h1 != max(h - abs(cx - x) - abs(cy - y), 0):
                break
        else:
            print(cx, cy, h)
            exit(0)
exit(1)

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

x0, y0, h0 = P[0]
for cy in range(101):
    for cx in range(101):
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for x, y, h1 in P[1:]:
            if h != h1 + abs(cx - x) + abs(cy - y):
                break
        else:
            print(cx, cy, h)
            exit(0)
exit(1)
Problem p03352 (python)

Fixed submission:
X = int(input())
def f():
    yield 1
    for y in range(2, X.bit_length()):
        x = 0
        while (x+1)**y <= X:
            x += 1
        if x**y <= X:
            yield x**y
print(max(f()))

Buggy submission (verdict: Runtime Error):
X = int(input())
def f():
    for y in range(2, X.bit_length()):
        x = 0
        while (x+1)**y <= X:
            x += 1
        if x**y <= X:
            yield x**y
print(max(f()))
Problem p03393 (python)

Fixed submission:
s = s0 = input()
d = {chr(c) for c in range(97, 123)}
for c in s:
    d.remove(c)
if d:
    s += min(d)
else:
    for c in reversed(s):
        s = s[:-1]
        if d and any(c < e for e in d):
            s += min(e for e in d if c < e)
            break
        d.add(c)
print(s if s else -1)
if s:
    assert s0 < s

Buggy submission (verdict: Runtime Error):
s = s0 = input()
d = {chr(c) for c in range(97, 123)}
for c in s:
    d.remove(c)
if d:
    s += min(d)
else:
    for c in reversed(s):
        s = s[:-1]
        if d and c < min(d):
            s += min(d)
            break
        d.add(c)
print(s if s else -1)
assert s0 < s
Problem p03442 (python)

Fixed submission:
N = int(input())
B = [0]*N
for i in range(N-1):
    x, y, a = map(int, input().split())
    B[x] ^= a
    B[y] ^= a
D = {}
for b in B:
    D[b] = D.get(b, 0) + 1
D[0] = 0
ans = 0
first = 0
for b in D:
    ans += D[b]//2
    if D[b]%2:
        first |= 1 << b

A = [0]*(1 << 16)
for i in range(1, 1<<16):
    bit = i & -i
    l = len(bin(bit))-3
    A[i] = A[i ^ bit] ^ l

memo = {0: 0}
def dfs(state):
    if state in memo:
        return memo[state]
    cur = state
    res = 10**9+7
    while cur:
        if A[cur] == 0:
            res = min(res, dfs(state ^ cur) + bin(cur).count('1')-1)
        cur -= 1
        cur &= state
    memo[state] = res
    return res
ans += dfs(first)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
B = [0]*N
for i in range(N-1):
    x, y, a = map(int, input().split())
    B[x] ^= a
    B[y] ^= a
D = {}
for b in B:
    D[b] = D.get(b, 0) + 1
D[0] = 0
ans = 0
first = 0
for b in D:
    ans += D[b]//2
    if D[b]%2:
        first |= 1 << b

A = [0]*(1 << 15)
for i in range(1, 1<<15):
    bit = i & -i
    l = len(bin(bit))-3
    A[i] = A[i ^ bit] ^ l

memo = {0: 0}
def dfs(state):
    if state in memo:
        return memo[state]
    cur = state
    res = 10**9+7
    while cur:
        if A[cur] == 0:
            res = min(res, dfs(state ^ cur) + bin(cur).count('1')-1)
        cur -= 1
        cur &= state
    memo[state] = res
    return res
ans += dfs(first)
print(ans)