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

Fixed submission:
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)

import math

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

mul_c = b // c - (a - 1) // c
mul_d = b // d - (a - 1) // d

gcd_c_d = gcd(c, d)
lcm_c_d = gcd_c_d * (c // gcd_c_d) * (d // gcd_c_d)
mul_c_d = b // lcm_c_d - (a - 1) // lcm_c_d

print(b - a + 1 - (mul_c + mul_d - mul_c_d))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)

import math

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

mul_c = b // c - int(math.ceil((a - 1) / c)) + 1
mul_d = b // d - int(math.ceil((a - 1) / d)) + 1

gcd_c_d = gcd(c, d)
lcm_c_d = gcd_c_d * (c / gcd_c_d) * (d / gcd_c_d)
mul_c_d = b // lcm_c_d - int(math.ceil((a - 1)) / lcm_c_d)) + 1

print(b - a + 1 - (mul_c + mul_d - mul_c_d))
Problem p03044 (python)

Fixed submission:
n = int(input())

g = [[] for _ in range(n)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    g[u - 1].append((v - 1, w))
    g[v - 1].append((u - 1, w))

color = [-1] * n
dist = [0] * n

import queue
def dfs(v):
    color[v] = dist[v] % 2
    q = queue.LifoQueue()
    q.put(v)

    while not q.empty():
        vv = q.get()
        for next_v in g[vv]:
            if color[next_v[0]] == -1 and next_v[1] != 0:
                dist[next_v[0]] = dist[vv] + next_v[1]
                color[next_v[0]] = dist[next_v[0]] % 2
                q.put(next_v[0])

# 0を始点として各点までの距離を求める
dfs(0)

for c in color:
    print(c)

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

g = [[] for _ in range(n)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    g[u - 1].append((v - 1, w))
    g[v - 1].append((u - 1, w))

color = [-1] * n
dist = [0] * n

import queue
def dfs(v):
    color[v] = dist[v] % 2
    for next_v in g[v]:
        if color[next_v[0]] == -1 and next_v[1] != 0:
            dist[next_v[0]] = dist[v] + next_v[1]
            dfs(next_v[0])

# 0を始点として各点までの距離を求める
dfs(0)

for c in color:
    print(c)

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

g = [[] for _ in range(n)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    g[u - 1].append((v - 1, w))
    g[v - 1].append((u - 1, w))

color = [-1] * n
dist = [0] * n

def dfs(v):
    for next_v in g[v]:
        if color[next_v[0]] == -1 and next_v[1] != 0:
            dist[next_v[0]] = dist[v] + next_v[1]
            color[next_v[0]] = dist[next_v[0]] % 2
            dfs(next_v[0])

# 0を始点として各点までの距離を求める
dfs(0)

for c in color:
    print(c)

Buggy submission (verdict: Runtime Error):
5
2 5 2
2 3 10
1 3 8
3 4 2

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

g = [[] for _ in range(n)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    g[u - 1].append((v - 1, w))
    g[v - 1].append((u - 1, w))

color = [-1] * n
dist = [0] * n

def dfs(v):
    for next_v in g[v]:
        if color[next_v[0]] == -1 and next_v[1] != 0:
            dist[next_v[0]] = dist[v] + next_v[1]
            color[next_v] = dist[next_v[0]] % 2
            dfs(next_v)

# 0を始点として各点までの距離を求める
dfs(0)

for c in color:
    print(c)

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

g = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    g[u - 1][v - 1] = w
    g[v - 1][u - 1] = w

color = [-1] * n

def dfs(v, cur = 0):
    color[v] = cur

    for next_v in range(n):
        if color[next_v] == -1:
            if g[v][next_v] != 0 and g[v][next_v] % 2 == 0:
                dfs(next_v, cur)
            else:
                dfs(next_v, 1 - cur)

dfs(0)

for c in color:
    print(c)
Problem p03085 (python)

Fixed submission:
b = input()
print("A" if b == "T" else "T" if b == "A" else "C" if b == "G" else "G")

Buggy submission (verdict: Runtime Error):
b = int(input())
print("A" if b == "T" else "T" if b == "A" else "C" if b == "G" else "G")
Problem p03136 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
print("Yes" if max(l) < sum(l) - max(l) else "No")

Buggy submission (verdict: Runtime Error):
n = int(input())
l = map(int, input().split())
print("Yes" if max(l) > sum(l) - max(l) else "No")

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [int(input()) for _ in range(n)]
print("Yes" if max(l) > sum(l) - max(l) else "No")
Problem p03351 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
print("Yes" if abs(c - a) <= d or (abs(c - b) <= d and abs(a - b) <= d) else "No")

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input())
print("Yes" if abs(c - a) <= d or (abs(c - b) <= d and abs(a - b) <= d) else "No")
Problem p03415 (python)

Fixed submission:
c = [input() for i in range(3)]
print(c[0][0] + c[1][1] + c[2][2])

Buggy submission (verdict: Runtime Error):
c = [input().split() for i in range(3)]
print(c[0][0] + c[1][1] + c[2][2])
Problem p03486 (python)

Fixed submission:
import sys

s = sorted(input())
t = sorted(input())[::-1]
print("Yes" if s < t else "No")

Buggy submission (verdict: Runtime Error):
import sys

s = sorted(input())
t = sorted(input())[::-1]
for i in range(len(s)):
    if s[i] < t[i]:
        print("Yes")
        sys.exit()
    elif s[i] > t[i]:
        print("No")
        sys.exit()
if len(t) > len(s):
    print("Yes")
else:
    print("No")
Problem p03502 (python)

Fixed submission:
x = input()
fx = sum(map(int, x))
print("Yes" if int(x) % fx == 0 else "No")

Buggy submission (verdict: Runtime Error):
x = input()
fx = sum(map(int, input()))
print("Yes" if int(x) % fx == 0 else "No")
Problem p03555 (python)

Fixed submission:
c = [input() for i in range(2)]
print("YES" if c[0] == c[1][::-1] else "NO")

Buggy submission (verdict: Runtime Error):
c = [input() for i in range(2)]
print("YES" if c[0] == c[1][::-1]) else "NO")
Problem p03826 (python)

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

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input())
print(max(a*b, c*d))
Problem p03852 (python)

Fixed submission:
c = input()
if c in 'aiueo':
    print('vowel')
else:
    print('consonant')

Buggy submission (verdict: Runtime Error):
c = int(input())
if c in 'aiueo':
    print('vowel')
else:
    print('consonant')
Problem p03943 (python)

Fixed submission:
l = sorted(map(int, input().split()))
print("Yes" if l[0] + l[1] == l[2] else "No")

Buggy submission (verdict: Runtime Error):
l = sorted(list(map, input().split()))
print("Yes" if l[0] + l[1] == l[2] else "No")
Problem p04043 (python)

Fixed submission:
lst = list(map(int, input().split()))
print("YES" if lst.count(5) == 2 and lst.count(7) == 1 else "NO")

Buggy submission (verdict: Runtime Error):
lst = map(int, input().split())
print("YES" if lst.count(5) == 2 and lst.count(7) == 1 else "NO")
Problem p02924 (python)

Fixed submission:
N = int(input())
print((N-1)*(N)//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(sum(list(range(N))[1:]))
Problem p03377 (python)

Fixed submission:
l = list(map(int, input().split()))
A, B, X = l[0], l[1], l[2]

if A <= X and A + B >= X:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
l = map(int, raw_input().split())
A, B, X = l[0], l[1], l[2]

if A <= X and A + B >= X:
    print('YES')
else:
    print('NO')
Problem p03000 (python)

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

count=1
D=0
for move in L :
    D = D + move
    if D<=x:
        count+=1
    else:
        break
print(count)

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

i=0
D=0
while(i<=n and D<=x):
    D+=L[i]
    i+=1
print(i)

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

i=0
D=0
while(i<=n+1 and D<=x):
    D+=L[i]
    i+=1
print(i)
Problem p03061 (python)

Fixed submission:
from fractions import gcd

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

L = [0]*(n+1)
R = [0]*(n+1)

for i in range(1,n+1):
    L[i] = gcd(L[i-1],a[i-1])
for i in range(0,n)[::-1]:
    R[i] = gcd(R[i+1],a[i])
    
gcd_ans=[]
for i in range(n):
    gcd_ans.append(gcd(L[i],R[i+1]))
        
print(max(gcd_ans))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

gcd_box=[]

for i in range(1,n-1):
    L_gcd=gcd_list(a[:i])
    R_gcd=gcd_list(a[i+1:])
    gcd_box.append(fractions.gcd(L_gcd,R_gcd))
    
print(max(gcd_box))
Problem p03400 (python)

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

a=[int(input()) for _ in range(n)]
sum_count=0
for i in range(n):
    A=0
    count=0
    
    while(A*a[i]+1<=d):
        count+=1
        A+=1
    sum_count+=count
print(sum_count+x)

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

for i in range(n):
    A=0
    count=0
    while(A*int(input())+1<=d):
        count+=1
        A+=1
    x+=count
print(x)
Problem p03486 (python)

Fixed submission:
ss = ''.join(sorted(input()))
tt = ''.join(sorted(input(), reverse=True))

if ss<tt:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
ss = ''.join(sorted(input()))
tt = ''.join(sorted(t, reverse=True))

if ss<tt:
    print("Yes")
else:
    print("No")
Problem p03633 (python)

Fixed submission:
n=int(input())

# 最上公倍数を考える
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

num_list=[]
for _ in range(n):
    num_list.append(int(input()))
print(lcm(*num_list))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

n=int(input())

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

num_list=[]
for _ in range(n):
    num_list.append(int(input()))
print(lcm(*num_list))

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

# 最上公倍数を考える
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

num_list=[]
for _ in range(n):
    num_list.append(int(input()))
print(lcm(*num_list))
Problem p03665 (python)

Fixed submission:
n,p=map(int, input().split())
a=list(map(int, input().split()))
total=sum( i%2 for i in a )

if total==0:
    if p==0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))

Buggy submission (verdict: Runtime Error):
n,p=map(int, input().split())
a=list(map(int, input().split()))
total=sum( n%2 for i in a )

if total=0:
    if p==0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))
Problem p03861 (python)

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

print( b//x - (a-1)//x )

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
count:int=0
for i in range(a, b+1):
    if i%x==0:
        count+=1
print(count)
Problem p04033 (python)

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

if a>0:
    print("Positive")
else:
    if b>=0:
        print("Zero")
    elif (a-b-1)%2==0:
        print("Positive")
    else:
        print("Negative")

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
num_list=list(range(a,b+1))

if a>0:
    print("Positive")
else:
    if b>=0:
        print("Zero")
    elif (a-b-1)%2==0:
        print("Positive")
    elif (a-b-1)%2==1:
        print("Negative")
Problem p03007 (python)

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

mn = A[0]
mx = A[-1]
if N ==2:
    print(A[1] - A[0])
    print(A[1],A[0])
    sys.exit()
ope = []
for a in A[1:-1]:
    if a <=0:
        ope.append([mx, a])
        mx -= a
    else:
        ope.append([mn, a])
        mn -= a
ope.append([mx,mn])
print(mx-mn)
for o in ope:
    print(o[0],o[1])

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

N = int(input())
A = deque(sorted(list(map(int,input().split()))))

operation = []
for i in range(N-1):
    if i%2==0: # Negative
        x = A.pop()
        y = A.popleft()
        operation.append(f'{x} {y}')
        A.appendleft(y + x * -1)
    else: # Positive
        x = A.popleft()
        y = A.pop() 
        operation.append(f'{x} {y}')
        A.append(y + x * -1)

print(sum(list(A)))
for o in operation:
    print(o)

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

N = int(input())
A = deque(sorted(list(map(int,input().split()))))

operation = []
for i in range(N-1):
    if i%2==0: # Negative
        x = A.pop()
        y = A.popleft()
        operation.append(f'{x} {y}')
        A.appendleft(y + x * -1)
    else: # Positive
        x = A.popleft()
        y = A.pop() 
        operation.append(f'{x} {y}')
        A.append(y + x * -1)

print(sum(list(A)))
for o in operation:
    print(o)
Problem p03043 (python)

Fixed submission:
import math
from math import log2
from math import ceil

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

def prob_wins(x,k):
    if x>=k:
        return 1
    return 0.5**ceil(log2(k/x))

ans = 0
for i in range(1,N+1):
    ans += prob_wins(i,K)
    # print(i,prob_wins(i,K))
print(ans/N)

Buggy submission (verdict: Runtime Error):
import math

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

def prob_wins(x,k):
    if x>=k:
        return 1
    return 0.5**math.ceil(math.log2(k/x))

ans = 0
for i in range(1,N+1):
    ans += prob_wins(i,K)
    # print(i,prob_wins(i,K))
print(ans/N)
Problem p03078 (python)

Fixed submission:
x,y,z,k = map(int, input().split())
aa = sorted(list(map(int, input().split())))
bb = sorted(list(map(int, input().split())))
cc = sorted(list(map(int, input().split())))

ab = sorted(a+b for a in aa for b in bb)[:-k-1:-1]
abc = sorted(s+c for s in ab[:k] for c in cc)[:-k-1:-1]
print(*abc, sep='\n')

Buggy submission (verdict: Runtime Error):
import bisect

x,y,z,k = map(int, input().split())
aa = sorted(list(map(int, input().split())))[::-1]
bb = sorted(list(map(int, input().split())))[::-1]
cc = sorted(list(map(int, input().split())))[::-1]

ia,ib,ic = 0,0,0
aa_ = [aa[ia]]
bb_ = [bb[ib]]
cc_ = [cc[ic]]
while len(aa_)*len(bb_)*len(cc_) <=k:
    if ia<x and aa[ia] == min(aa[ia],bb[ib],cc[ic]):
        ia +=1
        aa_ += [aa[ia]]
    if ib<y and bb[ib] == min(aa[ia],bb[ib],cc[ic]):
        ib +=1
        bb_ += [bb[ib]]
    else:
        ic +=1
        cc_ += [cc[ic]]

score = []
for a in aa_:
    for b in bb_:
        for c in cc_:
            bisect.insort_right(score, a+b+c)
for s in score[::-1][:k]:
    print(s)
Problem p03227 (python)

Fixed submission:
s = str(input())
if len(s)==2:
    print(s)
else:
    print(s[::-1])

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

def eat(a,b):
    a-= a%2
    b=int(b+a/2)
    a= int(a/2)
    return a,b

for i in range(k):
    if i%2==0:
        a,b = eat(a,b)
    else:
        b,a = eat(b,a)
print(a,b)
Problem p03228 (python)

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

def eat(a,b):
    a-= a%2
    b=int(b+a/2)
    a= int(a/2)
    return a,b

for i in range(k):
    if i%2==0:
        a,b = eat(a,b)
    else:
        b,a = eat(b,a)
print(a,b)

Buggy submission (verdict: Runtime Error):
%%time
# B
a,b,k = list(map(int, input().split()))

def eat(a,b):
    a-= a%2
    b=int(b+a/2)
    a= int(a/2)
    return a,b

for i in range(k):
    if i%2==0:
        a,b = eat(a,b)
    else:
        b,a = eat(b,a)
print(a,b)
Problem p03254 (python)

Fixed submission:
# 27
n,x = map(int, input().split())
aa = list(map(int, input().split()))
aa.sort()
ans = 0
for a in aa:
    if x<a:
        break
    ans+=1
    x-=a
else:    #for else文 - breakすると入らないことを利用=ループ完遂した場合の終端処理
    if x>0:
        ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
# 27
n,x = list(map(int, input().split()))
aa = list(map(int, input().split()))
aa.sort()
ans = 0
for a in aa:
    if x<a:
        break
    ans+=1
    x-=ai
else:    #for else文 - breakすると入らないことを利用=ループ完遂した場合の終端処理
    if x>0:
        ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
# 27
n,x = list(map(int, input().split()))
aa = list(map(int, input().split()))
aa.sort()
ans = 0
for a in aa:
    if x<a:
        break
    ans+=1
    x-=ai
else:    #for else文 - breakすると入らないことを利用=ループ完遂した場合の終端処理
    if x>0:
        ans-=1
print(num)

Buggy submission (verdict: Runtime Error):
# 27
n,x = list(map(int, input().split()))
aa = list(map(int, input().split()))
aa.sort()
ans = 0
for a in aa:
    if x<a:
        break
    ans+=1
    x-=ai
else:
    if x>0:
        ans-=1
print(num)
Problem p03294 (python)

Fixed submission:
# 3
import math

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

def f(m,a):
    ans=0
    for i in a:
        ans+=m%i
    return ans

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

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    ans=numbers[0]
    for i in range(1,len(numbers)):
        ans=lcm_base(ans,numbers[i])
    return ans

m= lcm_list(a)-1
print(f(m,a))

Buggy submission (verdict: Runtime Error):
# 3
import math

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

def f(m,a):
    ans=0
    for i in a:
        ans+=m%i
    return ans

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

def lcm_list(numbers):
    ans=numbers[0]
    for i in range(1,len(numbers)):
        ans=lcm_base(ans,numbers[i])
    return ans

m= lcm_list(a)-1
print(f(m,a))

Buggy submission (verdict: Runtime Error):
# 3
import math
from functools import reduce

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

def f(m,a):
    ans=0
    for i in a:
        ans+=m%i
    return ans

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

m= lcm_list(a)-1
# print(m)
print(f(m,a))
Problem p03331 (python)

Fixed submission:
n = int(input())
def digitsum(x):
    array = list(map(int, list(str(x))))
    return sum(array)

dsum = [digitsum(a)+digitsum(n-a) for a in range(1,int(n/2)+1)]
print(min(dsum))

Buggy submission (verdict: Runtime Error):
n = int(input())
def digitsum(x):
    array = list(map(int, list(str(x))))
    return sum(array)

dsum = [digitsum(a)+digitsum(n-a) for a in range(1,int(n/2))]
print(min(dsum))
Problem p03474 (python)

Fixed submission:
a,b=map(int,input().split())
s=input()
if s.count('-')==1 and s.index('-') ==a:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
import re
r = '[0-9]{}-[0-9]{}'.format(a,b)
if re.match(r'%s' % r, s) <> None:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
import re
r = '[0-9]{}-[0-9]{}'.format(a,b)
if re.match(r'%s' % r, s) <> None:
    print('Yes')
else:
    print('No')
Problem p03606 (python)

Fixed submission:
# 073B
n = int(input())
ll = [list(map(int, input().split())) for _ in range(n)]
ans=0
for l in ll:
    ans += l[1] - l[0]+1
print(ans)

Buggy submission (verdict: Runtime Error):
# 075B
h,w = map(int, input().split())
ss = [list(map(str,str(input()))) for _ in range(h)]
# print(ss)
def count_bombs(ss,i,j):
    count=0
    if ss[i][j]=='#':
        return '#'
    for y in [-1,0,1]:
        for x in [-1,0,1]:
#             print(i+y, x+j, count)
            if 0<=i+y<h and 0<=j+x<w and ss[i+y][j+x]=='#':
                count+=1
    return str(count)

for i in range(h):
    for j in range(w):
        ss[i][j] = count_bombs(ss,i,j)
#         print('## ',i,j,ss[i][j])
for s in ss:
    print(''.join(s))
Problem p03845 (python)

Fixed submission:
n = int(input())
tt = list(map(int, input().split()))
m = int(input())
drinks = [list(map(int,input().split())) for _ in range(m)]

ans = sum(tt)
for i in range(m):
    print(ans - (tt[drinks[i][0]-1] - drinks[i][1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
tt = list(map(int, input().split()))
m = int(input())
drinks = [list(map(int,input().split())) for _ in range(m)]

ans = sum(tt)
for i in range(m):
    print(ans - (tt[i] - drinks[i][1]))
Problem p03944 (python)

Fixed submission:
w,h,n = map(int,input().split())
paint = [list(map(int,input().split())) for _ in range(n)]
x1,x2,y1,y2 = 0,w,0,h
for p in paint:
    if p[2] == 1:
        x1 = max(x1,p[0])
    elif p[2] == 2:
        x2 = min(x2,p[0])
    elif p[2] == 3:
        y1 = max(y1,p[1])
    else:
        y2 = min(y2,p[1])
print(0 if x1>x2 or y1>y2 else (x2-x1)*(y2-y1))

Buggy submission (verdict: Runtime Error):
w,h,n = map(int,input().split())
paint = [list(map(int,input().split())) for _ in range(n)]
x1,x2,y1,y3 = 0,w,0,h
for p in paint:
    if p[2] == 1:
        x1 = p[0]
    elif p[2] == 2:
        x2 = p[0]
    elif p[2] == 3:
        y1 = p[1]
    else:
        y2 = p[1]
print( max(0,(x2-x1)*(y2-y1)))

Buggy submission (verdict: Runtime Error):
w,h,n = map(int,input().split())
paint = [list(map(int,input().split())) for _ in range(n)]
x1,x2,y1,y3 = 0,w,0,h
for p in paint:
    if p[2] == 1:
        x1 = p[0]
    elif p[2] == 2:
        x2 = p[0]
    elif p[2] == 3:
        y1 = p[1]
    else:
        y2 = p[1]
print( (x2-x1)*(y2-y1))
Problem p02936 (python)

Fixed submission:
n, q = list(map(int, input().split(" ")))
a = []
b = []
tree = []

class Node:
    def __init__(self, id):
        self.id = id
        self.counter = 0
        self.linked = []

    def add_node(self, node):
        self.linked.append(node)

    def add_count(self, count):
        self.counter += count

# make node
for i in range(n):
    tree.append(Node(i))

# add node
for i in range(n-1):
    j, k = list(map(int, input().split(" ")))
    tree[j-1].add_node(tree[k-1])

# add count
for i in range(q):
    j, k = list(map(int, input().split(" ")))
    tree[j-1].add_count(k)

# traverse
for i in tree:
    for j in i.linked:
        j.counter += i.counter

m = []
for i in tree:
    m.append(i.counter)

print(" ".join(map(str, m)))

Buggy submission (verdict: Runtime Error):
# 4 3
# 1 2
# 2 3
# 2 4
# 2 10
# 1 100
# 3 1

n, q = list(map(int, input().split(" ")))
a = []
b = []
for i in range(n-1):
    j, k = list(map(int, input().split(" ")))
    a.append(j)
    b.append(k)

p = []
x = []
for i in range(q):
    j, k = list(map(int, input().split(" ")))
    p.append(j)
    x.append(k)


class Node:
    def __init__(self, id):
        self.id = id
        self.counter = 0
        self.linked = []

    def add_node(self, node):
        self.linked.append(node)

    def add_count(self, count):
        self.counter += count
        for i in self.linked:
            i.add_count(count)

# make node
tree = []
for i in range(n):
    tree.append(Node(i))

for j, k in zip(a, b):
    tree[j-1].add_node(tree[k-1])

for j, k in zip(p, x):
    tree[j-1].add_count(k)

m = []
for i in tree:
    m.append(i.counter)

print(" ".join(map(str, m)))
Problem p02969 (python)

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

Buggy submission (verdict: Runtime Error):
r = input()
print(3 * r * r)
Problem p02973 (python)

Fixed submission:
import bisect

n = int(input())
a = [int(input()) for _ in range(n)]
# それぞれの色の最大値を入れる筒のリスト
t = [a[-1]]

for i in reversed(a[:-1]):
    # それぞれの色のどの値よりも小さかったとき
    idx = bisect.bisect_left(t, i+1)
    # print(i, idx)
    if idx == len(t):
        t.append(i)
    # 効率的な色の探索
    else:
        t[idx] = i
    # print(t)

print(len(t))

Buggy submission (verdict: Runtime Error):
import bisect

n = input()
a = []
n = int(n)

for i in range(n):
    a.append(int(input()))

# それぞれの色の最大値を入れる筒のリスト
t = []

for i in a:
    # それぞれの色のどの値よりも小さかったとき
    # 筒よりも小さかったとき
    if len(t) > 0 and i < t[0]:
        t.insert(0, i)
    # 筒よりも大きかったとき
    idx = bisect.bisect_left(t, i)
    t[idx-1] = i
    # print(t)

print(len(t))