Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# | A - K | = | B - K |
raw = raw_input().split()
A = int(raw[0])
B = int(raw[1])

up = (A**2-B**2)
down = (2 * ( A-B ))

if up % down == 0:
	print(up/down)
else:
	print("IMPOSSIBLE")

Fixed submission:
# | A - K | = | B - K |
A, B = map(int, input().split())

up = (A**2-B**2)
down = (2 * ( A-B ))

if up % down == 0:
	print(int(up/down))
else:
	print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
# | A - K | = | B - K |
in = raw_input().split()
A = in[0]
B = in[1]

K = (A**2-B**2) / 2 / ( A-B )

if isinstance(K, int):
	print(K)
else
	print("IMPOSSIBLE")

Fixed submission:
# | A - K | = | B - K |
A, B = map(int, input().split())

up = (A**2-B**2)
down = (2 * ( A-B ))

if up % down == 0:
	print(int(up/down))
else:
	print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
# | A - K | = | B - K |
in = raw_input().split()
A = in[0]
B = in[1]

K = (A**2-B**2) / 2 / ( A-B )

Fixed submission:
# | A - K | = | B - K |
A, B = map(int, input().split())

up = (A**2-B**2)
down = (2 * ( A-B ))

if up % down == 0:
	print(int(up/down))
else:
	print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split())
 
if a % 2 != b % 2:
  return "IMPOSSIBLE"
else:
  return int((a+b) / 2)

Fixed submission:
a, b = (int(i) for i in input().split())
 
if a % 2 != b % 2:
  print("IMPOSSIBLE")
else:
  print(int((a+b) / 2))

Buggy python submission (verdict: Time Limit Exceeded):
a, b = (int(i) for i in input().split())
 
for i in range(0, 10**9):
  if (a-i) == (b-i):
    print(i)
    break
    
print("IMPOSSIBLE")

Fixed submission:
a, b = (int(i) for i in input().split())
 
if a % 2 != b % 2:
  print("IMPOSSIBLE")
else:
  print(int((a+b) / 2))

Buggy python submission (verdict: Time Limit Exceeded):
a, b = (int(i) for i in input().split())

for i in range(0, 10**9):
  if (a-i) == (b-i):
    print(i)
    
print("IMPOSSIBLE")

Fixed submission:
a, b = (int(i) for i in input().split())
 
if a % 2 != b % 2:
  print("IMPOSSIBLE")
else:
  print(int((a+b) / 2))

Buggy python submission (verdict: Runtime Error):
a = int(input().split()[0])
b = int(input().split()[1])

for i in range(0, 10**9):
  if (a-i) == (b-i):
    return i
return "IMPOSSIBLE"




Fixed submission:
a, b = (int(i) for i in input().split())
 
if a % 2 != b % 2:
  print("IMPOSSIBLE")
else:
  print(int((a+b) / 2))
Buggy python submission (verdict: Runtime Error):
a = [for int(i) in input.split()]
 
count = 0
for i in range(0, len(a)-1):
  if a[i] > a[i+1]:
    count += 1
    if count > 2:
      print('NO')
      break
  
  if i == len(a)-1:
    print('YES')


Fixed submission:
N = int(input())
num_list = [int(_) for _ in input().split()]
 
count = 0
 
for i in range(0, N):
  if num_list[i] != i+1:
    count += 1
    
if count <= 2:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Runtime Error):
list = [for int(i) in input.split()]

count = 0
for i in range(0, len(list)-1):
  if list[i] < list[i+1]:
    count += 1
  	
if count > 2:
  print('NO')
else:
  print('YES')

Fixed submission:
N = int(input())
num_list = [int(_) for _ in input().split()]
 
count = 0
 
for i in range(0, N):
  if num_list[i] != i+1:
    count += 1
    
if count <= 2:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
import sys


a = int(sys.argv[1])
b = int(sys.argv[2])

k = (a + b) / 2

print(int(k), end="") if int(k) == k else print("IMPOSSIBLE", end="")





Fixed submission:
import sys

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

k = (i[0] + i[1]) / 2

print(int(k), end="") if int(k) == k else print("IMPOSSIBLE", end="")

Buggy python submission (verdict: Runtime Error):
import sys


a = int(sys.argv[1])
b = int(sys.argv[2])

k = (a + b) / 2

print(int(k)) if int(k) == k else print("IMPOSSIBLE")

Fixed submission:
import sys

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

k = (i[0] + i[1]) / 2

print(int(k), end="") if int(k) == k else print("IMPOSSIBLE", end="")

Buggy python submission (verdict: Runtime Error):
import sys


a = sys.argv[1]
b = sys.argv[2]

k = (a + b) / 2

print(k) if int(k) == k else print("IMPOSSIBLE")


Fixed submission:
import sys

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

k = (i[0] + i[1]) / 2

print(int(k), end="") if int(k) == k else print("IMPOSSIBLE", end="")
Buggy python submission (verdict: Runtime Error):
n, m, c - [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]

r = 0
for i in range(n):
  a = [int(i) for i in input().split(' ')]
  s = 0
  for j in range(m):
    s += a[j] * b[j]
  s += c
  if s > 0:
    r += 1
  
print(r)

Fixed submission:
n, m, c = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
 
r = 0
for i in range(n):
  a = [int(i) for i in input().split(' ')]
  s = 0
  for j in range(m):
    s += a[j] * b[j]
  s += c
  if s > 0:
    r += 1
  
print(r)
Buggy python submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split(' ')]
class P:
  def __init__(self, a, b)
  	self.a = a
    self.b = b

p = []
for i in range(n):
  a,b=[int(i) for i in input().split(' ')]
  p.append(P(a, b))

  
mon = 0
p.sort(key=lambda x: x.a)
for e in p:
  if m <= e.b:
    mon += e.q * m
    m = 0
  else:
    m -= e.b
    mon += e.a * e.b

print(mon)

Fixed submission:
n,m=[int(i) for i in input().split(' ')]
class P:
  def __init__(self, a, b):
    self.a = a
    self.b = b

p = []
for i in range(n):
  a,b=[int(i) for i in input().split(' ')]
  p.append(P(a, b))

  
mon = 0
p.sort(key=lambda x: x.a)
for e in p:
  if m <= e.b:
    mon += e.a * m
    m = 0
  else:
    m -= e.b
    mon += e.a * e.b

print(mon)
Buggy python submission (verdict: Time Limit Exceeded):
a, b = [int(i) for i in input().split(' ')]
for i in range(a, b):
  b ^= i

print(b)

Fixed submission:
a, b = [int(i) for i in input().split(' ')]

if a == b:
  print(a)
  exit()
  
c = 0
if a % 2 == 1:
  c = a
  a += 1

if a == b:
  print(c ^ a)
  exit()

d = (b - (a - 1)) // 2
if d % 2 == 0:
  c ^= 0
else:
  c ^= 1

if b % 2 == 0:
  c ^= b

print(c)
Buggy python submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split(" ")]

c = []
d = []
for i in range(n):
	a = [int(x) for x in input().split(" ")]
	if i == 0:
        c = a[- a[0] + 1:]
    else:
        b = a[- a[0]:]
        for ce in c:
            if ce in b:
                 d.append(ce)
        c = d
        d = []

print(len(c))
        

Fixed submission:
n, m = [int(x) for x in input().split(" ")]

c = []
d = []
for i in range(n):
    a = [int(x) for x in input().split(" ")]
    if i == 0:
        c = a[- a[0]:]
    else:
        b = a[- a[0]:]
        for ce in c:
            if ce in b:
                 d.append(ce)
        c = d
        d = []

print(len(c))
Buggy python submission (verdict: Runtime Error):
A,B=int(input()).split()
def asf(A,B):
  same_num=(A+B)/2
  k=same_num-min(A,B)
  return k
print(asf(A,B))

Fixed submission:
A,B=map(int,input().split())
def asf(A,B):
  same_num=(A+B)/2
  if same_num%1==0:
  	return int(same_num)
  else:
    return "IMPOSSIBLE"
print(asf(A,B))
Buggy python submission (verdict: Runtime Error):
N=int(input().split())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
def rescale(V,C):
  price=0
  for v,c in zip(V,C):
    if v>c:
      price=price+v-c
  return price 
print("{}".format(rescale(V,C)))


Fixed submission:
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
def rescale(V,C):
  price=0
  for v,c in zip(V,C):
    if v>c:
      price=price+v-c
  return price 
print("{}".format(rescale(V,C)))
Buggy python submission (verdict: Runtime Error):
import numpy as np 

N=int(input())
t=[0]*N
x=[0]*N
y=[0]*N
for i in range(N):
  t[i],x[i],y[i]=map(int,input().split())
  
def traveling(t,x,y):
  time_i=0
  for i,time in enumerate(t):
    time_i=time-time_i
    z=x[i]+y[i]
    if (t-z)%2==0:
      return "Yes"
    else:
      return "No"
    time_i=time
    
print("{}".format(traveling(t,x,y)))
     
  

Fixed submission:
N=int(input())
t=[0]*N
x=[0]*N
y=[0]*N
for i in range(N):
  t[i],x[i],y[i]=map(int,input().split())
  
def traveling(t,x,y):
  time_i=0
  x_i=0
  y_i=0
  for i,time in enumerate(t):
    time_i=time-time_i
    x_i=x[i]-x_i
    y_i=y[i]-y_i
    z=x_i+y_i
    if (time_i-z)%2!=0 or z>time_i:
      return "No"
    time_i=time
    x_i=x[i]
    y_i=y[i]
  return "Yes"
    
print("{}".format(traveling(t,x,y)))
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())import math
warareru = b-a+1
x = warareru//c
y = warareru//d
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

 #最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)
z = warareru//lcm(c,d)
print(warareru-(x+y-z))

Fixed submission:
a,b,c,d = map(int,input().split())
import math
#最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

 #最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

A = (a-1)//c + (a-1)//d - (a-1)//lcm(c,d)
B = b//c + b//d -b//lcm(c,d)

print((b-B)-((a-1)-A))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
suji = []
for i in range(b):
    if a+i<=b:
        suji.append(a+i)
    else:
        pass
count=0
for j in range(len(suji)):
    if suji[j]%c==0 or suji[j]%d==0:
        count+=0
    else:
        count+=1
print(count)

Fixed submission:
a,b,c,d = map(int,input().split())
import math
#最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

 #最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

A = (a-1)//c + (a-1)//d - (a-1)//lcm(c,d)
B = b//c + b//d -b//lcm(c,d)

print((b-B)-((a-1)-A))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
n = len(s)

if n == 1:
    print(1)
    exit(0)

l = []
if s[0] == "0":
    l.append(0)

temp = 1
for i in range(1, n):
    if s[i] == s[i - 1]:
        temp += 1
        if i == n - 1:
            l.append(temp)
    else:
        l.append(temp)
        temp = 1

if s[-1] == "0":
    l.append(0)

ans = 0
if 2 * k + 1 > len(l):
    sum(l[i * 2 : min(i * 2 + 2 * k + 1, len(l)) : 1])

b = []
b.append(l[0])
for i in range(1, len(l)):
    b.append(b[-1] + l[i])


for i in range((len(l) + 1)):
    if i * 2 + 2 * k + 1 > len(l):
        break
    ans = max(ans, b[min(i * 2 + 2 * k + 1, len(l))] - b[i * 2 - 1])
print(ans)


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

if n == 1:
    print(1)
    exit(0)

l = []
if s[0] == "0":
    l.append(0)

temp = 1
for i in range(1, n):
    if s[i] == s[i - 1]:
        temp += 1
        if i == n - 1:
            l.append(temp)
    else:
        l.append(temp)
        temp = 1
        if i == n - 1:
            l.append(temp)

if s[-1] == "0":
    l.append(0)

ans = 0

b = []
b.append(l[0])
for i in range(1, len(l)):
    b.append(b[-1] + l[i])


if 2 * k + 1 > len(l) - 1:
    print(b[len(l) - 1])
    exit(0)
else:
    ans = b[2 * k]


for i in range(1, len(l)):
    if i * 2 + 2 * k > len(l) - 1:
        break
    ans = max(ans, b[min(i * 2 + 2 * k, len(l) - 1)] - b[i * 2 - 1])
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=int(input().split());print(("No","Yes")[a<=c<=b])

Fixed submission:
a,b,c=map(int,input().split());print(("No","Yes")[a<=c<=b])
Buggy python submission (verdict: Runtime Error):
a=input();b=input();print a<b and'LESS'or a>b and'GREATER'or'EQUAL'

Fixed submission:
a=(int)(input())-(int)(input());print(a>0 and'GREATER'or a<0 and'LESS'or'EQUAL')

Buggy python submission (verdict: Runtime Error):
a=(int)(input()-input());print(a>0 and'GREATER'or a<0 and'LESS'or'EQUAL')

Fixed submission:
a=(int)(input())-(int)(input());print(a>0 and'GREATER'or a<0 and'LESS'or'EQUAL')

Buggy python submission (verdict: Runtime Error):
a=int(input()-input());print(a>0 and'GREATER'or a<0 and'LESS'or'EQUAL')

Fixed submission:
a=(int)(input())-(int)(input());print(a>0 and'GREATER'or a<0 and'LESS'or'EQUAL')

Buggy python submission (verdict: Runtime Error):
a=input()-input();print(a>0 and'GREATER'or a<0 and'LESS'or'EQUAL')

Fixed submission:
a=(int)(input())-(int)(input());print(a>0 and'GREATER'or a<0 and'LESS'or'EQUAL')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,raw_input().split());print(abs(a-b)<2and'Brown'or'Alice')

Fixed submission:
a,b=map(int,raw_input().split());print abs(a-b)<2and'Brown'or'Alice'
Buggy python submission (verdict: Runtime Error):
a=list(input())
flag=True
for i in range(len(a)-1):
  if a[i]==a[i+1]:
    print("Bad")
    return
print("Good")

Fixed submission:
a=list(input())
flag=True
for i in range(len(a)-1):
  if a[i]==a[i+1]:
    flag=False
print("Good" if flag else "Bad")
Buggy python submission (verdict: Time Limit Exceeded):
n, y = map(int, input().split())

a = 0  # 1000
b = 0  # 5000
c = 0  # 10000

c = y//10000
b = (y - c*10000)//5000
a = (y - c*10000 - b*5000)//1000

flag = True

while (a+b+c) <= n:
    num = a+b+c
#    print(num)
#    print(c,b,a)
    if num == n:
        flag = False
        break
    else:
        if num + 9 <= n and c > 0:
            c -= 1
            a += 10
            continue
        elif num + 4 <= n and b > 0:
            b -= 1
            a += 5
            continue
        elif num + 1 <= n and c > 0:
            c -= 1
            b += 2
            continue

if flag:
    print(-1, -1, -1)
else:
    print(c, b, a)




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

a = 0  # 1000
b = 0  # 5000
c = 0  # 10000

c = y//10000
b = (y - c*10000)//5000
a = (y - c*10000 - b*5000)//1000

flag = True

while (a+b+c) <= n:
    num = a+b+c
#    print(num)
#    print(c,b,a)
    if num == n:
        flag = False
        break
    else:
        if num + 9 <= n and c > 0:
            c -= 1
            a += 10
            continue
        elif num + 4 <= n and b > 0:
            b -= 1
            a += 5
            continue
        elif num + 1 <= n and c > 0:
            c -= 1
            b += 2
            continue
        else:
            break
if flag:
    print(-1, -1, -1)
else:
    print(c, b, a)

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

a = 0  # 1000
b = 0  # 5000
c = 0  # 10000

c = y//10000
b = (y - c*10000)//5000
a = (y - c*10000 - b*5000)//1000

#print(c,b,a)
flag = True

while (a+b+c) <= n:
    num = a+b+c
    if num == n:
        print(c, b, a)
        flag = False
        break
    else:
        if num + 9 <= n:
            c -= 1
            a += 10
        elif num + 4 <= n:
            b -= 1
            a += 5
        elif num + 1 <= n:
            c -= 1
            b += 2
        if c < 0 or b < 0:
            break

if flag:
   # print(-1, -1, -1)


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

a = 0  # 1000
b = 0  # 5000
c = 0  # 10000

c = y//10000
b = (y - c*10000)//5000
a = (y - c*10000 - b*5000)//1000

flag = True

while (a+b+c) <= n:
    num = a+b+c
#    print(num)
#    print(c,b,a)
    if num == n:
        flag = False
        break
    else:
        if num + 9 <= n and c > 0:
            c -= 1
            a += 10
            continue
        elif num + 4 <= n and b > 0:
            b -= 1
            a += 5
            continue
        elif num + 1 <= n and c > 0:
            c -= 1
            b += 2
            continue
        else:
            break
if flag:
    print(-1, -1, -1)
else:
    print(c, b, a)
Buggy python submission (verdict: Runtime Error):

A = input()
B = input()
A = int(A)
B = int(B)

if (A+B) % 2 == 0:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")
    

Fixed submission:
A, B = input().split()
A = int(A)
B = int(B)

if (A+B) % 2 == 0 and A != B:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):

A = input()
B = input()
A = int(A)
B = int(B)
K = (A+B) / 2
K = int(K)

if K % 2 == 0:
    print(K)
else:
    print("IMPOSSIBLE")
    

Fixed submission:
A, B = input().split()
A = int(A)
B = int(B)

if (A+B) % 2 == 0 and A != B:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):

A = input()
B = input()
A = int(A)
B = int(B)
K = (A+B) / 2

if K % 2 == 0:
    print(K)
else:
    print("IMPOSSIBLE")
    

Fixed submission:
A, B = input().split()
A = int(A)
B = int(B)

if (A+B) % 2 == 0 and A != B:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 29 14:29:48 2019

@author: re
"""

A = int(A)
B = int(B)


K = (A+B) / 2
K = int(K)

if abs(A-K) == abs(B-K):
    print(K)
else:
    print("IMPOSSIBLE")
    

Fixed submission:
A, B = input().split()
A = int(A)
B = int(B)

if (A+B) % 2 == 0 and A != B:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 29 14:29:48 2019

@author: re
"""

A = input()
B = input()
A = int(A)
B = int(B)


K = (A+B) / 2
K = int(K)

if abs(A-K) == abs(B-K):
    print(K)
else:
    print("IMPOSSIBLE")
    

Fixed submission:
A, B = input().split()
A = int(A)
B = int(B)

if (A+B) % 2 == 0 and A != B:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):

n,m=map(int,input().split())
s=[int(i) for i in input().split()]
t=[int(i) for i in input().split()]
maxim=(10**3)*2
mod=10**9+7
dp=[[0 for i in range(m+1)]for j in range(n+1)]

for i in range(n):
    for j in range(m):
        x=0
        if s[i]==t[j]:
            x=dp[i][j]+1
        dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1]-dp[i][j]+x)%mod
#print(dp)
print((dp[n][m]+1)%mod)


Fixed submission:
n,m=map(int,input().split())
s=[int(i) for i in input().split()]
t=[int(i) for i in input().split()]
mod=10**9+7
dp=[[0 for i in range(m+1)]for j in range(n+1)]
for i in range(n):
    for j in range(m):
        x=0
        if s[i]==t[j]:
            x=dp[i][j]+1
        dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1]-dp[i][j]+x)%mod
#print(dp)
print((dp[n][m]+1)%mod)
Buggy python submission (verdict: Runtime Error):
import bisect
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
ans=[]
x=bisect.bisect_left(a, 0)
m=a[:x]
p=a[x:]
if m==[]:
    m+=[p[0]-p[-1]]
    ans+=[[p[0],p[-1]]]
    del p[0]
    del p[-1]

if p==[]:
    p+=[m[-1]-m[0]]
    ans+=[[m[-1],m[0]]]
    del m[-1]
    del m[0]


while len(p)!=1:

    m+=[m[0]-p[0]]
    ans+=[[m[0],p[0]]]
    del p[0]
    del m[0]
cnt=p[0]
for i in m:
    ans+=[[cnt,i]]
    cnt-=i
print(cnt)
for i,j in ans:print(i,j)


Fixed submission:
import bisect
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
ans=[]
x=bisect.bisect_left(a, 0)
m=a[:x]
p=a[x:]

if n==2 and len(p)==2:
    print(p[1]-p[0])
    print(p[1],p[0])
    
    exit()
if m==[]:
    m+=[p[0]-p[-1]]
    ans+=[[p[0],p[-1]]]
    del p[0]
    del p[-1]

if p==[]:
    p+=[m[-1]-m[0]]
    ans+=[[m[-1],m[0]]]
    del m[-1]
    del m[0]

while len(p)!=1:

    m+=[m[0]-p[0]]
    ans+=[[m[0],p[0]]]
    del p[0]
    del m[0]
cnt=p[0]
for i in m:
    ans+=[[cnt,i]]
    cnt-=i
print(cnt)
for i,j in ans:print(i,j)

Buggy python submission (verdict: Runtime Error):
import itertools
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
for i in range(n-2):
    x,y=a[i],a[i+1]
    del a[i:i+2]
    a+=[x-y]
    a.sort()
    print(x,y)
print(a[1],a[0])



Fixed submission:
import bisect
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
ans=[]
x=bisect.bisect_left(a, 0)
m=a[:x]
p=a[x:]

if n==2 and len(p)==2:
    print(p[1]-p[0])
    print(p[1],p[0])
    
    exit()
if m==[]:
    m+=[p[0]-p[-1]]
    ans+=[[p[0],p[-1]]]
    del p[0]
    del p[-1]

if p==[]:
    p+=[m[-1]-m[0]]
    ans+=[[m[-1],m[0]]]
    del m[-1]
    del m[0]

while len(p)!=1:

    m+=[m[0]-p[0]]
    ans+=[[m[0],p[0]]]
    del p[0]
    del m[0]
cnt=p[0]
for i in m:
    ans+=[[cnt,i]]
    cnt-=i
print(cnt)
for i,j in ans:print(i,j)
Buggy python submission (verdict: Time Limit Exceeded):

h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
L=[[0 for i in range(w)]for i in range(h)]
R=[[0 for i in range(w)]for i in range(h)]
D=[[0 for i in range(w)]for i in range(h)]
U=[[0 for i in range(w)]for i in range(h)]
ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            if j==0:
                R[i][j]=1
            else:
                R[i][j]=R[i][j-1]+1

        if s[h-i-1][w-j-1]=='.':
            if j==0:
                L[h-i-1][w-j-1]=1
            else:
                L[h-i-1][w-j-1]=L[h-i-1][w-j]+1


        if s[h-i-1][w-j-1]=='.':
            if i==0:
                U[h-i-1][w-j-1]=1
            else:
                U[h-i-1][w-j-1]=U[h-i][w-j-1]+1

        if s[i][j]=='.':
            if i==0:
                D[i][j]=1
            else:
                D[i][j]=D[i-1][j]+1


for i in range(h):
    for j in range(w):
        ans=max(ans,L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)

print(ans)

Fixed submission:
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
L=[[0 for i in range(w)]for i in range(h)]
R=[[0 for i in range(w)]for i in range(h)]
D=[[0 for i in range(w)]for i in range(h)]
U=[[0 for i in range(w)]for i in range(h)]
ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            if j==0:
                R[i][j]=1
            else:
                R[i][j]=R[i][j-1]+1

        if s[h-i-1][w-j-1]=='.':
            if j==0:
                L[h-i-1][w-j-1]=1
            else:
                L[h-i-1][w-j-1]=L[h-i-1][w-j]+1


        if s[h-i-1][w-j-1]=='.':
            if i==0:
                U[h-i-1][w-j-1]=1
            else:
                U[h-i-1][w-j-1]=U[h-i][w-j-1]+1

        if s[i][j]=='.':
            if i==0:
                D[i][j]=1
            else:
                D[i][j]=D[i-1][j]+1


for i in range(h):
    for j in range(w):
        ans=max(ans,L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())

ans=0
for i in [i*r for i in range(n//r+1)]:
    for j in [i*g for i in range(n//g+1)]:
        A=n-i-j
        if A%b==0 and A>=0:

            ans+=1

print(ans)

Fixed submission:
r,g,b,n=map(int,input().split())

ans=0
for i in [i*r for i in range(n//r+1)]:
    for j in [i*g for i in range(n//g+1)]:
        A=n-i-j
        if A%b==0 and A>=0:

            ans+=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())

x=[i*r for i in range(n//r+1)]
y=[i*g for i in range(n//g+1)]
z=[i*b for i in range(n//b+1)]
ans=0
for i in x:
    for j in y:
        A=n-i-j
        if A in z:
            ans+=1

print(ans)

Fixed submission:
r,g,b,n=map(int,input().split())

ans=0
for i in [i*r for i in range(n//r+1)]:
    for j in [i*g for i in range(n//g+1)]:
        A=n-i-j
        if A%b==0 and A>=0:

            ans+=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=[v[i]-c[i] for i in range(n)]+[0]
x=[i for i in range(n)]

for i in range(2,n):
    for z in itertools.combinations(x, i):
        A=0
        for y in z:
            A+=v[y]-c[y]
        ans+=[A]
print(max(ans))

Fixed submission:
n=int(input())
v=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=[v[i]-c[i] for i in range(n)]
ans.sort(reverse=True)
A=0
for i in ans:
    if i>0:
        A+=i
    else:
        break
print(A)