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

Fixed submission:
import math
inp = [input() for i in range(2)]
N = int(inp[0])
A = list(map(int, inp[1].split()))
# B = 0
d = {}
for k in A:
    # a = A.count(k)
    # B += (a - 1) / 2
    if k in d.keys():
        d[k] += 1
    else:
        d[k] = 1

# for k in range(N):
#     c = A.count(A[k]) - 1
#     counter = B - c
#     print(int(counter))

p = {}
for k in d.keys():
    cnt = d[k]
    p[k] = cnt * (cnt-1) / 2

total = sum(p.values())

for item in A:
    print(int(total - d[item] + 1))

Buggy submission (verdict: Runtime Error):
import math
inp = [input() for i in range(2)]
N = int(inp[0])
A = list(map(int, inp[1].split()))
# B = 0
d = {}
for k in A:
    # a = A.count(k)
    # B += (a - 1) / 2
    if k in d.keys():
        d[i] += 1

# for k in range(N):
#     c = A.count(A[k]) - 1
#     counter = B - c
#     print(int(counter))

p = {}
for k in d.keys():
    cnt = d[k]
    p[k] = cnt * (cnt-1) / 2

total = sum(p.values())

for item in A:
    print(int(total - d[item] + 1))
Problem p02733 (python)

Fixed submission:
H, W, K = map(int, input().split())
S = list(input() for i in range(H))

sum = [[0] * (W+1) for i in range((H+1))]
for i in range(H):
    for j in range(W):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if S[i][j] == '1' else 0)

ans = H + W - 2

for ptn in range(1<<H-1): # 2^H - 1 通り
    cand = 0

    sep = [0] # 横方向の分割リスト、ここ天才
    for i in range(H-1):
        if((ptn >> i) & 1): # & を取ることで、上の桁を消せる
            sep.append(i+1)
            cand += 1
    sep.append(H)

    left = 0 # left は直前の分割
    for pos in range(W):
    	cur = [] # cur は今見てるホワイトチョコの個数のリスト

    	# 横方向に分割されている各部分について
    	for i in range(len(sep) - 1):
    		cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])

    	if max(cur) > K:
    		if left == pos: # 縦に分割できない場合(一列しかない場合)
    			cand = H * W
    			break
    		else:
    			cand += 1
    			left = pos

    ans = min(ans, cand)

print(ans)

Buggy submission (verdict: Runtime Error):
H, W, K = map(int, input().split())
S = list(input() for i in range(H))

sum = [[0] * (W+1) for i in range((H+1))]
for i in range(H):
    for j in range(W):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if s[i][j] == '1' else 0)

ans = H + W - 2

for ptn in range(1<<H-1): # 2^H - 1 通り
    cand = 0

    sep = [0] # 横方向の分割リスト、ここ天才
    for i in range(H-1):
        if((ptn >> i) & 1): # & を取ることで、上の桁を消せる
            sep.append(i+1)
            cand += 1
    sep.append(H)

    left = 0 # left は直前の分割
    for pos in range(W):
    	cur = [] # cur は今見てるホワイトチョコの個数のリスト

    	# 横方向に分割されている各部分について
    	for i in range(len(sep) - 1):
    		cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])

    	if max(cur) > K:
    		if left == pos: # 縦に分割できない場合(一列しかない場合)
    			cand = H * W
    			break
    		else:
    			cand += 1
    			left = pos

    ans = min(ans, cand)

print(ans)

Buggy submission (verdict: Runtime Error):
H, W, K = map(int, input().split())
S = list(input() for i in range(H))

sum = [[0] * (W+1) for i in range((H+1))]
for i in range(H):
    for j in range(W):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if s[i][j] == '1' else 0)

ans = H + W - 2

for ptn in range(1<<H-1): # 2^H - 1 通り
    cand = 0

    sep = [0] # 横方向の分割リスト、ここ天才
    for i in range(H-1):
        if((ptn >> i) & 1): # & を取ることで、上の桁を消せる
            sep.append(i+1)
            cand += 1
    sep.append(H)

    left = 0 # left は直前の分割
    for pos in range(W):
    	cur = [] # cur は今見てるホワイトチョコの個数のリスト

    	# 横方向に分割されている各部分について
    	for i in range(len(sep) - 1):
    		cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])

    	if max(cur) > K:
    		if left == pos: # 縦に分割できない場合(一列しかない場合)
    			cand = H * W
    			break
    		else:
    			cand += 1
    			left = pos

    ans = min(ans, cand)

   print(ans)
Problem p02576 (python)

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

if N%X==0:
    print(str(((N//X))*T))
else:
    print(str(((N//X)+1)*T))

Buggy submission (verdict: Runtime Error):
import numpy as np
from collections import Counter
H,W,M=map(int,input().split())

X=[]
Y=[]
tt=[]
for i in range(M):
    inp=list(map(int,input().split()))
    X.append(inp[0])
    Y.append(inp[1])
    tt.append((inp[0],inp[1]))
Z1=Counter(X)
Z2=Counter(Y)
maxmax=0
for i in Z1.keys():
    for j in Z2.keys():
        aa=0
        if (i,j) in tt:
            aa=-1
        if maxmax<(aa+Z1[i]+Z2[j]):
            maxmax=(aa+Z1[i]+Z2[j])
print(maxmax)

Buggy submission (verdict: Runtime Error):
import numpy as np
H,W,M=map(int,input().split())

B=np.zeros((H,W))
for i in range(M):
    inp=list(map(int,input().split()))
    B[inp[0]-1][inp[1]-1]=1
BT=B.T
maxmax=0
for i in range(H):
    for j in range(W):
        sumsum=0
        sumsum=np.sum(B[i])+np.sum(BT[j])-B[i][j]
        #print((np.sum(B[i]),np.sum(BT[j]),B[i][j]))
        if maxmax<sumsum:
            maxmax=sumsum
print(int(maxmax))
Problem p02658 (python)

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

result = 1
if 0 in A:
    print("0")
else:
    for a in A:
        result *= a
        if result > 10**18:
            result = -1
            break
    print(result)

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

result = "No"
for i in range(X + 1):
    if 2 * i + (X - i) * 4 == Y:
        result = "Yes"

print(result)
Problem p02945 (python)

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

Buggy submission (verdict: Runtime Error):
a,b = int(input())
print(max(a+b,a-b,a*b))
Problem p02953 (python)

Fixed submission:
n = int(input())
H = list(map(int, input().split()))
for i in reversed(range(n)):
    if i == 0:
        print("Yes")
    elif H[i] - H[i - 1] == -1:
        H[i - 1] -= 1
    elif H[i] - H[i - 1] < -1:
        print("No")
        break
    else:
        continue

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
for i in reversed(range(n)):
    if i == 0:
        print("Yes")
    elif H - H[i - 1] == -1:
        H[i - 1] -= 1
    elif H[i] - H[i - 1] < -1:
        print("No")
        break
    else:
        continue
Problem p02993 (python)

Fixed submission:
S = input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
  print("Bad")
else:
  print("Good")

Buggy submission (verdict: Runtime Error):
A,B,C,D = map(int,input().split())
X = max(C,D)
Y = min(C,D)
def gcd(a,b):
  while b!= 0:
    a,b = b,a%b
  return a
l = C*D/ gcd(X,Y)
def f(x):
  return x - (x//C + x//D - x//l)
ans = f(B) - f(A-1)
print(ans)

Buggy submission (verdict: Runtime Error):
N,L = map(int,input().split())
S = 0
b = abs(L)
for i in range(1,N+1):
  a = L + i - 1
  S += a
  b = min(abs(a),b)
if -N < L:
  ans = S - b
else:
  ans = S + b
print(ans)
Problem p02999 (python)

Fixed submission:
X,A = map(int,input().split())
if X<A:
  print(0)
if X>=A:
  print(10)

Buggy submission (verdict: Runtime Error):
W,H,x,y = map(int,input().split())
if x==0 or x==W or y==0 or y==H:
  s = H*W/2
  print('{:.10f}'.format(s))
else:
  a = min(x*H,(W-x)*H)
  b = min(y*W,(H-y)*W)
  s = max(a,b)
  print('{:.10f}'.format(s))
if x==0 and y==0:
  print(0)
elif x==W and y==0:
  print(0)
elif x==0 and y==H:
  print(0)
elif x==W and y==H:
  print(0)
elif y == H*x/W or y == (-1)*H*x/W:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
W,H,x,y = map(int,input().split())
if x==0 or x==W or y==0 or y==H:
  s = H*W/2
  print('{:.10f}'.format(s))
else:
  a = min(x*H,(W-x)*H)
  b = min(y*W,(H-y)*W)
  s = max(a,b)
  print('{:.10f}'.format(s))
if y == H*x/W:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
A,X = map(int,imput().split())
if X<A:
  print(0)
if x>=A:
  print(10)
Problem p03290 (python)

Fixed submission:
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

for bit in range(1 << d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))

    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            nokori.discard(i + 1)

    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < g:
        use = max(nokori)
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100

    if sum >= g:
        ans = min(ans, count)

print(ans)

Buggy submission (verdict: Runtime Error):
rom math import ceil

D, G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]

ans = float("inf")
for bit in range(1 << D):
    cnt = 0
    sum = 0
    remain = set(range(1,D+1))

    for i in range(D):
        if bit & (1 << i):
            cnt += pc[i][0]
            sum += pc[i][0]*(i+1)*100 + pc[i][1]
            remain.discard(i+1)

    if sum < G:
        use = max(remain)
        n = min(pc[use-1][0], ceil((G-sum)/(use*100)))
        """
        if use == 0:
            n = 0
        elif (G - sum)%(use%100) == 0:
            n = min(pc[use-1][0], (G - sum)//(use*100))
        else:
            n = min(pc[use-1][0], (G - sum)//(use*100)+1)
        """
        cnt += n
        sum += n*use*100

    if sum >= G:
        ans = min(ans,cnt)

print(ans)
Problem p02675 (python)

Fixed submission:
n=str(input())

l=len(n)


if n[l-1]=="3":
    print("bon")
elif (n[l-1]=="0" or n[l-1]=="1" or n[l-1]=="6" or n[l-1]=="8"):
    print("pon")

else :
    print("hon")

Buggy submission (verdict: Runtime Error):
n=str(input())

l=len(n)


if n[l-1]=="3":
    print("bon")
elif (n[l-1]==="0" or n[l-1]==="1" or n[l-1]==="6" or n[l-1]==="8"):
    print("pon")

else :
    print("hon")
Problem p02684 (python)

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


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

ar=[-1 for i in range(n+1)]
p=1

go=0


for i in range(1,k+1):
    
    
    
    

    ar[p]=i-1
    p=a[p-1]
    
    if ar[p]>0:
        j=ar[p]
        amari=(k-i)%(i-j)
        
        go=1
        break

if go==1:
    p=ar.index(j+amari)
    
    


print(p)

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


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

ar=[-1 for i in range(n+1)]
p=1

go=0


for i in range(1,k+1):
    
    
    
    

    ar[p]=i
    p=a[p-1]
    
    if ar[p]>0:
        j=ar[p]
        amari=(k-i-1)%(i-j)
        
        go=1
        break

if go==1:
    p=ar.index(j+amari)
    p=a[p-1]
    


print(p)

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


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

ar=[-1 for i in range(n+1)]
p=1
h=[]
go=0


for i in range(1,k+1):
    
    
    
    

    ar[p]=i
    p=a[p-1]
    
    if ar[p]>0:
        j=ar[p]
        amari=(k-i-1)%(i-j)
        
        go=1
        break

if go==1:
    p=ar.index(j+amari)
    p=a[p-1]


print(p)

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


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

ar=[-1 for i in range(n+1)]
p=1
h=[]
go=0


for i in range(1,k+1):
    
    
    
    

    ar[p]=i
    p=a[p-1]
    
    if ar[p]>0:
        j=ar[p]
        amari=(k-i-1)%(i-j)
        p=h[j+amari]
        go=1
        break

if go==1:
    p=ar.index(j+amari)
    p=a[p-1]


print(p)

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

a=input().split()

l=len(a)

for i in range(0,l):
    a[i]=int(a[i])

p=1
h=[]
go=0
i=0
while(go==0):
    i+=1
    
    

    h.append(p)
    p=a[p-1]
    if i==k:
        break
    if p in h:
        l=len(h)
        for j in range(0,l):
            if h[j]==p:
                amari=(k-i-1)%(i-j)
                p=h[j+amari+1]
                go=1
                break



print(p)
Problem p02706 (python)

Fixed submission:
N, M = map(int, input().split())
print(max(N - sum([int(x) for x in input().split()]), -1))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
print(max(N - sum([int(x) for x in input.split()]), -1))
Problem p02791 (python)

Fixed submission:
N = int(input())
P = [int(x) for x in input().split()]
pmin = max(P)
cnt = 0
for p in P:
  if p <= pmin:
    cnt += 1
    pmin = p
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input)
P = [int(x) for x in input().split()]
pmin = max(P)
cnt = 0
for p in P:
  if p <= pmin:
    cnt += 1
    pmin = p
print(cnt)
Problem p02900 (python)

Fixed submission:
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
k = 1
cnt = 1
while GCD > 1:
  k += 1
  if k ** 2 > GCD:
    cnt += 1
    break
  if GCD % k:
    continue
  cnt += 1
  while GCD % k == 0:
    GCD //= k
print(cnt)

Buggy submission (verdict: Runtime Error):
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
def eratosthenes(limit):
  E = [1] * (limit + 1)
  E[0], E[1] = 0, 0
  prime_table = []
  for i, e in enumerate(E):
    if e == 0:
      continue
    prime_table.append(i)
    for j in range(i, limit + 1, i):
      E[j] = 0
  return prime_table
P = eratosthenes(GCD)
print(len([p for p in P if GCD % p == 0]) + 1)

Buggy submission (verdict: Runtime Error):
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
E = [1] * (GCD + 1)
E[0], E[1] = 0, 0
P = []
for i, e in enumerate(E):
  if e == 0:
    continue
  P.append(i)
  for j in range(i, GCD + 1, i):
    E[j] = 0
print(len([p for p in P if GCD % p == 0]) + 1)

Buggy submission (verdict: Runtime Error):
import fractions
A, B = map(int, input().split())
GCD = fractions.gcd(A, B)
E = [1] * (GCD + 1)
E[0], E[1] = 0, 0
P = []
for i, e in enumerate(E):
  if e == 0:
    continue
  P.append(i)
  for j in range(i, GCD + 1, i):
    E[j] = 0
print(len([p for p in P if GCD % p == 0]) + 1)
Problem p02918 (python)

Fixed submission:
N, K = map(int, input().split())
S = 'R' + input() + 'L'
UH = [0] * (N + 1)
d = 'R'
for i, s in enumerate(S):
  if s == 'R':
    if S[i + 1] == 'L':
      UH[i] += 1
  else:
    if S[i - 1] == 'R':
      UH[i - 1] += 1
UH[0] = min(UH[0], 1)
UH[N] = min(UH[N], 1)
UH.sort(reverse=True)
for i in range(min(K, N + 1)):
  UH[i] = 0
if sum(UH) == 0:
  UH[0] = 1
print(N - sum(UH))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = 'R' + input() + 'L'
UH = [0] * (N + 1)
d = 'R'
for i, s in enumerate(S):
  if s == 'R':
    if S[i + 1] == 'L':
      UH[i] += 1
  else:
    if S[i - 1] == 'R':
      UH[i - 1] += 1
UH[0] = min(UH[0], 1)
UH[N] = min(UH[N], 1)
UH.sort(reverse=True)
for i in range(K):
  UH[i] = 0
if sum(UH) == 0:
  UH[0] = 1
print(N - sum(UH))
Problem p02949 (python)

Fixed submission:
N, M, P = map(int, input().split())
E = [[] for _ in range(M)]
for i in range(M):
  a, b, c = map(int, input().split())
  E[i] = [a - 1, b - 1, c]
D = [None] * N
D[0] = 0
for _ in range(N):
  for a, b, c in E:
    if D[a] == None:
      continue
    if D[b] == None:
      D[b] = D[a] + c - P
    else:
      D[b] = max(D[b], D[a] + c - P)
_D = D[-1]
for _ in range(N):
  for a, b, c in E:
    if D[a] == None:
      continue
    if D[b] == None:
      D[b] = D[a] + c - P
    else:
      D[b] = max(D[b], D[a] + c - P)
if D[-1] > _D:
  print(-1)
else:
  print(max(D[-1], 0))

Buggy submission (verdict: Runtime Error):
N, M, P = map(int, input().split())
E = [[] for _ in range(N)]
RE = [[] for _ in range(N)]
for _ in range(M):
  a, b, c = map(int, input().split())
  E[a - 1].append([b - 1, c])
  RE[b - 1].append(a - 1)
Reachable = [[False, False] for _ in range(N)]
Q = [0]
while(Q):
  q = Q.pop(0)
  Reachable[q][0] = True
  for adj, _ in E[q]:
    if not Reachable[adj][0]:
      Q.append(adj)
Q = [N - 1]
while(Q):
  q = Q.pop(0)
  Reachable[q][1] = True
  for adj in RE[q]:
    if not Reachable[adj][1]:
      Q.append(adj)
R = [r[0] and r[1] for r in Reachable]
C = [None] * N
C[0] = 0
A = [0, 0]
def DFS(s):
  if A[1] != 0:
    return 0
  if s == N - 1:
    A[0] = max(C[s], A[0])
  for adj, coin in E[s]:
    if not R[s]:
      continue
    if C[adj] == None:
      C[adj] = C[s] + coin - P
      DFS(adj)
      C[adj] = None
    elif C[adj] < C[s] + coin - P:
      A[1] = -1
      return 0
DFS(0)
if A[1] != 0:
  print(-1)
else:
  print(A[0])
Problem p02988 (python)

Fixed submission:
n = int(input())
P = [int(x) for x in input().split()]
cnt = 0
for i in range(1, n - 1):
  if P[i - 1] < P[i] and P[i + 1] < P[i]:
    continue
  if P[i] < P[i - 1] and P[i] < P[i + 1]:
    continue
  cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
P = [int(x) for x in input().split()]
cnt = 0
for i in range(1, n - 1):
  if p[i - 1] < p[i] and p[i + 1] < p[i]:
    continue
  if p[i] < p[i - 1] and p[i] < p[i + 1]:
    continue
  cnt += 1
print(cnt)
Problem p03001 (python)

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

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

Fixed submission:
A, B, T = map(int, input().split())
print((T // A) * B)

Buggy submission (verdict: Runtime Error):
A, B, T = map(int, input())
print((T // A) * B)
Problem p03076 (python)

Fixed submission:
A = [0] * 5
for i in range(5):
  A[i] = int(input())
A.sort(reverse=True, key=lambda x: x % 10)
for i in range(5):
  if A[4] % 10 == 0:
    A = [A[4]] + A[:4]
  else:
    break
t = 0
for a in A[:4]:
  a += 9
  t += a - a % 10
print(t + A[4])

Buggy submission (verdict: Runtime Error):
A = [0] * 5
for i in range(5):
  A[i] = int(input())
A.sort(reversed=True, key=lambda x: x % 10)
t = 0
for a in A[:4]:
  a += 9
  t += a - a % 10
print(t + a[4])
Problem p03097 (python)

Fixed submission:
N, A, B = map(int, input().split())
AB = A ^ B
D = bin(AB)[2:].count('1')
if D % 2 == 0:
  print('NO')
else:
  print('YES')
  C = [0] * (2 ** N)
  C[0] = str(A)
  P = []
  for i in range(N):
    if AB % 2:
      P = P + [i]
    else:
      P = [i] + P
    AB >>= 1
  for i in range(1, 2 ** N):
    k = 0
    b = i
    while b % 2 == 0:
      k += 1
      b >>= 1
    A ^= 1 << P[k]
    C[i] = str(A)
  k = 0
  for i in range(D // 2):
    k += 1 / (4 ** (i + 1))
    K = int(2 ** N * (1 - k))
    C = C[:K-1] + C[K+1:] + C[K-1:K+1][::-1]
  print(' '.join(C))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
AB = A ^ B
if bin(AB)[2:].count('1') != 1:
  print('NO')
else:
  print('YES')
  C = [0] * (1 << N)
  C[0] = str(A)
  pos = 0
  while AB % 2 == 0:
    pos += 1
    AB >>= 1
  for i in range(1, 1 << N):
    k = 0
    b = i
    while b % 2 == 0:
      k += 1
      b >>= 1
    A ^= 1 << ((pos + k + 1) % N)
    C[i] = str(A)
print(' '.join(C))
Problem p03197 (python)

Fixed submission:
N = int(input())
for i in range(N):
  if int(input()) % 2:
    print('first')
    break
else:
  print('second')

Buggy submission (verdict: Runtime Error):
N = int(input())
for i in range(N):
  if int(input)() % 2:
    print('first')
    break
else:
  print('second')
Problem p03240 (python)

Fixed submission:
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2], reverse=True)
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h != max(_H - abs(cx - x) - abs(cy - y), 0):
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

Buggy submission (verdict: Runtime Error):
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2])
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h and abs(cx - x) + abs(cy - y) + h != _H:
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

Buggy submission (verdict: Runtime Error):
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2])
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if abs(cx - x) + abs(cy - y) + h != _H:
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)
Problem p03241 (python)

Fixed submission:
import math
N, M = map(int, input().split())
_M = M
primes = [1]
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
if N > 1:
  devides[1] = 1
  for prime in primes:
    _devides = [d for d in devides]
    for i in range(N):
      if devides[i]:
        if i * prime < N:
          _devides[i * prime] = 1
        else:
          ans = max(M // i // prime, ans)
    devides = _devides
else:
  ans = M
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
_M = M
primes = [1]
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
devides[1] = 1
for prime in primes:
  _devides = [d for d in devides]
  for i in range(N):
    if devides[i]:
      if i * prime < N:
        _devides[i * prime] = 1
      else:
        ans = max(M // i // prime, ans)
  devides = _devides
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
_M = M
primes = []
prime = 2
for p in range(prime, int(math.sqrt(M))):
  while _M % p == 0:
    primes.append(p)
    _M //= p
    if _M == 1:
      break
  if p >= _M:
    break
if _M > 1:
  primes.append(_M)
ans = 1
devides = [0] * N
devides[1] = 1
for prime in primes:
  _devides = [d for d in devides]
  for i in range(N):
    if devides[i]:
      if i * prime < N:
        _devides[i * prime] = 1
      else:
        ans = max(M // i // prime, ans)
  devides = _devides
print(ans)
Problem p03260 (python)

Fixed submission:
A, B = map(int, input().split())
print('Yes' if A % 2 and B % 2 else 'No')

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print('Yes' A % 2 and B % 2 else 'No')
Problem p03269 (python)

Fixed submission:
L = int(input())
R = 0
while True:
  R += 1
  if 2 ** R > L:
    R -= 1
    break
N = R + 1
M = 2 * R
_L = L
for r in range(R, 0, -1):
  if _L - 2 ** (r - 1) >= 2 ** R:
    M += 1
    _L -= 2 ** (r - 1)
print(N, M)
for i in range(R):
  print(i + 1, i + 2, 2 ** i)
  print(i + 1, i + 2, 0)
for r in range(R, 0, -1):
  if L - 2 ** (r - 1) >= 2 ** R:
    print(r, N, L - 2 ** (r - 1))
    L -= 2 ** (r - 1)

Buggy submission (verdict: Runtime Error):
def n_ary_notation(N, n):
  if N == 0:
    return '0'
  else:
    s = ''
    while N:
      s = str(N % abs(n)) + s
      N -= N % abs(n)
      N //= n
    return s
strL = input()
N = 21
M = 61
K = 2
l = int(strL) - 1
while True:
  K += 1
  L = n_ary_notation(l, K)
  N = len(L) * 2
  M = K * (len(L) - 1)
  for l in L:
    M += int(l) + 1
  if N < 21 and M < 61:
    break
print(N, M)
for i, l in enumerate(L[:-1]):
  k = len(L) - 1 - i
  print(2 * i + 1, 2 * i + 3, int(l) * K ** k)
  for j in range(int(l)):
    print(2 * i + 1, 2 * i + 2, j * K ** k)
for i in range(int(L[-1]) + 1):
  print(2 * len(L) - 1, 2 * len(L), i)
for k in range(len(L) - 1):
  s = 2 * (len(L) - k)
  for i in range(K):
    print(2 * (len(L) - k - 1), 2 * (len(L) - k), i * K ** k)
Problem p03292 (python)

Fixed submission:
A = map(int, input().split())
A = sorted(A)
print(A[2] - A[0])

Buggy submission (verdict: Runtime Error):
A = map(int, input().split())
print(max(A) - min(A))
Problem p03323 (python)

Fixed submission:
[A, B] = [int(x) for x in input().split()]
if A < 9 and B < 9:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A < 9 and B < 9:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A < 9 and B < 9:
  print('Yay!')
else:
  print(':(')