ZhenlongDai/ACPR huggingface dataset:
Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b, c, d = [int(item) for item in input().split()]

u, l = 0, 0
while n > 0:
    if b <= a + u + (n-1) * d and b >= a + l + (n-1) * c:
        print("YES")
        exit()
    n -= 2
    u += d - c
    l -= d - c
print("NO")

Failing test case input:
364 1357504854 1140728524 2734001 3302098

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
n, a, b, c, d = [int(item) for item in input().split()]

u, l = 0, 0
while n > 1:
    if b <= a + u + (n-1) * d and b >= a + l + (n-1) * c:
        print("YES")
        exit()
    if b <= a + u + (n-1) * -c and b >= a + l + (n-1) * -d:
        print("YES")
        exit()
    n -= 2
    u += d - c
    l -= d - c
print("NO")
Problem: p00014
Buggy submission (Python3, verdict: Wrong Answer):
import sys

for line in sys.stdin:
    d = int(line)
    S = 0
    for x in range(1, 600, d):
        S += (x ** 2) * d
    print(S)

Failing test case input:
20
-233

Expected output:
68440000
0


Actual output:
68788600
0


Fixed submission (verdict: Accepted):
import sys

for line in sys.stdin:
    d = int(line)
    S = 0
    for x in range(0, 600, d):
        S += (x ** 2) * d
    print(S)

Problem: p00014
Buggy submission (Python3, verdict: Wrong Answer):
def function(a):
	s=0
	d=a
	for i in range(d,600-d+1,d):
		s+=a*(d**2)
		d+=a
		
	return s


n=int(input())
print(function(n))

Failing test case input:
20
-71

Expected output:
68440000
0


Actual output:
68440000


Fixed submission (verdict: Accepted):
def function(a):
	s=0
	d=a
	for i in range(d,600-d+1,d):
		s+=a*(d**2)
		d+=a
		
	return s

while True:
	try:
		n=int(input())
		print(function(n))
	except EOFError:
		break
Problem: p02736
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int,list(input())))
a = list(map(lambda x:x-1,a))
x = 0
for i,n in enumerate(a):
  if n%2==0:
    continue
  else:
    if ((N-1)^i)&i==0:
      x+=1

if x%2!=0:
  print(1)
  
elif 1 in a:
  print(0)

else:
  print(2)

Failing test case input:
4
44

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int,list(input())))
a = list(map(lambda x:x-1,a))
x = 0
for i,n in enumerate(a):
  if n%2==0:
    continue
  else:
    if ((N-1)^i)&i==0:
      x+=1

if x%2!=0:
  print(1)
  
elif 1 in a:
  print(0)

else:
  a = [x
  x = 0
  for i,n in enumerate(a):
    if n%2==0:
      continue
    else:
      if((N-1)&i)==i:
        x+=1
  if x%2!=0:
    print(2)
  else:
    print(0)

Problem: p02736
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def pascal_parity(N):
    if N & -N == N:
        return [1] * N
    else:
        n = N - (1<<(N.bit_length()-1))
        p = pascal_parity(n)
        return p + [0]*(N-2*n) + p

N = int(input())
A = list(map(int, input()))
if 1 in A:
    if sum(A) % 2 == 1:
        print(1)
    else:
        print(0)
else:
    P = pascal_parity(N)
    pa = 0
    for p, a in zip(P, A):
        if p==1 and a==2:
            pa += 1
    if pa % 2 == 1:
        print(2)
    else:
        print(0)


Failing test case input:
10
2192114600

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
def pascal_parity(N):
    if N & -N == N:
        return [1] * N
    else:
        n = N - (1<<(N.bit_length()-1))
        p = pascal_parity(n)
        return p + [0]*(N-2*n) + p

N = int(input())
A = list(map(lambda x: int(x)-1, input()))
P = pascal_parity(N)
if 1 in A:
    if sum(a*p for a,p in zip(A, P)) % 2 == 1:
        print(1)
    else:
        print(0)
else:
    pa = 0
    for p, a in zip(P, A):
        if p==1 and a==2:
            pa += 1
    if pa % 2 == 1:
        print(2)
    else:
        print(0)

Problem: p02736
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int,list(input())))
a = list(map(lambda x:x-1,a))
x = 0
N_b = list(map(int,list(bin(N-1))[2::][::-1]))
for i,n in enumerate(a):
  if n%2==0:
    continue
  else:
    tmp = list(map(int,list(bin(i))[2::][::-1]))
    judge = True
    for y,z in zip(N_b,tmp):
      if y<z:
        judge = False
    if judge:
      x+=1
      
if x%2!=0:
  print(1)

Failing test case input:
10
2357790932

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int,list(input())))
a = list(map(lambda x:x-1,a))
x = 0
for i,n in enumerate(a):
  if n%2==0:
    continue
  else:
    if ((N-1)^i)&i==0:
      x+=1

if x%2!=0:
  print(1)
  
elif 1 in a:
  print(0)

else:
  a = [x
  x = 0
  for i,n in enumerate(a):
    if n%2==0:
      continue
    else:
      if((N-1)&i)==i:
        x+=1
  if x%2!=0:
    print(2)
  else:
    print(0)
Problem: p02736
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(a)-1 for a in input()]

if A.count(1) == 0:
    r = 2
else:
    r = 1

def parity_of_binominal_coefficient(n, k):
    return (n&k)==k

for i, a in enumerate(A):
    ans = 1
    if a & 1:
        if not parity_of_binominal_coefficient(N-1,i):
            ans ^= 1

print(ans*r)

Failing test case input:
10
2149800

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(a)-1 for a in input()]

r = 1 if 1 in A else 2

def parity_of_nCk(n, k):
    return (n&k)==k

ans = 0
for i, a in enumerate(A):
    if a & r:
        if parity_of_nCk(N-1,i):
            ans ^= 1

print(ans*r)

Problem: p02736
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = input().rstrip('\n')
    A = [int(a) for a in A]

    while len(A) > 1:
        AA = [0]
        for a in A:
            if AA[-1] != a:
                AA.append(a)
        A_new = []
        for i in range(1, len(AA) - 1):
            x = abs(AA[i] - AA[i+1])
            if x:
                A_new.append(x)
        A = A_new
        if len(A) == 0:
            print(0)
            exit()
    print(A[0])


if __name__ == '__main__':
    main()


Failing test case input:
10
2224468077

Expected output:
0


Actual output:
5


Fixed submission (verdict: Accepted):
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = input().rstrip('\n')
    A = [int(a) for a in A]

    A = [abs(A[i+1] - A[i]) for i in range(N-1)]
    flg = 1
    if 1 not in A:
        flg = 2
        A = [a 
    else:
        A = [a % 2 for a in A]
    idx = []
    N -= 1
    for j in range(N.bit_length()):
        if N>>j&1:
            M = 2**j
            X = N%(M*2)
            if not idx:
                idx = list(range(M))
            else:
                idx_new = [X-1 - x for x in idx]
                idx.extend(idx_new)
    ans = 0
    
    
    for i in idx:
        ans ^= A[i]
    print(ans * flg)


if __name__ == '__main__':
    main()
Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[]
ans=0
for a,b in arr:
  ans+=a
  arr2.append([a-b,b])
arr2=sorted(arr2,reverse=True)
ans=-arr2[0][1]
print(ans)

Failing test case input:
2
2 1
2 3

Expected output:
3


Actual output:
-1


Fixed submission (verdict: Accepted):
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[]
ans=0
mb=10**18
for a,b in arr:
  ans+=a
  if a>b:
    mb=min(mb,b)
if mb==10**18:
  print(0)
else:
  print(ans-mb)

Problem: p03391
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]

mx = 0
sm = 0
for i in range(n):
    a, b = ab[i]
    sm += a
    if a >= b:
        mx = max(mx, b)
print(sm - mx)


Failing test case input:
2
0 3
2 -1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
ab = [tuple(map(int, input().split())) for _ in range(n)]

INF = 1 << 30
mx = INF
sm = 0
for i in range(n):
    a, b = ab[i]
    sm += a
    if a > b:
        mx = min(mx, b)
if mx == INF:
    print(0)
else:
    print(sm - mx)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n=int(input())
    min_b=10**10
    s=0
    for _ in range(n):
        a,b=map(int,input().split())
        s+=b
        if a>=b:
            min_b=min(min_b,b)
    print(s-min_b)

main()

Failing test case input:
2
1 1
3 3

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n = int(input())
    min_b = 10 ** 10
    s = 0
    for _ in range(n):
        a, b = map(int, input().split())
        s += b
        if a > b:
            min_b = min(min_b, b)
    print(0) if min_b == 10 ** 10 else print(s - min_b)

main()

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
Mi, Mv = 0, 0
for i, (A, B) in enumerate(AB) :
    s += A
    if A >= B :
        if A - B > Mv :
            Mi = i
            Mv = A - B
            
print(s - AB[Mi][1])

Failing test case input:
2
4 4
2 2

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
m = float('inf')
for i, (A, B) in enumerate(AB) :
    s += A
    if A > B :
        m = min(m, B)

if m == float('inf') :
    print(0)
else :
    print(s - m)
Problem: p03391
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
input=sys.stdin.readline
n=int(input())
ans=0
for i in range(n):
	a,b=map(int,input().split())
	ans+=abs(a-b)
print(ans)

Failing test case input:
3
8 3
0 1
4 8

Expected output:
9

Actual output:
10


Fixed submission (verdict: Accepted):
import sys
input=sys.stdin.readline
n=int(input())
B=[]
ans=0
for i in range(n):
	a,b=map(int,input().split())
	ans+=a
	if a>b:
		B.append(b)
if len(B)==0:
	print(0)
else:
	print(ans-min(B))

Problem: p03391
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
data = list(map(int,read().split()))

tot = 0
same = 0
max_b = 0
it = iter(data)
for a,b in zip(it,it):
    tot += a
    if(a==b):
        same += 1
    elif(a > b):
        max_b = max(max_b,b)

if(same==n):
    print(0)
else:
    print(tot-max_b)

Failing test case input:
2
0 2
1 -1

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
data = list(map(int,read().split()))

tot = 0
same = 0
min_b = 10**9
it = iter(data)
for a,b in zip(it,it):
    tot += a
    if(a==b):
        same += 1
    elif(a > b):
        min_b = min(min_b,b)

if(same==n):
    print(0)
else:
    print(tot-min_b)

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
t=0
m=1e18
for i in range(n):
  a,b=map(int,input().split())
  t+=a
  if a>b:m=min(m,b)
print(t-m)

Failing test case input:
2
0 0
4 4

Expected output:
0


Actual output:
-1e+18


Fixed submission (verdict: Accepted):
n=int(input())
t=0
m=1e18
f=0
for i in range(n):
  a,b=map(int,input().split())
  t+=a
  if a>b:m=min(m,b)
  if a!=b:f=1
if f:
  print(t-m)
else:
  print(0)

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
Mi, Mv = 0, 0
for i, (A, B) in enumerate(AB) :
    s += A
    if A > B :
        if A - B > Mv :
            Mi = i
            Mv = A - B
            
print(s - AB[Mi][1])

Failing test case input:
2
1 1
3 3

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
m = float('inf')
for i, (A, B) in enumerate(AB) :
    s += A
    if A > B :
        m = min(m, B)

if m == float('inf') :
    print(0)
else :
    print(s - m)
Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

plus_min, minus, total = 10**10, 0, 0
for _ in range(N):
    a, b = map(int, input().split())
    total += a
    if a > b:
        plus_min = min(plus_min, b)
    elif a < b:
        minus += a

if minus == 0:
    print(0)
    exit()

print(int(total - plus_min))

Failing test case input:
2
0 2
1 -1

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())

b_min, isequal, total = 10**10, 0, 0
for _ in range(N):
    a, b = map(int, input().split())
    total += a
    if a > b:
        if b < b_min:
            b_min = b
    elif a == b:
        isequal += 1

if isequal == N:
    print(0)
else:
    print(int(total - b_min))

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
INF=10**9+7
sum=0
m=INF
for i in range(n):
    a,b=map(int,input().split())
    sum+=a
    if a>b:
        m=min(m,b)
print(sum-m)

Failing test case input:
2
2 2
4 4

Expected output:
0


Actual output:
-1000000001


Fixed submission (verdict: Accepted):
n=int(input())
INF=10**9+7
sum=0
m=INF
for i in range(n):
    a,b=map(int,input().split())
    sum+=a
    if a>b:
        m=min(m,b)
if m==INF:
    print(0)
else:
    print(sum-m)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
n = int(input())
iptls = [list(map(int,input().split())) for i in range(n)]
a,b = zip(*iptls)
if a == b:
  print(0)
  exit()
ans = 10**18
for i in range(n):
  if a[i]>=b[i] and a[i]+b[i]>0:
    ans = min(ans,b[i])
print(sum(b)-ans)

Failing test case input:
2
1 -1
1 3

Expected output:
3


Actual output:
-999999999999999998


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
n = int(input())
iptls = [list(map(int,input().split())) for i in range(n)]
a,b = zip(*iptls)
if a == b:
  print(0)
  exit()
ans = 10**18
for i in range(n):
  if a[i]>b[i]:
    ans = min(ans,b[i])
print(sum(b)-ans)

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
N = int(input())
res = 0
t = float("inf")
for _ in range(N):
  x, y = map(int, input().split())
  if x >= y: t = min(y, t)
  res += x
print(res - t)

Failing test case input:
2
0 0
3 3

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
N = int(input())
res = 0
t = float("inf")
c = 0
for _ in range(N):
  x, y = map(int, input().split())
  if x > y: t = min(y, t)
  if x == y: c += 1
  res += x
if c == N:
  print(0)
  exit(0)
print(res - t)
Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,*L = map(int, open(0).read().split())
A = [0]*N
B = [0]*N
n = 10**10
for i,(a,b) in enumerate(zip(*[iter(L)]*2)):
  A[i] = a
  B[i] = b
  if a>b:
    n = min(n,b)
print(sum(A)-n)

Failing test case input:
1
-1 -1

Expected output:
0


Actual output:
-10000000001


Fixed submission (verdict: Accepted):
N,*L = map(int, open(0).read().split())
A = [0]*N
B = [0]*N
n = 10**10
flag = False
for i,(a,b) in enumerate(zip(*[iter(L)]*2)):
  A[i] = a
  B[i] = b
  if a!=b:
    flag = True
  if a>b:
    n = min(n,b)
print(sum(A)-n if flag else 0)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = 0
m = INF = 10**9+7
d = []
for i in range(N):
    a, b = map(int, input().split())
    ans += a
    if a > b:
        m = min(m, b)
print(0 if INF else ans-m)

Failing test case input:
3
8 3
-1 0
4 8

Expected output:
8


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
ans = 0
m = INF = 10**9+7
d = []
for i in range(N):
    a, b = map(int, input().split())
    ans += a
    if a > b:
        m = min(m, b)
print(0 if INF == m else ans-m)

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
Mi, Mv = 0, 0
for i, (A, B) in enumerate(AB) :
    s += A
    if A >= B :
        if A - B > Mv and A < AB[Mi][0]:
            Mi = i
            Mv = A - B
            
print(s - AB[Mi][1])

Failing test case input:
2
2 4
2 0

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
m = float('inf')
for i, (A, B) in enumerate(AB) :
    s += A
    if A > B :
        m = min(m, B)

if m == float('inf') :
    print(0)
else :
    print(s - m)

Problem: p03391
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def solve():
    ans = 0
    N = int(input())
    miny = float('inf')
    ans = 0
    for i in range(N):
        x,y = map(int, input().split())
        ans += x
        if x>=y:
            miny = min(miny,y)
    ans -= miny
    return ans
print(solve())

Failing test case input:
2
2 2
1 1

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
def solve():
    ans = 0
    N = int(input())
    miny = float('inf')
    ans = 0
    x = [0]*N
    y = [0]*N
    for i in range(N):
        x[i],y[i] = map(int, input().split())
    if x==y:
        return 0
    for i in range(N):
        ans += x[i]
        if x[i]>y[i]:
            miny = min(miny,y[i])
    ans -= miny
    return ans
print(solve())
Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


inf = 10**20

N = int(input())
s = 0
m = inf
for i in range(N):
    a, b = map(int, input().split(" "))
    if a > b:
        if m < b:
            m = b
    s += a
if m == inf:
    print(0)
else:
    print(s - m)

Failing test case input:
2
2 3
3 2

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):


inf = 10**20

N = int(input())
s = 0
m = inf
for i in range(N):
    a, b = map(int, input().split(" "))
    if a > b:
        if m > b:
            m = b
    s += a
if m == inf:
    print(0)
else:
    print(s - m)

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
N = int(input())
res = 0
t = float("inf")
for _ in range(N):
  x, y = map(int, input().split())
  if x > y: t = min(y, t)
  res += x
print(res - t)

Failing test case input:
2
-1 -1
1 1

Expected output:
0


Actual output:
-inf


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
N = int(input())
res = 0
t = float("inf")
c = 0
for _ in range(N):
  x, y = map(int, input().split())
  if x > y: t = min(y, t)
  if x == y: c += 1
  res += x
if c == N:
  print(0)
  exit(0)
print(res - t)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
rem=0
S=0
allissame=0
for i in range(n):
  a,b=map(int,input().split())
  S+=a
  if a<b:
    allissame|=1
    continue
  elif a>b:
    if rem < b:
      rem=b
    allissame|=1
  else:pass
if not allissame:
  print(0)
else:
  print(S-rem)


Failing test case input:
2
0 2
1 -1

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
rem=10**10
S=0
allissame=0
for i in range(n):
  a,b=map(int,input().split())
  S+=a
  if a<b:
    allissame|=1
    continue
  elif a>b:
    if rem > b:
      rem=b
    allissame|=1
  else:pass
if not allissame:
  print(0)
else:
  print(S-rem)

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
m = float('inf')
for i, (A, B) in enumerate(AB) :
    s += A
    if A >= B :
        m = min(m, B)
            
print(s - m)

Failing test case input:
2
2 2
3 3

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
m = float('inf')
for i, (A, B) in enumerate(AB) :
    s += A
    if A > B :
        m = min(m, B)

if m == float('inf') :
    print(0)
else :
    print(s - m)

Problem: p03391
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
d=0
s=10**9+1
for i in range(N):
  a,b=map(int, input().split())
  d+=a
  if a>b:
    s=min(s,b)
print(d-s)

Failing test case input:
2
4 4
2 2

Expected output:
0


Actual output:
-999999995


Fixed submission (verdict: Accepted):
N=int(input())
d=0
s=10**9+1
for i in range(N):
  a,b=map(int, input().split())
  d+=a
  if a>b:
    s=min(s,b)
if s==10**9+1:
  print(0)
  exit()
print(d-s)
Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[]
ans=0
for a,b in arr:
  ans+=a
  arr2.append([a-b,b])
arr2=sorted(arr2,reverse=True)
ans-=arr2[0][1]
print(ans)

Failing test case input:
2
2 2
4 4

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[]
ans=0
mb=10**18
for a,b in arr:
  ans+=a
  if a>b:
    mb=min(mb,b)
if mb==10**18:
  print(0)
else:
  print(ans-mb)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
c = 0
for _ in range(int(input())):
    a, b = map(int, input().split())
    if a == b: continue
    if a > b: c += a - b - 1
    else: c += a
print(c if c == 0 else c + 1)


Failing test case input:
2
-4 1
6 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
m = None
s = 0
for _ in range(int(input())):
    a, b = map(int, input().split())
    s += a
    if a == b: continue
    if a > b:
        if m is None or b < m: m = b
print(0 if m is None else s - m)

Problem: p03391
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a,b=[],[]
for i in range(n):x,y=map(int,input().split());a.append(x);b.append(y)
c=10**10
for i in range(n):
 if a[i]>b[i]:c=min(c,b[i])
print(sum(a)-c)

Failing test case input:
1
-4 -4

Expected output:
0


Actual output:
-10000000004


Fixed submission (verdict: Accepted):
n=int(input())
a,b=[],[]
for i in range(n):x,y=map(int,input().split());a.append(x);b.append(y)
c=float("inf")
for i in range(n):
 if a[i]>b[i]:c=min(c,b[i])
print(max(0,sum(a)-c))

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A,B = [],[]
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
if A == B:
    print(0)
    exit()
ans = 0
for i in range(N):
    if B[i] < A[i]:
        ans = min(ans,-B[i])
print(sum(B) + ans)
        


Failing test case input:
2
1 -1
1 3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
A,B = [],[]
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
if A == B:
    print(0)
    exit()
ans = 10**9+10
for i in range(N):
    if B[i] < A[i]:
        ans = min(ans,B[i])
print(sum(B) - ans)

Problem: p03391
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
ans = 0
m = 10**9
for i in range(n):
  a,b = map(int,input().split())
  ans += a
  if a > b:
    m = min(m,b)
print(ans-m)

Failing test case input:
2
1 1
3 3

Expected output:
0


Actual output:
-999999996


Fixed submission (verdict: Accepted):
n = int(input())
s = 0
f = False
m = 10**9
for i in range(n):
  a,b = map(int,input().split())
  s += a
  if a < b:
    f = True
  if a > b:
    f = True
    m = min(m,b)
if f:
  print(s-m)
else:
  print(0)
Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
M = 0
for A, B in AB :
    s += A
    if A >= B :
        M = max(M, B)
        
print(s - M)

Failing test case input:
2
1 -1
1 3

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
AB = [[int(i) for i in input().split()] for _ in range(N)]

s = 0
m = float('inf')
for i, (A, B) in enumerate(AB) :
    s += A
    if A > B :
        m = min(m, B)

if m == float('inf') :
    print(0)
else :
    print(s - m)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
_,*t=open(0).read().split()
t=map(int,t)
s=0
m=1e18
for a,b in zip(t,t):
 s+=a
 if a>b:m=min(m,b)
print(s-m)

Failing test case input:
2
0 0
3 3

Expected output:
0


Actual output:
-1e+18


Fixed submission (verdict: Accepted):
_,*t=open(0).read().split()
t=map(int,t)
s=0
m=1e18
for a,b in zip(t,t):
 s+=a
 if a>b:m=min(m,b)
print(max(0,s-m))

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
rem=0
S=0
allissame=0
for i in range(n):
  a,b=map(int,input().split())
  S+=a
  if a<b:
    allissame|=1
    continue
  elif a>b:
    if rem > b:
      rem=b
    allissame|=1
  else:pass
if not allissame:
  print(0)
else:
  print(S-rem)


Failing test case input:
2
1 3
4 2

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
n=int(input())
rem=10**10
S=0
allissame=0
for i in range(n):
  a,b=map(int,input().split())
  S+=a
  if a<b:
    allissame|=1
    continue
  elif a>b:
    if rem > b:
      rem=b
    allissame|=1
  else:pass
if not allissame:
  print(0)
else:
  print(S-rem)

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=[None]*n
    B=[None]*n
    for i in range(n):
        A[i],B[i]=map(int,input().split())

    d=sum(b-a for a,b in zip(A,B) if(a<b))
    s=min(b for a,b in zip(A,B) if(a>=b and a-b<=d))
    print(sum(A)-s)
resolve()

Failing test case input:
2
0 0
4 4

Expected output:
0


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=[None]*n
    B=[None]*n
    for i in range(n):
        A[i],B[i]=map(int,input().split())

    if(A==B):
        print(0)
        return
    print(sum(A)-min(b for a,b in zip(A,B) if(a>b)))
resolve()

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
mini = 10**10
s = 0
for i in range(n):
	a, b = map(int, input().split())
	s += a
	if a > b:
		mini = min(mini, b)
print(s-mini)

Failing test case input:
2
2 2
1 1

Expected output:
0


Actual output:
-9999999997


Fixed submission (verdict: Accepted):
n = int(input())
m = 10**10
s = 0
for i in range(n):
	a, b = map(int, input().split())
	s += a
	if a > b:
		m = min(m, b)
if m == 10**10:
	print(0)
else:
	print(s-m)
Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
n = int(input())
iptls = [list(map(int,input().split())) for i in range(n)]
a,b = zip(*iptls)
if a == b:
  print(0)
  exit()
ans = 10**18
for i in range(n):
  if a[i]<=b[i]:
    ans = min(ans,b[i])
print(sum(b)-ans)

Failing test case input:
2
1 0
4 5

Expected output:
5


Actual output:
0


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
n = int(input())
iptls = [list(map(int,input().split())) for i in range(n)]
a,b = zip(*iptls)
if a == b:
  print(0)
  exit()
ans = 10**18
for i in range(n):
  if a[i]>b[i]:
    ans = min(ans,b[i])
print(sum(b)-ans)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = [0] * N
b = [0] * N
for i in range(N):
    a1, b1 = map(int, input().split())
    a[i] = a1
    b[i] = b1

total = sum(a)
minans = total
for i in range(N):
    if a[i] > b[i]:
        minans = min(minans, total - b[i])

if minans == total:
    print(0)
else:
    print(minans)

Failing test case input:
2
0 3
3 0

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
a = [0] * N
b = [0] * N
for i in range(N):
    a1, b1 = map(int, input().split())
    a[i] = a1
    b[i] = b1

total = sum(a)
minans = total
for i in range(N):
    if a[i] > b[i]:
        minans = min(minans, b[i])

if minans == total:
    print(0)
else:
    print(total - minans)

Problem: p03391
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
csum = 0
min_b = 10**5+1
for _ in range(n):
    a,b = map(int, input().split())
    csum += a
    if a >= b:
        min_b = min(min_b,b)

ans = csum-min_b
print(ans)













Failing test case input:
2
2 2
4 4

Expected output:
0


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
INF = 10**9
csum = 0
min_b = INF
for _ in range(n):
    a,b = map(int, input().split())
    csum += a
    if a > b:
        min_b = min(min_b,b)

if min_b == INF:
    print(0)
else:
    ans = csum-min_b
    print(ans)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = 0
mi = float("inf")
for _ in range(N):
    A, B = map(int, input().split())
    if A>=B:
        mi = min(mi, B)
    ans += B
print(ans - mi if mi != float("inf") else 0)


Failing test case input:
2
1 1
3 3

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
ans = 0
mi = float("inf")
for _ in range(N):
    A, B = map(int, input().split())
    if A>B:
        mi = min(mi, B)
    ans += B
print(ans - mi if mi != float("inf") else 0)
Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
n = int(input())
ans = 0
flag = 0
for i in range(n):
  a,b = map(int,input().split())
  if a > b:flag = 1
  ans += a
print(ans*flag)


Failing test case input:
2
-4 1
6 1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
n = int(input())
m = 10**10
ans = 0
flag = 0
for i in range(n):
  a,b = map(int,input().split())
  if a > b:
    flag = 1
    m = min(m,b)
  ans += a
print((ans-m)*flag)

Problem: p03391
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
input=sys.stdin.readline
n=int(input())
ans=0
min_b=200_000
for i in range(n):
	a,b=map(int,input().split())
	ans+=a
	if a>=b:
		min_b=min(min_b,b)
print(ans-min_b)

Failing test case input:
2
-1 -1
1 1

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
input=sys.stdin.readline
n=int(input())
B=[]
ans=0
for i in range(n):
	a,b=map(int,input().split())
	ans+=a
	if a>b:
		B.append(b)
if len(B)==0:
	print(0)
else:
	print(ans-min(B))

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = 0
m = 10**9+7
d = []
for i in range(N):
    a, b = map(int, input().split())
    ans += a
    if a > b:
        m = min(m, b)
print(ans-m)

Failing test case input:
2
2 2
4 4

Expected output:
0


Actual output:
-1000000001


Fixed submission (verdict: Accepted):
N = int(input())
ans = 0
m = INF = 10**9+7
d = []
for i in range(N):
    a, b = map(int, input().split())
    ans += a
    if a > b:
        m = min(m, b)
print(0 if INF == m else ans-m)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
_,*t=open(0).read().split()
t=map(int,t)
s=0
m=9e9
for a,b in zip(t,t):
 s+=a
 if a>b:m=min(m,b)
print(s-m)

Failing test case input:
2
-1 -1
1 1

Expected output:
0


Actual output:
-9000000000.0


Fixed submission (verdict: Accepted):
_,*t=open(0).read().split()
t=map(int,t)
s=0
m=1e18
for a,b in zip(t,t):
 s+=a
 if a>b:m=min(m,b)
print(max(0,s-m))

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

if(A == B):
    print(1)
    exit()

ans = sum(A)
dis = 10**10
for a, b in zip(A, B):
    if a > b:
        dis = min(dis, b)
print(ans - dis)


Failing test case input:
2
-1 -1
1 1

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

if(A == B):
    print(0)
    exit()

ans = sum(A)
dis = 10**10
for a, b in zip(A, B):
    if a > b:
        dis = min(dis, b)
print(ans - dis)
Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = 0
m = 10000000000
flag = False
for i in range(n):
  a,b = list(map(int,input().split()))
  s += a
  if a != 0 and m > b:
    m = b
  if a != b:
    flag = True
if flag:
  print(s - m)
else:
  print(0)



Failing test case input:
3
8 3
-1 0
4 8

Expected output:
8


Actual output:
11


Fixed submission (verdict: Accepted):
n = int(input())
s = 0
m = 10000000000
flag = False
for i in range(n):
  a,b = list(map(int,input().split()))
  s += a
  if a != 0 and a > b and m > b:
    m = b
  if a != b:
    flag = True
if flag:
  print(s - m)
else:
  print(0)

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
t=0
m=1e18
for i in range(n):
  a,b=map(int,input().split())
  t+=a
  if a>=b:m=min(m,b)
print(t-m)

Failing test case input:
2
1 1
3 3

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
t=0
m=1e18
f=0
for i in range(n):
  a,b=map(int,input().split())
  t+=a
  if a>b:m=min(m,b)
  if a!=b:f=1
if f:
  print(t-m)
else:
  print(0)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
diff_a_b = []
for i in range(N):
  a, b = map(int, input().split())
  diff_a_b.append([a - b, a, b])

diff_a_b.sort()
if diff_a_b[0][0] == 0: 
  print(0)
  quit()

ans = 0
d = 0
for diff, a, b in diff_a_b:
  if diff <= 0: 
    ans += b
    d -= diff
  else:
    if d > diff:
      d -= diff
      ans += b
    else: 
      ans += d
      break

print(ans)

Failing test case input:
2
-2 1
4 1

Expected output:
1


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
diff_a_b = []
for i in range(N):
  a, b = map(int, input().split())
  diff_a_b.append([a - b, a, b])

diff_a_b.sort()
if diff_a_b[0][0] == 0: 
  print(0)
  quit()

ans = 0
d = 0
temp = 10**10
for diff, a, b in diff_a_b:
  if diff <= 0: 
    ans += b
    d -= diff
  else:
    ans += b
    temp = min(temp, b)

print(ans - temp)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

s = 0
m = 0
same = True
for _ in range(n):
    a,b = map(int, input().split())
    if a > b:
        m = max(m, b)
    s += a
    same &= a==b
if same:
    m = s
print(s-m)


Failing test case input:
2
1 -1
0 2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())

s = 0
m = 10**9+7
same = True
for _ in range(n):
    a,b = map(int, input().split())
    if a > b:
        m = min(m, b)
    s += a
    same &= a==b
if same:
    m = s
print(s-m)

Problem: p03391
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
input=sys.stdin.readline
n=int(input())
ans=0
min_b=200_000
for i in range(n):
	a,b=map(int,input().split())
	ans+=a
	if a>b:
		min_b=min(min_b,b)
print(ans-min_b)

Failing test case input:
1
-6 -6

Expected output:
0


Actual output:
-200006


Fixed submission (verdict: Accepted):
import sys
input=sys.stdin.readline
n=int(input())
B=[]
ans=0
for i in range(n):
	a,b=map(int,input().split())
	ans+=a
	if a>b:
		B.append(b)
if len(B)==0:
	print(0)
else:
	print(ans-min(B))
Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

plus, minus, equal = 0, 0, 0
for _ in range(N):
    a, b = map(int, input().split())
    if a > b:
        plus += a - b
    elif a < b:
        minus += a
    else:
        equal += a

if minus == 0:
    print(0)
    exit()

print(int(minus + plus + equal))

Failing test case input:
2
0 3
4 1

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())

b_min, isequal, total = 10**10, 0, 0
for _ in range(N):
    a, b = map(int, input().split())
    total += a
    if a > b:
        if b < b_min:
            b_min = b
    elif a == b:
        isequal += 1

if isequal == N:
    print(0)
else:
    print(int(total - b_min))

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A, B = [], []
d = -1
ind = -1
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    if a > b:
        if b > d:
            d = b
            ind = i

if d == -1:
    print(0)
else:
    print(sum(A) - B[ind])




Failing test case input:
2
0 2
1 -1

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
A, B = [], []
d = float('inf')
ind = -1
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    if a > b:
        if b < d:
            d = b
            ind = i

if d == float('inf'):
    print(0)
else:
    print(sum(A) - B[ind])

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    n = int(input())
    a, b = [], []
    minb = 10**10
    for _ in range(n):
        _a, _b = map(int, input().split())
        a.append(_a)
        b.append(_b)
        if _a != 0:
            minb = min(minb, _b)
    if a == b:
        print(0)
    else:
        print(sum(a) - minb)


if __name__ == '__main__':
    main()


Failing test case input:
3
8 3
-1 0
4 8

Expected output:
8


Actual output:
11


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    n = int(input())
    a, b = [], []
    minb = 10**10
    for _ in range(n):
        _a, _b = map(int, input().split())
        a.append(_a)
        b.append(_b)
        if _a != 0 and _b < _a:
            minb = min(minb, _b)
    if a == b:
        print(0)
    else:
        print(sum(a) - minb)


if __name__ == '__main__':
    main()

Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
INF=10**9+7
sum=0
m=INF
for i in range(n):
    a,b=map(int,input().split())
    sum+=a
    if a>b:
        m=min(m,b)
if m==0:
    print(0)
else:
    print(sum-m)

Failing test case input:
2
2 0
1 3

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
INF=10**9+7
sum=0
m=INF
for i in range(n):
    a,b=map(int,input().split())
    sum+=a
    if a>b:
        m=min(m,b)
if m==INF:
    print(0)
else:
    print(sum-m)
Problem: p03391
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = []
B = []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
if A == B:
  print(0)
else:
  M = sum(A)
  c = 0
  d = -1
  for a, b in zip(A, B):
    if c < a - b:
      c = a - b
      d = b
  print(M - b)


Failing test case input:
2
1 -1
0 2

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
A = []
B = []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
if A == B:
  print(0)
else:
  M = sum(A)
  c = 10**10
  for a, b in zip(A, B):
    if a > b:
      c = min(c, b)
  print(M - c)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
aSum = 0
abSum = 0
bMin = float('inf')

for i in range(n):
    a, b = list(map(int, input().split()))

    abSum += a
    if a > b:
        bMin = min(bMin, b)
    else:
        aSum += a

if aSum == 0:
    print(0)
else:
    print(abSum - bMin)
    

Failing test case input:
2
0 2
4 2

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
aSum = 0
abSum = 0
bMin = float('inf')

for i in range(n):
    a, b = list(map(int, input().split()))

    abSum += a
    if a > b:
        bMin = min(bMin, b)
    else:
        aSum += a

if aSum == abSum:
    print(0)
else:
    print(abSum - bMin)

Problem: p03391
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
rem=10**10
S=0
allissame=0
for i in range(n):
  a,b=map(int,input().split())
  S+=a
  if a<b:
    allissame|=1
    continue
  elif a>b:
    if rem < b:
      rem=b
    allissame|=1
  else:pass
if not allissame:
  print(0)
else:
  print(S-rem)


Failing test case input:
2
0 4
5 1

Expected output:
4


Actual output:
-9999999995


Fixed submission (verdict: Accepted):
n=int(input())
rem=10**10
S=0
allissame=0
for i in range(n):
  a,b=map(int,input().split())
  S+=a
  if a<b:
    allissame|=1
    continue
  elif a>b:
    if rem > b:
      rem=b
    allissame|=1
  else:pass
if not allissame:
  print(0)
else:
  print(S-rem)
Problem: p03471
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, y = map(int, input().split())

k = 0
for i in range(n+1):
  for j in range(n+1-i):
    if 10000*i + 5000*j + 1000*(n-i-j) == y:
      print(i, j, n-i-j)
      k += 1
      break
      
if k == 0:
  print('-1 -1 -1')



Failing test case input:
9 45000

Expected output:
4 0 5

Actual output:
0 9 0
4 0 5


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

k = 0
for i in range(min(n,y
  for j in range(n+1-i):
    if 10000*i + 5000*j + 1000*(n-i-j) == y:
      print(i, j, n-i-j)
      k += 1
      exit()
      
if k == 0:
  print('-1 -1 -1')

Problem: p03471
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, Y = list(map(int, input().split()))

y = 0
for z in range(N+1):
    if 10000 * z > Y:
        continue
    for y in range(N+1-z):
        if ((Y - (10000 * z + 5000 * y)) / 1000) == (N - (y + z)):
            print('{} {} {}' . format(N-y-z, y, z))
            exit(0)

print('-1 -1 -1')


Failing test case input:
6 45000

Expected output:
3 3 0


Actual output:
0 3 3


Fixed submission (verdict: Accepted):
N, Y = list(map(int, input().split()))

for z in range(N+1):
    if 10000 * z > Y:
        break
    for y in range(N+1-z):
        if ((Y - (10000 * z + 5000 * y)) 
            print('{} {} {}' . format(z, y, N-y-z))
            exit(0)

print('-1 -1 -1')

Problem: p03471
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,y=map(int,input().split())
x=0
for a in range(n+1):
    for b in range(n-a+1):
        if (n-a-b)*1000==y-10000*a-5000*b:
            print(a,b,n-a-b)
            x+=1
            break
        break

if x==0:
    print(-1,-1,-1)


Failing test case input:
1000 1234000

Expected output:
14 27 959

Actual output:
26 0 974


Fixed submission (verdict: Accepted):
n,y=map(int,input().split())
flag=False
for i in range(min(n+1,y
    for j in range(min(n-i+1,(y-10000*i)
        if y-10000*i-5000*j==1000*(n-i-j):
            print(i,j,n-i-j)
            flag=True
            break
    if flag:
        break
if not flag:
    print(-1,-1,-1)

Problem: p03471
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,y=map(int,input().split())
x=0
for a in range(n+1):
    for b in range(n-a+1):
        if (n-a-b)*1000==y-10000*a-5000*b:
            print(a,b,n-a-b)
            x+=1
            break
        break

if x==0:
    print('-1 -1 -1')


Failing test case input:
6 45000

Expected output:
3 3 0


Actual output:
-1 -1 -1


Fixed submission (verdict: Accepted):
n,y=map(int,input().split())
flag=False
for i in range(min(n+1,y
    for j in range(min(n-i+1,(y-10000*i)
        if y-10000*i-5000*j==1000*(n-i-j):
            print(i,j,n-i-j)
            flag=True
            break
    if flag:
        break
if not flag:
    print(-1,-1,-1)
Problem: p03069
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def minToggle(arr, n): 
  
    zero =[0 for i in range(n + 1+1)] 
    zero[0] = 0
   
    
    
    
    
    
    for i in range(1, n + 1): 
      
        
        
        if (arr[i-1] == 0): 
            zero[i] = zero[i-1] + 1
        else: 
            zero[i] = zero[i-1] 
   
    
    
    
    ans = n 
    for i in range(1, n + 1): 
        ans = min(ans, i - zero[i] + zero[n] - zero[i]) 
   
    return ans 
      

n=int(input())
s=input().rstrip()
arr=[]
for i in s:
    if i=='.':
        arr.append(0)
    else:
        arr.append(1)
n = len(arr) 
  
print(minToggle(arr, n)) 
  



Failing test case input:
3
##.

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
def minToggle(arr, n): 
  
    zero =[0 for i in range(n + 1+1)] 
    zero[0] = 0
   
    
    
    
    
    
    for i in range(1, n + 1): 
      
        
        
        if (arr[i-1] == 0): 
            zero[i] = zero[i-1] + 1
        else: 
            zero[i] = zero[i-1] 
   
    
    
    
    ans = n 
    for i in range(1, n + 1): 
        ans = min(ans, i - zero[i] + zero[n] - zero[i]) 
   
    return ans 
      

n=int(input())
s=input().rstrip()
arr=[]
ansi=min(s.count('.'),s.count('
for i in s:
    if i=='.':
        arr.append(0)
    else:
        arr.append(1)
n = len(arr) 
  
p=minToggle(arr, n)
ansi=min(ansi,p)
print(ansi)

Problem: p03069
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque
n=int(input())
s=input()
black=0
write=s.count(".")
koho=deque([])
for i in s:
    if i==".":
        write-=1
    else:
        black+=1
    koho.append(write+black)
print(min(koho))

Failing test case input:
3
##.

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import deque
n=int(input())
s=input()
black=0
write=s.count(".")
koho=deque([write,s.count("
for i in s:
    if i==".":
        write-=1
    else:
        black+=1
    koho.append(write+black)
print(min(koho))

Problem: p03069
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



N = int(input())
S = [x for x in input()]

cum_white = []
count = 0
for i, s in enumerate(S):
    if s == '.':
        count += 1
    cum_white.append(count)
    
if len(cum_white) == 0 or len(cum_white) == N:
    print(0)
else:
    min_num = int(1e10)
    for i, n_white in enumerate(cum_white):
        num = (i - n_white) + (N - cum_white[-1] - n_white)
        min_num = min(min_num, num)
        
    print(min_num)

Failing test case input:
3
.#

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):



N = int(input())
S = ['.'] + [x for x in input()] + ['

cum_white = []
count = 0
for i, s in enumerate(S):
    if s == '
        count += 1
    cum_white.append(count)
    
min_num = int(1e10)
for i, n_white in enumerate(cum_white):
    num = n_white + (N + 1 - i - (cum_white[-1] - n_white))
    min_num = min(min_num, num)
    
print(min_num)
Problem: p03069
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()
S = input()
list_S = list(S)
num = len(list_S)
N = 0
X = list_S.count('.')

if num == X:
    print('0')
else:
    for num in list_S:
        if list_S[N] == '.':
            N += 1
        else:
            list_SS = list_S[N:]
            X1 = list_SS.count('.')
            print(X1)
            break

Failing test case input:
5
.##.

Expected output:
2

Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
S = input()                                                      
list_S = list(S)
N1 = 0
list_X =[]
X = list_S.count('.')
list_X.append(X)
    
for color in list_S:
    if list_S[N1] == '.':
        X -= 1
        list_X.append(X)
        N1 +=1
    else:
        X += 1
        list_X.append(X)
        N1 +=1

X = list_S.count('
list_X.append(X)

X_MIN = min(list_X)
print(X_MIN)

Problem: p03069
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()

def inverse(num, index, first):
    offset = 0
    if first == '*':
        offset = 1
    count = 0
    for n, i in enumerate(num):
        if n <= index and n % 2 == offset:
            count += i
        elif n > index and n % 2 != offset:
            count += i
    return count

num = []
first = s[0]
end = s[-1]
pre = first
count = 0
for c in s:
    if c == pre:
        count += 1
    else:
        num.append(count)
        count = 1
        pre = c
num.append(count)

print(num)

if len(num) == 1:
    print(0)
else:
    minlist = []
    for i in range(len(num)):
        minlist.append(inverse(num, i, first))
    print(min(minlist))



Failing test case input:
3
.# 

Expected output:
0


Actual output:
[1, 1, 1]
1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

num = []
first = s[0]
end = s[-1]
pre = first
count = 0
for c in s:
    if c == pre:
        count += 1
    else:
        num.append(count)
        count = 1
        pre = c
num.append(count)

if len(num) == 1:
    print(0)
else:
    b = 0
    w = n
    offset = 0
    if first == '
        offset = 1
    w = sum(num[offset::2])
    minlist = [b + w]
    for i in range(len(num)):
        if i % 2 == offset:
            w -= num[i]
        else:
            b += num[i]
        minlist.append(b + w)
    print(min(minlist))