Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
H, W = map(int, raw_input().split())
h, w = map(int, raw_input().split())

print int((H-h)*(W-w)     

Fixed submission:
import numpy as np
H, W = map(int, raw_input().split())
h, w = map(int, raw_input().split())

print int((H-h)*(W-w))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, raw_input().split())
ab = [[0 for i in range(2)] for j in range(N)]
for i in range(N):
    ab[i][0], ab[i][1] = map(int, raw_input().split())
AB = sorted(ab, key=lambda x:x[0])
count = 0
total = 0
for i in range(N):
    for j in range(AB[i][1]):
        if count < M:
            total += AB[i][0]
            count += 1
        else:
            break
                                                                                                                    
print total


Fixed submission:
N,M = map(int, raw_input().split())
ab = [[0 for i in range(2)] for j in range(N)]
for i in range(N):
    ab[i][0], ab[i][1] = map(int, raw_input().split())
AB = sorted(ab, key=lambda x:x[0])
count = 0
total = 0
for AB_ in AB:
    num = min(M, AB_[1])
    total += AB_[0]*num
    M -= num
print total

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, raw_input().split())
ab = [[0 for i in range(2)] for j in range(N)]
for i in range(N):
    ab[i][0], ab[i][1] = map(int, raw_input().split())
AB = sorted(ab, key=lambda x:x[0])
count = 0
total = 0
for i in range(N):
    for j in range(AB[i][1]):
        if count < M:
            total += AB[i][0]
            count += 1
            if count > M:
                exit()

print total

Fixed submission:
N,M = map(int, raw_input().split())
ab = [[0 for i in range(2)] for j in range(N)]
for i in range(N):
    ab[i][0], ab[i][1] = map(int, raw_input().split())
AB = sorted(ab, key=lambda x:x[0])
count = 0
total = 0
for AB_ in AB:
    num = min(M, AB_[1])
    total += AB_[0]*num
    M -= num
print total
Buggy python submission (verdict: Time Limit Exceeded):
S = raw_input()
count = 0
flag = True
while(flag):
    if '01' in S:
        S = S.replace('01','',1)
        count += 2
        continue
    elif '10' in S:
        S = S.replace('10','',1)
        count += 2
        continue                                                                                                    
    flag = False
print count


Fixed submission:
S = raw_input()
print 2*min(S.count('0'), S.count('1'))

Buggy python submission (verdict: Time Limit Exceeded):
S = raw_input()
count = 0
flag = True
while(flag):
    if '01' in S:
        S = S.replace('01','',1)
        count += 2                                                                                                  
    elif '10' in S:
        S = S.replace('10','',1)
        count += 2
    else:
        flag = False
print count


Fixed submission:
S = raw_input()
print 2*min(S.count('0'), S.count('1'))
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
if A*C<=B:
    print(C)
else:
    n=B//A
    print(n)

Fixed submission:
A,B,C= map(int, input().split())
if A*C<=B:
    print(C)
else:
    n=B//A
    print(n)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
if A*C<=B:
    print(C)
else:
    n=B//A
    print(n)

Fixed submission:
A,B,C= map(int, input().split())
if A*C<=B:
    print(C)
else:
    n=B//A
    print(n)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
if A*C<=B:
    print(C)
else:
    n=B//A
    print(n)

Fixed submission:
A,B,C= map(int, input().split())
if A*C<=B:
    print(C)
else:
    n=B//A
    print(n)
Buggy python submission (verdict: Time Limit Exceeded):
def xor(a, b):
    ret = a
    for i in range(a+1, b+1):
        ret ^= i
    return ret


def xor_world(A, B):
    if A == B:
        return A

    if B < 8:
        return xor(A, B)

    n = 4
    while n < A:
        n <<= 1

    left = n

    while n <= B:
        n <<= 1

    right = (n >> 1) - 1

    if not (left < right):
        return xor(A, B)

    return xor(xor(A, left-1), xor(right+1, B))


if __name__ == "__main__":
    A, B = map(int, input().split())
    print(xor_world(A, B))

Fixed submission:
def xor_world(A, B):
    if A == 0:
        m  = (B+1) // 2
        pre = 0 if m % 2 == 0 else 1
        if B % 2 == 1: 
            return pre 
        else:
            return pre ^ B
            
    else:   
        return xor_world(0, A-1) ^ xor_world(0, B)
        
        
if __name__ == "__main__":
    A, B = map(int, input().split())
    print(xor_world(A, B))
Buggy python submission (verdict: Runtime Error):
s = input()
tgt = ['A', 'C', 'G', 'T']

lst = []
cnt = 0

for x in s:
  if x in tgt:
    cnt = cnt +1
  else:
    lst.append(cnt)
    cnt = 0

print(max(lst)


Fixed submission:
s = input()
tgt = ['A', 'C', 'G', 'T']

lst = []
cnt = 0

for x in s:
  if x in tgt:
    cnt = cnt +1
  else:
    lst.append(cnt)
    cnt = 0
    
lst.append(cnt)

print(max(lst))

Buggy python submission (verdict: Runtime Error):
s = input()
tgt = ['A', 'C', 'G', 'T', ]

lst = []
cnt = 0

for x in s:
  if x in tgt:
    cnt = cnt +1
  else:
    lst.append(cnt)
    cnt = 0

print(max(lst))

Fixed submission:
s = input()
tgt = ['A', 'C', 'G', 'T']

lst = []
cnt = 0

for x in s:
  if x in tgt:
    cnt = cnt +1
  else:
    lst.append(cnt)
    cnt = 0
    
lst.append(cnt)

print(max(lst))

Buggy python submission (verdict: Runtime Error):
def main():
    *S, = input()
    count = 0
    max = 0
    for i in S:
        if i == "A" or i == "C" or i == "G" or i == "T":
            count += 1
        else:
            if max < count:
                max = count
            count = 0
    print(max(count, max))
main()

Fixed submission:
def main():
    *S, = input()
    count = 0
    maximum = 0
    for i in S:
        if i == "A" or i == "C" or i == "G" or i == "T":
            count += 1
        else:
            if maximum < count:
                maximum = count
            count = 0
    print(max(count, maximum))
main()
Buggy python submission (verdict: Time Limit Exceeded):
B = [float('inf')]*(10 ** 5)
A = [float('inf')]*(10 ** 5)
def main():
    accum = 0
    cost = 0
    N, M = map(int, input().split())
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    while accum < M:
         index = A.index(min(A))
         Aind = A.pop(index)
         Bind = B.pop(index)
         if accum + Bind > M:
             cost += Aind * (M - accum)
             accum = M
         else:
             accum += Bind
             cost += Aind * Bind
    print(cost)

main()


Fixed submission:
from operator import itemgetter
A = []

def main():
    accum = 0
    cost = 0
    N, M = map(int, input().split())
    for i in range(N):
        A.append(list(map(int, input().split())))
    B = sorted(A, key = itemgetter(0))
    while accum < M:
         eB = B.pop(0)
         if accum + eB[1] > M:
             cost += eB[0] * (M - accum)
             accum = M
         else:
             accum += eB[1]
             cost += eB[0] * eB[1]
    print(cost)

main()
Buggy python submission (verdict: Runtime Error):
def main():
    A, B, K = map(int, input().split())
    CDD = []
    maxi = max(A,B)
    mini = min(A,B)
    for i in range(1, mini + 1):
        if mini % i == 0:
            if maxi % i == 0:
                CDD.append(i)
    print(CDD)
    print(CDD[-K:-K + 1][0])
main()

Fixed submission:
def main():
    A, B, K = map(int, input().split())
    CDD = []
    maxi = max(A,B)
    mini = min(A,B)
    for i in reversed(range(1, mini + 1)):
        if mini % i == 0:
            if maxi % i == 0:
                CDD.append(i)
    print(CDD[K - 1])
main()
Buggy python submission (verdict: Runtime Error):
K = [None]*30
A = [None]*30
Ms = [0]*30
def main():
    N, M = map(int, input().split())
    for i in range(N):
        K[i], *A[i], = map(int, input().split())
    for i in A:
        if i == None:
            break
        for j in i:
            Ms[j] += 1
    print(Ms.count(N))

main()


Fixed submission:
K = [None]*30
A = [None]*30
Ms = [0]*31
def main():
    N, M = map(int, input().split())
    for i in range(N):
        K[i], *A[i], = map(int, input().split())
    for i in A:
        if i == None:
            break
        for j in i:
            Ms[j] += 1
    print(Ms.count(N))

main()
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
from collections import Counter
def main():
    va = []
    vb = []
    n = int(input())
    *v, = map(int, input().split())
    for i in range(len(v)):
        if i % 2 == 0:
            va.append(v[i])
        else:
            vb.append(v[i])
    a1 = Counter(va).most_common()
    a2 = Counter(vb).most_common()
    how_many_a1 = a1[0][1]
    how_many_a2 = a2[0][1]
    if a1[0][0] != a2[0][0]:
        print(n - how_many_a1 - how_many_a2)
    else:
        if (len(va) - how_many_a1) + (len(vb) - how_many_a2[0][1])  > (len(vb) - how_many_a2) + (len(va) - how_many_a1[0][1]):
            print((len(vb) - how_many_a2) + (len(va) - how_many_a1[0][1]))
        else:
            print((len(va) - how_many_a1) + (len(vb) - how_many_a2[0][1]))
main()


Fixed submission:
from operator import itemgetter
from collections import Counter
def main():
    va = []
    vb = []
    n = int(input())
    *v, = map(int, input().split())
    for i in range(len(v)):
        if i % 2 == 0:
            va.append(v[i])
        else:
            vb.append(v[i])
    a1 = Counter(va).most_common()
    a2 = Counter(vb).most_common()
    how_many_a1 = a1[0][1]
    how_many_a2 = a2[0][1]
    if a1[0][0] != a2[0][0]:
        print(n - how_many_a1 - how_many_a2)
    else:
        if len(a1) == 1 and len(a2) == 1:
            print(int(n/2))
        elif len(a1) == 1:
            print(len(vb) - a2[1][1])
        elif  len(a2) == 1:
            print(len(va) - how_many_a1)
        elif (len(va) - how_many_a1) + (len(vb) - a2[1][1])  > (len(vb) - how_many_a2) + (len(va) - a1[1][1]):
            print((len(vb) - how_many_a2) + (len(va) - a1[1][1]))
        else:
            print((len(va) - how_many_a1) + (len(vb) - a2[1][1]))
main()
Buggy python submission (verdict: Runtime Error):
S = input()
Slist =　list(S)

i = 0
max = 0
for s in Slist:
  if s == "A" or "C" or "G" or "T":
    i += 1
    if i >= max:
      max = i
  elif:
    i = 0
    
print(max)

Fixed submission:
S = input()
 
i = 0
max = 0
for s in S:
  if s == "A" or s=="C" or s=="G" or s=="T":
    i += 1
    if i >= max:
      max = i
  else:
    i = 0
    
print(max)
Buggy python submission (verdict: Runtime Error):
|AB|,|BC|,|CA|= map(int,input().split())
print(|AB|*|BC|/2)

Fixed submission:
x,y,z= map(int,input().split())
print(int(x*y/2))
Buggy python submission (verdict: Runtime Error):
a=int(input())
if a ==7or5or3:
  print('YES')
else:
  print('NO')

Fixed submission:
a=int(input())
if a==3 or a==5 or a==7:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
x=int(input())
if x == 1:
  print('Hello World')
else:
  a,b=map(int,input().split())
  print(a+b)


Fixed submission:
x=int(input())
if x == 1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)

Buggy python submission (verdict: Runtime Error):
x=int(input())
if x == 1:
  print('Hello World')
elif x == 2:
  a,b=map(int,input().split())
  print(int(a+b))


Fixed submission:
x=int(input())
if x == 1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)

Buggy python submission (verdict: Runtime Error):
x=int(input())
a,b=map(int,input().split())
if x == 1:
  print('Hello World')
else:
  print(int(a+b))


Fixed submission:
x=int(input())
if x == 1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)

Buggy python submission (verdict: Runtime Error):
x=int(input())
if x == 1:
  print('Hello World')
else:
  a,b=map(int,input().split())
  print(int(a+b))

Fixed submission:
x=int(input())
if x == 1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)
Buggy python submission (verdict: Runtime Error):
a=int(input())
for i in a:
  if i ==1:
    i=9
  elif i ==9:
    i=1
  print(int(a))

Fixed submission:
a=int(input())
b=str(a).replace('1','a').replace('9','b')
c=b.replace('a','9').replace('b','1')
print(int(c))

Buggy python submission (verdict: Runtime Error):
a=int(input())
print(a.replace(1,9).replace(9,1))


Fixed submission:
a=int(input())
b=str(a).replace('1','a').replace('9','b')
c=b.replace('a','9').replace('b','1')
print(int(c))

Buggy python submission (verdict: Runtime Error):
print(int(input()).replace(1,9).replace(9,1))


Fixed submission:
a=int(input())
b=str(a).replace('1','a').replace('9','b')
c=b.replace('a','9').replace('b','1')
print(int(c))

Buggy python submission (verdict: Runtime Error):
print(input().replace(1,9).replace(9,1))

Fixed submission:
a=int(input())
b=str(a).replace('1','a').replace('9','b')
c=b.replace('a','9').replace('b','1')
print(int(c))
Buggy python submission (verdict: Runtime Error):
a = list(input())
b = [int(i) for i in a]
c=sorted(b,reverse=True)
d =10*c[0]+c[1]+c[2]
print(int(d))

Fixed submission:
a = input().split()
b = [int(i) for i in a]
c=sorted(b,reverse=True)
d =10*c[0]+c[1]+c[2]
print(d)

Buggy python submission (verdict: Runtime Error):
 = list(input())
b = [int(i) for i in a]
c=sorted(b,reverse=True)
d =10*c[0]+c[1]+c[2]
print(d)

Fixed submission:
a = input().split()
b = [int(i) for i in a]
c=sorted(b,reverse=True)
d =10*c[0]+c[1]+c[2]
print(d)
Buggy python submission (verdict: Runtime Error):
K=int(input()**2//4)

Fixed submission:
K=int(input())
if K%2==0:
  print(int((K/2)**2))
else:
  print(int((K-1)/2*(K+1)/2))

Buggy python submission (verdict: Runtime Error):
K=int(input()//2**2)

Fixed submission:
K=int(input())
if K%2==0:
  print(int((K/2)**2))
else:
  print(int((K-1)/2*(K+1)/2))
Buggy python submission (verdict: Runtime Error):
a=int(input())
if a%2==0:
  print(a)
else:
  print(2a)

Fixed submission:
a=int(input())
if a%2==0:
  print(a)
else:
  print(2*a)
Buggy python submission (verdict: Runtime Error):
print('Yes' if ''join(sorted(input()))=='abc' else 'No' )

Fixed submission:
print('Yes' if ''.join(sorted(input()))=='abc' else 'No' )

Buggy python submission (verdict: Runtime Error):
print('Yes' if ''join(sorted.input())=='abc' else 'No' )

Fixed submission:
print('Yes' if ''.join(sorted(input()))=='abc' else 'No' )

Buggy python submission (verdict: Runtime Error):
print('Yes' if ''.join.sorted.input()=='abc' else 'No' )

Fixed submission:
print('Yes' if ''.join(sorted(input()))=='abc' else 'No' )

Buggy python submission (verdict: Runtime Error):
print('Yes' if sorted.input()=='abc' else 'No' )

Fixed submission:
print('Yes' if ''.join(sorted(input()))=='abc' else 'No' )
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()));print(min(a[:2])+min(a[2:]))

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
z=[a,b,c,d]
print(min(z[:2])+min(z[2:]))

Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()));print(min(a[:1])+min(a[2:]))

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
z=[a,b,c,d]
print(min(z[:2])+min(z[2:]))

Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split());print(min(a[:1])+min(a[2:]))

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
z=[a,b,c,d]
print(min(z[:2])+min(z[2:]))
Buggy python submission (verdict: Runtime Error):
a=[(input()) for i in range(9)]
print(a[0]+a[4]+a[8])

Fixed submission:
a=list(input())
b=list(input())
c=list(input())
print(a[0]+b[1]+c[2])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print('Yes' if a%500<=b else 'No')

Fixed submission:
a=int(input())
b=int(input())
print('Yes' if a%500<=b else 'No')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());print('Even' if a*b%==0 else 'Odd')

Fixed submission:
a,b=map(int,input().split());print('Even' if a*b%2==0 else 'Odd')
Buggy python submission (verdict: Runtime Error):
s=list(input())
s[3]=8
print(''.join(s))

Fixed submission:
s=list(input())
s[3]='8'
print(''.join(s))
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split());print('Left' if a+b>c+d elif a+b<c+d 'Right' else 'Balanced')

Fixed submission:
a,b,c,d=map(int,input().split())
if a+b > c+d:
  print('Left')
elif a+b == c+d:
  print('Balanced')
else:
  print('Right')
Buggy python submission (verdict: Runtime Error):
map(int,input().split());print(-(-(a+b)//2))

Fixed submission:
a,b=map(int,input().split());print(-(-(a+b)//2))

Buggy python submission (verdict: Runtime Error):
print(-(-(a+b)//2))

Fixed submission:
a,b=map(int,input().split());print(-(-(a+b)//2))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split());print(min[a*b,c])

Fixed submission:
a,b,c=map(int,input().split());print(min([a*b,c]))
Buggy python submission (verdict: Runtime Error):
print('Yes' if len(set(input()[:3]))==1 else 'Yes' if len(set(input()[1:]))==1 else 'No')

Fixed submission:
a = input()
if len(set(a[:3]))==1 or len(set(a[1:]))==1:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
print('Yes' if len(set(input()[:3]))==1 or len(set(input()[1:]))==1 else 'No')

Fixed submission:
a = input()
if len(set(a[:3]))==1 or len(set(a[1:]))==1:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
print('Yes' if len(set(list(input()))))<3 else 'No')

Fixed submission:
a = input()
if len(set(a[:3]))==1 or len(set(a[1:]))==1:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
a,b=input();print('>' if a>b else '<' if a<b else '=')

Fixed submission:
a,b=input().split();print('>' if a>b else '<' if a<b else '=')

Buggy python submission (verdict: Runtime Error):
a,b=input();print('>' if a>b else '<' if a<b else '=')

Fixed submission:
a,b=input().split();print('>' if a>b else '<' if a<b else '=')

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());print('>' if a>b else '<' if a<b else '=')

Fixed submission:
a,b=input().split();print('>' if a>b else '<' if a<b else '=')
Buggy python submission (verdict: Runtime Error):
print(max(int(input())-int(input())),0)

Fixed submission:
a,b=map(int,input().split());print(a-b if a>=b else 0)
Buggy python submission (verdict: Runtime Error):
a=int(input());print('Yes' if a[0]==a[2] else 'No')

Fixed submission:
a=input();print('Yes' if a[0]==a[2] else 'No')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());print('Possible' if a%3==0 else 'Possible' if b%3==0 else 'Possible' (a+b)%3==0 else 'Impossible')

Fixed submission:
a,b=map(int,input().split());print('Possible' if a%3==0 else 'Possible' if b%3==0 else 'Possible' if (a+b)%3==0 else 'Impossible')

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());print('Possible' if a%3==0 else 'Possible' if b%3==0 else 'Possible' a+b%3==0 else 'Impossible')

Fixed submission:
a,b=map(int,input().split());print('Possible' if a%3==0 else 'Possible' if b%3==0 else 'Possible' if (a+b)%3==0 else 'Impossible')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a=1
for i in range(n):
	a = a * (i + 1)
print(a%(7+10**9))

Fixed submission:
import math
print(math.factorial(int(input()))%(7+10**9))
Buggy python submission (verdict: Runtime Error):
a = (int(input())+13) % 15
b = (int(input())+13) % 15

print('Alice' if a > b else 'Bob' if a < b else 'Draw')


Fixed submission:
x,y=map(int,input().split())
a = (x + 13) % 15
b = (y + 13) % 15
print('Alice' if a > b else 'Bob' if a < b else 'Draw')

Buggy python submission (verdict: Runtime Error):
a=(int(input())+13)%15;b=(int(input())+13)%15;print('Alice' if a>b else 'Bob' if a<b else 'Draw')

Fixed submission:
x,y=map(int,input().split())
a = (x + 13) % 15
b = (y + 13) % 15
print('Alice' if a > b else 'Bob' if a < b else 'Draw')

Buggy python submission (verdict: Runtime Error):
a,b=(map(int,input().split())+13)%15;print('Alice' if a>b else 'Bob' if a<b else 'Draw')

Fixed submission:
x,y=map(int,input().split())
a = (x + 13) % 15
b = (y + 13) % 15
print('Alice' if a > b else 'Bob' if a < b else 'Draw')

Buggy python submission (verdict: Runtime Error):
a,b=(map(int,input().split())+13)%15;print('Alice' if a>b else 'Bob' if a<b else 'Draw)

Fixed submission:
x,y=map(int,input().split())
a = (x + 13) % 15
b = (y + 13) % 15
print('Alice' if a > b else 'Bob' if a < b else 'Draw')
Buggy python submission (verdict: Runtime Error):
n=int(input())
t = list(map(int,input().split()))
m = int(input())
l = [list(map(int,input().split())) for i in range(m)]
print(sum(t)-t[l[0][0]-1]+l[0][1])
print(sum(t)-t[l[1][0]-1]+l[1][1])
print(sum(t)-t[l[2][0]-1]+l[2][1])

Fixed submission:
a,b,c=input().split()
print(eval(a+b+c))

Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
print(eval(abc))

Fixed submission:
a,b,c=input().split()
print(eval(a+b+c))

Buggy python submission (verdict: Runtime Error):
print(eval(*input()))

Fixed submission:
a,b,c=input().split()
print(eval(a+b+c))
Buggy python submission (verdict: Runtime Error):
n=int(input())
t = list(map(int,input().split()))
m = int(input())
l = [list(map(int,input().split())) for i in range(m)]
print(sum(t)-t[l[0][0]-1]+l[0][1])
print(sum(t)-t[l[1][0]-1]+l[1][1])
print(sum(t)-t[l[2][0]-1]+l[2][1])

Fixed submission:
n=int(input())
t = list(map(int,input().split()))
m = int(input())
l = [list(map(int, input().split())) for i in range(m)]
for j in range(m):
    print(sum(t)-t[l[j][0]-1]+l[j][1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
t = list(map(int,input().split()))
m = int(input())
l = [list(map(int,input().split())) for i in range(m)]
print(t)
print(l)
print(sum(t)-t[l[0][0]-1]+l[0][1])
print(sum(t)-t[l[1][0]-1]+l[1][1])
print(sum(t)-t[l[2][0]-1]+l[2][1])

Fixed submission:
n=int(input())
t = list(map(int,input().split()))
m = int(input())
l = [list(map(int, input().split())) for i in range(m)]
for j in range(m):
    print(sum(t)-t[l[j][0]-1]+l[j][1])
Buggy python submission (verdict: Runtime Error):
a,b,h=map(int,input().split());print(int((a+b)*h/2))

Fixed submission:
a,b,h=[int(input()) for i in range(3)];print(int((a+b)*h/2))

Buggy python submission (verdict: Runtime Error):
a,b,h=map(int,input().split());print((a+b)*h/2)

Fixed submission:
a,b,h=[int(input()) for i in range(3)];print(int((a+b)*h/2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
c = []
for _ in range(N):
    c.append(int(input()))

dp = [0] * N
dp[0] = 1

for i in range(1, N):
    if c[i] == c[i - 1]:
        dp[i] = dp[i - 1]
        continue
    for j in range(i):
        if j == 0 and c[j] == c[i]:
            dp[i] += 1
        if c[i] == c[j + 1] and c[j] != c[j + 1]:
            dp[i] += dp[j]
print(dp[N - 1])

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

N = int(input())
c = []
for _ in range(N):
    c.append(int(input()))

dp = [0] * N
dp[0] = 1
dpc = [0] * (max(c) + 1)
dpc[c[0]] = 1

for i in range(1, N):
    dp[i] = dp[i - 1]
    if c[i] != c[i - 1]:
        dp[i] += dpc[c[i]]
        dpc[c[i]] += dp[i - 1]

print(dp[N - 1] % (10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
from copy import copy

N = int(input())
C = []
for _ in range(N):
    C.append(int(input()))

def is_fin(C):
    hist = set([C[0]])
    active = C[0]
    for i in C:
        if i != active:
            if i in hist:
                return False
            hist.add(i)
            active = i
    return True

ret = set()
def dfs(C, depth):
    if depth >=5 :
        return
    ret.add(str(C))
    if is_fin(C):
        return

    for i in range(len(C)):
        for j in range(i + 1, len(C)):
            if C[i] == C[j] and len(set(C[i:j])) >= 2:
                _C = copy(C)
                _C[i:j] = [C[i]] * (j - i)
                dfs(_C, depth+1)

dfs(C, 0)
print(len(ret))


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

N = int(input())
c = []
for _ in range(N):
    c.append(int(input()))

dp = [0] * N
dp[0] = 1
dpc = [0] * (max(c) + 1)
dpc[c[0]] = 1

for i in range(1, N):
    dp[i] = dp[i - 1]
    if c[i] != c[i - 1]:
        dp[i] += dpc[c[i]]
        dpc[c[i]] += dp[i - 1]

print(dp[N - 1] % (10**9+7))