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

Fixed submission:
def solve(A,B):
  if A==B:
    return 0,A[:]
  a1 = 0
  for p1 in range(len(A)):
    if A[p1]>0:
      A[p1] -= 1
      a2 = 9999
      for p2 in range(len(B)):
        if B[p2]>0:
          B[p2] -= 1
          a,b = solve(A,B)
          a += 1
          if a<a2:
            a2 = a
            b2 = b
          B[p2] += 1
      if a2>a1:
        a1 = a2
        b1 = b2
      A[p1] += 1
  return a1,b2

#print solve([1,3], [2,2]) # (2, [1, 2])
#print solve([8,0,4], [3,1,8]) # (9, [3,0,0])
#print solve([3,3,1,1], [1,1,3,3]) # (7, [1, 0, 0, 0])
#print solve([4,3,1,1], [2,1,3,3]) # (8, [1, 0, 0, 0])
#print solve([2,2,3,1], [2,2,1,3]) # (7, [1, 0, 0, 0])
#print solve([2,2,2,0], [1,1,1,3]) # (5, [1, 0, 0, 0])
#print solve([1,1,1,0], [0,0,0,3]) # (3, [0, 0, 0, 0])
#print solve([1,2,1,0], [0,1,0,3]) # (4, [0, 0, 0, 0])
#print solve([1,2,2,0], [0,1,1,3]) # (5, [0, 0, 0, 0])
#print solve([3,3,3,0], [2,2,2,3]) # (7, [2, 0, 0, 0])

N = input()
A,B = [0]*N, [0]*N
for i in range(N):
  A[i], B[i] = map(int, raw_input().split())
t = 9999999999
for i in range(N):
  if A[i]>B[i]:
    t = min(t, B[i])
if t==9999999999:
  print 0
else:
  print sum(B)-t

Buggy submission (verdict: Runtime Error):
def solve(A,B):
  if A==B:
    return 0,A[:]
  a1 = 0
  for p1 in range(len(A)):
    if A[p1]>0:
      A[p1] -= 1
      a2 = 9999
      for p2 in range(len(B)):
        if B[p2]>0:
          B[p2] -= 1
          a,b = solve(A,B)
          a += 1
          if a<a2:
            a2 = a
            b2 = b
          B[p2] += 1
      if a2>a1:
        a1 = a2
        b1 = b2
      A[p1] += 1
  return a1,b2

#print solve([1,3], [2,2]) # (2, [1, 2])
#print solve([8,0,4], [3,1,8]) # (9, [3,0,0])
#print solve([3,3,1,1], [1,1,3,3]) # (7, [1, 0, 0, 0])
#print solve([4,3,1,1], [2,1,3,3]) # (8, [1, 0, 0, 0])
#print solve([2,2,3,1], [2,2,1,3]) # (7, [1, 0, 0, 0])

N = input()
A,B = [0]*N, [0]*N
for i in range(N):
  A[i], B[i] = map(int, raw_input().split())
c = 0
p = 0
for i in range(N):
  if A[i]>B[i]:
    c += 1
    p = i
if c==0:
  print 0
elif c==1:
  print sum(B)-B[p],1/0
else:
  print sum(A)-1
Problem p03688 (python)

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

if max(a)-min(a)>=2:
  print "No"
elif max(a)-min(a)==0:
  if N>=2*a[0] or N==a[0]+1:
    print "Yes"
  else:
    print "No"
else:
  cn = max(a)-a.count(min(a))
  if a.count(max(a))>=2 and cn>0 and N>=a.count(min(a))+2*cn:
    print "Yes"
  else:
    print "No"

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

if max(a)-min(a)>=2:
  print "No"
elif max(a)-min(a)==0:
  if N>=2*a[0] or N==a[0]+1:
    print "Yes"
  else:
    print "No"
else:
  if a.count(max(a))>=2 and a.count(min(a))==min(a):
    print "Yes"
  else:
    exit(-1)
    print "No"

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

if max(a)-min(a)>=2:
  exit(-1)
  print "No"
elif max(a)-min(a)==0:
  exit(-1)
  if N>=2*a[0] or N==a[0]+1:
    print "Yes"
  else:
    print "No"
else:
  if a.count(max(a))>=2 and a.count(min(a))==min(a):
    print "Yes"
  else:
    print "No"
Problem p03863 (python)

Fixed submission:
s=raw_input()
print"First"if len(s)%2^int(s[0]==s[-1])else"Second"

Buggy submission (verdict: Runtime Error):
s=raw_input()
print "First"if len(s)%2^s[0]==s[-1]else"Second"
Problem p02909 (python)

Fixed submission:
N = input()
if N == 'Rainy':
 print('Sunny')
elif N == 'Sunny':
 print('Cloudy')
elif N == 'Cloudy':
  print('Rainy')

Buggy submission (verdict: Runtime Error):
N = int(input())
print(N*N*N)
Problem p04043 (python)

Fixed submission:
l = [int(x) for x in input().split()]
l = sorted(l)
if l.count(5)==2 and l.count(7)==1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
l = [int(x) for x in input().split()]
l = sorted(l)
if l.count(5)==2 and l.count(7)==1:
  print("YES")
else:
  print("NO"
Problem p02608 (python)

Fixed submission:
import math
n = int(input())

highest = int(math.sqrt(n))
l = [0]*n
cal = 0

for x in range(1, highest+1):
  for y in range(1, highest+1):
    for z in range(1, highest+1):
      cal = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if cal > n:
        continue
      else:
        l[cal-1] += 1
        
for i in range(len(l)):
  print(l[i])

Buggy submission (verdict: Runtime Error):
import math
n = int(input())

highest = int(math.sqrt(n))
l = [0]*n
cal = 0

for x in range(1, highest+1):
  for y in range(1, highest+1):
    for z in range(1, highest+1):
      cal = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if cal > n+1:
        continue
      else:
        l[cal-1] += 1
        
for i in range(len(l)):
  print(l[i])
Problem p02718 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse=True)

vote = sum(a)

if a[m-1] >= vote*1/(4*m):
  print('Yes')
else:
  print('No')

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

a.sort(reverse=True)

vote = sum(a)

if a[m-1] => vote*1/(4*m):
  print('Yes')
else:
  print('No')
Problem p02730 (python)

Fixed submission:
S = str(input())
N = len(S)
 
head = round((N-1)/2)
end = round((N+3)/2-1)

headS = S[:head]
endS = S[end:]

if S==S[::-1] and headS == headS[::-1] and endS == endS[::-1]:
	print('Yes')
else:
  	print('No')

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)

front = s[:(n-1)//2]
rear = s[(n+1)//2:]

if s == s[::-1] and front == front[::-1] ans rear == rear[::-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = str(input())
N = len(S)

small = round((N-1)/2)
big = round((N+3)/2)-1
smallS = S[0:small]
bigS = S[big:N]

if L > 5:
    if smallS == bigS:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
if L > 5:
    small = round((N-1)/2)
    big = round((N+3)/2)-1
    smallS = S[0:small]
    bigS = S[big:N]

    if smallS == bigS:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = str(input())
N = len(S)

if L > 5:
    small = round((N-1)/2)
    big = round((N+3)/2)-1
    smallS = S[0:small]
    bigS = S[big:N]

    if smallS == bigS:
        print('Yes')
    else:
        print('No')
Problem p02731 (python)

Fixed submission:
L = int(input())
HWL = L/3

print(HWL ** 3)

Buggy submission (verdict: Runtime Error):
L = str(input())
HWL = L/3

print(HWL ** 3)
Problem p03378 (python)

Fixed submission:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

# xは最初の位置
# nは目的地
# aは料金所（コスト1）

cost = 0
cost2 = 0

for i in a:
  if i > x:
    cost += 1
  else:
    cost2 += 1
    
if cost < cost2:
  print(cost)
else:
  print(cost2)

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

# xは最初の位置
# nは目的地
# aは料金所（コスト1）

cost = 0
cost2 = 0

for i in range(len(a)):
  if a[i] > x and a[i] < n:
    cost += 1
for j in range(x):
  if a[j] > 0 and a[j] < x :
    cost2 += 1
    
if cost < cost2:
  print(cost)
else:
  print(cost2)
Problem p04043 (python)

Fixed submission:
A=list(map(int,input().split()))
ans=sorted(A)
if ans==[5,5,7]:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().sprit()))
ans = sorted(A)
if ans == [5,5,7]:
  print('YES')
else:
  print('NO')
Problem p02936 (python)

Fixed submission:
a,b=map(int,input().split())
y=[]
for i in range(a-1):
    v=list(map(int,input().split()))
    y.append(v)
y.sort(key=lambda n:n[0])
ans=[0]*a
for j in range(b):
    c,d=map(int,input().split())
    ans[c-1]=ans[c-1]+d
for k in range(a-1):
    ans[y[k][1]-1]=ans[y[k][1]-1]+ans[y[k][0]-1]
print(*ans,sep=" ")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
y=[]
for i in range(a-1):
    v=list(map(int,input().split()))
    y.append(v)
y.sort(key=lambda net:net[0])
ans=[0]*a
for j in range(b):
    c,d=map(int,input().split())
    ans[c-1]=ans[c-1]+d
for k in range(a-1):
    ans[zz]=ans[y[k][1]-1]+ans[y[k][0]-1]
print(*ans,sep=" ")
Problem p02780 (python)

Fixed submission:
import sys
import numpy as np

val = np.fromstring(sys.stdin.buffer.read(), np.int64, sep=' ')
n,k = val[:2]
p_list = val[2:]

S = np.zeros(n+1, np.int64)
S[1:] = p_list.cumsum()

KS = S[k:] - S[0:-k]
print((KS.max()+k)/2)

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

n,k = map(int, input().split())
p_list = np.fromstring(input(), int, sep=' ')

Cumulative_sum = np.zeros(n+1)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

print((length_k_sum_list.max()+k)/2)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np

n,k = map(int,input().split())
p_list = np.fromstring(input(),int,sep=' ')

Cumulative_sum = np.zeros(n+1, int)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = S[k:] - S[0:-k]

print((length_k_sum_list.max()+k)/2)

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

n,k = map(int,input().split())
p_list = np.fromstring(input(), int)

Cumulative_sum = np.zeros(n+1, np.int64)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

ans = (length_k_sum_list.max() + k) / 2

print(ans)

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

n,k = map(int,input().split())
p_list = np.fromstring(input(), np.int64, sep=' ')

Cumulative_sum = np.zeros(n+1, np.int64)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

ans = (length_k_sum.max() + k) / 2

print(ans)
Problem p02803 (python)

Fixed submission:
import sys
import queue
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

d = [[-1,0],[1,0],[0,-1],[0,1]]

H,W = LI()
S = [list(input()) for _ in range(H)]

def bfs(s):
    dist = [[-1]*W for _ in range(H)]
    h,w = s
    dist[h][w] = 0
    que = queue.Queue()
    que.put(s)
    while(not(que.empty())):
        h,w = que.get_nowait()
        for dh,dw in d:
            nh,nw = h+dh,w+dw
            if 0<=nh<H and 0<=nw<W and dist[nh][nw]==-1 and S[nh][nw]=='.':
                dist[nh][nw] = dist[h][w] + 1
                que.put([nh,nw])
    return dist[h][w]

def main():
    ans = 0
    for h in range(H):
        for w in range(W):
            if S[h][w] == '.':
                ans = max(ans,bfs([h,w]))
#                if (((h==0 or S[h-1][w]=='#') or (h==H-1 or S[h+1][w]=='#')) and 
#                        ((w==0 or S[h][w-1]=='#') or (w==W-1 or S[h][w+1]=='#'))):
#                    ans = max(ans,bfs([h,w]))
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import queue
dx=[1,0,-1,0]
dy=[0,1,0,-1]
H,W=map(int,input().split())
S=[]
for h in range(H):
  S.append(input())

def bfs(s):
  dist = [[-1]*H for _ in range(W)]
  
  h,w = s
  dist[h][w]=0
  que = queue.Queue()
  que.put(s)
  
  while not(que.empty()):
    h,w = que.get()
    for d in range(4):
      nh = h + dx[d]
      nw = w + dy[d]
      if nh<0 or H<=nh or nw<0 or W<=nw:
        continue
      if S[nh][nw]=="#":
        continue
      if dist[nh][nw]==-1:
        dist[nh][nw]=dist[h][w]+1
        que.put([nh,nw])
  return dist[h][w]

ans = 0
for h in range(H):
  for w in range(W):
    if S[h][w]==".":
      ans = max(ans,bfs([h,w]))
print(ans)

Buggy submission (verdict: Runtime Error):
import Queue
dx=[1,0,-1,0]
dy=[0,1,0,-1]
H,W=input().split()
S=[]
for h in range(H):
  S.append(input())

def bfs(s):
  dist = [[-1]*H for _ in range(W)]
  
  h,w = s
  dist[h][w]=0
  que = queue.Queue()
  que.put(s)
  
  while not(que.empty):
    h,w = que.get()
    for d in range(4):
      nh = h + dx[d]
      nw = w + dy[d]
      if nh<0 or H<=nh or nw<0 or W<=nw:
        continue
      if S[nh][nw]=="#":
        continue
      if dist[nh][nw]==-1:
        dist[nh][nw]=dist[h][w]+1
        que.put([nh,nw])
  return dist(h,w)

ans = 0
for h in range(H):
  for w in range(W):
    if S[h][w]==".":
      ans = max(ans,bfs([h,w]))
print(ans)
Problem p02839 (python)

Fixed submission:
import sys
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def main():
    H,W = LI()
    A = [LI() for _ in range(H)]
    B = [LI() for _ in range(H)]
    D = [[abs(A[h][w]-B[h][w]) for w in range(W)] for h in range(H)]
    dp=[[0]*W for _ in range(H)]
    dp[0][0]=1<<D[0][0]<<20000

    for h in range(H):
        for w in range(W):
            if(h>0):
                dp[h][w] |= dp[h-1][w]<<D[h][w]
                dp[h][w] |= dp[h-1][w]>>D[h][w]
            if(w>0):
                dp[h][w] |= dp[h][w-1]<<D[h][w]
                dp[h][w] |= dp[h][w-1]>>D[h][w]
    for i in range(81):
        bit = 1<<(20000+i)
        bit |= 1<<(20000-i)
        if dp[H-1][W-1]&bit:
            return(i)
 
if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import sys
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def main():
    H,W = LI()
    A = [LI() for _ in range(H)]
    B = [LI() for _ in range(H)]
    D = [[abs(A[h][w]-B[h][w]) for w in range(W)] for h in range(H)]
    dp=[[0]*W for _ in range(H)]
    dp[0][0]=1<<D[0][0]<<20000

    for h in range(H):
        for w in range(W):
            if(h>0):
                dp[h][w] |= dp[h-1][w]<<D[h][w]
                dp[h][w] |= dp[h-1][w]>>D[h][w]
            if(w>0):
                dp[h][w] |= dp[h][w-1]<<D[h][w]
                dp[h][w] |= dp[h][w-1]>>D[h][w]
    for i in range(81):
        bit = 1<<(20000+i)
        bit |= 1<<(20000-i)
        if dp[H-1][W-1]&bit
            return(i)
 
if __name__ == "__main__":
    print(main())
Problem p02843 (python)

Fixed submission:
x = int(input())
while(x>=0):
    if x%100==0:
        print("1")
        break
    elif x<100:
        print("0")
        break
    elif x%100>=5:
        x -= 105
        continue
    else:
        x-=(x%100)+100
        continue

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

if ((x%100)+4)//5 > x//100:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
nt(input())

if ((x%100)+4)//5 > x//100:
    print(0)
else:
    print(1)
Problem p02848 (python)

Fixed submission:
n=int(input())
s=list(input())
a=""
for c in s:
  a+=chr((ord(c)-ord("A")+n)%26+ord("A"))
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
a=""
for c in s:
  a+=chr((ord(c)-ord(a)+n)%26+ord(a))
print(a)
Problem p02934 (python)

Fixed submission:
n = int(input())
A = [int(a) for a in input().split()]

ans_r = 0
for a in A:
  ans_r += 1/a

print(1/ans_r)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [int(a) for a in input().split()]

ans_r = 0
for a in A:
  ans_r += 1/a

print(1/ans)
Problem p02936 (python)

Fixed submission:
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    N,Q = LI()
    node=[[] for _ in range(N)]
    flag = [True for _ in range(N)]
    for _ in range(N-1):
        a,b = LI()
        node[a-1].append(b-1)
        node[b-1].append(a-1)

    counter = [0] * N
    for _ in range(Q):
        p,x = LI()
        counter[p-1] += x

    cur = [[0,0]]
    while cur:
        nxt = []
        for a,c in cur:
            flag[a]=False
            counter[a]+=c
            for b in node[a]:
                if flag[b]:
                    nxt.append([b,counter[a]])
        cur = [x for x in nxt]

    r = [counter[i] for i in range(N)]

    return(" ".join(map(str,r)))

if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    N,Q = LI()
    node=[[] for _ in range(N)]
    flag = [True for _in range(N)]
    for _ in range(N-1):
        a,b = LI()
        node[a-1].append(b-1)
        node[b-1].append(a-1)

    counter = [0] * N
    for _ in range(Q):
        p,x = LI()
        counter[p-1] += x

    cur = [[0,0]]
    while cur:
        nxt = []
        for a,c in cur:
            flag[a]=False
            counter[a]+=c
            for b in node[a]:
                if flag[b]:
                    nxt.append([b,counter[a]])
        cur = [x for x in nxt]

    r = [counter[i] for i in range(N)]

    return(" ".join(map(str,r)))

if __name__ == "__main__":
    print(main())
Problem p02939 (python)

Fixed submission:
import sys
def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def s(): return(input())

def main():
  S = s()
  cur = [[1,S[0],""],[0,"",S[0]]]
  nxt = []
  N = len(S)
  
  for i in range(1,N):
    for c,p,n in cur:
      if len(n)==1 and p!=n+S[i]:
        nxt.append([c+1,n+S[i],""])
      elif len(n)==0:
        nxt.append([c,p,n+S[i]])
        if p!=n+S[i]:
          nxt.append([c+1,n+S[i],""])
    nxt.sort(key = lambda x: x[0], reverse = True)
    nxt.sort(key = lambda x:(x[1],x[2]))
    cur = [nxt[0]]
    for j in range(1,len(nxt)):
      if cur[-1][1:] != nxt[j][1:]:
        cur.append(nxt[j])
    nxt = []
  r = -1
  for c,p,n in cur:
    if n == "":
      r = max(r,c)
  return r

if __name__ == "__main__":
  print(main())

Buggy submission (verdict: Runtime Error):
import sys
def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(input())

def main():
  S = S()
  cur = [[1,S[0],""],[0,"",S[0]]]
  nxt = []
  N = len(S)
  
  for i in range(1,N):
    for c,p,n in cur:
      if len(n)==2 and p!=n+S[i]:
        nxt.append([c+1,n+S[i],""])
      elif len(n)=<1:
        nxt.append([c,p,n+S[i]])
        if p!=n+S[i]:
          nxt.append([c+1,n+S[i],""])
    nxt.sort(key = lambda x: x[0], reverse = True)
    nxt.sort(key = lambda x:(x[1],x[2]))
    cur = [nxt[0]]
    for j in range(1,len(nxt)):
      if cur[-1][1:] != nxt[j][1:]:
        cur.append(nxt[j])
    nxt = []
  r = -1
  for c,p,n in cur:
    if n == "":
      r = max(r,c)
  return r

if __name__ == "__main__":
  print(main())
Problem p02963 (python)

Fixed submission:
import sys
import math
input = sys.stdin.readline

def main():
    S = int(input())
    X1 = 0
    Y1 = 0
    X2 = int(math.sqrt(S))
    Y3 = S//X2
    if X2*Y3==S:
        X3=0
        Y2=0
    else:
        Y3+=1
        if Y3>10**9:
            X2=10**9
            Y3=10**9
        X3 = 1
        Y2 = (X2*Y3-S)
    print(X1,Y1,X2,Y2,X3,Y3)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

def main():
    S = int(input())
    X1 = 0
    Y1 = 0
    X2 = int(math.sqrt(S))
    Y3 = S//X2
    if X2*Y3==S:
        X3=0
        Y2=0
    else:
        Y3+=1  
        if Y3>10**9:
            X2=10**9
            Y3=10**9
        X3 = 1
        Y2 = (X2*Y3-S) 
    print(X1,Y1,X2,Y2,X3,Y3)
if __name__ == '__main__':
    test()
Problem p03001 (python)

Fixed submission:
W,H,x,y = map(int,input().split())

menseki = W*H/2
if x==W/2 and y==H/2:
    ans = 1
else:
    ans = 0
print(menseki,ans)

Buggy submission (verdict: Runtime Error):
W,H,x,y = map(int,input())

menseki = W*H/2
if x==W/2 and y==H/2:
    ans = 1
else:
    ans = 0
print(menseki,ans)
Problem p03005 (python)

Fixed submission:
N,K = map(int,input().split())
if K==1:
    print(0)
else:          
    print(N-K)

Buggy submission (verdict: Runtime Error):
N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]
def gdb(a,b):
    a,b = abs(a),abs(b)
    while b:
        a,b = b,a%b
    return a
def make_slope(a,b):
    if a==0:
        print("error")
    elif a>0:
        return(a//gdb(a,b),b//gdb(a,b))
    elif a<0:
        return(-1*a//gdb(a,b),-1*b//gdb(a,b))


slope_list = []
for i in range(1,N):
    for j in range(i):
        x1,y1 = XY[i]
        x2,y2 = XY[j]
        d_x = x2-x1
        d_y = y2-y1
        if d_x != 0:
            d_x,d_y = make_slope(d_x,d_y)
            if not([d_x,d_y] in slope_list):
                slope_list.append([d_x,d_y])

if N <= 2:
    print(1)
else:
    tmp = []
    for x,y in XY:
        if not (x in tmp):
            tmp.append(x)
    ans = len(tmp)

    for d_x,d_y in slope_list:
        XY_list = []
        for x1,y1 in XY:
            if XY_list == []:
                XY_list.append([x1,y1])
            else:
                for x2,y2 in XY_list:
                    d_x_tmp = x2-x1
                    d_y_tmp = y2-y1
                    if d_x_tmp == 0:
                        break
                    d_x_tmp,d_y_tmp = make_slope(d_x_tmp,d_y_tmp)
                    if d_x_tmp==d_x and d_y_tmp==d_y:
                        break
                else:
                    XY_list.append([x1,y1])
        ans = min(ans,len(XY_list))
    print(ans)
Problem p03044 (python)

Fixed submission:
N = int(input())
uvw = [[int(x) for x in input().split()] for _ in range(N-1)]

path = [[] for _ in range(N)]

ans = [-1]*N
ans[0] = 0

for u,v,w in uvw:
    path[u-1].append([v-1,w%2])
    path[v-1].append([u-1,w%2])
    
Q = [0]     
while Q:
    v = Q.pop(-1)
    for p,d in path[v]:
        if ans[p] == -1:
            ans[p] = (ans[v]+d)%2
            Q.append(p)
            
for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
uvw = [[int(x) for x in input().split()] for _ in range(N-1)]

par = [i for i in range(N)]
dist = [0]*N

def root(x):
    if(par[x]==x):
        return x
    else:
        return root(par[x])

def unite(x,y,z):
    rx = root(x)
    ry = root(y)
    if rx==ry:
        return
    else:
        par[rx] = ry
        dist[rx] = z%2

def dist_type(x):
    if(par[x]==x):
        return 0
    else:
        return (dist_type(par[x])+dist[x])%2

for u,v,w in uvw:
    unite(u-1,v-1,w%2)

for i in range(N):
    print(dist_type(i))
Problem p03047 (python)

Fixed submission:
N,K = map(int,input().split())
print(N+1-K)

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
A = [int(a) for a in input().split()]

C_sum = [0]
s = {0}

for a in A:
    C_sum.append(C_sum[-1]^a)
    s.add(C_sum[-1])

if C_sum[-1] != 0:
    print(1)
else:
    dic_state = {}
    dic = {}
    for x in s:
        dic_state[x] = 0
        dic[x] = [0]
    for c in C_sum:
        if c==0:
            for d in dic:
                if dic_state[d] == 0:
                    dic[d][-1] += 1
                else:
                    dic[d].append(1)
                    dic_state[d] = 0
        else:
            if dic_state[c] == c:
                dic[c][-1] += 1
            else:
                dic[c].append(1)
                dic_state[c] = c

    ans = pow(2,dic[0][0]-2,10**9+7)

    for d in dic:
        tmp_0 = 1
        tmp_x = 0

        for i in range(1,len(dic[d])):
            if i%2==1:
                tmp_x += tmp_0 * dic[d][i]
                tmp_x %= 10**9+7
            else:
                tmp_0 += tmp_x * dic[d][i]
                tmp_0 %= 10**9+7

        ans += tmp_x
        ans %= 10**9+7

    print(ans)